From 6a9e7bb4d349b419816891e85ae8e95c46b9d2f5 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 28 Oct 2012 10:49:44 +0100 Subject: Further doc relocations and conversions --- plugins/perl/hexchat-perl.html | 1207 ------------------------------------ plugins/perl/hexchat-perldocs.html | 475 -------------- 2 files changed, 1682 deletions(-) delete mode 100644 plugins/perl/hexchat-perl.html delete mode 100644 plugins/perl/hexchat-perldocs.html (limited to 'plugins/perl') diff --git a/plugins/perl/hexchat-perl.html b/plugins/perl/hexchat-perl.html deleted file mode 100644 index 6092047e..00000000 --- a/plugins/perl/hexchat-perl.html +++ /dev/null @@ -1,1207 +0,0 @@ - - - - -X-Chat 2 Perl Interface - - - - - - - - -
- X-Chat 2 Perl Interface -
- - - -
-

- - - -
-
- - -

-

-

X-Chat 2 Perl Interface

-

-

-

Introduction

-

This is the new Perl interface for X-Chat 2. However, due to changes in -xchat's plugin code you will need xchat 2.0.8 or above to load this. Scripts -written using the old interface will continue to work. If there are any -problems, questions, comments or suggestions please email them to the address -on the bottom of this page.

-

-

-

Constants

-

-

-

Priorities

- -

-

-

Return values

- -

-

-

Timer and fd hooks

- -

-

-

hook_fd flags

- -

-

-

Functions

-

-

-

Xchat::register( $name, $version, [$description,[$callback]] )

- -

This is the first thing to call in every script.

-

-

-

Xchat::hook_server( $message, $callback, [\%options] )

-

-

-

Xchat::hook_command( $command, $callback, [\%options] )

-

-

-

Xchat::hook_print( $event,$callback, [\%options] )

-

-

-

Xchat::hook_timer( $timeout,$callback, [\%options | $data] )

-

-

-

Xchat::hook_fd( $handle, $callback, [ \%options ] )

-

These functions can be to intercept various events. -hook_server can be used to intercept any incoming message from the IRC server. -hook_command can be used to intercept any command, if the command doesn't currently exist then a new one is created. -hook_print can be used to intercept any of the events listed in Setttings->Advanced->Text Events -hook_timer can be used to create a new timer

-
-

Valid keys for \%options:

- - - - - - - -
data Additional data that is to be associated with the
- hook. For timer hooks this value can be provided either as
- Xchat::hook_timer( $timeout, $cb,{data=>$data})
- or Xchat::hook_timer( $timeout, $cb, $data ).
- However, this means that hook_timer cannot be provided
- with a hash reference containing data as a key.
example:
- my $options = { data => [@arrayOfStuff] };
- Xchat::hook_timer( $timeout, $cb, $options );
-
- In this example, the timer's data will be
- [@arrayOfStuff] and not { data => [@arrayOfStuff] }
-
- This key is valid for all of the hook functions.
-
- Default is undef.
-
priority Sets the priority for the hook.
- It can be set to one of the - Xchat::PRI_* constants.
-
- This key only applies to server, command - and print hooks.
-
- Default is Xchat::PRI_NORM. -
help_text Text displayed for /help $command.
-
- This key only applies to command hooks.
-
- Default is "". -
flags Specify the flags for a fd hook.
-
- See hook fd flags section for valid values.
-
- On Windows if the handle is a pipe you specify
- Xchat::FD_NOTSOCKET in addition to any other flags you might be using.
-
- This key only applies to fd hooks.
- Default is Xchat::FD_READ -

-

-

When callbacks are invoked

-

Each of the hooks will be triggered at different times depending on the type -of hook.

- - - - - - - - - - - - - -
Hook Type When the callback will be invoked
server hooks a $message message is - received from the server -
command hooks the $command command is - executed, either by the user or from a script -
print hooks X-Chat is about to print the message for the - $event event -
timer hooks called every $timeout milliseconds - (1000 millisecond is 1 second)
- the callback will be executed in the same context where - the hook_timer was called, if the context no longer exists - then it will execute in a random context -
fd hooks depends on the flags that were passed to hook_fd
- See hook_fd flags section. -

