From: CMDR furrycat Date: Thu, 29 Sep 2016 17:01:14 +0000 (+0100) Subject: Ignore messages sent to roles or channels. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=0ee25802b0a373eb6743ad8b15b3e0cdba1e22a3;p=furrycat%2Fcatbot.git Ignore messages sent to roles or channels. --- diff --git a/bot.py b/bot.py index 26d5aed..e6b768f 100755 --- a/bot.py +++ b/bot.py @@ -610,13 +610,25 @@ def on_ready(): asyncio.async(do_feeds(feeds)) asyncio.async(maybe_sleep()) +def mentioned_in(message, explicit = True): + if message.channel.is_private: + return True + if not client.user.mentioned_in(message): + return False + if explicit: + for member in message.mentions: + if member.id == client.user.id: + return True + return False + return True + @client.event @asyncio.coroutine def on_message(message): if message.author.id == client.user.id: return log.debug('Got message from {}: {}'.format(message.author, message.content)) - if not client.user.mentioned_in(message) and not message.channel.is_private: + if not mentioned_in(message): log.debug('Message is not for me!') return raw = re.sub('<@{}>'.format(client.user.id), '', message.content).strip()