Hooks

Discussion about Perl, TCL or Python scripts and C/C++ plugins (using and writing them).

Hooks

Postby Martin48535 » 06 Jan 2010 21:01

What is the proper hook to get it to run on a failed connection, preferably only when type is: "Connection refused"

I'm trying to make a script that changes my proxy type to 0 if that happens. The rest is easy, I just don't know the hook.

IRC::command("/set net_proxy_type 0");

command("set net_proxy_type 0");

I managed to get that for both languages (pearl and python) so in what languages the hooks function doesn't matter. (I'd prefer python though if at all possible)
Martin48535
 
Posts: 6
Joined: 19 Dec 2008 15:43

Postby Khisanth » 08 Jan 2010 23:05

you can use hook_print on the "Connection Failed" event then check the reason, this would be $_[0][0] in Perl and word[1] in Python.

The IRC::* interface really shouldn't be used for any new code, it's only around for backwards compatibility purposes,
Khisanth
 
Posts: 1724
Joined: 10 Jun 2004 05:23

Postby Martin48535 » 09 Jan 2010 19:53

Thanks, I got it working.

For those who might also be able to use it:


Code: Select all
import xchat

def proxchange(word, word_eol, userdata):
   if word[0] == "Connection refused":
      xchat.command("set net_proxy_type 0")
   return xchat.EAT_NONE
xchat.hook_print("Connection Failed", proxchange)


All it does is set proxy type to 0 if your proxy refuses your connection. Nothing big but useful if you use go through a SSH tunnel that at times collapses.
Martin48535
 
Posts: 6
Joined: 19 Dec 2008 15:43

Postby Khisanth » 09 Jan 2010 22:08

Except 'set net_proxy_type 0' is global and permanent so setting it more than once is useless unless you have something setting it to some other value.
Khisanth
 
Posts: 1724
Joined: 10 Jun 2004 05:23

Postby Martin48535 » 12 Jan 2010 06:07

I set it back to 3 once I get my tunnel back up an running. I prefer to have it going through that tunnel but if it collapses (network isn't the greatest) then I'd rather have it connect unsecurely from my own network then to mis X hours.
Martin48535
 
Posts: 6
Joined: 19 Dec 2008 15:43


Return to Scripts and Plugins

Who is online

Users browsing this forum: No registered users and 0 guests