fix delete command, add count command to channel helper
This commit is contained in:
parent
867a3b84dc
commit
626cc2b990
@ -126,14 +126,20 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig):
|
|||||||
return
|
return
|
||||||
reply_to_id = update.effective_message.reply_to_message.message_id
|
reply_to_id = update.effective_message.reply_to_message.message_id
|
||||||
try:
|
try:
|
||||||
msg = QueuedItem.objects.get(message_id=reply_to_id)
|
msg = QueuedItem.objects.get(message_id=reply_to_id, config=self)
|
||||||
msg.delete()
|
msg.delete()
|
||||||
except QueuedItem.DoesNotExist:
|
except QueuedItem.DoesNotExist:
|
||||||
update.effective_message.reply_text('Deleted')
|
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):
|
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(['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
|
return dispatcher
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user