def watch_part(message: str, bot: humphrey.IRCClient): tokens = message.split(maxsplit=3) source = tokens[0].lstrip(':') nick, user, host = bot.parse_hostmask(source) text = '- {} [{}] has left {}'.format(nick, source, bot.c.get('irc:channel')) if len(tokens) > 3: text = '{} [{}]'.format(text, tokens[3].lstrip(':')) SeenHandler.record_sighting(nick, text, bot)
def watch_action(message: str, bot: humphrey.IRCClient): tokens = message.split(maxsplit=3) target = tokens[2] if not bot.is_irc_channel(target): return source = tokens[0].lstrip(':') nick, user, host = bot.parse_hostmask(source) text = tokens[3].split(maxsplit=1)[1].rstrip('\x01') SeenHandler.record_sighting(nick, '* {} {}'.format(nick, text), bot)
def watch_topic(message: str, bot: humphrey.IRCClient): tokens = message.split(maxsplit=3) source = tokens[0].lstrip(':') nick, user, host = bot.parse_hostmask(source) topic = tokens[3].lstrip(':') if topic: text = '- {} changed the topic of {} to: {}'.format(nick, tokens[2], topic) else: text = '- Topic unset by {} on {}'.format(nick, tokens[2]) SeenHandler.record_sighting(nick, text, bot)
def watch_nick(message: str, bot: humphrey.IRCClient): tokens = message.split() source = tokens[0].lstrip(':') nick, user, host = bot.parse_hostmask(source) SeenHandler.record_sighting(nick, '- {} is now known as {}'.format(nick, tokens[2].lstrip(':')), bot)
def watch_join(message: str, bot: humphrey.IRCClient): tokens = message.split() source = tokens[0].lstrip(':') nick, user, host = bot.parse_hostmask(source) SeenHandler.record_sighting(nick, '- {} [{}] has joined {}'.format(nick, source, bot.c.get('irc:channel')), bot)
def watch_quit(message: str, bot: humphrey.IRCClient): tokens = message.split(maxsplit=2) source = tokens[0].lstrip(':') nick, user, host = bot.parse_hostmask(source) SeenHandler.record_sighting(nick, '- {} [{}] has quit [{}]'.format(nick, source, tokens[2].lstrip(':')), bot)