* 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;
|
chomp $data;
|
||||||
# Debug.
|
# Debug.
|
||||||
dbug "$cskey -> You: $data";
|
dbug "$cskey -> You: $data";
|
||||||
|
|
||||||
|
# Parse data.
|
||||||
|
Parser::IRC::_parse($cskey, $data);
|
||||||
}
|
}
|
||||||
}) or err(2, "Failed to create process for ".$cskey, 0) and next;
|
}) or err(2, "Failed to create process for ".$cskey, 0) and next;
|
||||||
# Success!
|
# Success!
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Parse PING and Numeric:001.
|
||||||
* Begin on the IRC parser.
|
* Begin on the IRC parser.
|
||||||
* Added sockets, support for multiple asynchronous sockets.
|
* Added sockets, support for multiple asynchronous sockets.
|
||||||
* Bug fix: conf_get() now returns correct data by checking
|
* Bug fix: conf_get() now returns correct data by checking
|
||||||
|
|||||||
@@ -6,5 +6,66 @@
|
|||||||
package Parser::IRC;
|
package Parser::IRC;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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