if message.author.bot:
log.debug('Ignoring message from bot!')
return
+
+ # Strip our mention from the message.
raw = re.sub('<@{}>'.format(client.user.id), '', message.content).strip()
- m = re.match(r'^\s*(\S+)', raw)
+
+ # Handle copy/paste; Discord client will prepend (BOT)<user>: to pasted
+ # text. Deal with the common cases of the user copying his own message
+ # or quoting the bot.
+ raw = re.sub('^(?:BOT{}|{}):\s+'.format(client.user.name, message.author.name), '', raw)
+
+ m = re.match(r'^(\S+)', raw)
if m is None:
return
command = m.group(1)