-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_telegram_ids.py
36 lines (29 loc) · 943 Bytes
/
get_telegram_ids.py
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
29
30
31
32
33
34
35
36
# this is a helper script to find out chat ids of telegram groups that
# have added our bot "theweeklyOSMbot" to their groups.
# How to use:
# source spamenv/bin/activate
# python get_telegram_ids.py
# deactivate
import telepot
import yaml
with open("configs/private/secrets/weekly.yaml") as f:
# use safe_load instead load
secrets = yaml.safe_load(f)
bot = telepot.Bot(secrets["telegram_TOKEN"])
resp = bot.getUpdates()
chats = []
for update in resp:
try:
info = update["message"]["chat"]
if not info in chats:
chats.append(info)
print(info)
except KeyError:
continue
# recipient = -1001064379468
# message = "Hello from weeklyteam. We will notify you here about new issues of https://weeklyosm.eu from now on. Feedback welcome at [email protected]"
# try:
# resp = bot.sendMessage(int(recipient), message)
# print (resp)
# except Exception as e:
# print (e)