From 626cc2b990bc747f1952b8a007b1dd187daf97d2 Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Wed, 23 Mar 2022 12:30:10 +0300 Subject: [PATCH] fix delete command, add count command to channel helper --- bots/modules/channel_helper.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bots/modules/channel_helper.py b/bots/modules/channel_helper.py index 0d9b791..65c586c 100644 --- a/bots/modules/channel_helper.py +++ b/bots/modules/channel_helper.py @@ -126,14 +126,20 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig): return reply_to_id = update.effective_message.reply_to_message.message_id try: - msg = QueuedItem.objects.get(message_id=reply_to_id) + msg = QueuedItem.objects.get(message_id=reply_to_id, config=self) msg.delete() except QueuedItem.DoesNotExist: update.effective_message.reply_text('Deleted') + def handle_count(self, update: Update, ctx: CallbackContext): + if update.effective_message.chat_id != self.chat_id: + return + update.effective_message.reply_text(f'{QueuedItem.objects.filter(config=self).count()} items queued') + def build_dispatcher(self, dispatcher: Dispatcher): - dispatcher.add_handler(MessageHandler(Filters.private, self.handle_message)) dispatcher.add_handler(CommandHandler(['delete', 'del', 'remove', 'rem'], self.handle_delete, Filters.reply)) + dispatcher.add_handler(CommandHandler(['count'], self.handle_count)) + dispatcher.add_handler(MessageHandler(Filters.private, self.handle_message)) return dispatcher