The value return from these hook functions can be passed to Xchat::unhook -to remove the hook.

-

-

-

Callback Arguments

-

All callback functions will receive their arguments in @_ like every -other Perl subroutine.

-

-Server and command callbacks
-
-$_[0] - array reference containing the IRC message or command and -arguments broken into words
-example:
-/command arg1 arg2 arg3
-$_[0][0] - command
-$_[0][1] - arg1
-$_[0][2] - arg2
-$_[0][3] - arg3
-
-$_[1] - array reference containing the Nth word to the last word
-example:
-/command arg1 arg2 arg3
-$_[1][0] - command arg1 arg2 arg3
-$_[1][1] - arg1 arg2 arg3
-$_[1][2] - arg2 arg3
-$_[1][3] - arg3
-
-$_[2] - the data that was passed to the hook function
-
-Print callbacks
-
-$_[0] - array reference containing the values for the - text event see Settings->Advanced->Text Events
-$_[1] - the data that was passed to the hook function
-
-Timer callbacks
-
-$_[0] - the data that was passed to the hook function
-
fd callbacks
-
-$_[0] - the handle that was passed to hook_fd
-$_[1] - flags indicating why the callback was called
-$_[2] - the data that was passed to the hook function
-

-

-

Callback return values

-

All server, command and print callbacks should return one of -the Xchat::EAT_* constants. -Timer callbacks can return Xchat::REMOVE to remove -the timer or Xchat::KEEP to keep it going

-

-

-

Miscellaneous Hook Related Information

-

For server hooks, if $message is "RAW LINE" then $cb will be called for -every IRC message than X-Chat receives.

-

For command hooks if $command is "" then $cb will be called for -messages entered by the user that is not a command.

-

For print hooks besides those events listed in -Settings->Advanced->Text Events, these additional events can be used.

- - - - - - - - - - - - - - - -
Event Description
"Open Context" a new context is created
"Close Context" a context has been close
"Focus Tab" when a tab is brought to the front
"Focus Window" when a top level window is focused or the - main tab window is focused by the window manager -
"DCC Chat Text" when text from a DCC Chat arrives. - $_[0] will have these values
-
- $_[0][0] - Address
- $_[0][1] - Port
- $_[0][2] - Nick
- $_[0][3] - Message
-
"Key Press" used for intercepting key presses
- $_[0][0] - key value
- $_[0][1] - state bitfield, 1 - shift, 4 - control, 8 - alt
- $_[0][2] - string version of the key which might be empty for unprintable keys
- $_[0][3] - length of the string in $_[0][2]
-

-

-

Xchat::unhook( $hook )

- -

This function is used to removed a hook previously added with one of -the Xchat::hook_* functions

-

It returns the data that was passed to the Xchat::hook_* function when -the hook was added

-

-

-

Xchat::print( $text | \@lines, [$channel,[$server]] )

- -

The first argument can either be a string or an array reference of strings. -Either or both of $channel and $server can be undef.

-

If called as Xchat::print( $text ), it will always return true. -If called with either the channel or the channel and the server -specified then it will return true if a context is found and -false otherwise. The text will not be printed if the context -is not found. The meaning of setting $channel or $server to -undef is the same as -find_context.

-

-

-

Xchat::printf( $format, LIST )

- -

-

-

Xchat::command( $command | \@commands, [$channel,[$server]] )

- -

The first argument can either be a string or an array reference of strings. -Either or both of $channel and $server can be undef.

-

If called as Xchat::command( $command ), it will always return true. -If called with either the channel or the channel and the server -specified then it will return true if a context is found and false -otherwise. The command will not be executed if the context is not found. -The meaning of setting $channel or $server to undef is the same -as find_context.

-

-

-

Xchat::commandf( $format, LIST )

- -

-

-

Xchat::find_context( [$channel, [$server]] )

- -

Either or both of $channel and $server can be undef. Calling -Xchat::find_context() is the same as calling -Xchat::find_context( undef, undef) and -Xchat::find_context( $channel ) is -the same as Xchat::find_context( $channel, undef ).

