In your code snippet, despite what you print out, you're not actually
changing $heap->{nick}, so you're reconnecting with the same name as
before...

Nick.

On Sun, 18 Apr 2004, Ciro wrote:

> Psilon, my modular POE IRC bot, is coming along fairly well. I've run
> into a bit of a snafu though. If the preset nick is in use, the bot will
> just hang there in a sort of "half-connected" state, until the connection
> times out, and the server gives a 443 Numeric. Theory on this below.
>
> I'd originally tried to deal with this situation by changing the nick,
> then issuing a "ghost" command to the local nickserv equivalent, but it
> never triggered the nick change so nothing else happend. Now I am just
> trying to reconnect with a random number (1-9999) appended to the nick,
> a-la AOL. (Code Below)
>
> This event is linked to 'on_irc_443', and it's part of it's own module,
> which includes wrappers for most of the PoCo::IRC commands (thus the
> $self references in the function calls. The names should be obvious.)
>
> I suppose this might be more of a question for IRC hackers than POE
> hackers, but I figure there has to be SOME crossover because the module
> exists. :) The crux of the problem seems to be that the IRC server only
> returns a Numeric Reply if the nick change FAILS (according to RFC 1459).
> Anyone have any idea how I might work around this so I don't have to drop
> and re-establish connection? If I can get that working, then I can get the
> nickserv's 'ghost' command implimented.
>
> Thanks!
>
> -Ciro
>
>
>
> #--------- Begin Code Snippet -----------
>
> sub irc_433  #nickname in use
> {
> #use the serverhost as a session alias. Makes multi-net usage a lot easer
> #to debug
>     my $self=shift;
>     my $server=shift;
>     my $sess=$self->{KERNEL}->alias_resolve($server);
>     my $heap=$sess->get_heap(); #pull the heap with our settings
>     my $nick=$heap->{"nick"};
>
>     #drop existing connection
>     $self->disconnect($server, ": $nick in use.\n");
>
>     #generate random nick
>     $nick = $nick . int(rand(10000)));
>
>     print "Reconnecting with nick: $nick\n";   #reconnect
>     $self->{KERNEL}->post(
>                 $server,
>                 'connect',{
>               Nick     => $heap->{"nick"},
>               Server   => $server,
>               Username => $heap->{"username"},
>               Ircname  => $heap->{"realname"},}
>                 );
>
> }
>
>
>
>
>

Reply via email to