diff --git a/main.py b/main.py
index 5fbd57f..8509e8f 100755
--- a/main.py
+++ b/main.py
@@ -212,6 +212,27 @@ def _process_media_group(bot: Bot, messages: List[Message]):
_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'{sub.uid:>14}
'
+ if sub.uid < 0:
+ msg += str(sub.name)
+ else:
+ msg += f'{sub.name}'
+ 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):
current_chat = m.chat_id
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(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(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.start_polling()