@@ -78,42 +78,51 @@ void wx_cleanup(WeChat *wechat) {
7878 * @return int 发送状态码(成功为 0x0,失败为非零值)
7979 */
8080int send_to (Platform Platform , const char * log_content ) {
81+ DING_DING dingding ;
82+ Discord discord ;
83+ WeChat bot ;
84+ char * webhook_url ;
85+ int result = -0x1 ;
86+
8187 switch (Platform ) {
8288 case PLATFORM_TELEGRAM :
8389 return telegram_send_message (log_content );
84- case PLATFORM_DINGDING :
85- DING_DING dingding ;
8690
91+ case PLATFORM_DINGDING :
8792 if (dingding_init (& dingding ) != 0x0 ) {
8893 fprintf (stderr , "Failed to initialize dingding webhook\n" );
8994 return -0x1 ;
9095 }
96+ result = dingding_send (& dingding , log_content , dingding_cleanup );
97+ break ;
9198
92- return dingding_send (& dingding , log_content , dingding_cleanup );
9399 case PLATFORM_DISCORD :
94- Discord discord ;
95-
96- char * webhook_url = yaml_get_value ("discord_webhook_url" );
97-
100+ webhook_url = yaml_get_value ("discord_webhook_url" );
98101 if (discord_bot_init (& discord , webhook_url ) != 0x0 ) {
99102 fprintf (stderr , "Failed to initialize discord webhook\n" );
100103 return -0x1 ;
101104 }
102-
103- return discord_bot_send ( & discord , "user" , log_content , NULL ) ;
105+ result = discord_bot_send ( & discord , "user" , log_content , NULL );
106+ break ;
104107
105108 case PLATFORM_WECHAT :
106- WeChat bot ;
107-
108- if (wechat_bot_init (& bot , "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXXXX" ) != 0x0 ) {
109+ if (wechat_bot_init (& bot , "https://qyapi.d?key=XXXXXX" ) != 0x0 ) {
109110 fprintf (stderr , "初始化失败\n" );
110111 return 0x1 ;
111112 }
112-
113- return wechat_bot_send (& bot , log_content , wx_cleanup );
114- default :
115- return -0x1 ;
113+ result = wechat_bot_send (& bot , log_content , wx_cleanup );
114+ break ;
115+
116+ case PLATFORM_SLACK :
117+ case PLATFORM_MSTEAMS :
118+ case PLATFORM_NONE :
119+ case PLATFORM_FEISHU :
120+ fprintf (stderr , "Platform not implemented yet\n" );
121+ result = -0x1 ;
122+ break ;
116123 }
124+
125+ return result ;
117126}
118127
119128/**
0 commit comments