25 lines
628 B
Python
Executable File
25 lines
628 B
Python
Executable File
#!/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()
|
|
|
|
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())
|
|
messages.append(f'<code>#{sub.id:<4} {sub.user_id:>14} </code><a href="tg://user?id={sub.user_id}">{chat_name}</a>')
|
|
|
|
|
|
for i in range(0, len(messages), 10):
|
|
sl = messages[i*10:i*10+10]
|
|
bot.send_message(98934915, '\n'.join(sl), parse_mode='html')
|