Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: POE::IRC, Where was that tall building again?

by pc88mxer (Vicar)
on Jul 16, 2008 at 15:22 UTC ( [id://698035]=note: print w/replies, xml ) Need Help??


in reply to POE::IRC, Where was that tall building again?

I just had a crazy idea but if by chance I return the data I want in &on_who return $account, $channel; will that return a value to where I typed $irc->yield( who => '#poe')?
From the POE docs, yield always returns true. You are simply posting a new event to the queue which POE will act on later. However, if you call call, you will be invoking another method synchronously and it will return the return value(s) of that method. But call won't work for you in this case since the who handler doesn't return the parsed who output.

The general way to handle this problem is to remember why you made the who call and then perform the tail end of the action in the on_who handler, i.e.:

# in code which calls 'who': $reason_for_calling_who = 'whatever'; $irc->yield('who'); ... # in on_who handler: if ($reason_for_calling_who eq 'whatever') { # complete processing for this case } elsif ($reason_for_calling_who eq ...) { ... }

Replies are listed 'Best First'.
Re^2: POE::IRC, Where was that tall building again?
by bingos (Vicar) on Jul 16, 2008 at 15:45 UTC

    Yeah, each state handler has access to a HEAP variable where you can store that kind of state data.

    # in code which calls 'who': $_[HEAP]->{reason_for_calling_who} = 'whatever'; $irc->yield('who'); ... # in on_who handler: if ($_[HEAP]->{reason_for_calling_who} eq 'whatever') { # complete processing for this case } elsif ($_[HEAP]->{reason_for_calling_who} eq ...) { ... }
Re^2: POE::IRC, Where was that tall building again?
by novastorm0 (Beadle) on Jul 16, 2008 at 18:25 UTC
    Fixed. Used IRC::State.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://698035]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-23 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found