* Parse the data.
* Parse PING and Numeric:001.
This commit is contained in:
1 parent
cff3b8662d
commit
3573c7339b
3 files changed
+65
No files matched your search
@@ -114,6 +114,9 @@ foreach my $cskey (keys %cservers) {
|
||||
chomp $data;
|
||||
# Debug.
|
||||
dbug "$cskey -> You: $data";
|
||||
|
||||
# Parse data.
|
||||
Parser::IRC::_parse($cskey, $data);
|
||||
}
|
||||
}) or err(2, "Failed to create process for ".$cskey, 0) and next;
|
||||
# Success!
|
||||
|
||||
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
||||
|
||||
3.0 Indev
|
||||
==================================================================
|
||||
* Parse PING and Numeric:001.
|
||||
* Begin on the IRC parser.
|
||||
* Added sockets, support for multiple asynchronous sockets.
|
||||
* Bug fix: conf_get() now returns correct data by checking
|
||||
|
||||
@@ -6,5 +6,66 @@
|
||||
package Parser::IRC;
|
||||
use strict;
|
||||
use warnings;
|
||||
use API::Std qw(conf_get);
|
||||
use Data::Dumper;
|
||||
|
||||
|
||||
# Raw parsing hash.
|
||||
our %RAWC = (
|
||||
'001' => \&num001,
|
||||
);
|
||||
|
||||
# Parse raw data.
|
||||
sub _parse
|
||||
{
|
||||
my ($svr, $data) = @_;
|
||||
|
||||
# Split spaces into @ex.
|
||||
my @ex = split(' ', $data);
|
||||
|
||||
# Make sure there is enough data.
|
||||
if (defined $ex[0] and defined $ex[1]) {
|
||||
# If it's a ping...
|
||||
if ($ex[0] eq 'PING') {
|
||||
# send a PONG.
|
||||
Auto::socksnd($svr, "PONG ".$ex[1]);
|
||||
}
|
||||
else {
|
||||
# otherwise, check %RAWC for ex[1].
|
||||
if (defined $RAWC{$ex[1]}) {
|
||||
&{ $RAWC{$ex[1]} }($svr, @ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
###########################
|
||||
# Raw parsing subroutines #
|
||||
###########################
|
||||
|
||||
# Parse: Numeric:001
|
||||
sub num001
|
||||
{
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
# Get the auto-join from the config.
|
||||
my @cajoin = @{ (conf_get("server:$svr:ajoin"))[0] };
|
||||
|
||||
# Join the channels.
|
||||
unless (defined $cajoin[1]) {
|
||||
# For single-line ajoins.
|
||||
my @sajoin = split(',', $cajoin[0]);
|
||||
|
||||
foreach my $sjoin (@sajoin) {
|
||||
Auto::socksnd($svr, "JOIN $sjoin");
|
||||
}
|
||||
}
|
||||
else {
|
||||
# For multi-line ajoins.
|
||||
foreach my $sjoin (@cajoin) {
|
||||
Auto::socksnd($svr, "JOIN $sjoin");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in new issue
Block a user