-

If $server is undef, find any channel named $channel. -If $channel is undef, find the front most window -or tab named $server.If both $channel and -$server are undef, find the currently focused tab or window.

-

Return the context found for one of the above situations or undef if such -a context cannot be found.

-

-

-

Xchat::get_context()

-

Returns the current context.

-

-

-

Xchat::set_context( $context | $channel,[$server] )

- -

See find_context for more details on $channel and $server.

-

Returns true on success, false on failure

-

-

-

Xchat::get_info( $id )

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IDReturn valueAssociated Command(s)
awayaway reason or undef if you are not awayAWAY, BACK
channelcurrent channel nameSETTAB
charsetcharacter-set used in the current contextCHARSET
event_text <Event Name> text event format string for <Event name>
- Example: -
-
1
-
-
my $channel_msg_format = Xchat::get_info( "event_text Channel Message" );
-
-
-
hostreal hostname of the current server
idconnection id
inputboxcontents of the inputboxSETTEXT
libdirfsthe system wide directory where xchat will look for plugins. - this string is in the same encoding as the local file system
modesthe current channels modes or undef if not knownMODE
networkcurrent network name or undef, this value is taken from the Network List
nickcurrent nickNICK
nickservnickserv password for this network or undef, this value is taken from the Network List
server current server name
- (what the server claims to be) undef if not connected -
state_cursorcurrent inputbox cursor position in charactersSETCURSOR
topiccurrent channel topicTOPIC
versionxchat version number
win_statusstatus of the xchat window, possible values are "active", "hidden" - and "normal"GUI
win_ptr native window pointer, GtkWindow * on Unix, HWND on Win32.
- On Unix if you have the Glib module installed you can use my $window = Glib::Object->new_from_pointer( Xchat::get_info( "win_ptr" ) ); to get a Gtk2::Window object.
- Additionally when you have detached tabs, each of the windows will return a different win_ptr for the different Gtk2::Window objects.
- See char_count.pl for a longer example of a script that uses this to show how many characters you currently have in your input box. -
gtkwin_ptrsimilar to win_ptr except it will always be a GtkWindow *
xchatdir xchat config directory encoded in UTF-8
- examples:
- /home/user/.xchat2
- C:\Documents and Settings\user\Application Data\X-Chat 2 -
xchatdirfs same as xchatdir except encoded in the locale file system encoding

This function is used to retrieve certain information about the current -context. If there is an associated command then that command can be used to change the value for a particular ID.

-

-

Xchat::get_prefs( $name )

- -

This function provides a way to retrieve X-Chat's setting information.

-

Returns undef if there is no setting called called $name.

-

-

-

Xchat::emit_print( $event, LIST )

- -

This functions is used to generate one of the events listed under -Settings->Advanced->Text Events

-

Note: when using this function you MUST return Xchat::EAT_ALL otherwise you will end up with duplicate events. -One is the original and the second is the one you emit.

-

Returns true on success, false on failure

-

-

-

Xchat::send_modes( $target | \@targets, $sign, $mode, [ $modes_per_line ] )

- -

Send multiple mode changes for the current channel. It may send multiple MODE lines if the request doesn't fit on one.

-

Example:

-
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
-
use strict;
-use warning;
-use Xchat qw(:all);
-
-hook_command( "MODES", sub {
-   my (undef, $who, $sign, $mode) = @{$_[0]};
-   my @targets = split /,/, $who;
-   if( @targets > 1 ) {
-      send_modes( \@targets, $sign, $mode, 1 );
-   } else {
-      send_modes( $who, $sign, $mode );
-   }
-   return EAT_XCHAT;
-});
-
-

-

-

Xchat::nickcmp( $nick1, $nick2 )

- -

The comparsion is based on the current server. Either a RFC1459 compliant -string compare or plain ascii will be using depending on the server. The -comparison is case insensitive.

-

Returns a number less than, equal to or greater than zero if -$nick1 is -found respectively, to be less than, to match, or be greater than -$nick2.

-

-

-

Xchat::get_list( $name )

- -

This function will return a list of hash references. The hash references -will have different keys depend on the list. An empty list is returned -if there is no such list.

-

"channels" - list of channels, querys and their server

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Key Description
channel tab name
chantypeschannel types supported by the server, typically "#&"
context can be used with set_context
flags Server Bits:
- 0 - Connected
- 1 - Connecting
- 2 - Away
- 3 - EndOfMotd(Login complete)
- 4 - Has WHOX
- 5 - Has IDMSG (FreeNode)
-
-

The following correspond to the /chanopt command

- 6 - Hide Join/Part Message (text_hidejoinpart)
- 7 - unused (was for color paste)
- 8 - Beep on message (alert_beep)
- 9 - Blink Tray (alert_tray)
- 10 - Blink Task Bar (alert_taskbar)
-

Example of checking if the current context has Hide Join/Part messages set:

-
-
1
-
2
-
3
-
-
if( Xchat::context_info->{flags} & (1 << 6) ) {
-  Xchat::print( "Hide Join/Part messages is enabled" );
-}
-
-
id Unique server ID
laglag in milliseconds
maxmodes Maximum modes per line
network network name to which this channel belongs
nickprefixes Nickname prefixes e.g. "+@"
nickmodes Nickname mode chars e.g. "vo"
queuenumber of bytes in the send queue
server server name to which this channel belongs
type the type of this context
- 1 - server
- 2 - channel
- 3 - dialog
- 4 - notices
- 5 - server notices
-
users Number of users in this channel

"dcc" - list of DCC file transfers

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Key Value
address32 address of the remote user(ipv4 address)
cps bytes per second(speed)
destfile destination full pathname
file file name
nicknick of the person this DCC connection is connected to
port TCP port number
pos bytes sent/received
poshigh bytes sent/received, high order 32 bits
resume point at which this file was resumed
- (zero if it was not resumed) -
resumehigh point at which this file was resumed, high order 32 bits
-
size file size in bytes low order 32 bits
sizehigh file size in bytes, high order 32 bits (when the files is > 4GB)
status DCC Status:
- 0 - queued
- 1 - active
- 2 - failed
- 3 - done
- 4 - connecting
- 5 - aborted -
type DCC Type:
- 0 - send
- 1 - receive
- 2 - chatrecv
- 3 - chatsend -

"ignore" - current ignore list

- - - - - - -
Key Value
mask ignore mask. e.g: *!*@*.aol.com
flags Bit field of flags.
- 0 - private
- 1 - notice
- 2 - channel
- 3 - ctcp
- 4 - invite
- 5 - unignore
- 6 - nosave
- 7 - dcc
-

"notify" - list of people on notify

- - - - - - - - - - - - - - - - - -
Key Value
networkscomma separated list of networks where you will be notfified about this user's online/offline status or undef if you will be notificed on every network you are connected to
nick nickname
flags 0 = is online
on time when user came online
off time when user went offline
seen time when user was last verified still online

the values indexed by on, off and seen can be passed to localtime -and gmtime, see perldoc -f localtime and perldoc -f gmtime for more -detail

"users" - list of users in the current channel

- - - - - - - - - - - - - - - - - - - - - -
Key Value
away away status(boolean)
lasttalklast time a user was seen talking, this is the an epoch time(number of seconds since a certain date, that date depends on the OS)
nick nick name
hosthost name in the form: user@host or undef if not known
prefix prefix character, .e.g: @ or +
realnameReal name or undef
selectedselected status in the user list, only works when retrieving the user list of the focused tab. You can use the /USELECT command to select the nicks

"networks" - list of networks and the associated settings from network list

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Key Value
autojoins An object with the following methods:
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodDescription
channels()returns a list of this networks' autojoin channels in list context, a count of the number autojoin channels in scalar context
keys()returns a list of the keys to go with the channels, the order is the same as the channels, if a channel doesn't have a key, '' will be returned in it's place
pairs()a combination of channels() and keys(), returns a list of (channels, keys) pairs. This can be assigned to a hash for a mapping from channel to key.
as_hash()return the pairs as a hash reference
as_string()the original string that was used to construct this autojoin object, this can be used with the JOIN command to join all the channels in the autojoin list
as_array()return an array reference of hash references consisting of the keys "channel" and "key"
as_bool()returns true if the network has autojoins and false otherwise
-
connect_commands An array reference containing the connect commands for a network. An empty array if there aren't any
encoding the encoding for the network
flags - a hash reference corresponding to the checkboxes in the network edit window - - - - - - - - - - - - - - - - - - - - -
allow_invalidtrue if "Accept invalid SSL certificate" is checked
autoconnecttrue if "Auto connect to this network at startup" is checked
cycletrue if "Connect to selected server only" is NOT checked
use_globaltrue if "Use global user information" is checked
use_proxytrue if "Bypass proxy server" is NOT checked
use_ssltrue if "Use SSL for all the servers on this network" is checked
-
irc_nick1Corresponds with the "Nick name" field in the network edit window
irc_nick2Corresponds with the "Second choice" field in the network edit window
irc_real_nameCorresponds with the "Real name" field in the network edit window
irc_user_nameCorresponds with the "User name" field in the network edit window
networkName of the network
nickserv_passwordCorresponds with the "Nickserv password" field in the network edit window
selectedIndex into the list of servers in the "servers" key, this is used if the "cycle" flag is false
server_passwordCorresponds with the "Server password" field in the network edit window
serversAn array reference of hash references with a "host" and "port" key. If a port is not specified then 6667 will be used.

-

-

Xchat::user_info( [$nick] )

- -

This function is mainly intended to be used as a shortcut for when you need -to retrieve some information about only one user in a channel. Otherwise it -is better to use get_list. -If $nick is found a hash reference containing the same keys as those in the -"users" list of get_list is returned otherwise undef is returned. -Since it relies on get_list this function can only be used in a -channel context.

-

-

-

Xchat::context_info( [$context] )

- -

This function will return the information normally retrieved with get_info, except this is for the context that is passed in. The information will be returned in the form of a hash. The keys of the hash are the $id you would normally supply to get_info as well as all the keys that are valid for the items in the "channels" list from get_list. Use of this function is more efficient than calling get_list( "channels" ) and searching through the result.

-

Example:

-
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
-
use strict;
-use warnings;
-use Xchat qw(:all); # imports all the functions documented on this page
-
-register( "User Count", "0.1",
-   "Print out the number of users on the current channel" );
-hook_command( "UCOUNT", \&display_count );
-sub display_count {
-   prnt "There are " . context_info()->{users} . " users in this channel.";
-   return EAT_XCHAT;
-}
-
-

-

-

Xchat::strip_code( $string )

- -

This function will remove bold, color, beep, reset, reverse and underline codes from $string. It will also remove ANSI escape codes which might get used by certain terminal based clients. If it is called in void context $string will be modified otherwise a modified copy of $string is returned.

-

-

-

Examples

-

-

-

Asynchronous DNS resolution with hook_fd

-
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
-
use strict;
-use warnings;
-use Xchat qw(:all);
-use Net::DNS;
-   
-hook_command( "BGDNS", sub {
-   my $host = $_[0][1];
-   my $resolver = Net::DNS::Resolver->new;
-   my $sock = $resolver->bgsend( $host );
-   
-   hook_fd( $sock, sub {
-      my $ready_sock = $_[0];
-      my $packet = $resolver->bgread( $ready_sock );
-      
-      if( $packet->authority && (my @answers = $packet->answer ) ) {
-         
-         if( @answers ) {
-            prnt "$host:";
-            my $padding = " " x (length( $host ) + 2);
-            for my $answer ( @answers ) {
-               prnt $padding . $answer->rdatastr . ' ' . $answer->type;
-            }
-         }
-      } else {
-         prnt "Unable to resolve $host";
-      }
-      
-      return REMOVE;
-   },
-   {
-      flags => FD_READ,
-   });
-   
-   return EAT_XCHAT;
-});
-
-
- -

-

-

Contact Information

-

Contact Lian Wan Situ at <atmcmnky [at] yahoo.com> for questions, comments and -corrections about this page or the Perl plugin itself. You can also find me -in #xchat on FreeNode under the nick Khisanth.

- - -
- X-Chat 2 Perl Interface -
- - - - diff --git a/plugins/perl/hexchat-perldocs.html b/plugins/perl/hexchat-perldocs.html deleted file mode 100644 index 10d8f314..00000000 --- a/plugins/perl/hexchat-perldocs.html +++ /dev/null @@ -1,475 +0,0 @@ -XChat - IRC (chat) client for UNIX - - - -

This interface is deprecated

- - - - - -
-
-

Xchat Perl Docs

- - -
- - -
- -Introduction -
-
- -
-

Good Hello!

-

The purpose of this page is to give people some quick documentation on the -things that they will encounter when they try to code scripts for X-Chat. -It is not meant to be a comprehensive programming tutorial, -by any means. If that's what you're looking for, then you can just keep on -looking.

-

If you're going to do any scripting with X-Chat at all, you will -need to know perl. It also won't hurt to have had experience writing tcl for -eggdrops or ircII scripts. Otherwise you're going to have to be very careful -to avoid creating conditions which could flood you offline or do other -not-so-optimal things. ;) Thankfully, it shouldn't take most intelligent -people more than a week (month on the outside) enough perl to do some nice -things in it. -Perl is a very flexible language.

-

You should probably also go read (or at least skim over and then carefully -bookmark this copy of the thing that defines how IRC works: RFC 1459. -Other documents that scripters might find useful would be this -nice list of server -numerics, and this list of changes -for Hybrid 6 which is something everyone on EFNet should read. In fact, I -strongly suggest saving copies of these documents to your local -hard drive, because you will be back to look at them again soon.

-

One last thing... While you may hear that RFC 1459 isn't being followed very -well, and this is partly true, do your absolute best to stick with RFC-compliant -behaviours anyway because otherwise there's a good chance that your script will -never interoperate properly with others, or at least just piss off a lot of other -people. Pay special attention to section 2.2 of the RFC.

-
- - -
-Standard Disclaimer - -
-This documentation is provided on an "as-is" basis and comes with no warranty of accuracy or usefulness, either expressed or implied. It is subject to change without any notice, and may contain omissions or errors which could cause your genitalia to shrivel and fall off, or spontaneously combust. If you have any further questions,
please feel free to seek professional help.
-
- - -
- - -
- -About Handlers -
-
- -
-There are [currently] four basic ways to make things call the subroutines you write for X-Chat and they are: -
  • message handlers - Triggered by messagse sent from the IRC server to your client
  • -
  • command handlers - triggered by / commands typed in by the user at the keyboard
  • -
  • timeout handlers - triggered by gtk+
  • -
  • print handlers - triggered just before xchat calls its built in print handlers for events
-
- - -
- - -
- -About Exit Codes -
-
- -
-These are very important. Every time you set up a handler, it takes precedent over the built-in functions and commands of X-Chat. That is, whatever thing which triggered your subroutine will go to your code before it goes to X-Chat to be dealt with. In this way you can replace almost every built-in function that the client has with your own routines. The thing to remember is that if your code exits by hitting the end of your subroutine, or by a plain 'return' statement, processing of the event will go on to whatever other things have set up hooks for the event, and then (provided nothing else exits with a return value of 1) to X-Chat itself. There is only one problem with this, (which is solved by the brokering handler that I'll explain that later) and that is that you cannot really control what order the custom routines get called. Normally they will execute in order of which ones were installed first, but a single script has no real way of knowing this. Beware. -
- - -
- - -
- -About @_ -
-
- -
-If you've never heard of @_ before, then you've obviously not coded in perl. When a message handler triggers, the raw line from the IRC server is passed to the subroutine you specify in @_. When a command handler is triggered, only the arguments are passed to the routine through @_ and they are not broken into a list, but left as one long string. You'll have to parse those yourself with split. (I advise using s/\s+/ /g to collapse the blank space to single space first.) When a timer handler is triggered, I *think* absolutely nothing is passed in @_, but it's not like anything terrifically important could be passed along anyway. Be especially careful when setting up message handlers for mode changes, since the modes are not broken up into individual events like they are with eggdrop. The upside of this is that X-Chat has no mode hooks of it's own, so you don't have to worry about it too much. (This is not the case with the brokering handler, however.) -
- - -
- - -
- -About Context -
-
- -
-There are some really nice things about coding for X-Chat, and the biggest one is that it's fairly good about determining the proper context for things. If a server sends something that triggers a message handler, then you can be sure that unless you specify otherwise, that your IRC::print or IRC::command function call will go back to that server and that server alone. If you really really need to know what the current context is, use the IRC::get_info function as detailed below. -
- -
- - -
- - -
- -script initialization commands -
-
- - -
- - -
- -IRC::register(scriptname, version, shutdownroutine, unused); -
-
- -
-

This is the first function your script should call, example:

-

IRC::register ("my script", "1.0", "", "");

-

The "shutdownroutine" arg is a function that will be called when X-Chat shuts down, so you get a chance to save config files etc. You can omit this arg, it is optional. The "unused" arg is reserved for future use, for now just provide "". This function also returns X-Chat's version number.

-
- - -
- - -
- -Handler initialization commands -
-
- - -
- - -
- -IRC::add_message_handler(message, subroutine_name); -
-
- -
-

This function allows you to set up hooks to subroutines so that when a particular message arrives from the IRC server that you are connected to, it can be passed to a subroutine to be dealt with appropriately. The message argument is essentially the second solid token from the raw line sent by the IRC server, and X-Chat doesn't know that some numeric messages have associated text messages, so for now set up a handler for both if you want to be sure odd servers don't screw up your expectations. (Read: fear IRCNet.) The entire line sent by the IRC server will be passed to your subroutine in @_. For the completely uninitiated, messages are things like 'PRIVMSG', 'NOTICE', '372', etc.

-
- - -
- - -
- -IRC::add_command_handler(command, subroutine_name); -
-
- -
-

This function allows you to set up hooks for actual commands that the user can type into the text window. The arguments are passed to the subroutine via @_, and arrive as a single string. @_ will be null if no arguments are supplied. It's recommended that you be sure and collapse the excess whitespace with s/\s+/ /g before attempting to chop the line up with split. As mentioned earlier, exiting with an undefined return value will allow the command to be parsed by other handlers, while using a return value of 1 will signal the program that no further parsing needs to be done with this command.

-
- - -
- - -
- -IRC::add_timeout_handler(interval, subroutine_name); -
-
- -
-

This function allows you to set up hooks for subroutines to be called at a particular interval. The interval is measured in milliseconds, so don't use a particularly small value unless you wish to drive the CPU load through the roof. 1000ms = 1 second. No values will be passed to the routine via @_ and return values don't affect anything either.

-
- - -
- - -
- -IRC::add_print_handler(message, subroutine_name); -
-
- -
-

This function allows you to catch the system messages (those who generally start by three stars) and to execute a function each time an event appear. The events are those you can see in "Settings->Edit Events Texts". message is the name of the event (you can find it in the Edit Events box, "Events" column) , subroutine_name is the name of the function that will get messages. Be carrful: all the arguments are sent to function in $_[0] separated by spaces.

-
- - -
- - -
- -Output commands -
-
- - -
- - -
- -IRC::print(text); -
-
- -
-This is a very simple routine. All it does is put the contents of the text string to the current window. The current window will be whichever window a command was typed into when called from a command handler, or in whichever window the message command is appropriate to if it is called from within a message handler. As with any perl program, newlines are not assumed, so don't forget to end the line with \n if you don't want things to look screwey. -
- - -
- - -
- -IRC::print_with_channel( text, channelname, servername ); -
-
- -
-This routine does the same thing as IRC::Print does, except it allows you to direct the output to a specific window. It returns 1 on success, 0 on fail. -
- - -
- - -
- -IRC::command(text); -
-
- -
-This routine allows you to execute commands in the current context. The text string containing the command will be parsed by everything that would normally parse a command, including your own command handlers, so be careful. Newlines are assumed, thankfully. -
- - -
- - -
- -IRC::command_with_server(text, servername); -
-
- -
-This routine allows you to specify the context of the server for which the command will be executed. It's not particularly useful unless you're managing a connection manually, yet the command still exists for it's usefulness in doing things like managing a bnc connection, etc. Newlines are assumed here as well. -
- - -
- - -
- -IRC::send_raw(text); -
-
- -
-This routine is very useful in that it allows you to send a string directly to the IRC server you are connected to. It is assumed that the server will be the one you first connected to if there is no clear context for the command, otherwise it will go to whatever server triggered the message handler or command handler window. You must specify newlines here always or you can be guaranteed that strange things will happen. The text message you specify should be a proper RAW IRC message, so don't play with it if you don't know how to do these. Additionally, while newlines are also not assumed here as with the IRC::print function, the RFC specifies that newlines are a CR+LF pair, even if most servers will accept a mere newline. It's best to play it safe and use \r\n instead of just \n. -
- - -
- - -
- -Information retrieval commands -
-
- - -
- - -
- -IRC::get_info(integer); -
-
- -
-This function returns a bit of selected information depending on what the value of the integer is. -Here's a list of the currently supported values: -
  • 0 - xchat version
  • -
  • 1 - your nickname
  • -
  • 2 - channel
  • -
  • 3 - server
  • -
  • 4 - xchatdir
  • -
  • 5 - away status
  • -
  • 6 - network name
  • -
  • 7 - server hostname
  • -
  • 8 - channel topic
-

If you are requesting information that isn't available in the current context, then it will return null.

-

Any numbers other than the above will return an error message.

-
- - -
- - -
- -IRC::get_prefs(var); -
-
- -
-This command lets you read the preferences that are set in the xchat configuration file. Just look at the xchat.conf dir to see what variables are available to use with this command. Returns the value of the variable requested or "Unknown Variable" if the variable isn't available. -
- - -
- - -
- -IRC::user_info( nickname ); -
-
- -
-Returns a flat list of information on the nickname specified consisting of... nickname, nick host, and whether they have op or voice in the current context. -
- - -
- - -
- -IRC::channel_list( ); -
-
- -
-This command returns a flat list which contains the current channel, server, and nickname for all channels the client is currently in. You'll have to break the list up into groups of three yourself. No arguments are necessary, or used [currently]. -
- - -
- - -
- -IRC::server_list( ); -
-
- -
-This command returns a flat list of servers. (Note, it is incompatible with xchat 1.8 in that it also returns a list of servers you are NOT connected to as well.) -
- - -
- - -
- -IRC::user_list(channel, server); -
-
- -
-

Works very much like the dcc_list command below, except that is returns information about the users on the channel provided as first argument. The second argument is the server and is optional.

-

NOTE: If a user has both op and voice, only the op flag will be set to 1 by this command in xchat2.

-
- - -
- - -
- -IRC::user_list_short(channel, server); -
-
- -
-

A simpler version of IRC::user_list that returns pairs of nick & user@host suitable for assigning to a hash.

-

NOTE: If a user has both op and voice, only the op flag will be set to 1 by this command in xchat2.

-
- - -
- - -
- -IRC::dcc_list( ); -
-
- -
-This command does essentially the same thing as channel_list, giving you the details of each DCC connection currently in progress. I have no idea exactly what is returned because I haven't had a chance to poke at this one much, but suffice it to say that it's a flat list, and the first time you play with it the meaning of the returned values should be pretty obvious. -
- - -
- - -
- -IRC::ignore_list( ); -
-
- -
-This command returns a flat list of the contents of your ignore list. You'll have to play with it a little as I have not had a chance to yet. Works basically the same as the other list commands. -
- - -
- - -
- -Unimplemented commands that were available in xchat 1.8.x -
-
- -
-add_user_list , sub_user_list , clear_user_list, notify_list were available in xchat 1.8.x but are not implemented in xchat 2 at this time. -
- -
-
-

-This document originally written by Dagmar d'Surreal on March 26th, 1998 for xchat 1.4
-Updated on July 30th, 1999 by Peter Zelezny
-Updated on May 16th, 2003 by DaNumber8 to comply with the perl plugin for xchat2 version 2.0.3
- -- cgit 1.4.1