Skip to content
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
10 changes: 7 additions & 3 deletions discord_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def begin(self):
async def checkMarvinActions(self, message):
"""Check if Marvin should perform any actions"""
words = self.tokenize(message.content)
if self.user.name.lower() in words:
if self.user.mentioned_in(message) or self.user.name.lower() in words:
for action in self.ACTIONS:
response = action(words)
if response:
await message.channel.send(response)
await message.reply(response)
else:
for action in self.GENERAL_ACTIONS:
response = action(words)
if response:
await message.channel.send(response)
await message.reply(response)

async def on_message(self, message):
"""Hook run on every message"""
Expand All @@ -50,3 +50,7 @@ async def on_message(self, message):
# don't react to own messages
return
await self.checkMarvinActions(message)

async def on_message_edit(self, _, after):
"""Hook run on every edited message"""
await self.on_message(after)
Loading