forked from tobih7/testflight-watcher
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtelegram_bot.py
More file actions
executable file
·28 lines (22 loc) · 873 Bytes
/
telegram_bot.py
File metadata and controls
executable file
·28 lines (22 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
import testflight_watcher
import requests
import sys
import os
CHAT_ID = os.environ['CHAT_ID']
TRACKERS = os.environ['TRACKERS']
BOT_TOKEN = os.environ['BOT_TOKEN']
BOT_URL = "https://api.telegram.org/bot{}/sendMessage".format(BOT_TOKEN)
MSG_NO_FULL = "TestFlight slots for <b>{}</b> beta are now available! \
<a href='{}'>Download now</a>"
MSG_FULL = "<b>{}</b> beta program on TestFlight is now full"
def send_notification(tf_id, free_slots, title):
dl_url = testflight_watcher.TESTFLIGHT_URL.format(tf_id)
if free_slots:
message = MSG_NO_FULL.format(title, dl_url)
else:
message = MSG_FULL.format(title)
requests.get(
BOT_URL, params={"chat_id": CHAT_ID, "text": message, "parse_mode": "html", "disable_web_page_preview": "true"}
)
testflight_watcher.watch(TRACKERS.split(","), send_notification)