lono/get_users_list.py

22 lines
557 B
Python
Raw Normal View History

2019-03-03 18:34:28 +00:00
#!/usr/bin/env python3
from html import escape
from models import Subscriber
from telegram import Bot
from config import BOT_TOKEN
bot = Bot(BOT_TOKEN)
subs = Subscriber.select()
2019-03-03 18:38:51 +00:00
2019-03-03 18:34:28 +00:00
messages = []
for sub in subs:
chat = bot.send_message(sub.user_id, '.').chat
chat_name = escape(f'{chat.first_name or ""} {chat.last_name or ""} {chat.title or ""}'.rstrip())
2019-03-03 18:38:51 +00:00
messages.append(f'<pre>#{sub.id:>4} {sub.user_id:>20} </pre><a href="tg://user?id={sub.user_id}">{chat_name}</a>')
2019-03-03 18:34:28 +00:00
2019-03-03 18:38:51 +00:00
bot.send_message(98934915, '\n'.join(messages), parse_mode='html')