Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log the content of a message that matched a trigger. #296

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions botto/tld_botto.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,13 @@ def clean_message(self, actual_motto: str, guild: Guild) -> str:
return actual_motto

def check_triggers(self, message: Message) -> tuple[Callable, re.Match]:
def search_triggers(content: str, trigger_dict: dict):
def search_triggers(content: str, trigger_dict: dict[Callable, re.Match]):
for name, triggers in trigger_dict.items():
for trigger in triggers:
if matched := trigger.match(content):
log.debug(
f"Matched trigger {name} Match groups: {matched.groupdict()}"
)
return name, matched

at_command = None
Expand Down Expand Up @@ -783,12 +786,13 @@ async def process_dm(self, message: Message):
logging.info(f"Sending help message in response to {message}")
await dm_channel.send(
"Sorry, I am not currently capable of extended conversation, but I have "
"forwarded your message to my operators. " + help_message
"forwarded your message to my operators.\n" + help_message
)
await asyncio.gather(react_task, log_task)

async def log_dm(self, message: Message):
support_config = self.config["support"]
message.embeds
dm_log_channel_id = support_config.get("dm_log_channel")
if not dm_log_channel_id:
log.warning("No DM log channel configured")
Expand Down