* Parse NICK.

* Do not import API::IRC subroutines to Parser::IRC, instead use the class.
* Added usrc() to API::IRC for formatting a source.
This commit is contained in:
Elijah Perrault committed 2011-01-20 21:46:43 -07:00
1 parent e872082eb9
commit 512c351577
3 files changed
+44 -10

No files matched your search

+2
View File
@@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log
3.0 Indev
==================================================================
* Parse NICK.
* Added usrc() to API::IRC for formatting a source.
* Added awarn() to API::Std for warnings.
* Parse Numeric:432.
* Parse Numeric:433.
+17 -1
View File
@@ -9,7 +9,7 @@ use warnings;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(cjoin cpart cmode privmsg notice quit nick);
our @EXPORT_OK = qw(cjoin cpart cmode privmsg notice quit nick usrc);
# Join a channel.
@@ -91,3 +91,19 @@ sub quit
delete $Parser::IRC::botnick{$svr} if (defined $Parser::IRC::botnick{$svr});
}
# Get nick, ident and host from a <nick>!<ident>@<host>
sub usrc
{
my ($ex) = @_;
my @si = split('!', $ex);
my @sii = split('@', $si[1]);
return (
nick => $si[0],
ident => $si[1],
host => $sii[1]
);
}
+25 -9
View File
@@ -6,14 +6,15 @@
package Parser::IRC;
use strict;
use warnings;
use API::Std qw(conf_get err);
use API::IRC qw(cjoin nick quit);
use API::Std qw(conf_get err awarn);
use API::IRC;
# Raw parsing hash.
our %RAWC = (
'001' => \&num001,
'432' => \&num432,
'433' => \&num433,
'001' => \&num001,
'432' => \&num432,
'433' => \&num433,
'NICK' => \&nick,
);
# Variables for various functions.
@@ -63,11 +64,11 @@ sub num001
# For single-line ajoins.
my @sajoin = split(',', $cajoin[0]);
cjoin($svr, $_) foreach (@sajoin);
API::IRC::cjoin($svr, $_) foreach (@sajoin);
}
else {
# For multi-line ajoins.
cjoin($svr, $_) foreach (@cajoin);
API::IRC::cjoin($svr, $_) foreach (@cajoin);
}
}
@@ -82,7 +83,7 @@ sub num432
}
else {
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
quit($svr, "An error occurred.");
API::IRC::quit($svr, "An error occurred.");
}
}
@@ -93,8 +94,23 @@ sub num433
my ($svr, undef) = @_;
if (defined $botnick{$svr}) {
nick($svr, $botnick{$svr}."_");
API::IRC::nick($svr, $botnick{$svr}."_");
}
}
# Parse: NICK
sub nick
{
my ($svr, @ex) = @_;
my %src = API::IRC::usrc(substr($ex[0], 1));
# Check if this is coming from ourselves, meaning a forced nick change.
if ($src{nick} eq $botnick{$svr}) {
# It is a forced nick change.
awarn(3, "Incoming NICK from myself?");
$botnick{$svr} = $ex[2];
}
}
1;