diff --git a/README.md b/README.md index eb9d694..e79e61f 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,28 @@ server酱配置在 40行的 server 函数中,ps:因微信的原因,server [server酱新版](https://sct.ftqq.com/)支持多通道(微信、客户端、群机器人、邮件和短信) +### Telegram Bot推送支持 + +@[atsud0](https://github.com/atsud0) 师傅添加了 Telegram 推送 + +安装telegram bot + +``` +pip install python-telegram-bot +``` + +生成bot 获得群组或用户聊天ID + +创建bot详情谷歌 + +#### 获得ID + +将bot加入群组后,发送几条消息。访问https://api.telegram.org/bot{TOKEN}/getUpdates + +用户ID同理, + +![image-20210225090416314](images/124256679-27701e00-db5e-11eb-9432-d3a9048daeec.png) + ## 效果图 ![image-20210225090416314](images/image-20210225090416314.png) diff --git a/github_cve_monitor.py b/github_cve_monitor.py index a5c11d6..3735dc8 100644 --- a/github_cve_monitor.py +++ b/github_cve_monitor.py @@ -41,6 +41,15 @@ def server(text, msg): uri = 'https://sc.ftqq.com/xxxx.send?text={}&desp={}'.format(text, msg) requests.get(uri) +# 添加Telegram Bot推送支持 +def tgbot(text,msg): + import telegram + # Your Telegram Bot Token + bot = telegram.Bot(token='123456:aaa-sdasdsa') + group_id='Your Group ID' + bot.send_message(chat_id=group_id,text='{}\r\n{}'.format(text,msg)) + + # 通过检查name 和 description 中是否存在test字样,排除test def regular(req): @@ -73,9 +82,10 @@ def sendNews(): regular(req) # 检查name 和 description 中是否存在test字样 和 是否更新 if regular(req) and total_count != getNews()[0]: - # 二选一即可,没配置的 注释或者删掉 - server(text, msg) + # 三选一即可,没配置的 注释或者删掉 + # server(text, msg) dingding(text, msg) + # tgbot(text,msg) print(msg) else: pass diff --git a/images/124256679-27701e00-db5e-11eb-9432-d3a9048daeec.png b/images/124256679-27701e00-db5e-11eb-9432-d3a9048daeec.png new file mode 100644 index 0000000..92e03c1 Binary files /dev/null and b/images/124256679-27701e00-db5e-11eb-9432-d3a9048daeec.png differ