Skip to content

Commit

Permalink
TonyC noticed that the dynamic channel listing was broken. It didn't
Browse files Browse the repository at this point in the history
list anything until the bot side was kicked and invited back, and then
it only listed the channel it was re-invited to.  This patch reworks
the channel management functions in Util::Data and also disambiguates
lc() calls in Client::IRC.

Actually, it seems that a previous patch removed irc_join.  We put it
back as well.
  • Loading branch information
rcaputo committed Nov 13, 2003
1 parent bdf7222 commit 9e3bcaa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 7 additions & 1 deletion Client/IRC.pm
Expand Up @@ -409,12 +409,18 @@ foreach my $server (get_names_by_type('irc')) {
delete $heap->{users}{$where}{$nick};
},

irc_join => sub {
my ($kernel, $who, $where) = @_[KERNEL, ARG0, ARG1];
my ($nick) = $who =~ /^([^!]+)/;
add_channel($where) if lc($nick) eq lc($conf{nick});
},

# who reply
irc_352 => sub {
my ($kernel, $heap, $what) = @_[KERNEL, HEAP, ARG1];

my @reply = split " ", $what, 8;
@{$heap->{users}{$reply[0]}{$reply[4]}}{qw(ident host mode real)} =
@{$heap->{users}{$reply[0]}{$reply[4]}}{qw(ident host mode real)} =
($reply[1], $reply[2], $reply[5], $reply[7]);
},

Expand Down
20 changes: 8 additions & 12 deletions Util/Data.pm
Expand Up @@ -30,7 +30,7 @@ sub PASTE_HOST () { 5 }
my $id_sequence = 0;
my %paste_cache;
my %ignores; # $ignores{$ircnet}{lc $channel} = [ mask, mask, ... ];
my @channels;
my %channels;

# return a list of all paste ids

Expand Down Expand Up @@ -207,29 +207,25 @@ sub clear_channel_ignores {
# Channels we're on

sub channels {
return @channels;
return sort keys %channels;
}

sub clear_channels {
@channels = ();
return if @channels; # Should never happen
%channels = ();
return if keys %channels; # Should never happen
return 1;
}

sub add_channel {
my ($channel) = @_;
$channel = lc $channel;
return if grep $_ eq $channel, @channels;
return push @channels, $channel;
$channel = lc($channel);
$channels{$channel} = 1;
}

sub remove_channel {
my ($channel) = @_;
$channel = lc $channel;
my $found = 0;
@channels = grep { $_ eq $channel ? do { $found++; 0; } : 1 } @channels;
return if not $found;
return $found;
$channel = lc($channel);
delete $channels{$channel}; # returns automatically
}

# Init stuff
Expand Down

0 comments on commit 9e3bcaa

Please sign in to comment.