import weechat def redirect_cb(data, signal, hashtable): weechat.prnt("", "python: redirect_whois: error: '%s', server: %s, pattern: %s, signal: %s, command: %s, output_size: %s, output:\n%s" % (hashtable["error"], hashtable["server"], hashtable["pattern"], hashtable["signal"], hashtable["command"], hashtable["output_size"], hashtable["output"])) return weechat.WEECHAT_RC_OK def redir1_cmd(data, buffer, args): items = args.split(' ', 1) if len(items) > 1: weechat.prnt("", "redirect_command: pattern=%s, string=%s" % (items[0], items[1])) weechat.hook_hsignal_send("irc_redirect_command", { "server": "local", "pattern": items[0], "signal": "flashcode", "count": "1", "string": items[1], "timeout": "5", "cmd_filter": "" }) return weechat.WEECHAT_RC_OK def redir_cmd(data, buffer, args): items = args.split(' ', 2) if len(items) > 1: pattern = items[0] command = items[1] arguments = '' if len(items) > 2: arguments = items[2] weechat.hook_hsignal_send("irc_redirect_command", { "server": "local", "pattern": pattern, "signal": "flashcode", "count": "1", "string": arguments, "timeout": "5", "cmd_filter": "" }) weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING, "local;;;;/%s %s" % (command, arguments)) return weechat.WEECHAT_RC_OK weechat.register("redirect", "Sebastien Helleu ", "0.1", "GPL3", "IRC redirection example", "", "") weechat.hook_hsignal("irc_redirection_flashcode_*", "redirect_cb", "") weechat.hook_command("redir1", "IRC redirection example", "", "", "", "redir1_cmd", "") weechat.hook_command("redir", "IRC redirection example", "", "", "", "redir_cmd", "")