Skip to content

Commit

Permalink
bot now ignores messages that start with ~
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmatthis committed Aug 21, 2023
1 parent 174fb31 commit f1273b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions jonbot/layer0_frontends/discord_bot/discord_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async def on_ready(self):
@discord.Cog.listener()
async def on_message(self, message: discord.Message) -> None:


if not allowed_to_reply(message):
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
TRANSCRIBED_AUDIO_PREFIX = "Transcribed audio for"
RESPONSE_INCOMING_TEXT = "response incoming..."
ERROR_MESSAGE_REPLY_PREFIX_TEXT = f"Sorry, an error occurred while processing your request"

IGNORE_PREFIX = "~" # If a message starts with this, the bot will ignore it


def this_message_is_from_a_bot(message: discord.Message) -> bool:
Expand All @@ -22,13 +22,22 @@ def check_if_transcribed_audio_message(message: discord.Message) -> bool:
message.content.startswith(FINISHED_VOICE_RECORDING_PREFIX))


def message_starts_with_ignore_prefix(message:discord.Message) -> bool:
return message.content.startswith(IGNORE_PREFIX)



def should_reply(message: discord.Message,
bot_user_name: str) -> bool:

if not allowed_to_reply(message):
logger.debug(f"Message `{message.content}` was not handled by the bot {bot_user_name} (reason: not allowed to reply)")
return False

if message_starts_with_ignore_prefix(message):
logger.debug(f"Message `{message.content}` was not handled by the bot {bot_user_name} (reason: starts with ignore prefix{IGNORE_PREFIX})")
return False

if this_message_is_from_a_bot(message):
logger.debug(f"Message `{message.content}` was not handled by the bot {bot_user_name} (reason: bot message)")
return False
Expand Down

0 comments on commit f1273b4

Please sign in to comment.