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-E<gt>Advanced-E<gt>Text Events
hook_timer can be used to create a new timer
=over 3
=item *
C<$message> - server message to hook such as PRIVMSG
=item *
C<$command> - command to intercept, without the leading /
=item *
C<$event> - one of the events listed in Settings-E<gt>Advanced-E<gt>Text Events
=item *
C<$timeout> - timeout in milliseconds
=item *
C<$handle> - the I/O handle you want to monitor with hook_fd. This must be something that has a fileno. See perldoc -f fileno or L<fileno|http://perldoc.perl.org/functions/fileno.html>
=item *
C<$callback> - callback function, this is called whenever
the hooked event is trigged, the following are
the conditions that will trigger the different hooks.
This can be either a reference to a
function or an anonymous sub reference.
=item *
\%options - a hash reference containing addional options for the hooks
=back
Valid keys for \%options:
=begin html
<table border="1">
<tr>
<td>data</td> <td>Additional data that is to be associated with the<br />
hook. For timer hooks this value can be provided either as<br />
<td>win_ptr</td> <td>native window pointer, GtkWindow * on Unix, HWND on Win32.<br />
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.<br />
Additionally when you have detached tabs, each of the windows will return a different win_ptr for the different Gtk2::Window objects.<br />
See <a href="http://xchat.cvs.sourceforge.net/viewvc/xchat/xchat2/plugins/perl/char_count.pl?view=markup">char_count.pl</a> for a longer example of a script that uses this to show how many characters you currently have in your input box.
<td>comma 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</td>
</tr>
<tr>
<td>nick</td> <td>nickname</td>
</tr>
<tr>
<td>flags</td> <td>0 = is online</td>
</tr>
<tr>
<td>on</td> <td>time when user came online</td>
</tr>
<tr>
<td>off</td> <td>time when user went offline</td>
</tr>
<tr>
<td>seen</td> <td>time when user was last verified still online</td>
</tr>
</table>
<p>the values indexed by on, off and seen can be passed to localtime
and gmtime, see perldoc -f <a href="http://perldoc.perl.org/functions/localtime.html">localtime</a> and perldoc -f <a href="http://perldoc.perl.org/functions/gmtime.html">gmtime</a> for more
detail</p>
<p>"users" - list of users in the current channel</p>
<table border="1">
<tr style="background-color: #dddddd">
<td>Key</td> <td>Value</td>
</tr>
<tr>
<td>away</td> <td>away status(boolean)</td>
</tr>
<tr>
<td>lasttalk</td>
<td>last 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)</td>
</tr>
<tr>
<td>nick</td> <td>nick name</td>
</tr>
<tr>
<td>host</td>
<td>host name in the form: user@host or undef if not known</td>
</tr>
<tr>
<td>prefix</td> <td>prefix character, .e.g: @ or +</td>
</tr>
<tr>
<td>realname</td>
<td>Real name or undef</td>
</tr>
<tr>
<td>selected</td>
<td>selected 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</td>
</tr>
</table>
<p>"networks" - list of networks and the associated settings from network list</p>
<table border="1">
<tr style="background-color: #dddddd">
<td>Key</td> <td>Value</td>
</tr>
<tr>
<td>autojoins</td> <td>An object with the following methods:<br />
<table>
<tr>
<td>Method</td>
<td>Description</td>
</tr>
<tr>
<td>channels()</td>
<td>returns a list of this networks' autojoin channels in list context, a count of the number autojoin channels in scalar context</td>
</tr>
<tr>
<td>keys()</td>
<td>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</td>
</tr>
<tr>
<td>pairs()</td>
<td>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.</td>
</tr>
<tr>
<td>as_hash()</td>
<td>return the pairs as a hash reference</td>
</tr>
<tr>
<td>as_string()</td>
<td>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</td>
</tr>
<tr>
<td>as_array()</td>
<td>return an array reference of hash references consisting of the keys "channel" and "key"</td>
</tr>
<tr>
<td>as_bool()</td>
<td>returns true if the network has autojoins and false otherwise</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>connect_commands</td> <td>An array reference containing the connect commands for a network. An empty array if there aren't any</td>
</tr>
<tr>
<td>encoding</td> <td>the encoding for the network</td>
</tr>
<tr>
<td>flags</td>
<td>
a hash reference corresponding to the checkboxes in the network edit window
<table>
<tr>
<td>allow_invalid</td>
<td>true if "Accept invalid SSL certificate" is checked</td>
</tr>
<tr>
<td>autoconnect</td>
<td>true if "Auto connect to this network at startup" is checked</td>
</tr>
<tr>
<td>cycle</td>
<td>true if "Connect to selected server only" is <strong>NOT</strong> checked</td>
</tr>
<tr>
<td>use_global</td>
<td>true if "Use global user information" is checked</td>
</tr>
<tr>
<td>use_proxy</td>
<td>true if "Bypass proxy server" is <strong>NOT</strong> checked</td>
</tr>
<tr>
<td>use_ssl</td>
<td>true if "Use SSL for all the servers on this network" is checked</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>irc_nick1</td>
<td>Corresponds with the "Nick name" field in the network edit window</td>
</tr>
<tr>
<td>irc_nick2</td>
<td>Corresponds with the "Second choice" field in the network edit window</td>
</tr>
<tr>
<td>irc_real_name</td>
<td>Corresponds with the "Real name" field in the network edit window</td>
</tr>
<tr>
<td>irc_user_name</td>
<td>Corresponds with the "User name" field in the network edit window</td>
</tr>
<tr>
<td>network</td>
<td>Name of the network</td>
</tr>
<tr>
<td>nickserv_password</td>
<td>Corresponds with the "Nickserv password" field in the network edit window</td>
</tr>
<tr>
<td>selected</td>
<td>Index into the list of servers in the "servers" key, this is used if the "cycle" flag is false</td>
</tr>
<tr>
<td>server_password</td>
<td>Corresponds with the "Server password" field in the network edit window</td>
</tr>
<tr>
<td>servers</td>
<td>An array reference of hash references with a "host" and "port" key. If a port is not specified then 6667 will be used.</td>
</tr>
</table>
=end html
=head3 C<Xchat::user_info( [$nick] )>
=over 3
=item *
C<$nick> - the nick to look for, if this is not given your own nick will be
used as default
=back
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 L<get_list|xchat_get_list>.
If C<$nick> is found a hash reference containing the same keys as those in the
"users" list of L<get_list|xchat_get_list> is returned otherwise undef is returned.
Since it relies on L<get_list|xchat_get_list> this function can only be used in a
channel context.
=head3 C<Xchat::context_info( [$context] )>
=over 3
=item *
C<$context> - context returned from L<get_context|xchat_get_context>, L<find_context|xchat_find_context> and L<get_list|xchat_get_list>, this is the context that you want infomation about. If this is omitted, it will default to current context.
=back
This function will return the information normally retrieved with L<get_info|xchat_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 C<$id> you would normally supply to L<get_info|xchat_get_info> as well as all the keys that are valid for the items in the "channels" list from L<get_list|xchat_get_list>. Use of this function is more efficient than calling get_list( "channels" ) and searching through the result.
=begin html
<p>Example:</p>
<div class="example">
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;
}
</div>
=end html
=head3 C<Xchat::strip_code( $string )>
=over 3
=item *
C<$string> - string to remove codes from
=back
This function will remove bold, color, beep, reset, reverse and underline codes from C<$string>. It will also remove ANSI escape codes which might get used by certain terminal based clients. If it is called in void context C<$string> will be modified otherwise a modified copy of C<$string> is returned.