big update

This commit is contained in:
2019-03-04 02:23:12 +03:00
parent 5c0efb068b
commit f4c739a964
11 changed files with 296 additions and 104 deletions

31
send_users_list.py Executable file
View 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()