You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
775 B
32 lines
775 B
#!/usr/bin/env python3
|
|
|
|
from telegram import Bot
|
|
|
|
from db import get_conn, Subscriber
|
|
from config import BOT_TOKEN, ADMIN
|
|
|
|
|
|
def send_users_list(bot: Bot = None):
|
|
conn = get_conn(read_only=True)
|
|
|
|
if not bot:
|
|
bot = Bot(BOT_TOKEN)
|
|
|
|
subs = conn.root.subscribers.values()
|
|
|
|
messages = [f'Count: {subs.count()}\n']
|
|
for sub in subs: # type: Subscriber
|
|
msg = f'<code>#{sub.id:<4} {sub.uid:>14} </code>'
|
|
if sub.uid < 0:
|
|
msg += str(sub.name)
|
|
else:
|
|
msg += f'<a href="tg://user?id={sub.uid}">{sub.name}</a>'
|
|
messages.append(msg)
|
|
|
|
for i in range(0, len(messages), 40):
|
|
bot.send_message(ADMIN, '\n'.join(messages[i:i+40]), parse_mode='html')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
send_users_list()
|