shealyw2 has asked for the wisdom of the Perl Monks concerning the following question:

Thanks for all the help. With mbethk's help i was able to figure it out

I am having trouble using this method:

http://search.cpan.org/~hinrik/POE-Component-IRC-6.78/lib/POE/Component/IRC.pm#who

I have tried:

$kernel->call(who => $where);

I want all the users in a channel. I am also not sure where the results will be stored i tried $_arg0, but it does not appear to be there.

Thanks.

Replies are listed 'Best First'.
Re: Poe:Component:Irc Use of the who method.
by ww (Archbishop) on Jun 30, 2012 at 12:04 UTC

    This is a WAG (and very possibly, irrelevant and/or flat-out-wrong), but if you search the (whole) document, http://search.cpan.org/~hinrik/POE-Component-IRC-6.78/lib/POE/Component/IRC.pm (note: a PM link, created by surrounding the URL with square brackets), you'll find this example code using "$who":

    sub irc_public { my ($sender, $who, $where, $what) = @_[SENDER, ARG0 .. ARG2]; my $nick = ( split /!/, $who )[0]; my $channel = $where->[0]; if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) { $rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M]; $irc->yield( privmsg => $channel => "$nick: $rot13" ); } return; }

    which suggests an approach; an approach, only, but the referenced part of the doc says:

    Lists the logged-on users matching a particular channel name, hostname, nickname, or what-have-you. Takes one optional argument: a string for it to search for. Wildcards are allowed; in the absence of this argument, it will return everyone who's currently logged in (bad move). Tack an "o" on the end if you want to list only IRCops, as per the RFC.

    All told, that makes me wonder if there's some internal magic to stuff an arrayref of who instances into $nick, which is then returned.

    And, for good measure, if you haven't done so already, check "whois" and "whowas." BUT, reiterating my warning, this is a WAG from a non-user of IRC and POE.

      In that case it was using the variable $who as a something different than what it means in this case. It really is just a bad choice of varible names in that example i beleive, since it conflicts with a method that is also defined. Thanks though.
Re: Poe:Component:Irc Use of the who method.
by mbethke (Hermit) on Jun 30, 2012 at 15:49 UTC

    There's one obvious problem with your call(): it uses "who" as the session name so the call goes nowhere. The first argument must be the name of your IRC session. You can directly call handlers on the IRC session object but that doesn't seem the right way of using it. Synchronous calls should only be used when you can immediately obtain a result, which in this case you can't anyway because it has to handle IRC protocol stuff first which is itself asynchronous.

    Try $irc->yield(who => $where); with the example code in the SYNOPSIS, as the last thing in _start. The result should be returned in some message---which one will be visible in the output from the _default handler.

      I tried the yield earlier just like that. It works that way but now i realize that the function is not designed to do what i was expecting it to do. So it works now, just not the way i was hoping.

      Thanks for your help