Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新特性请求:增加向telegram推送日志 #26

Open
n0thing2speak opened this issue Mar 20, 2022 · 2 comments
Open

新特性请求:增加向telegram推送日志 #26

n0thing2speak opened this issue Mar 20, 2022 · 2 comments

Comments

@n0thing2speak
Copy link

你好:因为tg使用更加简单,请求添加一个tg的日志推送模块
如:
tg_bot_token:telegram的bot token
tg_user_id:telegram的用户id:

sync请求示例:

import requests
TG_USER_ID=tg_user_id
TG_BOT_TOKEN=tg_bot_token
TG_API_HOST = 'api.telegram.org'
def telegram(log_detail:str):
    data = (('chat_id', TG_USER_ID), ('text', 'nb_log日志推送 \n\n' + log_detail:str))
    response = requests.post('https://' + TG_API_HOST + '/bot' + TG_BOT_TOKEN +
                             '/sendMessage',
                             data=data)
    if response.status_code != 200:
        print('Telegram Bot 推送失败')
    else:
        print('Telegram Bot 推送成功')
@ydf0509
Copy link
Owner

ydf0509 commented Mar 21, 2022

telegram国内能用吗?

@n0thing2speak
Copy link
Author

可以搭建一个转发,再说也不一定都是国内用这个库啊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants