PagerMaid_Plugins_Pyro/telegram_update.py
sourcery-ai[bot] 1360fe05e2
'Refactored by Sourcery' (#8)
Co-authored-by: Sourcery AI <>
2022-06-14 15:54:55 +08:00

36 lines
979 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json, time, sys
from httpx import get, post
token = str(sys.argv[1])
main = json.loads(get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2").content)
text = (
(
(
(
"#更新日志 #pyro #"
+ main['commit']['author']['name'].replace('_', '')
+ ' \n\n🔨 ['
+ main['sha'][:7]
)
+ '](https://github.com/TeamPGM/PagerMaid_Plugins_Pyro/commit/'
)
+ main['sha']
)
+ '): '
) + main['commit']['message']
push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown',
'text': text}
url = f'https://api.telegram.org/bot{token}/sendMessage'
try:
main_req = post(url, data=push_content)
except:
pass
push_content['chat_id'] = '-1001319957857'
time.sleep(1)
try:
main_req = post(url, data=push_content)
except:
pass
print(main['sha'] + " ok")