PYTHON 20
Redirect.py Guest on 7th September 2020 11:43:31 AM
  1. import weechat
  2.  
  3. def redirect_cb(data, signal, hashtable):
  4.     weechat.prnt("", "python: redirect_whois: error: '%s', server: %s, pattern: %s, signal: %s, command: %s, output_size: %s, output:\n%s"
  5.                  % (hashtable["error"], hashtable["server"], hashtable["pattern"], hashtable["signal"], hashtable["command"],
  6.                     hashtable["output_size"], hashtable["output"]))
  7.     return weechat.WEECHAT_RC_OK
  8.  
  9. def redir1_cmd(data, buffer, args):
  10.     items = args.split(' ', 1)
  11.     if len(items) > 1:
  12.         weechat.prnt("", "redirect_command: pattern=%s, string=%s" % (items[0], items[1]))
  13.         weechat.hook_hsignal_send("irc_redirect_command",
  14.                                   { "server": "local", "pattern": items[0], "signal": "flashcode", "count": "1", "string": items[1], "timeout": "5", "cmd_filter": "" })
  15.     return weechat.WEECHAT_RC_OK
  16.  
  17. def redir_cmd(data, buffer, args):
  18.     items = args.split(' ', 2)
  19.     if len(items) > 1:
  20.         pattern = items[0]
  21.         command = items[1]
  22.         arguments = ''
  23.         if len(items) > 2:
  24.             arguments = items[2]
  25.         weechat.hook_hsignal_send("irc_redirect_command",
  26.                                   { "server": "local", "pattern": pattern, "signal": "flashcode", "count": "1", "string": arguments, "timeout": "5", "cmd_filter": "" })
  27.         weechat.hook_signal_send("irc_input_send", weechat.WEECHAT_HOOK_SIGNAL_STRING, "local;;;;/%s %s" % (command, arguments))
  28.     return weechat.WEECHAT_RC_OK
  29.  
  30. weechat.register("redirect", "Sebastien Helleu <[email protected]>", "0.1", "GPL3", "IRC redirection example", "", "")
  31. weechat.hook_hsignal("irc_redirection_flashcode_*", "redirect_cb", "")
  32. weechat.hook_command("redir1", "IRC redirection example", "", "", "", "redir1_cmd", "")
  33. weechat.hook_command("redir", "IRC redirection example", "", "", "", "redir_cmd", "")

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.