[feat] 合并atsud0师傅添加的Telegram Bot推送

This commit is contained in:
yhy0 2021-07-03 18:27:24 +08:00
parent 75626ff53d
commit 262c0d4a2c
3 changed files with 34 additions and 2 deletions

View File

@ -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)

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB