Skip Menu |

This queue is for tickets about the POE-Component-IRC CPAN distribution.

Report information
The Basics
Id: 32265
Status: resolved
Worked: 30 min
Priority: 0/
Queue: POE-Component-IRC

People
Owner: BINGOS [...] cpan.org
Requestors: hinrik.sig [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: is_away() support in State.pm
The following patch adds support for checking the away status of nicks tracked by State.pm.
Subject: away.diff
--- State.pm.old 2008-01-12 06:38:00.000000000 +0000 +++ State.pm 2008-01-12 06:42:57.000000000 +0000 @@ -228,6 +228,18 @@ return PCI_EAT_NONE; } +sub S_305 { + my ($self,$irc) = splice @_, 0, 2; + delete $self->{STATE}->{away}; + return PCI_EAT_NONE; +} + +sub S_306 { + my ($self,$irc) = splice @_, 0, 2; + $self->{STATE}->{away} = 1; + return PCI_EAT_NONE; +} + # Channel MODE sub S_mode { my ($self,$irc) = splice @_, 0, 2; @@ -379,6 +391,12 @@ if ( $status =~ /\*/ ) { $self->{STATE}->{Nicks}->{ $unick }->{IRCop} = 1; } + if ( $status =~ /G/ ) { + $self->{STATE}->{Nicks}->{ $unick }->{Away} = 1; + } + else { + $self->{STATE}->{Nicks}->{ $unick }->{Away} = 0; + } return PCI_EAT_NONE; } @@ -684,6 +702,20 @@ return map { $self->{STATE}->{Nicks}->{$_}->{Nick} } keys %{ $self->{STATE}->{Chans}->{ $channel }->{Nicks} }; } +sub is_away { + my $self = shift; + my $mapping = $self->isupport('CASEMAPPING'); + my $nick = u_irc $_[0], $mapping || return; + return unless $self->_nick_exists($nick); + if ($nick eq u_irc $self->{RealNick}) { + # more accurate + return 1 if $self->{STATE}->{away}; + return 0; + } + return 1 if $self->{STATE}->{Nicks}->{ $nick }->{Away}; + return 0; +} + sub is_operator { my $self = shift; my $mapping = $self->isupport('CASEMAPPING'); @@ -1039,6 +1071,11 @@ Expects a channel as parameter. Returns a list of all nicks on the specified channel. If the component happens to not be on that channel an empty list will be returned. +=item is_away + +Expects a nick as parameter. Returns 1 if the specified nick is away or 0 otherwise. If the nick does +not exist in the state then a 0 will be returned. + =item is_operator Expects a nick as parameter. Returns 1 if the specified nick is an IRC operator or 0 otherwise. If the nick does
From: hinrik.sig [...] gmail.com
Hm. Also, the documentation should mention that it's only guaranteed to be accurate for the IRC component's nick.
From: hinrik.sig [...] gmail.com
On Sat Jan 12 01:57:25 2008, HINRIK wrote: Show quoted text
> The following patch adds support for checking the away status of nicks > tracked by State.pm.
Updated it. Fixes a bug and adds documentation.
--- State.pm 2008-01-13 08:50:26.000000000 +0000 +++ State.pm.new 2008-01-13 08:53:33.000000000 +0000 @@ -228,6 +228,18 @@ return PCI_EAT_NONE; } +sub S_305 { + my ($self,$irc) = splice @_, 0, 2; + delete $self->{STATE}->{away}; + return PCI_EAT_NONE; +} + +sub S_306 { + my ($self,$irc) = splice @_, 0, 2; + $self->{STATE}->{away} = 1; + return PCI_EAT_NONE; +} + # Channel MODE sub S_mode { my ($self,$irc) = splice @_, 0, 2; @@ -379,6 +391,12 @@ if ( $status =~ /\*/ ) { $self->{STATE}->{Nicks}->{ $unick }->{IRCop} = 1; } + if ( $status =~ /G/ ) { + $self->{STATE}->{Nicks}->{ $unick }->{Away} = 1; + } + else { + $self->{STATE}->{Nicks}->{ $unick }->{Away} = 0; + } return PCI_EAT_NONE; } @@ -684,6 +702,20 @@ return map { $self->{STATE}->{Nicks}->{$_}->{Nick} } keys %{ $self->{STATE}->{Chans}->{ $channel }->{Nicks} }; } +sub is_away { + my $self = shift; + my $mapping = $self->isupport('CASEMAPPING'); + my $nick = u_irc $_[0], $mapping || return; + if ($nick eq u_irc $self->{RealNick}) { + # more accurate + return 1 if $self->{STATE}->{away}; + return 0; + } + return unless $self->_nick_exists($nick); + return 1 if $self->{STATE}->{Nicks}->{ $nick }->{Away}; + return 0; +} + sub is_operator { my $self = shift; my $mapping = $self->isupport('CASEMAPPING'); @@ -1039,6 +1071,12 @@ Expects a channel as parameter. Returns a list of all nicks on the specified channel. If the component happens to not be on that channel an empty list will be returned. +=item is_away + +Expects a nick as parameter. Returns 1 if the specified nick is away or 0 otherwise. If the nick does +not exist in the state then a 0 will be returned. This is only guaranteed to be accurate for the Component's +nick. + =item is_operator Expects a nick as parameter. Returns 1 if the specified nick is an IRC operator or 0 otherwise. If the nick does
Many thanks, patch applied and tested, new version released to CPAN.