in reply to Re: POE::IRC Not joining Channel
in thread POE::IRC Not joining Channel

I changed the code.
its connecting as you can see.
also added "use strict" and didnt find anything.
use Data::Dumper; use POE::Kernel; use POE::Session; use POE::Component::IRC; use strict; sub start { my ($kernel, $session) = @_[KERNEL, SESSION]; $kernel->post( 'test', 'connect', { Debug => 1, Nick => 'Bot', Server => 'irc.psam.se', Port => '6667', Username => 'BotV6-Poe', Ircname => 'ModHelp', } )and print("connecting\n"); $kernel->post( 'test', 'register','all')and print("registered\n"); } sub stop { my ($kernel) = $_[KERNEL]; $kernel->call( 'test', 'quit', 'Neenios on ice!' ); } sub on_connect { my ($kernel) = $_[KERNEL]; print("in on_Connect\n"); $kernel->post( 'test', 'join', '#Alex' )and print("Joined\n"); } sub on_msg { my @args = @_[ ARG0 .. $#_ ]; my $list=join(" . ",@args); $kernel->post('test','privmsg','Isa',@_[ARG0]); } sub conn { my ($server) = $_[ARG0]; print("connected to $server\n"); } $| = 1; POE::Component::IRC->new('test'); POE::Session->create(inline_states =>{ irc_connected=>\&conn, _start=>\&start, _stop=>\&stop, irc_001=>\&on_connect, irc_msg=>\&on_msg,},); $poe_kernel->run();
the output is:
connecting
registered
connected to irc.psam.se

Replies are listed 'Best First'.
Re: Re: Re: POE::IRC Not joining Channel
by antirice (Priest) on Oct 11, 2003 at 15:47 UTC

    You're not checking whether or not your nickname is in use. Try this:

    use Data::Dumper; use POE::Kernel; use POE::Session; use POE::Component::IRC; use strict; sub start { my ($kernel, $session) = @_[KERNEL, SESSION]; $kernel->post( 'test', 'connect', { Debug => 1, Nick => 'Bot', Server => 'irc.psam.se', Port => '6667', Username => 'BotV6-Poe', Ircname => 'ModHelp', } )and print("connecting\n"); $kernel->post( 'test', 'register','all')and print("registered\n"); } sub stop { my ($kernel) = $_[KERNEL]; $kernel->call( 'test', 'quit', 'Neenios on ice!' ); } sub on_connect { my ($kernel) = $_[KERNEL]; print("in on_Connect\n"); $kernel->post( 'test', 'join', '#Alex' )and print("Joined\n"); } sub on_msg { my $kernel = @_[KERNEL]; my @args = @_[ ARG0 .. $#_ ]; my $list=join(" . ",@args); $kernel->post('test','privmsg','Isa',@_[ARG0]); } sub conn { my ($server) = $_[ARG0]; print("connected to $server\n"); } sub in_use { my $kernel = @_[KERNEL]; print "Nickname is currently in use\n"; $kernel->post( 'test','nick','Mr' . int rand 200); } POE::Component::IRC->new('test'); POE::Session->create(inline_states =>{ irc_connected=>\&conn, _start=>\&start, _stop=>\&stop, irc_001=>\&on_connect, irc_msg=>\&on_msg, # ERR_NICKNAMEINUSE => 433 irc_433=>\&in_use },); $poe_kernel->run();

    Hope this helps.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: Re: Re: POE::IRC Not joining Channel
by Thelonius (Priest) on Oct 11, 2003 at 14:00 UTC
    When I run your code I get
    Global symbol "$kernel" requires explicit package name at 298494b.pl l +ine 38
    That is, $kernel is undeclared (and undefined) in the subroutine on_msg.
      I noticed that i forgot to declare it there,
      already fixed that,
      the proplem is that it never gets to the "on_connect" sub
      it looks like its not geting the irc_001 event.