Hi all
I had a botscript which used Net::IRC, but when I heard
about P::C::IRC, I thought I have a look at it and liked it
very much at once. So I wanted to convert the script to use this
component. I got it converted fine mostly, only a few things I don't
understand and need some help with.
In my old script I had somethin' like:
sub some_routine {
$self = shift;
$self->privmsg($channel,"This is a test line");
...
$pid=fork();
if (not defined $pid) {
$self->privmsg($channel,"fork Failed!");
} elsif ($pid == 0) {
# we're the child
print "DEBUG: inside the child";
$self->privmsg($channel,"inside child session now");
} else {
# we're the parent
print "DEBUG: inside the parent";
$self->privmsg($channel,"inside the parent");
}
}
now converting it to POE I tried it like this:
sub some_routine {
$kernel = shift;
$kernel->post('ircbot','privmsg',$channel,"This is a test line");
...
pid=fork();
if (not defined $pid) {
$kernel->post('ircbot','privmsg',$channel,"fork Failed!");
} elsif ($pid == 0) {
# we're the child
print "DEBUG: inside the child";
$kernel->post('ircbot','privmsg',$channel,"inside the child now");
} else {
# we're the parent
print "DEBUG: inside the parent";
$kernel->post('ircbot','privmsg',$channel,"inside the parent");
}
}
Everything works fine, the print statements work both inside parent &
child, only thing that doesn't work is the kernel->post inside the
child, the message doesn't show up on IRC. Any clue on this, and how
I should fix it to get it to work ? Seems like from inside the child I
can't send anything to the POE::Component::IRC. I was told I shouldn't use
fork unless there's no POE-able way to do somethin, but I'm not sure
how I would do this otherwise.
Any help and example code very much appreciated