Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Commit

Permalink
Improve bot message exclusion so that user messages can still be foun…
Browse files Browse the repository at this point in the history
…d. Make '>' commands unquotable.
  • Loading branch information
Martin Wurm committed Jan 25, 2018
1 parent 28975ac commit e56f71d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parrotbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,14 @@ async def search_message_by_quote(self, quote, partial=False):
):
if not match["author"] \
or await self.is_same_user(message.author, match["author"]):
if message.id.find(match["content"]) == 0 and not partial \
if not message.author.bot \
and not message.content.startswith(">") \
and (message.id.find(match["content"]) == 0 and not partial \
or re.search(
re.escape(match["content"]),
message.content,
flags=re.IGNORECASE
):
)):
return message

return None
Expand Down Expand Up @@ -366,7 +368,7 @@ async def quote_message(self, quote, partial=False):
# Check if the bot is allowed to send messages in that channel.
bot_may_send = quote.channel.permissions_for(bot_member).send_messages

if quoted_message and bot_may_send and not quoted_message.author.bot:
if quoted_message and bot_may_send:
if partial:
quote_request_match = self.re_partial_quote.fullmatch(
quote.content
Expand Down

0 comments on commit e56f71d

Please sign in to comment.