boobot: Support ignored users

And ignore irkers by default
This commit is contained in:
Laurent Bachelier 2013-06-23 21:17:13 +02:00
commit a488edbd69

View file

@ -42,6 +42,7 @@ from weboob.tools.storage import StandardStorage
IRC_CHANNELS = os.getenv('BOOBOT_CHANNELS', '#weboob').split(',') IRC_CHANNELS = os.getenv('BOOBOT_CHANNELS', '#weboob').split(',')
IRC_NICKNAME = os.getenv('BOOBOT_NICKNAME', 'boobot') IRC_NICKNAME = os.getenv('BOOBOT_NICKNAME', 'boobot')
IRC_SERVER = os.getenv('BOOBOT_SERVER', 'chat.freenode.net') IRC_SERVER = os.getenv('BOOBOT_SERVER', 'chat.freenode.net')
IRC_IGNORE = [re.compile(i) for i in os.getenv('BOOBOT_IGNORE', '!~?irker@').split(',')]
STORAGE_FILE = os.getenv('BOOBOT_STORAGE', 'boobot.storage') STORAGE_FILE = os.getenv('BOOBOT_STORAGE', 'boobot.storage')
@ -239,9 +240,14 @@ class Boobot(SingleServerIRCBot):
if callable(event.arguments): if callable(event.arguments):
text = ' '.join(event.arguments()) text = ' '.join(event.arguments())
channel = event.target() channel = event.target()
nick = event.source()
else: else:
text = ' '.join(event.arguments) text = ' '.join(event.arguments)
channel = event.target channel = event.target
nick = event.source
for ignore in IRC_IGNORE:
if ignore.search(nick):
return
for m in re.findall('([\w\d_\-]+@\w+)', text): for m in re.findall('([\w\d_\-]+@\w+)', text):
for msg in self.on_boobid(m): for msg in self.on_boobid(m):
self.send_message(msg, channel) self.send_message(msg, channel)