lono/import_users.py
2019-03-04 02:33:57 +03:00

23 lines
544 B
Python
Executable File

#!/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()
uids = input('Please input user ids split by spaces: ')
for uid in uids.split():
try:
uid = int(uid)
except (ValueError, TypeError):
pass
conn.root.subscribers[uid] = Subscriber.from_chat(bot.get_chat(uid))
commit()
conn.close()
print('Users have been successfully imported')