[feat] 合并atsud0师傅添加的Telegram Bot推送
This commit is contained in:
parent
75626ff53d
commit
262c0d4a2c
22
README.md
22
README.md
@ -32,6 +32,28 @@ server酱配置在 40行的 server 函数中,ps:因微信的原因,server
|
|||||||
|
|
||||||
[server酱新版](https://sct.ftqq.com/)支持多通道(微信、客户端、群机器人、邮件和短信)
|
[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)
|
![image-20210225090416314](images/image-20210225090416314.png)
|
||||||
|
@ -41,6 +41,15 @@ def server(text, msg):
|
|||||||
uri = 'https://sc.ftqq.com/xxxx.send?text={}&desp={}'.format(text, msg)
|
uri = 'https://sc.ftqq.com/xxxx.send?text={}&desp={}'.format(text, msg)
|
||||||
requests.get(uri)
|
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
|
# 通过检查name 和 description 中是否存在test字样,排除test
|
||||||
def regular(req):
|
def regular(req):
|
||||||
@ -73,9 +82,10 @@ def sendNews():
|
|||||||
regular(req)
|
regular(req)
|
||||||
# 检查name 和 description 中是否存在test字样 和 是否更新
|
# 检查name 和 description 中是否存在test字样 和 是否更新
|
||||||
if regular(req) and total_count != getNews()[0]:
|
if regular(req) and total_count != getNews()[0]:
|
||||||
# 二选一即可,没配置的 注释或者删掉
|
# 三选一即可,没配置的 注释或者删掉
|
||||||
server(text, msg)
|
# server(text, msg)
|
||||||
dingding(text, msg)
|
dingding(text, msg)
|
||||||
|
# tgbot(text,msg)
|
||||||
print(msg)
|
print(msg)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
BIN
images/124256679-27701e00-db5e-11eb-9432-d3a9048daeec.png
Normal file
BIN
images/124256679-27701e00-db5e-11eb-9432-d3a9048daeec.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
Loading…
Reference in New Issue
Block a user