add users list
This commit is contained in:
parent
2c81d4937f
commit
295cc4799b
23
main.py
23
main.py
@ -212,6 +212,27 @@ def _process_media_group(bot: Bot, messages: List[Message]):
|
|||||||
_remove_user(uid)
|
_remove_user(uid)
|
||||||
|
|
||||||
|
|
||||||
|
def users_list(bot: Bot, update: Update):
|
||||||
|
current_chat = update.effective_chat.id
|
||||||
|
subs = conn.root.subscribers # type: Dict[int, Subscriber]
|
||||||
|
if current_chat not in subs:
|
||||||
|
return
|
||||||
|
|
||||||
|
messages = [f'Count: {len(subs)}\n']
|
||||||
|
for sub in subs.values(): # type: Subscriber
|
||||||
|
msg = f'<code>{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):
|
||||||
|
update.effective_message.reply_text('\n'.join(messages[i:i+40]), parse_mode='html')
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
def _process_message(bot: Bot, m: Message):
|
def _process_message(bot: Bot, m: Message):
|
||||||
current_chat = m.chat_id
|
current_chat = m.chat_id
|
||||||
users = conn.root.subscribers # type: Dict[int, Subscriber]
|
users = conn.root.subscribers # type: Dict[int, Subscriber]
|
||||||
@ -332,7 +353,7 @@ if __name__ == '__main__':
|
|||||||
updater.dispatcher.add_handler(CallbackQueryHandler(add_user, pattern=r'^add (\d+)$', pass_groups=True))
|
updater.dispatcher.add_handler(CallbackQueryHandler(add_user, pattern=r'^add (\d+)$', pass_groups=True))
|
||||||
updater.dispatcher.add_handler(CommandHandler('remove', remove_user, Filters.chat(MANAGEMENT_CHAT), pass_args=True))
|
updater.dispatcher.add_handler(CommandHandler('remove', remove_user, Filters.chat(MANAGEMENT_CHAT), pass_args=True))
|
||||||
updater.dispatcher.add_handler(CallbackQueryHandler(remove_user, pattern=r'^remove (\d+)$', pass_groups=True))
|
updater.dispatcher.add_handler(CallbackQueryHandler(remove_user, pattern=r'^remove (\d+)$', pass_groups=True))
|
||||||
updater.dispatcher.add_handler(CommandHandler('users', users, Filters.chat(MANAGEMENT_CHAT)))
|
updater.dispatcher.add_handler(CommandHandler('users', users_list, Filters.private))
|
||||||
updater.dispatcher.add_handler(MessageHandler(Filters.private, msg))
|
updater.dispatcher.add_handler(MessageHandler(Filters.private, msg))
|
||||||
|
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
|
Loading…
Reference in New Issue
Block a user