xjackkx commited on
Commit
ba45c04
·
verified ·
1 Parent(s): 544ed90

Delete notify.py

Browse files
Files changed (1) hide show
  1. notify.py +0 -1167
notify.py DELETED
@@ -1,1167 +0,0 @@
1
- #!/usr/bin/env python3
2
- # _*_ coding:utf-8 _*_
3
- import base64
4
- import hashlib
5
- import hmac
6
- import json
7
- import os
8
- import re
9
- import threading
10
- import time
11
- import urllib.parse
12
- import smtplib
13
- from email.mime.text import MIMEText
14
- from email.header import Header
15
- from email.utils import formataddr
16
-
17
- import requests
18
-
19
- # 原先的 print 函数和主线程的锁
20
- _print = print
21
- mutex = threading.Lock()
22
-
23
-
24
- # 定义新的 print 函数
25
- def print(text, *args, **kw):
26
- """
27
- 使输出有序进行,不出现多线程同一时间输出导致错乱的问题。
28
- """
29
- with mutex:
30
- _print(text, *args, **kw)
31
-
32
-
33
- # 通知服务
34
- # fmt: off
35
- push_config = {
36
- 'HITOKOTO': False, # 启用一言(随机句子)
37
-
38
- 'BARK_PUSH': '', # bark IP 或设备码,例:https://api.day.app/DxHcxxxxxRxxxxxxcm/
39
- 'BARK_ARCHIVE': '', # bark 推送是否存档
40
- 'BARK_GROUP': '', # bark 推送分组
41
- 'BARK_SOUND': '', # bark 推送声音
42
- 'BARK_ICON': '', # bark 推送图标
43
- 'BARK_LEVEL': '', # bark 推送时效性
44
- 'BARK_URL': '', # bark 推送跳转URL
45
-
46
- 'CONSOLE': False, # 控制台输出
47
-
48
- 'DD_BOT_SECRET': '', # 钉钉机器人的 DD_BOT_SECRET
49
- 'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
50
-
51
- 'FSKEY': '', # 飞书机器人的 FSKEY
52
-
53
- 'GOBOT_URL': '', # go-cqhttp
54
- # 推送到个人QQ:http://127.0.0.1/send_private_msg
55
- # 群:http://127.0.0.1/send_group_msg
56
- 'GOBOT_QQ': '', # go-cqhttp 的推送群或用户
57
- # GOBOT_URL 设置 /send_private_msg 时填入 user_id=个人QQ
58
- # /send_group_msg 时填入 group_id=QQ群
59
- 'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
60
-
61
- 'GOTIFY_URL': '', # gotify地址,如https://push.example.de:8080
62
- 'GOTIFY_TOKEN': '', # gotify的消息应用token
63
- 'GOTIFY_PRIORITY': 0, # 推送消息优先级,默认为0
64
-
65
- 'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
66
-
67
- 'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
68
-
69
- 'DEER_KEY': '', # PushDeer 的 PUSHDEER_KEY
70
- 'DEER_URL': '', # PushDeer 的 PUSHDEER_URL
71
-
72
- 'CHAT_URL': '', # synology chat url
73
- 'CHAT_TOKEN': '', # synology chat token
74
-
75
- 'PUSH_PLUS_TOKEN': '', # pushplus 推送的用户令牌
76
- 'PUSH_PLUS_USER': '', # pushplus 推送的群组编码
77
- 'PUSH_PLUS_TEMPLATE': 'html', # pushplus 发送模板,支持html,txt,json,markdown,cloudMonitor,jenkins,route,pay
78
- 'PUSH_PLUS_CHANNEL': 'wechat', # pushplus 发送渠道,支持wechat,webhook,cp,mail,sms
79
- 'PUSH_PLUS_WEBHOOK': '', # pushplus webhook编码,可在pushplus公众号上扩展配置出更多渠道
80
- 'PUSH_PLUS_CALLBACKURL': '', # pushplus 发送结果回调地址,会把推送最终结果通知到这个地址上
81
- 'PUSH_PLUS_TO': '', # pushplus 好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id
82
-
83
- 'WE_PLUS_BOT_TOKEN': '', # 微加机器人的用户令牌
84
- 'WE_PLUS_BOT_RECEIVER': '', # 微加机器人的消息接收者
85
- 'WE_PLUS_BOT_VERSION': 'pro', # 微加机器人的调用版本
86
-
87
- 'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY
88
- 'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE
89
-
90
- 'QYWX_ORIGIN': '', # 企业微信代理地址
91
-
92
- 'QYWX_AM': '', # 企业微信应用
93
-
94
- 'QYWX_KEY': '', # 企业微信机器人
95
-
96
- 'TG_BOT_TOKEN': '', # tg 机器人的 TG_BOT_TOKEN,例:1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ
97
- 'TG_USER_ID': '', # tg 机器人的 TG_USER_ID,例:1434078534
98
- 'TG_API_HOST': '', # tg 代理 api
99
- 'TG_PROXY_AUTH': '', # tg 代理认证参数
100
- 'TG_PROXY_HOST': '', # tg 机器人的 TG_PROXY_HOST
101
- 'TG_PROXY_PORT': '', # tg 机器人的 TG_PROXY_PORT
102
-
103
- 'AIBOTK_KEY': '', # 智能微秘书 个人中心的apikey 文档地址:http://wechat.aibotk.com/docs/about
104
- 'AIBOTK_TYPE': '', # 智能微秘书 发送目标 room 或 contact
105
- 'AIBOTK_NAME': '', # 智能微秘书 发送群名 或者好友昵称和type要对应好
106
-
107
- 'SMTP_SERVER': '', # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
108
- 'SMTP_SSL': 'false', # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
109
- 'SMTP_EMAIL': '', # SMTP 发件邮箱
110
- 'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
111
- 'SMTP_NAME': '', # SMTP 发件人姓名,可随意填写
112
- 'SMTP_EMAIL_TO': '', # SMTP 收件邮箱,可选,缺省时将自己发给自己,多个收件邮箱逗号间隔
113
- 'SMTP_NAME_TO': '', # SMTP 收件人姓名,可选,可随意填写,多个收件人逗号间隔,顺序与 SMTP_EMAIL_TO 保持一致
114
-
115
- 'PUSHME_KEY': '', # PushMe 的 PUSHME_KEY
116
- 'PUSHME_URL': '', # PushMe 的 PUSHME_URL
117
-
118
- 'CHRONOCAT_QQ': '', # qq号
119
- 'CHRONOCAT_TOKEN': '', # CHRONOCAT 的token
120
- 'CHRONOCAT_URL': '', # CHRONOCAT的url地址
121
-
122
- 'WEBHOOK_URL': '', # 自定义通知 请求地址
123
- 'WEBHOOK_BODY': '', # 自定义通知 请求体
124
- 'WEBHOOK_HEADERS': '', # 自定义通知 请求头
125
- 'WEBHOOK_METHOD': '', # 自定义通知 请求方法
126
- 'WEBHOOK_CONTENT_TYPE': '', # 自定义通知 content-type
127
-
128
- 'NTFY_URL': '', # ntfy地址,如https://ntfy.sh
129
- 'NTFY_TOPIC': '', # ntfy的消息应用topic
130
- 'NTFY_PRIORITY':'3', # 推送消息优先级,默认为3
131
- 'NTFY_TOKEN': '', # 推送token,可选
132
- 'NTFY_USERNAME': '', # 推送用户名称,可选
133
- 'NTFY_PASSWORD': '', # 推送用户密码,可选
134
- 'NTFY_ACTIONS': '', # 推送用户动作,可选
135
-
136
- 'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
137
- 'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
138
- 'WXPUSHER_UIDS': '', # wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
139
-
140
- 'DODO_BOTTOKEN': '', # DoDo机器人的token DoDo开发平台https://doker.imdodo.com/
141
- 'DODO_BOTID': '', # DoDo机器人的id
142
- 'DODO_LANDSOURCEID': '', # DoDo机器人所在的群ID
143
- 'DODO_SOURCEID': '', # DoDo机器人推送目标用户的ID
144
- }
145
- # fmt: on
146
-
147
- for k in push_config:
148
- if os.getenv(k):
149
- v = os.getenv(k)
150
- push_config[k] = v
151
-
152
-
153
- def bark(title: str, content: str) -> None:
154
- """
155
- 使用 bark 推送消息。
156
- """
157
- if not push_config.get("BARK_PUSH"):
158
- return
159
- print("bark 服务启动")
160
-
161
- if push_config.get("BARK_PUSH").startswith("http"):
162
- url = f'{push_config.get("BARK_PUSH")}'
163
- else:
164
- url = f'https://api.day.app/{push_config.get("BARK_PUSH")}'
165
-
166
- bark_params = {
167
- "BARK_ARCHIVE": "isArchive",
168
- "BARK_GROUP": "group",
169
- "BARK_SOUND": "sound",
170
- "BARK_ICON": "icon",
171
- "BARK_LEVEL": "level",
172
- "BARK_URL": "url",
173
- }
174
- data = {
175
- "title": title,
176
- "body": content,
177
- }
178
- for pair in filter(
179
- lambda pairs: pairs[0].startswith("BARK_")
180
- and pairs[0] != "BARK_PUSH"
181
- and pairs[1]
182
- and bark_params.get(pairs[0]),
183
- push_config.items(),
184
- ):
185
- data[bark_params.get(pair[0])] = pair[1]
186
- headers = {"Content-Type": "application/json;charset=utf-8"}
187
- response = requests.post(
188
- url=url, data=json.dumps(data), headers=headers, timeout=15
189
- ).json()
190
-
191
- if response["code"] == 200:
192
- print("bark 推送成功!")
193
- else:
194
- print("bark 推送失败!")
195
-
196
-
197
- def console(title: str, content: str) -> None:
198
- """
199
- 使用 控制台 推送消息。
200
- """
201
- if str(push_config.get("CONSOLE")).lower() != "false":
202
- print(f"{title}\n\n{content}")
203
-
204
-
205
- def dingding_bot(title: str, content: str) -> None:
206
- """
207
- 使用 钉钉机器人 推送消息。
208
- """
209
- if not push_config.get("DD_BOT_SECRET") or not push_config.get("DD_BOT_TOKEN"):
210
- return
211
- print("钉钉机器人 服务启动")
212
-
213
- timestamp = str(round(time.time() * 1000))
214
- secret_enc = push_config.get("DD_BOT_SECRET").encode("utf-8")
215
- string_to_sign = "{}\n{}".format(timestamp, push_config.get("DD_BOT_SECRET"))
216
- string_to_sign_enc = string_to_sign.encode("utf-8")
217
- hmac_code = hmac.new(
218
- secret_enc, string_to_sign_enc, digestmod=hashlib.sha256
219
- ).digest()
220
- sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
221
- url = f'https://oapi.dingtalk.com/robot/send?access_token={push_config.get("DD_BOT_TOKEN")}&timestamp={timestamp}&sign={sign}'
222
- headers = {"Content-Type": "application/json;charset=utf-8"}
223
- data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
224
- response = requests.post(
225
- url=url, data=json.dumps(data), headers=headers, timeout=15
226
- ).json()
227
-
228
- if not response["errcode"]:
229
- print("钉钉机器人 推送成功!")
230
- else:
231
- print("钉钉机器人 推送失败!")
232
-
233
-
234
- def feishu_bot(title: str, content: str) -> None:
235
- """
236
- 使用 飞书机器人 推送消息。
237
- """
238
- if not push_config.get("FSKEY"):
239
- return
240
- print("飞书 服务启动")
241
-
242
- url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
243
- data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
244
- response = requests.post(url, data=json.dumps(data)).json()
245
-
246
- if response.get("StatusCode") == 0 or response.get("code") == 0:
247
- print("飞书 推送成功!")
248
- else:
249
- print("飞书 推送失败!错误信息如下:\n", response)
250
-
251
-
252
- def go_cqhttp(title: str, content: str) -> None:
253
- """
254
- 使用 go_cqhttp 推送消息。
255
- """
256
- if not push_config.get("GOBOT_URL") or not push_config.get("GOBOT_QQ"):
257
- return
258
- print("go-cqhttp 服务启动")
259
-
260
- url = f'{push_config.get("GOBOT_URL")}?access_token={push_config.get("GOBOT_TOKEN")}&{push_config.get("GOBOT_QQ")}&message=标题:{title}\n内容:{content}'
261
- response = requests.get(url).json()
262
-
263
- if response["status"] == "ok":
264
- print("go-cqhttp 推送成功!")
265
- else:
266
- print("go-cqhttp 推送失败!")
267
-
268
-
269
- def gotify(title: str, content: str) -> None:
270
- """
271
- 使用 gotify 推送消息。
272
- """
273
- if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"):
274
- return
275
- print("gotify 服务启动")
276
-
277
- url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}'
278
- data = {
279
- "title": title,
280
- "message": content,
281
- "priority": push_config.get("GOTIFY_PRIORITY"),
282
- }
283
- response = requests.post(url, data=data).json()
284
-
285
- if response.get("id"):
286
- print("gotify 推送成功!")
287
- else:
288
- print("gotify 推送失败!")
289
-
290
-
291
- def iGot(title: str, content: str) -> None:
292
- """
293
- 使用 iGot 推送消息。
294
- """
295
- if not push_config.get("IGOT_PUSH_KEY"):
296
- return
297
- print("iGot 服务启动")
298
-
299
- url = f'https://push.hellyw.com/{push_config.get("IGOT_PUSH_KEY")}'
300
- data = {"title": title, "content": content}
301
- headers = {"Content-Type": "application/x-www-form-urlencoded"}
302
- response = requests.post(url, data=data, headers=headers).json()
303
-
304
- if response["ret"] == 0:
305
- print("iGot 推送成功!")
306
- else:
307
- print(f'iGot 推送失败!{response["errMsg"]}')
308
-
309
-
310
- def serverJ(title: str, content: str) -> None:
311
- """
312
- 通过 serverJ 推送消息。
313
- """
314
- if not push_config.get("PUSH_KEY"):
315
- return
316
- print("serverJ 服务启动")
317
-
318
- data = {"text": title, "desp": content.replace("\n", "\n\n")}
319
-
320
- match = re.match(r"sctp(\d+)t", push_config.get("PUSH_KEY"))
321
- if match:
322
- num = match.group(1)
323
- url = f'https://{num}.push.ft07.com/send/{push_config.get("PUSH_KEY")}.send'
324
- else:
325
- url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
326
-
327
- response = requests.post(url, data=data).json()
328
-
329
- if response.get("errno") == 0 or response.get("code") == 0:
330
- print("serverJ 推送成功!")
331
- else:
332
- print(f'serverJ 推送失败!错误码:{response["message"]}')
333
-
334
-
335
- def pushdeer(title: str, content: str) -> None:
336
- """
337
- 通过PushDeer 推送消息
338
- """
339
- if not push_config.get("DEER_KEY"):
340
- return
341
- print("PushDeer 服务启动")
342
- data = {
343
- "text": title,
344
- "desp": content,
345
- "type": "markdown",
346
- "pushkey": push_config.get("DEER_KEY"),
347
- }
348
- url = "https://api2.pushdeer.com/message/push"
349
- if push_config.get("DEER_URL"):
350
- url = push_config.get("DEER_URL")
351
-
352
- response = requests.post(url, data=data).json()
353
-
354
- if len(response.get("content").get("result")) > 0:
355
- print("PushDeer 推送成功!")
356
- else:
357
- print("PushDeer 推送失败!错误信息:", response)
358
-
359
-
360
- def chat(title: str, content: str) -> None:
361
- """
362
- 通过Chat 推送消息
363
- """
364
- if not push_config.get("CHAT_URL") or not push_config.get("CHAT_TOKEN"):
365
- return
366
- print("chat 服务启动")
367
- data = "payload=" + json.dumps({"text": title + "\n" + content})
368
- url = push_config.get("CHAT_URL") + push_config.get("CHAT_TOKEN")
369
- response = requests.post(url, data=data)
370
-
371
- if response.status_code == 200:
372
- print("Chat 推送成功!")
373
- else:
374
- print("Chat 推送失败!错误信息:", response)
375
-
376
-
377
- def pushplus_bot(title: str, content: str) -> None:
378
- """
379
- 通过 pushplus 推送消息。
380
- """
381
- if not push_config.get("PUSH_PLUS_TOKEN"):
382
- return
383
- print("PUSHPLUS 服务启动")
384
-
385
- url = "https://www.pushplus.plus/send"
386
- data = {
387
- "token": push_config.get("PUSH_PLUS_TOKEN"),
388
- "title": title,
389
- "content": content,
390
- "topic": push_config.get("PUSH_PLUS_USER"),
391
- "template": push_config.get("PUSH_PLUS_TEMPLATE"),
392
- "channel": push_config.get("PUSH_PLUS_CHANNEL"),
393
- "webhook": push_config.get("PUSH_PLUS_WEBHOOK"),
394
- "callbackUrl": push_config.get("PUSH_PLUS_CALLBACKURL"),
395
- "to": push_config.get("PUSH_PLUS_TO"),
396
- }
397
- body = json.dumps(data).encode(encoding="utf-8")
398
- headers = {"Content-Type": "application/json"}
399
- response = requests.post(url=url, data=body, headers=headers).json()
400
-
401
- code = response["code"]
402
- if code == 200:
403
- print("PUSHPLUS 推送请求成功,可根据流水号查询推送结果:" + response["data"])
404
- print(
405
- "注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果"
406
- )
407
- elif code == 900 or code == 903 or code == 905 or code == 999:
408
- print(response["msg"])
409
-
410
- else:
411
- url_old = "http://pushplus.hxtrip.com/send"
412
- headers["Accept"] = "application/json"
413
- response = requests.post(url=url_old, data=body, headers=headers).json()
414
-
415
- if response["code"] == 200:
416
- print("PUSHPLUS(hxtrip) 推送成功!")
417
-
418
- else:
419
- print("PUSHPLUS 推送失败!")
420
-
421
-
422
- def weplus_bot(title: str, content: str) -> None:
423
- """
424
- 通过 微加机器人 推送消息。
425
- """
426
- if not push_config.get("WE_PLUS_BOT_TOKEN"):
427
- return
428
- print("微加机器人 服务启动")
429
-
430
- template = "txt"
431
- if len(content) > 800:
432
- template = "html"
433
-
434
- url = "https://www.weplusbot.com/send"
435
- data = {
436
- "token": push_config.get("WE_PLUS_BOT_TOKEN"),
437
- "title": title,
438
- "content": content,
439
- "template": template,
440
- "receiver": push_config.get("WE_PLUS_BOT_RECEIVER"),
441
- "version": push_config.get("WE_PLUS_BOT_VERSION"),
442
- }
443
- body = json.dumps(data).encode(encoding="utf-8")
444
- headers = {"Content-Type": "application/json"}
445
- response = requests.post(url=url, data=body, headers=headers).json()
446
-
447
- if response["code"] == 200:
448
- print("微加机器人 推送成功!")
449
- else:
450
- print("微加机器人 推送失败!")
451
-
452
-
453
- def qmsg_bot(title: str, content: str) -> None:
454
- """
455
- 使用 qmsg 推送消息。
456
- """
457
- if not push_config.get("QMSG_KEY") or not push_config.get("QMSG_TYPE"):
458
- return
459
- print("qmsg 服务启动")
460
-
461
- url = f'https://qmsg.zendee.cn/{push_config.get("QMSG_TYPE")}/{push_config.get("QMSG_KEY")}'
462
- payload = {"msg": f'{title}\n\n{content.replace("----", "-")}'.encode("utf-8")}
463
- response = requests.post(url=url, params=payload).json()
464
-
465
- if response["code"] == 0:
466
- print("qmsg 推送成功!")
467
- else:
468
- print(f'qmsg 推送失败!{response["reason"]}')
469
-
470
-
471
- def wecom_app(title: str, content: str) -> None:
472
- """
473
- 通过 企业微信 APP 推送消息。
474
- """
475
- if not push_config.get("QYWX_AM"):
476
- return
477
- QYWX_AM_AY = re.split(",", push_config.get("QYWX_AM"))
478
- if 4 < len(QYWX_AM_AY) > 5:
479
- print("QYWX_AM 设置错误!!")
480
- return
481
- print("企业微信 APP 服务启动")
482
-
483
- corpid = QYWX_AM_AY[0]
484
- corpsecret = QYWX_AM_AY[1]
485
- touser = QYWX_AM_AY[2]
486
- agentid = QYWX_AM_AY[3]
487
- try:
488
- media_id = QYWX_AM_AY[4]
489
- except IndexError:
490
- media_id = ""
491
- wx = WeCom(corpid, corpsecret, agentid)
492
- # 如果没有配置 media_id 默认就以 text 方式发送
493
- if not media_id:
494
- message = title + "\n\n" + content
495
- response = wx.send_text(message, touser)
496
- else:
497
- response = wx.send_mpnews(title, content, media_id, touser)
498
-
499
- if response == "ok":
500
- print("企业微信推送成功!")
501
- else:
502
- print("企业微信推送失败!错误信息如下:\n", response)
503
-
504
-
505
- class WeCom:
506
- def __init__(self, corpid, corpsecret, agentid):
507
- self.CORPID = corpid
508
- self.CORPSECRET = corpsecret
509
- self.AGENTID = agentid
510
- self.ORIGIN = "https://qyapi.weixin.qq.com"
511
- if push_config.get("QYWX_ORIGIN"):
512
- self.ORIGIN = push_config.get("QYWX_ORIGIN")
513
-
514
- def get_access_token(self):
515
- url = f"{self.ORIGIN}/cgi-bin/gettoken"
516
- values = {
517
- "corpid": self.CORPID,
518
- "corpsecret": self.CORPSECRET,
519
- }
520
- req = requests.post(url, params=values)
521
- data = json.loads(req.text)
522
- return data["access_token"]
523
-
524
- def send_text(self, message, touser="@all"):
525
- send_url = (
526
- f"{self.ORIGIN}/cgi-bin/message/send?access_token={self.get_access_token()}"
527
- )
528
- send_values = {
529
- "touser": touser,
530
- "msgtype": "text",
531
- "agentid": self.AGENTID,
532
- "text": {"content": message},
533
- "safe": "0",
534
- }
535
- send_msges = bytes(json.dumps(send_values), "utf-8")
536
- respone = requests.post(send_url, send_msges)
537
- respone = respone.json()
538
- return respone["errmsg"]
539
-
540
- def send_mpnews(self, title, message, media_id, touser="@all"):
541
- send_url = (
542
- f"{self.ORIGIN}/cgi-bin/message/send?access_token={self.get_access_token()}"
543
- )
544
- send_values = {
545
- "touser": touser,
546
- "msgtype": "mpnews",
547
- "agentid": self.AGENTID,
548
- "mpnews": {
549
- "articles": [
550
- {
551
- "title": title,
552
- "thumb_media_id": media_id,
553
- "author": "Author",
554
- "content_source_url": "",
555
- "content": message.replace("\n", "<br/>"),
556
- "digest": message,
557
- }
558
- ]
559
- },
560
- }
561
- send_msges = bytes(json.dumps(send_values), "utf-8")
562
- respone = requests.post(send_url, send_msges)
563
- respone = respone.json()
564
- return respone["errmsg"]
565
-
566
-
567
- def wecom_bot(title: str, content: str) -> None:
568
- """
569
- 通过 企业微信机器人 推送消息。
570
- """
571
- if not push_config.get("QYWX_KEY"):
572
- return
573
- print("企业微信机器人服务启动")
574
-
575
- origin = "https://qyapi.weixin.qq.com"
576
- if push_config.get("QYWX_ORIGIN"):
577
- origin = push_config.get("QYWX_ORIGIN")
578
-
579
- url = f"{origin}/cgi-bin/webhook/send?key={push_config.get('QYWX_KEY')}"
580
- headers = {"Content-Type": "application/json;charset=utf-8"}
581
- data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
582
- response = requests.post(
583
- url=url, data=json.dumps(data), headers=headers, timeout=15
584
- ).json()
585
-
586
- if response["errcode"] == 0:
587
- print("企业微信机器人推送成功!")
588
- else:
589
- print("企业微信机器人推送失败!")
590
-
591
-
592
- def telegram_bot(title: str, content: str) -> None:
593
- """
594
- 使用 telegram 机器人 推送消息。
595
- """
596
- if not push_config.get("TG_BOT_TOKEN") or not push_config.get("TG_USER_ID"):
597
- return
598
- print("tg 服务启动")
599
-
600
- if push_config.get("TG_API_HOST"):
601
- url = f"{push_config.get('TG_API_HOST')}/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
602
- else:
603
- url = (
604
- f"https://api.telegram.org/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
605
- )
606
- headers = {"Content-Type": "application/x-www-form-urlencoded"}
607
- payload = {
608
- "chat_id": str(push_config.get("TG_USER_ID")),
609
- "text": f"{title}\n\n{content}",
610
- "disable_web_page_preview": "true",
611
- }
612
- proxies = None
613
- if push_config.get("TG_PROXY_HOST") and push_config.get("TG_PROXY_PORT"):
614
- if push_config.get("TG_PROXY_AUTH") is not None and "@" not in push_config.get(
615
- "TG_PROXY_HOST"
616
- ):
617
- push_config["TG_PROXY_HOST"] = (
618
- push_config.get("TG_PROXY_AUTH")
619
- + "@"
620
- + push_config.get("TG_PROXY_HOST")
621
- )
622
- proxyStr = "http://{}:{}".format(
623
- push_config.get("TG_PROXY_HOST"), push_config.get("TG_PROXY_PORT")
624
- )
625
- proxies = {"http": proxyStr, "https": proxyStr}
626
- response = requests.post(
627
- url=url, headers=headers, params=payload, proxies=proxies
628
- ).json()
629
-
630
- if response["ok"]:
631
- print("tg 推送成功!")
632
- else:
633
- print("tg 推送失败!")
634
-
635
-
636
- def aibotk(title: str, content: str) -> None:
637
- """
638
- 使用 智能微秘书 推送消息。
639
- """
640
- if (
641
- not push_config.get("AIBOTK_KEY")
642
- or not push_config.get("AIBOTK_TYPE")
643
- or not push_config.get("AIBOTK_NAME")
644
- ):
645
- return
646
- print("智能微秘书 服务启动")
647
-
648
- if push_config.get("AIBOTK_TYPE") == "room":
649
- url = "https://api-bot.aibotk.com/openapi/v1/chat/room"
650
- data = {
651
- "apiKey": push_config.get("AIBOTK_KEY"),
652
- "roomName": push_config.get("AIBOTK_NAME"),
653
- "message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"},
654
- }
655
- else:
656
- url = "https://api-bot.aibotk.com/openapi/v1/chat/contact"
657
- data = {
658
- "apiKey": push_config.get("AIBOTK_KEY"),
659
- "name": push_config.get("AIBOTK_NAME"),
660
- "message": {"type": 1, "content": f"【青龙快讯】\n\n{title}\n{content}"},
661
- }
662
- body = json.dumps(data).encode(encoding="utf-8")
663
- headers = {"Content-Type": "application/json"}
664
- response = requests.post(url=url, data=body, headers=headers).json()
665
- print(response)
666
- if response["code"] == 0:
667
- print("智能微秘书 推送成功!")
668
- else:
669
- print(f'智能微秘书 推送失败!{response["error"]}')
670
-
671
-
672
- def smtp(title: str, content: str) -> None:
673
- """
674
- 使用 SMTP 邮件 推送消息。
675
- """
676
- if (
677
- not push_config.get("SMTP_SERVER")
678
- or not push_config.get("SMTP_SSL")
679
- or not push_config.get("SMTP_EMAIL")
680
- or not push_config.get("SMTP_PASSWORD")
681
- or not push_config.get("SMTP_NAME")
682
- ):
683
- return
684
- print("SMTP 邮件 服务启动")
685
-
686
- message = MIMEText(content, "plain", "utf-8")
687
- message["From"] = formataddr(
688
- (
689
- Header(push_config.get("SMTP_NAME"), "utf-8").encode(),
690
- push_config.get("SMTP_EMAIL"),
691
- )
692
- )
693
- if not push_config.get("SMTP_EMAIL_TO"):
694
- smtp_email_to = push_config.get("SMTP_EMAIL")
695
- message["To"] = formataddr(
696
- (
697
- Header(push_config.get("SMTP_NAME"), "utf-8").encode(),
698
- push_config.get("SMTP_EMAIL"),
699
- )
700
- )
701
- else:
702
- smtp_email_to = push_config.get("SMTP_EMAIL_TO").split(",")
703
- smtp_name_to = push_config.get("SMTP_NAME_TO","").split(",")
704
- message["To"] = ",".join([formataddr(
705
- (
706
- Header(smtp_name_to[i] if len(smtp_name_to) > i else "", "utf-8").encode(),
707
- email_to,
708
- )
709
- ) for i, email_to in enumerate(smtp_email_to)])
710
- message["Subject"] = Header(title, "utf-8")
711
-
712
- try:
713
- smtp_server = (
714
- smtplib.SMTP_SSL(push_config.get("SMTP_SERVER"))
715
- if push_config.get("SMTP_SSL") == "true"
716
- else smtplib.SMTP(push_config.get("SMTP_SERVER"))
717
- )
718
- smtp_server.login(
719
- push_config.get("SMTP_EMAIL"), push_config.get("SMTP_PASSWORD")
720
- )
721
- smtp_server.sendmail(
722
- push_config.get("SMTP_EMAIL"),
723
- smtp_email_to,
724
- message.as_bytes(),
725
- )
726
- smtp_server.close()
727
- print("SMTP 邮件 推送成功!")
728
- except Exception as e:
729
- print(f"SMTP 邮件 推送失败!{e}")
730
-
731
-
732
- def pushme(title: str, content: str) -> None:
733
- """
734
- 使用 PushMe 推送消息。
735
- """
736
- if not push_config.get("PUSHME_KEY"):
737
- return
738
- print("PushMe 服务启动")
739
-
740
- url = (
741
- push_config.get("PUSHME_URL")
742
- if push_config.get("PUSHME_URL")
743
- else "https://push.i-i.me/"
744
- )
745
- data = {
746
- "push_key": push_config.get("PUSHME_KEY"),
747
- "title": title,
748
- "content": content,
749
- "date": push_config.get("date") if push_config.get("date") else "",
750
- "type": push_config.get("type") if push_config.get("type") else "",
751
- }
752
- response = requests.post(url, data=data)
753
-
754
- if response.status_code == 200 and response.text == "success":
755
- print("PushMe 推送成功!")
756
- else:
757
- print(f"PushMe 推送失败!{response.status_code} {response.text}")
758
-
759
-
760
- def chronocat(title: str, content: str) -> None:
761
- """
762
- 使用 CHRONOCAT 推送消息。
763
- """
764
- if (
765
- not push_config.get("CHRONOCAT_URL")
766
- or not push_config.get("CHRONOCAT_QQ")
767
- or not push_config.get("CHRONOCAT_TOKEN")
768
- ):
769
- return
770
-
771
- print("CHRONOCAT 服务启动")
772
-
773
- user_ids = re.findall(r"user_id=(\d+)", push_config.get("CHRONOCAT_QQ"))
774
- group_ids = re.findall(r"group_id=(\d+)", push_config.get("CHRONOCAT_QQ"))
775
-
776
- url = f'{push_config.get("CHRONOCAT_URL")}/api/message/send'
777
- headers = {
778
- "Content-Type": "application/json",
779
- "Authorization": f'Bearer {push_config.get("CHRONOCAT_TOKEN")}',
780
- }
781
-
782
- for chat_type, ids in [(1, user_ids), (2, group_ids)]:
783
- if not ids:
784
- continue
785
- for chat_id in ids:
786
- data = {
787
- "peer": {"chatType": chat_type, "peerUin": chat_id},
788
- "elements": [
789
- {
790
- "elementType": 1,
791
- "textElement": {"content": f"{title}\n\n{content}"},
792
- }
793
- ],
794
- }
795
- response = requests.post(url, headers=headers, data=json.dumps(data))
796
- if response.status_code == 200:
797
- if chat_type == 1:
798
- print(f"QQ个人消息:{ids}推送成功!")
799
- else:
800
- print(f"QQ群消息:{ids}推送成功!")
801
- else:
802
- if chat_type == 1:
803
- print(f"QQ个人消息:{ids}推送失败!")
804
- else:
805
- print(f"QQ群消息:{ids}推送失败!")
806
-
807
-
808
- def ntfy(title: str, content: str) -> None:
809
- """
810
- 通过 Ntfy 推送消息
811
- """
812
-
813
- def encode_rfc2047(text: str) -> str:
814
- """将文本编码为符合 RFC 2047 标准的格式"""
815
- encoded_bytes = base64.b64encode(text.encode("utf-8"))
816
- encoded_str = encoded_bytes.decode("utf-8")
817
- return f"=?utf-8?B?{encoded_str}?="
818
-
819
- if not push_config.get("NTFY_TOPIC"):
820
- return
821
- print("ntfy 服务启动")
822
- priority = "3"
823
- if not push_config.get("NTFY_PRIORITY"):
824
- print("ntfy 服务的NTFY_PRIORITY 未设置!!默认设置为3")
825
- else:
826
- priority = push_config.get("NTFY_PRIORITY")
827
-
828
- # 使用 RFC 2047 编码 title
829
- encoded_title = encode_rfc2047(title)
830
-
831
- data = content.encode(encoding="utf-8")
832
- headers = {"Title": encoded_title, "Priority": priority, "Icon": "https://qn.whyour.cn/logo.png"} # 使用编码后的 title
833
- if push_config.get("NTFY_TOKEN"):
834
- headers['Authorization'] = "Bearer " + push_config.get("NTFY_TOKEN")
835
- elif push_config.get("NTFY_USERNAME") and push_config.get("NTFY_PASSWORD"):
836
- authStr = push_config.get("NTFY_USERNAME") + ":" + push_config.get("NTFY_PASSWORD")
837
- headers['Authorization'] = "Basic " + base64.b64encode(authStr.encode('utf-8')).decode('utf-8')
838
- if push_config.get("NTFY_ACTIONS"):
839
- headers['Actions'] = encode_rfc2047(push_config.get("NTFY_ACTIONS"))
840
-
841
- url = push_config.get("NTFY_URL") + "/" + push_config.get("NTFY_TOPIC")
842
- response = requests.post(url, data=data, headers=headers)
843
- if response.status_code == 200: # 使用 response.status_code 进行检查
844
- print("Ntfy 推送成功!")
845
- else:
846
- print("Ntfy 推送失败!错误信息:", response.text)
847
-
848
- def dodo_bot(title: str, content: str) -> None:
849
- """
850
- 通过 DoDo机器人 推送消息
851
- """
852
- required_keys = [
853
- 'DODO_BOTTOKEN',
854
- 'DODO_BOTID',
855
- 'DODO_LANDSOURCEID',
856
- 'DODO_SOURCEID'
857
- ]
858
- if not all(push_config.get(key) for key in required_keys):
859
- missing = [key for key in required_keys if not push_config.get(key)]
860
- print(f"DoDo 服务配置不完整,缺少以下参数: {', '.join(missing)}\n取消推送")
861
- return
862
- print("DoDo 服务启动")
863
- url="https://botopen.imdodo.com/api/v2/personal/message/send"
864
-
865
- botID=push_config.get('DODO_BOTID')
866
- botToken=push_config.get('DODO_BOTTOKEN')
867
- islandSourceId=push_config.get('DODO_LANDSOURCEID')
868
- dodoSourceId=push_config.get('DODO_SOURCEID')
869
-
870
- headers = {
871
- 'Authorization': f'Bot {botID}.{botToken}',
872
- 'Content-Type': 'application/json',
873
- 'Host': 'botopen.imdodo.com'
874
- }
875
- payload = json.dumps({
876
- "islandSourceId": islandSourceId,
877
- "dodoSourceId": dodoSourceId,
878
- "messageType": 1,
879
- "messageBody": {
880
- "content": f"{title}\n\n{content}"
881
- }
882
- })
883
-
884
- try:
885
- response = requests.post(url, headers=headers, data=payload)
886
- if response.status_code == 200:
887
- response = response.json()
888
- if response.get("status") == 0 and response.get("message") == "success":
889
- print(f'DoDo 推送成功!')
890
- else:
891
- print(f'DoDo 推送失败!错误信息:\n{response}')
892
- else:
893
- print("DoDo 推送失败!错误信息:", response.text)
894
- except Exception as e:
895
- print(f"DoDo 推送请求异常: {str(e)}")
896
-
897
- def wxpusher_bot(title: str, content: str) -> None:
898
- """
899
- 通过 wxpusher 推送消息。
900
- 支持的环境变量:
901
- - WXPUSHER_APP_TOKEN: appToken
902
- - WXPUSHER_TOPIC_IDS: 主题ID, 多个用英文分号;分隔
903
- - WXPUSHER_UIDS: 用户ID, 多个用英文分号;分隔
904
- """
905
- if not push_config.get("WXPUSHER_APP_TOKEN"):
906
- return
907
-
908
- url = "https://wxpusher.zjiecode.com/api/send/message"
909
-
910
- # 处理topic_ids和uids,将分号分隔的字符串转为数组
911
- topic_ids = []
912
- if push_config.get("WXPUSHER_TOPIC_IDS"):
913
- topic_ids = [
914
- int(id.strip())
915
- for id in push_config.get("WXPUSHER_TOPIC_IDS").split(";")
916
- if id.strip()
917
- ]
918
-
919
- uids = []
920
- if push_config.get("WXPUSHER_UIDS"):
921
- uids = [
922
- uid.strip()
923
- for uid in push_config.get("WXPUSHER_UIDS").split(";")
924
- if uid.strip()
925
- ]
926
-
927
- # topic_ids uids 至少有一个
928
- if not topic_ids and not uids:
929
- print("wxpusher 服务的 WXPUSHER_TOPIC_IDS 和 WXPUSHER_UIDS 至少设置一个!!")
930
- return
931
-
932
- print("wxpusher 服务启动")
933
-
934
- data = {
935
- "appToken": push_config.get("WXPUSHER_APP_TOKEN"),
936
- "content": f"<h1>{title}</h1><br/><div style='white-space: pre-wrap;'>{content}</div>",
937
- "summary": title,
938
- "contentType": 2,
939
- "topicIds": topic_ids,
940
- "uids": uids,
941
- "verifyPayType": 0,
942
- }
943
-
944
- headers = {"Content-Type": "application/json"}
945
- response = requests.post(url=url, json=data, headers=headers).json()
946
-
947
- if response.get("code") == 1000:
948
- print("wxpusher 推送成功!")
949
- else:
950
- print(f"wxpusher 推送失败!错误信息:{response.get('msg')}")
951
-
952
-
953
- def parse_headers(headers):
954
- if not headers:
955
- return {}
956
-
957
- parsed = {}
958
- lines = headers.split("\n")
959
-
960
- for line in lines:
961
- i = line.find(":")
962
- if i == -1:
963
- continue
964
-
965
- key = line[:i].strip().lower()
966
- val = line[i + 1 :].strip()
967
- parsed[key] = parsed.get(key, "") + ", " + val if key in parsed else val
968
-
969
- return parsed
970
-
971
-
972
- def parse_string(input_string, value_format_fn=None):
973
- matches = {}
974
- pattern = r"(\w+):\s*((?:(?!\n\w+:).)*)"
975
- regex = re.compile(pattern)
976
- for match in regex.finditer(input_string):
977
- key, value = match.group(1).strip(), match.group(2).strip()
978
- try:
979
- value = value_format_fn(value) if value_format_fn else value
980
- json_value = json.loads(value)
981
- matches[key] = json_value
982
- except:
983
- matches[key] = value
984
- return matches
985
-
986
-
987
- def parse_body(body, content_type, value_format_fn=None):
988
- if not body or content_type == "text/plain":
989
- return value_format_fn(body) if value_format_fn and body else body
990
-
991
- parsed = parse_string(body, value_format_fn)
992
-
993
- if content_type == "application/x-www-form-urlencoded":
994
- data = urllib.parse.urlencode(parsed, doseq=True)
995
- return data
996
-
997
- if content_type == "application/json":
998
- data = json.dumps(parsed)
999
- return data
1000
-
1001
- return parsed
1002
-
1003
-
1004
- def custom_notify(title: str, content: str) -> None:
1005
- """
1006
- 通过 自定义通知 推送消息。
1007
- """
1008
- if not push_config.get("WEBHOOK_URL") or not push_config.get("WEBHOOK_METHOD"):
1009
- return
1010
-
1011
- print("自定义通知服务启动")
1012
-
1013
- WEBHOOK_URL = push_config.get("WEBHOOK_URL")
1014
- WEBHOOK_METHOD = push_config.get("WEBHOOK_METHOD")
1015
- WEBHOOK_CONTENT_TYPE = push_config.get("WEBHOOK_CONTENT_TYPE")
1016
- WEBHOOK_BODY = push_config.get("WEBHOOK_BODY")
1017
- WEBHOOK_HEADERS = push_config.get("WEBHOOK_HEADERS")
1018
-
1019
- if "$title" not in WEBHOOK_URL and "$title" not in WEBHOOK_BODY:
1020
- print("请求头或者请求体中必须包含 $title 和 $content")
1021
- return
1022
-
1023
- headers = parse_headers(WEBHOOK_HEADERS)
1024
- body = parse_body(
1025
- WEBHOOK_BODY,
1026
- WEBHOOK_CONTENT_TYPE,
1027
- lambda v: v.replace("$title", title.replace("\n", "\\n")).replace(
1028
- "$content", content.replace("\n", "\\n")
1029
- ),
1030
- )
1031
- formatted_url = WEBHOOK_URL.replace(
1032
- "$title", urllib.parse.quote_plus(title)
1033
- ).replace("$content", urllib.parse.quote_plus(content))
1034
- response = requests.request(
1035
- method=WEBHOOK_METHOD, url=formatted_url, headers=headers, timeout=15, data=body
1036
- )
1037
-
1038
- if response.status_code == 200:
1039
- print("自定义通知推送成功!")
1040
- else:
1041
- print(f"自定义通知推送失败!{response.status_code} {response.text}")
1042
-
1043
-
1044
- def one() -> str:
1045
- """
1046
- 获取一条一言。
1047
- :return:
1048
- """
1049
- url = "https://v1.hitokoto.cn/"
1050
- res = requests.get(url).json()
1051
- return res["hitokoto"] + " ----" + res["from"]
1052
-
1053
-
1054
- def add_notify_function():
1055
- notify_function = []
1056
- if push_config.get("BARK_PUSH"):
1057
- notify_function.append(bark)
1058
- if push_config.get("CONSOLE"):
1059
- notify_function.append(console)
1060
- if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"):
1061
- notify_function.append(dingding_bot)
1062
- if push_config.get("FSKEY"):
1063
- notify_function.append(feishu_bot)
1064
- if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
1065
- notify_function.append(go_cqhttp)
1066
- if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
1067
- notify_function.append(gotify)
1068
- if push_config.get("IGOT_PUSH_KEY"):
1069
- notify_function.append(iGot)
1070
- if push_config.get("PUSH_KEY"):
1071
- notify_function.append(serverJ)
1072
- if push_config.get("DEER_KEY"):
1073
- notify_function.append(pushdeer)
1074
- if push_config.get("CHAT_URL") and push_config.get("CHAT_TOKEN"):
1075
- notify_function.append(chat)
1076
- if push_config.get("PUSH_PLUS_TOKEN"):
1077
- notify_function.append(pushplus_bot)
1078
- if push_config.get("WE_PLUS_BOT_TOKEN"):
1079
- notify_function.append(weplus_bot)
1080
- if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
1081
- notify_function.append(qmsg_bot)
1082
- if push_config.get("QYWX_AM"):
1083
- notify_function.append(wecom_app)
1084
- if push_config.get("QYWX_KEY"):
1085
- notify_function.append(wecom_bot)
1086
- if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
1087
- notify_function.append(telegram_bot)
1088
- if (
1089
- push_config.get("AIBOTK_KEY")
1090
- and push_config.get("AIBOTK_TYPE")
1091
- and push_config.get("AIBOTK_NAME")
1092
- ):
1093
- notify_function.append(aibotk)
1094
- if (
1095
- push_config.get("SMTP_SERVER")
1096
- and push_config.get("SMTP_SSL")
1097
- and push_config.get("SMTP_EMAIL")
1098
- and push_config.get("SMTP_PASSWORD")
1099
- and push_config.get("SMTP_NAME")
1100
- ):
1101
- notify_function.append(smtp)
1102
- if push_config.get("PUSHME_KEY"):
1103
- notify_function.append(pushme)
1104
- if (
1105
- push_config.get("CHRONOCAT_URL")
1106
- and push_config.get("CHRONOCAT_QQ")
1107
- and push_config.get("CHRONOCAT_TOKEN")
1108
- ):
1109
- notify_function.append(chronocat)
1110
- if (
1111
- push_config.get("DODO_BOTTOKEN")
1112
- and push_config.get("DODO_BOTID")
1113
- and push_config.get("DODO_LANDSOURCEID")
1114
- and push_config.get("DODO_SOURCEID")
1115
- ):
1116
- notify_function.append(dodo_bot)
1117
- if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
1118
- notify_function.append(custom_notify)
1119
- if push_config.get("NTFY_TOPIC"):
1120
- notify_function.append(ntfy)
1121
- if push_config.get("WXPUSHER_APP_TOKEN") and (
1122
- push_config.get("WXPUSHER_TOPIC_IDS") or push_config.get("WXPUSHER_UIDS")
1123
- ):
1124
- notify_function.append(wxpusher_bot)
1125
- if not notify_function:
1126
- print(f"无推送渠道,请检查通知变量是否正确")
1127
- return notify_function
1128
-
1129
-
1130
- def send(title: str, content: str, ignore_default_config: bool = False, **kwargs):
1131
- if kwargs:
1132
- global push_config
1133
- if ignore_default_config:
1134
- push_config = kwargs # 清空从环境变量获取的配置
1135
- else:
1136
- push_config.update(kwargs)
1137
-
1138
- if not content:
1139
- print(f"{title} 推送内容为空!")
1140
- return
1141
-
1142
- # 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔
1143
- skipTitle = os.getenv("SKIP_PUSH_TITLE")
1144
- if skipTitle:
1145
- if title in re.split("\n", skipTitle):
1146
- print(f"{title} 在SKIP_PUSH_TITLE环境变量内,跳过推送!")
1147
- return
1148
-
1149
- hitokoto = push_config.get("HITOKOTO")
1150
- if hitokoto and str(hitokoto).lower() != "false":
1151
- content += "\n\n" + one()
1152
-
1153
- notify_function = add_notify_function()
1154
- ts = [
1155
- threading.Thread(target=mode, args=(title, content), name=mode.__name__)
1156
- for mode in notify_function
1157
- ]
1158
- [t.start() for t in ts]
1159
- [t.join() for t in ts]
1160
-
1161
-
1162
- def main():
1163
- send("title", "content")
1164
-
1165
-
1166
- if __name__ == "__main__":
1167
- main()