big update
This commit is contained in:
31
send_users_list.py
Executable file
31
send_users_list.py
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/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()
|
Reference in New Issue
Block a user