use lib get_info 'xchatdir';
use Xchat::XPI;
use Xchat::XPI::Events qw<delay>;
-use Xchat::XPI::Utils qw<save_context local_context>;
+use Xchat::XPI::Utils qw<irc_lc save_context local_context>;
use constant {
JOIN_DELAY => 1000,
POST => "\n",
};
+die 'Invalid PRE/POST' unless irc_lc(PRE . POST) eq PRE . POST;
+
our $VERSION = '0.04';
my ($ph, %users, %fetched);
sub add {
my ($nick, $host, $serv, $chan) = @_;
+ $chan = irc_lc $chan;
+
my $hosts = $users{$serv}{$chan};
$users{$serv}{$chan} = $hosts = { } unless defined $hosts;
$nick = PRE . $nick . POST;
if (defined $clones) {
- if (index($clones, $nick) < $[) {
+ if (index(irc_lc($clones), irc_lc($nick)) < $[) {
$hosts->{$host} = dualvar int($clones) + 1, $clones . $nick;
}
} else {
sub remove {
my ($nick, $host, $serv, $chan) = @_;
+ $nick = irc_lc $nick;
+ $chan = irc_lc $chan;
+
my $hosts = $users{$serv}{$chan};
return 0 unless $hosts;
return 0 unless $clones;
$nick = PRE . $nick . POST;
- if ((my $off = index $clones, $nick) >= $[) {
+ if ((my $off = index irc_lc($clones), $nick) >= $[) {
my $count = int $clones;
if ($count > 1) {
substr $clones, $off, length $nick, '';
sub replace {
my ($old, $new, $host, $serv, $chan) = @_;
+ $old = irc_lc $old;
+ $chan = irc_lc $chan;
+
my $hosts = $users{$serv}{$chan};
$users{$serv}{$chan} = $hosts = { } unless defined $hosts;
my $clones = $hosts->{$host};
$_ = PRE . $_ . POST for $old, $new;
- if (defined $clones and (my $off = index $clones, $old) >= $[) {
+ if (defined $clones and (my $off = index irc_lc($clones), $old) >= $[) {
my $count = int $clones;
substr $clones, $off, length $old, '';
$hosts->{$host} = dualvar $count, $clones . $new;
sub scan {
my ($serv, $chan) = @_;
+ $chan = irc_lc $chan;
+
return unless $fetched{$serv}{$chan};
my $hosts = $users{$serv}{$chan};
sub flush {
my ($serv, $chan) = @_;
- return 0 unless $serv and $chan and $fetched{$serv}{$chan};
+ return 0 unless $serv and $chan;
+
+ $chan = irc_lc $chan;
+ return 0 unless $fetched{$serv}{$chan};
delete $users{$serv}{$chan};
delete $users{$serv} unless keys %{$users{$serv}};
add $_->{nick}, host($host), $serv, $chan;
++$users;
}
- $fetched{$serv}{$chan} = 1 if $users;
+ $fetched{$serv}{irc_lc($chan)} = 1 if $users;
return $users;
}
hook_server '315', sub { # WHO end
my $serv = get_info 'server';
- my $chan = lc $_[0][3];
+ my $chan = $_[0][3];
- return EAT_NONE if $fetched{$serv}{$chan};
+ return EAT_NONE if $fetched{$serv}{irc_lc($chan)};
local_context $chan, $serv => sub {
fetch $serv, $chan;
hook_server 'JOIN', sub {
my ($nick, $userhost) = ($_[0][0] =~ /^:([^!]+)!(.*)/);
my $serv = get_info 'server';
- my $chan = lc substr $_[0][2], 1; # starts with colon
+ my $chan = substr $_[0][2], 1; # starts with colon
my $clones = add $nick, host($userhost), $serv, $chan;
return EAT_NONE unless $clones > 0;
hook_server 'KICK', sub {
my $nick = $_[0][3];
my $serv = get_info 'server';
- my $chan = lc $_[0][2];
+ my $chan = $_[0][2];
if (nickcmp get_info('nick'), $nick) {
my $userinfo = user_info $nick;
hook_server 'PART', sub {
my ($nick, $userhost) = ($_[0][0] =~ /^:([^!]+)!(.*)/);
my $serv = get_info 'server';
- my $chan = lc $_[0][2];
+ my $chan = $_[0][2];
if (nickcmp get_info('nick'), $nick) {
my $clones = remove $nick, host($userhost), $serv, $chan;
hook_server 'QUIT', sub {
my ($nick, $userhost) = ($_[0][0] =~ /^:([^!]+)!(.*)/);
my $serv = get_info 'server';
- my @chans = map [ lc $_->{channel}, $_->{context} ],
+ my @chans = map [ $_->{channel}, $_->{context} ],
grep { $_->{type} == 2 and $_->{server} eq $serv }
get_list 'channels';
# Otherwise, the new nick would be added right now, and the old one would be
# when the WHO responses arrives (which may still refer to the old nick).
replace $old => $new, host($userhost),
- get_info('server'), lc get_info('channel');
+ get_info('server'), get_info('channel');
}
return EAT_NONE;
hook_command 'CLSCAN', sub {
my $serv = get_info 'server';
- my $chan = lc get_info 'channel';
+ my $chan = get_info 'channel';
- if (!$fetched{$serv}{$chan} and !fetch($serv, $chan)) {
+ if (!$fetched{$serv}{irc_lc($chan)} and !fetch($serv, $chan)) {
print $ph "Data still not available\n";
} elsif (!scan($serv, $chan)) {
print $ph "No clones found\n";
use lib get_info 'xchatdir';
use Xchat::XPI;
-use Xchat::XPI::Utils qw<save_context>;
+use Xchat::XPI::Utils qw<irc_lc save_context>;
our $VERSION = '0.03';
my $serv = get_info 'server';
my $nick = $_[0][7];
- return EAT_NONE if $opers{$serv}{$nick};
- $opers{$serv}{$nick} = 1;
+ return EAT_NONE if $opers{$serv}{irc_lc($nick)};
+ $opers{$serv}{irc_lc($nick)} = $nick;
my $host = $_[0][4] . '@' . $_[0][5];
my %chans;
my ($nick) = $_[0][0] =~ /^:([^!]+)!/;
my $serv = get_info 'server';
- delete $opers{$serv}{$nick};
+ delete $opers{$serv}{irc_lc($nick)};
return EAT_NONE;
};
sub nick_cb {
my ($old, $new) = @{$_[0]};
+ $old = irc_lc $old;
+
my $ops = $opers{get_info 'server'};
if ($ops and $ops->{$old}) {
- $ops->{$new} = 1;
+ $ops->{irc_lc($new)} = $new;
delete $ops->{$old};
}
my ($name, @ops);
if ($isnet) {
$name = 'network';
- @ops = keys %{$opers{$serv}};
+ @ops = values %{$opers{$serv}};
} else {
$name = 'channel';
@ops = map $_->{nick},
- grep $opers{$serv}{$_->{nick}},
+ grep $opers{$serv}{irc_lc($_->{nick})},
get_list 'users';
}