Skip to content

Commit

Permalink
State.pm: Reorder some code and add is_channel_synced()
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik committed Apr 6, 2008
1 parent 651b77c commit 63051e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -5,6 +5,7 @@ Revision history for Perl extension POE::Component::IRC.
- State.pm: Only WHO users once even if they join many chans (Hinrik)
- State.pm: Added channel_creation_time() method (Hinrik)
- State.pm: Made channel_modes() return mode arguments as well (Hinrik)
- State.pm: Add is_channel_synced() (Hinrik)

5.74 Thu Apr 03 15:14:04 GMT 2008
- Logger.pm: Do charset conversion on everything, not just messages. This
Expand Down
26 changes: 18 additions & 8 deletions lib/POE/Component/IRC/State.pm
Expand Up @@ -75,29 +75,29 @@ sub S_join {
$self->yield(who => $channel );
$self->yield(mode => $channel );
$self->yield(mode => $channel => 'b');

if ($self->{awaypoll}) {
$poe_kernel->state(_away_sync => $self);
$poe_kernel->delay_add(_away_sync => $self->{awaypoll} => $channel);
}

}
else {
if ( (!exists $self->{whojoiners} || $self->{whojoiners})
&& !exists $self->{STATE}->{Nicks}->{ $unick }->{Real}) {
$self->yield (who => $nick);
$self->yield(who => $nick);
push @{ $self->{NICK_SYNCH}->{ $unick } }, $channel;
}
else {
# Fake 'irc_nick_sync'
$self->_send_event(irc_nick_sync => $nick, $channel);
}

$self->{STATE}->{Nicks}->{ $unick }->{Nick} = $nick;
$self->{STATE}->{Nicks}->{ $unick }->{User} = $user;
$self->{STATE}->{Nicks}->{ $unick }->{Host} = $host;
$self->{STATE}->{Nicks}->{ $unick }->{CHANS}->{ $uchan } = '';
$self->{STATE}->{Chans}->{ $uchan }->{Nicks}->{ $unick } = '';
}

$self->{STATE}->{Nicks}->{ $unick }->{Nick} = $nick;
$self->{STATE}->{Nicks}->{ $unick }->{User} = $user;
$self->{STATE}->{Nicks}->{ $unick }->{Host} = $host;
$self->{STATE}->{Nicks}->{ $unick }->{CHANS}->{ $uchan } = '';
$self->{STATE}->{Chans}->{ $uchan }->{Nicks}->{ $unick } = '';

return PCI_EAT_NONE;
}
Expand Down Expand Up @@ -848,6 +848,11 @@ sub is_channel_mode_set {
return;
}

sub is_channel_synced {
my ($self, $channel) = @_;
return $self->_channel_sync($channel);
}

sub channel_creation_time {
my ($self, $channel) = @_;
my $mapping = $self->isupport('CASEMAPPING');
Expand Down Expand Up @@ -1274,6 +1279,11 @@ the nick is a half-operator on the specified channel. Returns false if the nick
is not a half-operator on the channel or if the nick/channel does not exist in
the state.
=item C<is_channel_synced>
Expects a channel as a parameter. Returns true if the channel has been synced.
Returns false if it has not been synced or if the channel is not in the state.
=item C<has_channel_voice>
Expects a channel and a nickname as parameters. Returns a true value if
Expand Down

0 comments on commit 63051e1

Please sign in to comment.