By default, XChat provides the /HOP command, which is used to give chanhalf-op to the provided nickname. We will not replace this command as it still may be useful on some networks, instead we will use a new command, say /PJ (or any other you like).
The script
Here's how the script looks like:
What does it do?
Xchat::register ("PJ", "0.1.0", "Part/Join");
Xchat::hook_command ("PJ", cmd_pj);
Xchat::command ("ECHO PART/JOIN script loaded. Use it typing /PJ.");
sub cmd_pj
{
$chan = Xchat::get_info ("channel");
Xchat::command ("PART $chan");
Xchat::command ("JOIN $chan");
return Xchat::EAT_ALL;
}
Basically, the first command will tell XChat the information about the script (name, version number, description). The second one will declare the command /PJ and the subroutine to use when it's triggered, cmd_pj. The body under sub cmd_pj contains what the command will actually do, and that's to get the name of the current channel, part it and rejoin.
Save the script under any name, say pj.pl, and put it under your ~/.xchat2/ directory, where ~ is your home directory. The script will be automatically loaded each time XChat starts.
3 comments:
A slight delay on this, but for people who search and find this blog post, the command is built into XChat already as /cycle
While it is true that Xchat has the /cycle command, learning a new language for scripting it is best to start simple, and this "/hop" command is simple and gives a defiant starting point for building more complex scripts from.
very nice. this has me started
Post a Comment