Skip to content

Commit

Permalink
feat: ignore unknown commands in group chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanssen0 committed Dec 9, 2023
1 parent 645951a commit 9248644
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion BotHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def start_bot(self):
self._application.add_handler(CommandHandler(BOT_COMMAND_ADMIN_BROADCAST, self.bot_command_broadcast))

# Unknown command -> send help
self._application.add_handler(MessageHandler(filters.COMMAND, self.bot_command_help))
self._application.add_handler(MessageHandler(filters.COMMAND, self.bot_command_unknown))

# Add buttons handler
self._application.add_handler(CallbackQueryHandler(self.query_callback))
Expand Down Expand Up @@ -1634,6 +1634,17 @@ async def bot_command_or_message_request_raw(self, request_type: int,
context,
reply_to_message_id=request_response.reply_message_id)

async def bot_command_unknown(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""
unknown command
:param update:
:param context:
:return:
"""
if update.message.chat.type.lower() != "private":
return
await self.bot_command_help(update, context)

async def bot_command_help(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""
/help command
Expand Down

0 comments on commit 9248644

Please sign in to comment.