fix(discord): correct group_policy default to mention and style cleanup
This commit is contained in:
@@ -174,7 +174,7 @@ class DiscordChannel(BaseChannel):
|
|||||||
# Capture bot user ID for mention detection
|
# Capture bot user ID for mention detection
|
||||||
user_data = payload.get("user") or {}
|
user_data = payload.get("user") or {}
|
||||||
self._bot_user_id = user_data.get("id")
|
self._bot_user_id = user_data.get("id")
|
||||||
logger.info(f"Discord bot connected as user {self._bot_user_id}")
|
logger.info("Discord bot connected as user {}", self._bot_user_id)
|
||||||
elif op == 0 and event_type == "MESSAGE_CREATE":
|
elif op == 0 and event_type == "MESSAGE_CREATE":
|
||||||
await self._handle_message_create(payload)
|
await self._handle_message_create(payload)
|
||||||
elif op == 7:
|
elif op == 7:
|
||||||
@@ -287,8 +287,6 @@ class DiscordChannel(BaseChannel):
|
|||||||
|
|
||||||
def _should_respond_in_group(self, payload: dict[str, Any], content: str) -> bool:
|
def _should_respond_in_group(self, payload: dict[str, Any], content: str) -> bool:
|
||||||
"""Check if bot should respond in a group channel based on policy."""
|
"""Check if bot should respond in a group channel based on policy."""
|
||||||
channel_id = str(payload.get("channel_id", ""))
|
|
||||||
|
|
||||||
if self.config.group_policy == "open":
|
if self.config.group_policy == "open":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -303,7 +301,7 @@ class DiscordChannel(BaseChannel):
|
|||||||
# Also check content for mention format <@USER_ID>
|
# Also check content for mention format <@USER_ID>
|
||||||
if f"<@{self._bot_user_id}>" in content or f"<@!{self._bot_user_id}>" in content:
|
if f"<@{self._bot_user_id}>" in content or f"<@!{self._bot_user_id}>" in content:
|
||||||
return True
|
return True
|
||||||
logger.debug(f"Discord message in {channel_id} ignored (bot not mentioned)")
|
logger.debug("Discord message in {} ignored (bot not mentioned)", payload.get("channel_id"))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class DiscordConfig(Base):
|
|||||||
allow_from: list[str] = Field(default_factory=list) # Allowed user IDs
|
allow_from: list[str] = Field(default_factory=list) # Allowed user IDs
|
||||||
gateway_url: str = "wss://gateway.discord.gg/?v=10&encoding=json"
|
gateway_url: str = "wss://gateway.discord.gg/?v=10&encoding=json"
|
||||||
intents: int = 37377 # GUILDS + GUILD_MESSAGES + DIRECT_MESSAGES + MESSAGE_CONTENT
|
intents: int = 37377 # GUILDS + GUILD_MESSAGES + DIRECT_MESSAGES + MESSAGE_CONTENT
|
||||||
group_policy: str = "open" # "mention" or "open"
|
group_policy: Literal["mention", "open"] = "mention"
|
||||||
|
|
||||||
|
|
||||||
class MatrixConfig(Base):
|
class MatrixConfig(Base):
|
||||||
|
|||||||
Reference in New Issue
Block a user