#!/usr/bin/perl # xchat_ircx_supp v0.6 - IRCX support. # Copyright (C) 2004 James Michael Fultz # License: GNU GPLv2 or later use strict; use warnings; my %script = ( name => 'xchat_ircx_supp', version => '0.6', description => 'IRCX support.' ); my %ircx_serv; Xchat::register($script{'name'}, $script{'version'}, $script{'description'}); Xchat::print("$script{'name'} v$script{'version'} - Loaded."); Xchat::hook_server('001', \&hook_ircrpl_welcome); Xchat::hook_server('800', \&hook_ircrpl_ircx); Xchat::hook_server('KNOCK', \&hook_knock); Xchat::hook_server('WHISPER', \&hook_whisper); Xchat::hook_command( 'owhisper', \&cmd_owhisper, {help_text => 'OWHISPER , Send IRCX Whisper to channel ops.'} ); sub hook_ircrpl_welcome { my $serv = Xchat::get_info('server'); $ircx_serv{$serv} = 0 if exists $ircx_serv{$serv}; Xchat::command('quote ISIRCX'); return Xchat::EAT_NONE(); } sub hook_ircrpl_ircx { my $state = $_[0][3]; my $serv = Xchat::get_info('server'); if (not $ircx_serv{$serv} and $state == 0) { $ircx_serv{$serv} = 1; Xchat::command('quote IRCX'); } elsif ($ircx_serv{$serv} and $state == 1) { ircx_supp(); } return Xchat::EAT_XCHAT(); } sub ircx_supp { my $serv = Xchat::get_info('server'); my $nick = Xchat::get_info('nick'); my $netw = Xchat::get_info('network'); Xchat::print("IRCX support enabled for $netw.", undef, $serv); Xchat::command('recv :' . $serv . ' 005 :' . $nick . ' PREFIX=(qov).@+'); } sub hook_knock { my $ident = $_[0][0]; $ident =~ s/^://; my ($nick, $userhost) = split(/!/, $ident, 2); my $channel = $_[0][2]; my $numeric = $_[0][3]; my $knock_msg = "$nick ($userhost) $channel knock"; my %error = ( 471 => 'Channel is full', 472 => 'Unknown mode', 473 => 'Channel is invite only', 474 => 'Banned from channel', 475 => 'Bad channel key', 476 => 'Bad channel mask' ); if ($error{$numeric}) { $knock_msg .= ' [' . $error{$numeric} . ']'; } Xchat::emit_print('Server Notice', $knock_msg); return Xchat::EAT_XCHAT(); } sub hook_whisper { my $ident = $_[0][0]; $ident =~ s/^://; my ($nick, $userhost) = split(/!/, $ident, 2); my $channel = $_[0][2]; my $targets = $_[0][3]; $targets =~ s/,/ /g; my $message = $_[1][4]; $message =~ s/^://; my $whisper_msg = "$nick/Whisper [$channel: $targets] $message"; Xchat::emit_print('Server Notice', $whisper_msg); return Xchat::EAT_XCHAT(); } sub cmd_owhisper { my $channel = Xchat::get_info('channel'); my $message = $_[1][1]; return if not $channel; my @users = Xchat::get_list('users'); my @chanops; foreach (@users) { if ($_->{'prefix'} eq '.' or $_->{'prefix'} eq '@') { push @chanops, $_->{'nick'}; } } return if not @chanops; my $chops = join ',', @chanops; Xchat::command( "quote WHISPER " . $channel . " " . $chops . " :To Ops: " . $message ); }