feat: respond to all messages in DMs without requiring @mention
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
bot.py
12
bot.py
@@ -279,7 +279,9 @@ class Bot:
|
|||||||
await self._send_text(room.room_id, HELP_TEXT)
|
await self._send_text(room.room_id, HELP_TEXT)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if bot is mentioned (display name or user ID)
|
# In DMs (2 members), respond to all messages; in groups, require @mention
|
||||||
|
is_dm = room.member_count == 2
|
||||||
|
if not is_dm:
|
||||||
bot_display = self.client.user_id.split(":")[0].lstrip("@")
|
bot_display = self.client.user_id.split(":")[0].lstrip("@")
|
||||||
mentioned = (
|
mentioned = (
|
||||||
BOT_USER in body
|
BOT_USER in body
|
||||||
@@ -405,11 +407,15 @@ class Bot:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def on_megolm(self, room, event: MegolmEvent):
|
async def on_megolm(self, room, event: MegolmEvent):
|
||||||
"""Log undecryptable messages."""
|
"""Request keys for undecryptable messages."""
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Undecryptable event %s in %s from %s",
|
"Undecryptable event %s in %s from %s — requesting keys",
|
||||||
event.event_id, room.room_id, event.sender,
|
event.event_id, room.room_id, event.sender,
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
await self.client.request_room_key(event)
|
||||||
|
except Exception:
|
||||||
|
logger.debug("Key request failed", exc_info=True)
|
||||||
|
|
||||||
async def on_key_verification(self, event):
|
async def on_key_verification(self, event):
|
||||||
"""Auto-accept key verification requests."""
|
"""Auto-accept key verification requests."""
|
||||||
|
|||||||
Reference in New Issue
Block a user