diff --git a/bin/auto b/bin/auto index 44c7aab..c658e20 100755 --- a/bin/auto +++ b/bin/auto @@ -169,9 +169,7 @@ foreach my $cskey (keys %cservers) { socksnd($cskey, "USER ".$cservers{$cskey}{'ident'}[0]." * * :".$cservers{$cskey}{'realname'}[0]) or err(2, "Failed to connect to server: ".$cskey." [".$cservers{$cskey}{'host'}[0].":".$cservers{$cskey}{'port'}[0]."]", 0) and next; - socksnd($cskey, "NICK ".$cservers{$cskey}{'nick'}[0]) or - err(2, "Failed to connect to server: ".$cskey." [".$cservers{$cskey}{'host'}[0].":".$cservers{$cskey}{'port'}[0]."]", 0) - and next; + API::IRC::nick($cskey, $cservers{$cskey}{'nick'}[0]); # Create the process. $SOCKPROC{$cskey} = Async->new(sub { # Infinite loop. diff --git a/doc/CHANGELOG b/doc/CHANGELOG index bafdc26..95fba34 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Parse Numeric:433. * Added nick() to API::IRC. * Added %got_001 to Parser::IRC for checking if we've been sent 001. diff --git a/src/API/IRC.pm b/src/API/IRC.pm index 2228442..e12f158 100644 --- a/src/API/IRC.pm +++ b/src/API/IRC.pm @@ -9,7 +9,7 @@ use warnings; use Exporter; our @ISA = qw(Exporter); -our @EXPORT_OK = qw(cjoin cpart mode privmsg notice quit); +our @EXPORT_OK = qw(cjoin cpart cmode privmsg notice quit nick); # Join a channel. @@ -71,6 +71,8 @@ sub nick my ($svr, $newnick) = @_; Auto::socksnd($svr, "NICK $newnick"); + + $Parser::IRC::botnick{$svr} = $newnick; } # Quit IRC. diff --git a/src/Parser/IRC.pm b/src/Parser/IRC.pm index 1edab50..3f0028c 100644 --- a/src/Parser/IRC.pm +++ b/src/Parser/IRC.pm @@ -7,15 +7,16 @@ package Parser::IRC; use strict; use warnings; use API::Std qw(conf_get); -use API::IRC qw(cjoin); +use API::IRC qw(cjoin nick); # Raw parsing hash. our %RAWC = ( '001' => \&num001, + '433' => \&num433, ); # Variables for various functions. -our (%got_001); +our (%got_001, %botnick); # Parse raw data. sub _parse @@ -68,4 +69,14 @@ sub num001 } } +# Parse: Numeric:433 +sub num433 +{ + my ($svr, undef) = @_; + + if (defined $botnick{$svr}) { + nick($svr, $botnick{$svr}."_"); + } +} + 1;