|
|
|
@ -1,8 +1,12 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import argparse
|
|
|
|
|
import re
|
|
|
|
|
import yaml
|
|
|
|
|
from irc.client import NickMask
|
|
|
|
|
from pinhook import plugin, bot
|
|
|
|
|
|
|
|
|
|
RELAY_REGEX = re.compile(r'^<([^@]+@(?:tilde|bread))>\s?(.*)$')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BreadBot(bot.Bot):
|
|
|
|
|
|
|
|
|
@ -12,6 +16,24 @@ class BreadBot(bot.Bot):
|
|
|
|
|
for channel in self.chanlist:
|
|
|
|
|
self.process_output(c, channel, plugin.message('bread'))
|
|
|
|
|
|
|
|
|
|
def process_event(self, c, e):
|
|
|
|
|
# Handle BreadRelay by suppressing it
|
|
|
|
|
if e.source.nick == 'BreadRelay' and e.arguments:
|
|
|
|
|
match = RELAY_REGEX.match(e.arguments[0])
|
|
|
|
|
if match:
|
|
|
|
|
nick, e.arguments[0] = match.groups()
|
|
|
|
|
# e.source.nick is a property, and e.source is a string
|
|
|
|
|
# in the nick!userhost format, so we reconstruct it
|
|
|
|
|
e.source = NickMask(f'{nick}!{e.source.userhost}')
|
|
|
|
|
|
|
|
|
|
# Ignore messages sent by the bot itself
|
|
|
|
|
if e.source.nick == self.bot_nick:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
print(e.source, e.arguments)
|
|
|
|
|
|
|
|
|
|
return super().process_event(c, e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|