diff --git a/src/gptbot/callbacks/message.py b/src/gptbot/callbacks/message.py index 5f5a176..d5c8fa4 100644 --- a/src/gptbot/callbacks/message.py +++ b/src/gptbot/callbacks/message.py @@ -33,7 +33,7 @@ async def message_callback(room: MatrixRoom | str, event: RoomMessageText | Mego if event.sender == bot.matrix_client.user_id: bot.logger.log("Message is from bot itself - ignoring") - elif event.body.startswith("!gptbot"): + elif event.body.startswith("!gptbot") or event.body.startswith("* !gptbot"): await bot.process_command(room, event) elif event.body.startswith("!"): diff --git a/src/gptbot/classes/bot.py b/src/gptbot/classes/bot.py index 9800581..101d17d 100644 --- a/src/gptbot/classes/bot.py +++ b/src/gptbot/classes/bot.py @@ -195,7 +195,7 @@ class GPTBot: return user_id - async def _last_n_messages(self, room: str | MatrixRoom, n: Optional[int]): + async def _last_n_messages(self, room: str | MatrixRoom, n: Optional[int], ignore_bot_commands: bool = True): messages = [] n = n or self.max_messages room_id = room.room_id if isinstance(room, MatrixRoom) else room @@ -233,7 +233,7 @@ class GPTBot: if event.body.startswith("!gptbot ignoreolder"): break if (not event.body.startswith("!")) or ( - event.body.startswith("!gptbot") + event.body.startswith("!gptbot") and not ignore_bot_commands ): messages.append(event) @@ -319,6 +319,10 @@ class GPTBot: f"Received command {event.body} from {event.sender} in room {room.room_id}", "debug", ) + + if event.body.startswith("* "): + event.body = event.body[2:] + command = event.body.split()[1] if event.body.split()[1:] else None await COMMANDS.get(command, COMMANDS[None])(room, event, self)