lono/import_users.py

23 lines
544 B
Python
Raw Normal View History

2019-03-03 23:23:12 +00:00
#!/usr/bin/env python3
from telegram import Bot
from db import get_conn, Subscriber, commit
from config import BOT_TOKEN
if __name__ == '__main__':
bot = Bot(BOT_TOKEN)
conn = get_conn()
2019-03-03 23:25:10 +00:00
uids = input('Please input user ids split by spaces: ')
2019-03-03 23:23:12 +00:00
for uid in uids.split():
2019-03-03 23:33:57 +00:00
try:
uid = int(uid)
except (ValueError, TypeError):
pass
2019-03-03 23:23:12 +00:00
conn.root.subscribers[uid] = Subscriber.from_chat(bot.get_chat(uid))
commit()
2019-03-03 23:26:51 +00:00
conn.close()
2019-03-03 23:23:12 +00:00
print('Users have been successfully imported')