6
6
import log
7
7
from app .helper import ThreadHelper
8
8
from app .message .client ._base import _IMessageClient
9
- from app .utils import RequestUtils , ExceptionUtils
9
+ from app .utils import RequestUtils , ExceptionUtils , StringUtils
10
10
from config import Config
11
11
12
12
lock = Lock ()
@@ -200,7 +200,10 @@ def _res_parse(result):
200
200
if image :
201
201
# 发送图文消息
202
202
values = {"chat_id" : chat_id , "photo" : image , "caption" : caption ,
203
- "parse_mode" : "Markdown" , "message_thread_id" : thread_id }
203
+ "parse_mode" : "Markdown" }
204
+ if StringUtils .is_string_and_not_empty (thread_id ):
205
+ values .update ({"message_thread_id" : thread_id })
206
+
204
207
sc_url = "%s/bot%s/sendPhoto?" % (self ._telegram_domain ,
205
208
self ._telegram_token )
206
209
res = RequestUtils (proxies = proxies ).get_res (
@@ -214,8 +217,9 @@ def _res_parse(result):
214
217
sc_url = "%s/bot%s/sendPhoto" % (
215
218
self ._telegram_domain , self ._telegram_token )
216
219
data = {"chat_id" : chat_id , "caption" : caption ,
217
- "parse_mode" : "Markdown" ,
218
- "message_thread_id" : thread_id }
220
+ "parse_mode" : "Markdown" }
221
+ if StringUtils .is_string_and_not_empty (thread_id ):
222
+ data .update ({"message_thread_id" : thread_id })
219
223
files = {"photo" : photo_req .content }
220
224
res = requests .post (
221
225
sc_url , proxies = proxies , data = data , files = files )
@@ -224,7 +228,9 @@ def _res_parse(result):
224
228
return flag , msg
225
229
# 发送文本消息
226
230
values = {"chat_id" : chat_id , "text" : caption ,
227
- "parse_mode" : "Markdown" , "message_thread_id" : thread_id }
231
+ "parse_mode" : "Markdown" }
232
+ if StringUtils .is_string_and_not_empty (thread_id ):
233
+ values .update ({"message_thread_id" : thread_id })
228
234
sc_url = "%s/bot%s/sendMessage?" % (
229
235
self ._telegram_domain , self ._telegram_token )
230
236
res = RequestUtils (proxies = proxies ).get_res (
0 commit comments