Pass through messages even if they're commands
This commit is contained in:
+15
-15
@@ -226,7 +226,7 @@ class Bot(AbstractUser):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def handle_command(self, message: Message) -> Optional[bool]:
|
async def handle_command(self, message: Message) -> None:
|
||||||
def reply(reply_text: str) -> Awaitable[Message]:
|
def reply(reply_text: str) -> Awaitable[Message]:
|
||||||
return self.client.send_message(message.chat_id, reply_text, reply_to=message.id)
|
return self.client.send_message(message.chat_id, reply_text, reply_to=message.id)
|
||||||
|
|
||||||
@@ -234,9 +234,8 @@ class Bot(AbstractUser):
|
|||||||
|
|
||||||
if self.match_command(text, "start"):
|
if self.match_command(text, "start"):
|
||||||
pcm = config["bridge.relaybot.private_chat.message"]
|
pcm = config["bridge.relaybot.private_chat.message"]
|
||||||
if not pcm:
|
if pcm:
|
||||||
return True
|
await reply(pcm)
|
||||||
await reply(pcm)
|
|
||||||
return
|
return
|
||||||
elif self.match_command(text, "id"):
|
elif self.match_command(text, "id"):
|
||||||
await self.handle_command_id(message, reply)
|
await self.handle_command_id(message, reply)
|
||||||
@@ -246,18 +245,19 @@ class Bot(AbstractUser):
|
|||||||
|
|
||||||
portal = po.Portal.get_by_entity(message.to_id)
|
portal = po.Portal.get_by_entity(message.to_id)
|
||||||
|
|
||||||
if self.match_command(text, "portal"):
|
is_portal_cmd = self.match_command(text, "portal")
|
||||||
|
is_invite_cmd = self.match_command(text, "invite")
|
||||||
|
if is_portal_cmd or is_invite_cmd:
|
||||||
if not await self.check_can_use_commands(message, reply):
|
if not await self.check_can_use_commands(message, reply):
|
||||||
return
|
return
|
||||||
await self.handle_command_portal(portal, reply)
|
if is_portal_cmd:
|
||||||
elif self.match_command(text, "invite"):
|
await self.handle_command_portal(portal, reply)
|
||||||
if not await self.check_can_use_commands(message, reply):
|
elif is_invite_cmd:
|
||||||
return
|
try:
|
||||||
try:
|
mxid = text[text.index(" ") + 1:]
|
||||||
mxid = text[text.index(" ") + 1:]
|
except ValueError:
|
||||||
except ValueError:
|
mxid = ""
|
||||||
mxid = ""
|
await self.handle_command_invite(portal, reply, mxid_input=UserID(mxid))
|
||||||
await self.handle_command_invite(portal, reply, mxid_input=UserID(mxid))
|
|
||||||
|
|
||||||
def handle_service_message(self, message: MessageService) -> None:
|
def handle_service_message(self, message: MessageService) -> None:
|
||||||
to_peer = message.to_id
|
to_peer = message.to_id
|
||||||
@@ -291,7 +291,7 @@ class Bot(AbstractUser):
|
|||||||
and isinstance(update.message.entities[0], MessageEntityBotCommand)
|
and isinstance(update.message.entities[0], MessageEntityBotCommand)
|
||||||
and update.message.entities[0].offset == 0)
|
and update.message.entities[0].offset == 0)
|
||||||
if is_command:
|
if is_command:
|
||||||
return not await self.handle_command(update.message)
|
await self.handle_command(update.message)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_in_chat(self, peer_id) -> bool:
|
def is_in_chat(self, peer_id) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user