4 my ($script_name, $version, $callback) = @_;
6 $callback = Xchat
::Embed
::fix_callback
( $package, undef, $callback) if $callback;
7 Xchat
::register
( $script_name, $version, undef, $callback );
11 sub IRC
::add_command_handler
{
12 my ($command, $callback) = @_;
15 $callback = Xchat
::Embed
::fix_callback
( $package, undef, $callback );
17 # starting index for word_eol array
18 # this is for compatibility with '' as the command
19 my $start_index = $command ?
1 : 0;
21 Xchat
::hook_command
( $command,
24 return &{$callback}($_[1][$start_index]);
30 sub IRC
::add_message_handler
{
31 my ($message, $callback) = @_;
33 $callback = Xchat
::Embed
::fix_callback
( $package, undef, $callback );
35 Xchat
::hook_server
( $message,
38 return &{$callback}( $_[1][0] );
44 sub IRC
::add_print_handler
{
45 my ($event, $callback) = @_;
47 $callback = Xchat
::Embed
::fix_callback
( $package, undef, $callback );
48 Xchat
::hook_print
( $event,
52 return &{$callback}( join( ' ', @word[0..3] ), @word );
58 sub IRC
::add_timeout_handler
{
59 my ($timeout, $callback) = @_;
61 $callback = Xchat
::Embed
::fix_callback
( $package, undef, $callback );
62 Xchat
::hook_timer
( $timeout,
74 if( $command =~ m{^/} ) {
76 Xchat
::command
( $command );
78 Xchat
::command
( qq[say $command] );
82 sub IRC
::command_with_channel
{
83 my ($command, $channel, $server) = @_;
84 my $old_ctx = Xchat
::get_context
;
85 my $ctx = Xchat
::find_context
( $channel, $server );
88 Xchat
::set_context
( $ctx );
89 IRC
::command
( $command );
90 Xchat
::set_context
( $ctx );
94 sub IRC
::command_with_server
{
95 my ($command, $server) = @_;
96 my $old_ctx = Xchat
::get_context
;
97 my $ctx = Xchat
::find_context
( undef, $server );
100 Xchat
::set_context
( $ctx );
101 IRC
::command
( $command );
102 Xchat
::set_context
( $ctx );
108 for my $dcc ( Xchat
::get_list
( 'dcc' ) ) {
109 push @dccs, $dcc->{nick
};
110 push @dccs, $dcc->{file
} ?
$dcc->{file
} : '';
111 push @dccs, @
{$dcc}{qw(type status cps size)};
112 push @dccs, $dcc->{type
} == 0 ?
$dcc->{pos} : $dcc->{resume
};
113 push @dccs, $dcc->{address32
};
114 push @dccs, $dcc->{destfile
} ?
$dcc->{destfile
} : '';
119 sub IRC
::channel_list
{
121 for my $channel ( Xchat
::get_list
( 'channels' ) ) {
122 push @channels, @
{$channel}{qw(channel server)},
123 Xchat
::context_info
( $channel->{context
} )->{nick
};
130 my @ids = qw(version nick channel server xchatdir away network host topic);
132 if( $id >= 0 && $id <= 8 && $id != 5 ) {
133 my $info = Xchat
::get_info
($ids[$id]);
134 return defined $info ?
$info : '';
137 return Xchat
::get_info
( 'away' ) ?
1 : 0;
145 return 'Unknown variable' unless defined $_[0];
146 my $result = Xchat
::get_prefs
(shift);
147 return defined $result ?
$result : 'Unknown variable';
150 sub IRC
::ignore_list
{
152 for my $ignore ( Xchat
::get_list
( 'ignore' ) ) {
153 push @ignores, $ignore->{mask
};
154 my $flags = $ignore->{flags
};
155 push @ignores, $flags & 1, $flags & 2, $flags & 4, $flags & 8, $flags & 16,
162 Xchat
::print( $_ ) for @_;
166 sub IRC
::print_with_channel
{
171 Xchat
::commandf
( qq[quote
%s], shift );
174 sub IRC
::server_list
{
176 for my $channel ( Xchat
::get_list
( 'channels' ) ) {
177 push @servers, $channel->{server
} if $channel->{server
};
185 $user = Xchat
::user_info
( shift );
187 $user = Xchat
::user_info
();
192 push @info, $user->{nick
};
193 if( $user->{host
} ) {
194 push @info, $user->{host
};
196 push @info, 'FETCHING';
198 push @info, $user->{prefix
} eq '@' ?
1 : 0;
199 push @info, $user->{prefix
} eq '+' ?
1 : 0;
205 my ($channel, $server) = @_;
206 my $ctx = Xchat
::find_context
( $channel, $server );
207 my $old_ctx = Xchat
::get_context
;
210 Xchat
::set_context
( $ctx );
212 for my $user ( Xchat
::get_list
( 'users' ) ) {
213 push @users, $user->{nick
};
214 if( $user->{host
} ) {
215 push @users, $user->{host
};
217 push @users, 'FETCHING';
219 push @users, $user->{prefix
} eq '@' ?
1 : 0;
220 push @users, $user->{prefix
} eq '+' ?
1 : 0;
223 Xchat
::set_context
( $old_ctx );
230 sub IRC
::user_list_short
{
231 my ($channel, $server) = @_;
232 my $ctx = Xchat
::find_context
( $channel, $server );
233 my $old_ctx = Xchat
::get_context
;
236 Xchat
::set_context
( $ctx );
238 for my $user ( Xchat
::get_list
( 'users' ) ) {
239 my $nick = $user->{nick
};
240 my $host = $user->{host
} || 'FETCHING';
241 push @users, $nick, $host;
243 Xchat
::set_context
( $old_ctx );
251 sub IRC
::add_user_list
{}
252 sub IRC
::sub_user_list
{}
253 sub IRC
::clear_user_list
{}
254 sub IRC
::notify_list
{}
255 sub IRC
::perl_script_list
{}