elif _type == 'quit': send("Quit", nick, args[15:-1], userhost) elif _type == 'kicked': send("Kick", nick, word[5], channel, word_eol[6][9:-1]) elif _type == 'changed': send("Topic Change", nick, args[14:], channel) else: send("Server Error", "Unhandled *buffextras event:") send("Server Error", " {}".format(word_eol[3][1:])) return hexchat.EAT_HEXCHAT return hexchat.EAT_NONE # extra tools def split_prefix(prefix): if '!' in prefix: nick, _, userhostpart = prefix.partition('!') user, _, host = userhostpart.partition('@') else: nick, _, host = prefix.partition('@') user = '' return (nick, user, host) hexchat.hook_server_attrs('PRIVMSG', privmsg)
def disignore(word, word_eol, userdata): printlist() return hexchat.EAT_ALL def printlist(): global ignorelist global botlist if len(ignorelist) == 0: hexchat.prnt('Ignorelist is empty') else: hexchat.prnt('Ignorelist: ' + ', '.join(ignorelist)) if len(botlist) == 0: hexchat.prnt('Botlist is empty') else: hexchat.prnt('Bot List: ' + ', '.join("{!s}={!r}".format(key, val) for (key, val) in botlist.items())) loadlist() hexchat.hook_command("addignore", addignore) hexchat.hook_command("delignore", delignore) hexchat.hook_command("ignorelist", disignore) hexchat.hook_command("addbot", addbot) hexchat.hook_command("delbot", delbot) hexchat.hook_server_attrs('PRIVMSG', privmsg) hexchat.prnt(__module_name__ + " " + __module_version__ + " loaded!") printlist()
# :nick!ident@host quit with message: [Quit: Leaving.] send("Quit", nick, args[15:-1], userhost) elif _type == 'kicked': send("Kick", nick, word[5], channel, word_eol[6][9:-1]) elif _type == 'changed': send("Topic Change", nick, args[14:], channel) else: send("Server Error", "Unhandled *buffextras event:") send("Server Error", " {}".format(word_eol[3][1:])) return hexchat.EAT_ALL return hexchat.EAT_NONE # extra tools def split_prefix(prefix): if '!' in prefix: nick, _, userhostpart = prefix.partition('!') user, _, host = userhostpart.partition('@') else: nick, _, host = prefix.partition('@') user = '' return (nick, user, host) hexchat.hook_server_attrs('PRIVMSG', privmsg, priority=hexchat.PRI_HIGHEST)
def connection(word, word_eol, userdata, attributes): """ Display all messages at once 5 seconds after a connection. That way, messages can be sorted by time instead of having all from one channel, then all from another, etc. """ global waiting waiting += 1 hexchat.command('timer 5 backlog') # Get last hilight (so we don't print hls already seen from backlogs) previous_session_last_hl = hexchat.get_pluginpref(PREF) if previous_session_last_hl: previous_session_last_hl = int(previous_session_last_hl) last_hl = previous_session_last_hl else: previous_session_last_hl = 0 last_hl = 0 hexchat.hook_print_attrs('Channel Msg Hilight', message) hexchat.hook_print_attrs('Channel Action Hilight', message) hexchat.hook_command('backlog', forcePrint) # 376: RPL_ENDOFMOTD (just before starting receiving backlogs if any) hexchat.hook_server_attrs('376', connection) print('%s\tLoaded' % __module_name__)
def decorator(func): wrapper = Wrapper(func, on_error) hookid = hexchat.hook_server_attrs(cmd.upper(), wrapper, userdata, priority) wrapper.set_hook(hookid) return wrapper
def server_attrs(msg, cb): return hexchat.hook_server_attrs(msg, twitchOnly(cb), msg)