diff --git a/bots/modules/channel_helper.py b/bots/modules/channel_helper.py index 53e208f..ea4affe 100644 --- a/bots/modules/channel_helper.py +++ b/bots/modules/channel_helper.py @@ -213,10 +213,20 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig): def build_dispatcher(self, dispatcher: Dispatcher): dispatcher.add_handler(CommandHandler(['delete', 'del', 'remove', 'rem'], self.handle_delete, Filters.reply)) dispatcher.add_handler(CommandHandler(['count'], self.handle_count)) + dispatcher.add_handler(CommandHandler(['dump_db'], self.dump_db)) dispatcher.add_handler(CallbackQueryHandler(self.handle_delete_callback, pattern=r'^del (\d+)$')) dispatcher.add_handler(MessageHandler(Filters.private, self.handle_message)) return dispatcher + def dump_db(self, update: Update, ctx: CallbackContext): + if self.users.count() and not self.users.filter(user_id=update.effective_user.id).count(): + update.effective_message.reply_text('GTFO') + return + update.effective_message.reply_document( + BytesIO(json.dumps(list(QueuedItem.objects.filter(config=self).values()), indent=2).encode()), + filename='dump.json', + ) + def should_send_photo_group(self): # noinspection PyChainedComparisons return self.send_photo_groups or (