PagerMaid_Plugins_Pyro/telegram_update.py

40 lines
1.0 KiB
Python
Raw Normal View History

2022-07-24 10:36:57 +00:00
import time
import sys
import contextlib
2022-06-08 08:58:40 +00:00
from httpx import get, post
token = str(sys.argv[1])
2023-07-01 12:18:58 +00:00
main = get(
"https://api.github.com/repos/TeamPGM/PagerMaid_Plugins_Pyro/commits/v2"
).json()
text = (
(
(
(
"#更新日志 #pyro #"
2023-07-01 12:18:58 +00:00
+ main["commit"]["author"]["name"].replace("_", "")
+ " \n\n🔨 ["
+ main["sha"][:7]
)
2023-07-01 12:18:58 +00:00
+ "](https://github.com/TeamPGM/PagerMaid_Plugins_Pyro/commit/"
)
2023-07-01 12:18:58 +00:00
+ main["sha"]
)
2023-07-01 12:18:58 +00:00
+ "): "
) + main["commit"]["message"]
2023-07-01 12:18:58 +00:00
url = f"https://api.telegram.org/bot{token}/sendMessage"
for cid in ["-1001441461877", "-1001319957857"]:
push_content = {
"chat_id": cid,
"disable_web_page_preview": "True",
"parse_mode": "markdown",
"text": text,
}
if cid == "-1001441461877":
push_content["message_thread_id"] = 1027828
2022-07-24 10:36:57 +00:00
with contextlib.suppress(Exception):
main_req = post(url, data=push_content)
time.sleep(1)
2023-07-01 12:18:58 +00:00
print(main["sha"] + " ok")