Revert "Getting rid of tabs."

This reverts commit cc1c8fd5bc.
Failed.
This commit is contained in:
Elijah Perrault committed 2011-02-20 20:47:09 -07:00
1 parent cc1c8fd5bc
commit 92c9a64793
20 files changed
+1277 -1279

No files matched your search

+152 -152
View File
@@ -12,18 +12,18 @@ sub new
my ($file) = @_;
my $self = bless {}, $class;
ssss# Check to see if the configuration file exists.
ssssif (!-e "$Auto::Bin/../etc/$file") {
ssss return 0;
ssss}
ssss
ssss# Open, read and close the config.
ssssopen(my $FCONF, q{<}, "$Auto::Bin/../etc/$file") or return 0;
ssssmy @cosfl = <$FCONF> or return 0;
ssssclose $FCONF or return 0;
ssss
ssss# Save it to self variable.
ssss$self->{'config'}->{'path'} = "$Auto::Bin/../etc/$file";
# Check to see if the configuration file exists.
if (!-e "$Auto::Bin/../etc/$file") {
return 0;
}
# Open, read and close the config.
open(my $FCONF, q{<}, "$Auto::Bin/../etc/$file") or return 0;
my @cosfl = <$FCONF> or return 0;
close $FCONF or return 0;
# Save it to self variable.
$self->{'config'}->{'path'} = "$Auto::Bin/../etc/$file";
return $self;
}
@@ -31,148 +31,148 @@ ssss$self->{'config'}->{'path'} = "$Auto::Bin/../etc/$file";
# Parse the configuration file.
sub parse
{
ssss# Get the path to the file.
ssssmy $self = shift;
ssssmy $file = $self->{'config'}->{'path'};
ssssmy $blk = 0;
ssssmy (%rs);
ssss
ssss# Open, read and close it.
ssssopen(my $FCONF, q{<}, "$file") or return 0;
ssssmy @fbuf = <$FCONF> or return 0;
ssssclose $FCONF or return 0;
ssss
ssss# Iterate the file.
ssssforeach my $buff (@fbuf) {
ssss # Main newline buffer.
ssss if (defined $buff) {
ssss # If the line begins with a #, it's a comment so ignore it.
ssss if (substr($buff, 0, 1) eq '#') {
ssss next;
ssss }
ssss
ssss if ($buff =~ m/;/) {
ssss # Semicolon buffer.
ssss my @asbuf = split(';', $buff);
ssss foreach my $asbuff (@asbuf) {
ssss if (defined $asbuff) {
ssss
ssss # Space buffer.
ssss my @ebuf = split(' ', $asbuff);
ssss if (!defined $ebuf[0] or !defined $ebuf[1]) {
ssss # Garbage. Ignoring.
ssss next;
ssss }
ssss my $param = $ebuf[1];
ssss
ssss if (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) ne '"') {
ssss # Multi-word string.
ssss $param = substr($param, 1);
ssss
ssss for (my $i = 2; $i < scalar(@ebuf); $i++) {
ssss if (substr($ebuf[$i], length($ebuf[$i]) - 1, 1) eq '"') {
ssss $param .= " ".substr($ebuf[$i], 0, length($ebuf[$i]) - 1);
ssss last;
ssss }
ssss else {
ssss $param .= " ".$ebuf[$i];
ssss }
ssss }
ssss }
ssss elsif (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) eq '"') {
ssss # Single-word string.
ssss $param = substr($param, 1, length($ebuf[1]) - 2);
ssss }
ssss elsif ($param =~ m/[0-9]/) {
ssss # Numeric.
ssss $param =~ s/[^0-9.]//g;
ssss }
ssss else {
ssss # Garbage.
ssss next;
ssss }
ssss
ssss my @param = ($param);
ssss
ssss unless (!$blk) {
ssss # We're inside a block.
ssss if ($blk =~ m/@@@/) {
ssss # We're inside a block with a parameter.
ssss my @sblk = split('@@@', $blk);
ssss
ssss # Check to see if this config option already exists.
ssss if (defined $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]}) {
ssss # It does, so merely push this second one to the existing array.
ssss push(@{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} }, $param);
ssss }
ssss else {
ssss # It doesn't, create it as an array.
ssss @{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} } = @param;
ssss }
ssss }
ssss else {
ssss # We're inside a block with no parameter.
ssss
ssss # Check to see if this config option already exists.
ssss if (defined $rs{$blk}{$ebuf[0]}) {
ssss # It does, so merely push this second one to the existing array.
# Get the path to the file.
my $self = shift;
my $file = $self->{'config'}->{'path'};
my $blk = 0;
my (%rs);
# Open, read and close it.
open(my $FCONF, q{<}, "$file") or return 0;
my @fbuf = <$FCONF> or return 0;
close $FCONF or return 0;
# Iterate the file.
foreach my $buff (@fbuf) {
# Main newline buffer.
if (defined $buff) {
# If the line begins with a #, it's a comment so ignore it.
if (substr($buff, 0, 1) eq '#') {
next;
}
if ($buff =~ m/;/) {
# Semicolon buffer.
my @asbuf = split(';', $buff);
foreach my $asbuff (@asbuf) {
if (defined $asbuff) {
# Space buffer.
my @ebuf = split(' ', $asbuff);
if (!defined $ebuf[0] or !defined $ebuf[1]) {
# Garbage. Ignoring.
next;
}
my $param = $ebuf[1];
if (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) ne '"') {
# Multi-word string.
$param = substr($param, 1);
for (my $i = 2; $i < scalar(@ebuf); $i++) {
if (substr($ebuf[$i], length($ebuf[$i]) - 1, 1) eq '"') {
$param .= " ".substr($ebuf[$i], 0, length($ebuf[$i]) - 1);
last;
}
else {
$param .= " ".$ebuf[$i];
}
}
}
elsif (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) eq '"') {
# Single-word string.
$param = substr($param, 1, length($ebuf[1]) - 2);
}
elsif ($param =~ m/[0-9]/) {
# Numeric.
$param =~ s/[^0-9.]//g;
}
else {
# Garbage.
next;
}
my @param = ($param);
unless (!$blk) {
# We're inside a block.
if ($blk =~ m/@@@/) {
# We're inside a block with a parameter.
my @sblk = split('@@@', $blk);
# Check to see if this config option already exists.
if (defined $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]}) {
# It does, so merely push this second one to the existing array.
push(@{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} }, $param);
}
else {
# It doesn't, create it as an array.
@{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} } = @param;
}
}
else {
# We're inside a block with no parameter.
# Check to see if this config option already exists.
if (defined $rs{$blk}{$ebuf[0]}) {
# It does, so merely push this second one to the existing array.
push(@{ $rs{$blk}{$ebuf[0]} }, $param);
ssss }
ssss else {
ssss # It doesn't, create it as an array.
ssss @{ $rs{$blk}{$ebuf[0]} } = @param;
ssss }
ssss }
ssss }
ssss else {
ssss # We're not inside a block.
ssss
ssss # Check to see if this config option already exists.
ssss if (defined $rs{$ebuf[0]}) {
ssss # It does, so merely push this second one to the existing array.
ssss push(@{ $rs{$ebuf[0]} }, $param);
ssss }
ssss else {
ssss # It doesn't, create it as an array.
ssss @{ $rs{$ebuf[0]} } = @param;
ssss }
ssss }
ssss }
ssss }
ssss }
ssss else {
ssss # No semicolon space buffer.
ssss my @ebuf = split(' ', $buff);
ssss
ssss if (!defined $ebuf[0]) {
ssss # Garbage. Ignoring.
ssss next;
ssss }
ssss
ssss if (defined $ebuf[1]) {
ssss if ($ebuf[1] eq '{') {
ssss # This is the beginning of a block with no parameter.
}
else {
# It doesn't, create it as an array.
@{ $rs{$blk}{$ebuf[0]} } = @param;
}
}
}
else {
# We're not inside a block.
# Check to see if this config option already exists.
if (defined $rs{$ebuf[0]}) {
# It does, so merely push this second one to the existing array.
push(@{ $rs{$ebuf[0]} }, $param);
}
else {
# It doesn't, create it as an array.
@{ $rs{$ebuf[0]} } = @param;
}
}
}
}
}
else {
# No semicolon space buffer.
my @ebuf = split(' ', $buff);
if (!defined $ebuf[0]) {
# Garbage. Ignoring.
next;
}
if (defined $ebuf[1]) {
if ($ebuf[1] eq '{') {
# This is the beginning of a block with no parameter.
$blk = $ebuf[0];
ssss }
ssss elsif (defined $ebuf[2]) {
ssss if ($ebuf[2] eq '{') {
ssss # This is the beginning of a block with a parameter.
ssss my $param = $ebuf[1];
ssss $param =~ s/"//g;
ssss $blk = $ebuf[0].'@@@'.$param;
ssss }
ssss }
ssss }
ssss if ($ebuf[0] eq '}') {
ssss # This is the end of a block.
ssss $blk = 0;
ssss }
ssss }
ssss }
ssss}
ssss
ssss# Return the configuration data.
ssssreturn %rs;
}
elsif (defined $ebuf[2]) {
if ($ebuf[2] eq '{') {
# This is the beginning of a block with a parameter.
my $param = $ebuf[1];
$param =~ s/"//g;
$blk = $ebuf[0].'@@@'.$param;
}
}
}
if ($ebuf[0] eq '}') {
# This is the end of a block.
$blk = 0;
}
}
}
}
# Return the configuration data.
return %rs;
}
+250 -250
View File
@@ -9,26 +9,26 @@ use API::IRC;
# Raw parsing hash.
our %RAWC = (
ssss'001' => \&num001,
ssss'005' => \&num005,
ssss'353' => \&num353,
ssss'432' => \&num432,
ssss'433' => \&num433,
ssss'438' => \&num438,
ssss'465' => \&num465,
ssss'471' => \&num471,
ssss'473' => \&num473,
ssss'474' => \&num474,
ssss'475' => \&num475,
ssss'477' => \&num477,
ssss'JOIN' => \&cjoin,
'001' => \&num001,
'005' => \&num005,
'353' => \&num353,
'432' => \&num432,
'433' => \&num433,
'438' => \&num438,
'465' => \&num465,
'471' => \&num471,
'473' => \&num473,
'474' => \&num474,
'475' => \&num475,
'477' => \&num477,
'JOIN' => \&cjoin,
'KICK' => \&kick,
'MODE' => \&mode,
ssss'NICK' => \&nick,
ssss'NOTICE' => \&notice,
'NICK' => \&nick,
'NOTICE' => \&notice,
'PART' => \&part,
ssss'PRIVMSG' => \&privmsg,
ssss'QUIT' => \&quit,
'PRIVMSG' => \&privmsg,
'QUIT' => \&quit,
'TOPIC' => \&topic,
);
@@ -50,33 +50,33 @@ API::Std::event_add("on_topic");
# Parse raw data.
sub ircparse
{
ssssmy ($svr, $data) = @_;
ssss
ssss# Split spaces into @ex.
ssssmy @ex = split /\s+/, $data;
my ($svr, $data) = @_;
# Split spaces into @ex.
my @ex = split /\s+/, $data;
ssss# Make sure there is enough data.
ssssif (defined $ex[0] and defined $ex[1]) {
ssss # If it's a ping...
ssss if ($ex[0] eq 'PING') {
ssss # send a PONG.
ssss Auto::socksnd($svr, "PONG ".$ex[1]);
ssss }
ssss # If it's AUTHENTICATE
ssss elsif ($ex[0] eq 'AUTHENTICATE') {
ssss if (API::Std::mod_exists("SASLAuth")) {
# 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]);
}
# If it's AUTHENTICATE
elsif ($ex[0] eq 'AUTHENTICATE') {
if (API::Std::mod_exists("SASLAuth")) {
M::SASLAuth::handle_authenticate($svr, @ex);
ssss }
ssss }
ssss else {
ssss # otherwise, check %RAWC for ex[1].
ssss if (defined $RAWC{$ex[1]}) {
ssss &{ $RAWC{$ex[1]} }($svr, @ex);
ssss }
ssss }
ssss}
ssss
ssssreturn 1;
}
}
else {
# otherwise, check %RAWC for ex[1].
if (defined $RAWC{$ex[1]}) {
&{ $RAWC{$ex[1]} }($svr, @ex);
}
}
}
return 1;
}
###########################
@@ -87,41 +87,41 @@ ssssreturn 1;
# Successful connection.
sub num001
{
ssssmy ($svr, @ex) = @_;
ssss
ssss$got_001{$svr} = 1;
ssss
ssss# In case we don't get NICK from the server.
ssssif (defined $botnick{$svr}{newnick}) {
ssss $botnick{$svr}{nick} = $botnick{$svr}{newnick};
ssss delete $botnick{$svr}{newnick};
ssss}
my ($svr, @ex) = @_;
$got_001{$svr} = 1;
# In case we don't get NICK from the server.
if (defined $botnick{$svr}{newnick}) {
$botnick{$svr}{nick} = $botnick{$svr}{newnick};
delete $botnick{$svr}{newnick};
}
# Trigger on_connect.
API::Std::event_run("on_connect", $svr);
ssss
ssssreturn 1;
return 1;
}
# Parse: Numeric:005
# Prefixes and channel modes.
sub num005
{
ssssmy ($svr, @ex) = @_;
ssss
ssss# Find PREFIX and CHANMODES.
ssssforeach my $ex (@ex) {
ssss if ($ex =~ m/^PREFIX/xsm) {
ssss # Found PREFIX.
ssss my $rpx = substr($ex, 8);
ssss my ($pm, $pp) = split('\)', $rpx);
ssss my @apm = split(//, $pm);
ssss my @app = split(//, $pp);
ssss foreach my $ppm (@apm) {
ssss # Store data.
ssss $csprefix{$svr}{$ppm} = shift(@app);
ssss }
ssss }
my ($svr, @ex) = @_;
# Find PREFIX and CHANMODES.
foreach my $ex (@ex) {
if ($ex =~ m/^PREFIX/xsm) {
# Found PREFIX.
my $rpx = substr($ex, 8);
my ($pm, $pp) = split('\)', $rpx);
my @apm = split(//, $pm);
my @app = split(//, $pp);
foreach my $ppm (@apm) {
# Store data.
$csprefix{$svr}{$ppm} = shift(@app);
}
}
elsif ($ex =~ m/^CHANMODES/xsm) {
# Found CHANMODES.
my ($mtl, $mtp, $mtpp, $mts) = split m/[,]/xsm, substr($ex, 10);
@@ -134,186 +134,186 @@ ssss }
# Modes without parameter.
foreach (split(//, $mts)) { $chanmodes{$svr}{$_} = 4; }
}
ssss}
ssss
ssssreturn 1;
}
return 1;
}
# Parse: Numeric:353
# NAMES reply.
sub num353
{
ssssmy ($svr, @ex) = @_;
ssss
ssss# Get rid of the colon.
ssss$ex[5] = substr($ex[5], 1);
ssss# Delete the old chanusers hash if it exists.
ssssdelete $chanusers{$svr}{$ex[4]} if (defined $chanusers{$svr}{$ex[4]});
ssss# Iterate through each user.
ssssfor (my $i = 5; $i < scalar(@ex); $i++) {
ssss my $fi = 0;
ssss foreach (keys %{ $csprefix{$svr} }) {
ssss # Check if the user has status in the channel.
ssss if (substr($ex[$i], 0, 1) eq $csprefix{$svr}{$_}) {
ssss # He/she does. Lets set that.
ssss if (defined $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))}) {
ssss # If the user has multiple statuses.
ssss $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} .= $_;
ssss }
ssss else {
ssss # Or not.
ssss $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} = $_;
ssss }
ssss $fi = 1;
ssss }
ssss }
ssss # They had status, so go to the next user.
ssss next if $fi;
ssss # They didn't, set them as a normal user.
ssss if (!defined $chanusers{$svr}{$ex[4]}{lc($ex[$i])}) {
ssss $chanusers{$svr}{$ex[4]}{lc($ex[$i])} = 1;
ssss }
ssss}
ssss
ssssreturn 1;
my ($svr, @ex) = @_;
# Get rid of the colon.
$ex[5] = substr($ex[5], 1);
# Delete the old chanusers hash if it exists.
delete $chanusers{$svr}{$ex[4]} if (defined $chanusers{$svr}{$ex[4]});
# Iterate through each user.
for (my $i = 5; $i < scalar(@ex); $i++) {
my $fi = 0;
foreach (keys %{ $csprefix{$svr} }) {
# Check if the user has status in the channel.
if (substr($ex[$i], 0, 1) eq $csprefix{$svr}{$_}) {
# He/she does. Lets set that.
if (defined $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))}) {
# If the user has multiple statuses.
$chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} .= $_;
}
else {
# Or not.
$chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} = $_;
}
$fi = 1;
}
}
# They had status, so go to the next user.
next if $fi;
# They didn't, set them as a normal user.
if (!defined $chanusers{$svr}{$ex[4]}{lc($ex[$i])}) {
$chanusers{$svr}{$ex[4]}{lc($ex[$i])} = 1;
}
}
return 1;
}
# Parse: Numeric:432
# Erroneous nickname.
sub num432
{
ssssmy ($svr, undef) = @_;
ssss
ssssif ($got_001{$svr}) {
ssss err(3, "Got error from server[".$svr."]: Erroneous nickname.", 0);
ssss}
sssselse {
ssss err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
ssss API::IRC::quit($svr, "An error occurred.");
ssss}
ssss
ssssdelete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
ssss
ssssreturn 1;
my ($svr, undef) = @_;
if ($got_001{$svr}) {
err(3, "Got error from server[".$svr."]: Erroneous nickname.", 0);
}
else {
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
API::IRC::quit($svr, "An error occurred.");
}
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
return 1;
}
# Parse: Numeric:433
# Nickname is already in use.
sub num433
{
ssssmy ($svr, undef) = @_;
ssss
ssssif (defined $botnick{$svr}{newnick}) {
ssss API::IRC::nick($svr, $botnick{$svr}{newnick}."_");
ssss delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
ssss}
ssss
ssssreturn 1;
my ($svr, undef) = @_;
if (defined $botnick{$svr}{newnick}) {
API::IRC::nick($svr, $botnick{$svr}{newnick}."_");
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
}
return 1;
}
# Parse: Numeric:438
# Nick change too fast.
sub num438
{
ssssmy ($svr, @ex) = @_;
ssss
ssssif (defined $botnick{$svr}{newnick}) {
ssss API::Std::timer_add("num438_".$botnick{$svr}{newnick}, 1, $ex[11], sub {
ssss API::IRC::nick($Parser::IRC::botnick{$svr}{newnick});
ssss delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
ssss });
ssss}
ssss
ssssreturn 1;
my ($svr, @ex) = @_;
if (defined $botnick{$svr}{newnick}) {
API::Std::timer_add("num438_".$botnick{$svr}{newnick}, 1, $ex[11], sub {
API::IRC::nick($Parser::IRC::botnick{$svr}{newnick});
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
});
}
return 1;
}
# Parse: Numeric:465
# You're banned creep!
sub num465
{
ssssmy ($svr, undef) = @_;
ssss
sssserr(3, "Banned from ".$svr."! Closing link...", 0);
ssss
ssssreturn 1;
my ($svr, undef) = @_;
err(3, "Banned from ".$svr."! Closing link...", 0);
return 1;
}
# Parse: Numeric:471
# Cannot join channel: Channel is full.
sub num471
{
ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Channel is full.", 0);
ssss
ssssreturn 1;
my ($svr, (undef, undef, undef, $chan)) = @_;
err(3, "Cannot join channel ".$chan." on ".$svr.": Channel is full.", 0);
return 1;
}
# Parse: Numeric:473
# Cannot join channel: Channel is invite-only.
sub num473
{
ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Channel is invite-only.", 0);
ssss
ssssreturn 1;
my ($svr, (undef, undef, undef, $chan)) = @_;
err(3, "Cannot join channel ".$chan." on ".$svr.": Channel is invite-only.", 0);
return 1;
}
# Parse: Numeric:474
# Cannot join channel: Banned from channel.
sub num474
{
ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Banned from channel.", 0);
ssss
ssssreturn 1;
my ($svr, (undef, undef, undef, $chan)) = @_;
err(3, "Cannot join channel ".$chan." on ".$svr.": Banned from channel.", 0);
return 1;
}
# Parse: Numeric:475
# Cannot join channel: Bad key.
sub num475
{
ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Bad key.", 0);
ssss
ssssreturn 1;
my ($svr, (undef, undef, undef, $chan)) = @_;
err(3, "Cannot join channel ".$chan." on ".$svr.": Bad key.", 0);
return 1;
}
# Parse: Numeric:477
# Cannot join channel: Need registered nickname.
sub num477
{
ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Need registered nickname.", 0);
ssss
ssssreturn 1;
my ($svr, (undef, undef, undef, $chan)) = @_;
err(3, "Cannot join channel ".$chan." on ".$svr.": Need registered nickname.", 0);
return 1;
}
# Parse: JOIN
sub cjoin
{
ssssmy ($svr, @ex) = @_;
ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
my ($svr, @ex) = @_;
my %src = API::IRC::usrc(substr($ex[0], 1));
my $chan = $ex[2];
$chan =~ s/^://gxsm;
ssss
ssss# Check if this is coming from ourselves.
ssssif ($src{nick} eq $botnick{$svr}{nick}) {
ssss $botchans{$svr}{lc $chan} = 1;
ssss API::Std::event_run("on_ucjoin", ($svr, $chan));
ssss}
sssselse {
ssss # It isn't. Update chanusers and trigger on_rcjoin.
# Check if this is coming from ourselves.
if ($src{nick} eq $botnick{$svr}{nick}) {
$botchans{$svr}{lc $chan} = 1;
API::Std::event_run("on_ucjoin", ($svr, $chan));
}
else {
# It isn't. Update chanusers and trigger on_rcjoin.
$chanusers{$svr}{lc $chan}{$src{nick}} = 1;
$src{svr} = $svr;
ssss API::Std::event_run("on_rcjoin", (\%src, $chan));
ssss}
ssss
ssssreturn 1;
API::Std::event_run("on_rcjoin", (\%src, $chan));
}
return 1;
}
# Parse: KICK
@@ -454,35 +454,35 @@ sub mode
# Parse: NICK
sub nick
{
ssssmy ($svr, ($uex, undef, $nex)) = @_;
my ($svr, ($uex, undef, $nex)) = @_;
$nex = substr($nex, 1);
ssssmy %src = API::IRC::usrc(substr($uex, 1));
ssss
ssss# Check if this is coming from ourselves.
ssssif ($src{nick} eq $botnick{$svr}{nick}) {
ssss # It is. Update bot nick hash.
ssss $botnick{$svr}{nick} = $nex;
ssss delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
ssss}
sssselse {
ssss # It isn't. Update chanusers and trigger on_nick.
my %src = API::IRC::usrc(substr($uex, 1));
# Check if this is coming from ourselves.
if ($src{nick} eq $botnick{$svr}{nick}) {
# It is. Update bot nick hash.
$botnick{$svr}{nick} = $nex;
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
}
else {
# It isn't. Update chanusers and trigger on_nick.
foreach my $chk (keys %{ $chanusers{$svr} }) {
if (defined $chanusers{$svr}{$chk}{$src{nick}}) {
$chanusers{$svr}{$chk}{$nex} = $chanusers{$svr}{$chk}{$src{nick}};
delete $chanusers{$svr}{$chk}{$src{nick}};
}
}
ssss API::Std::event_run("on_nick", ($svr, \%src, $nex));
ssss}
ssss
ssssreturn 1;
API::Std::event_run("on_nick", ($svr, \%src, $nex));
}
return 1;
}
# Parse: NOTICE
sub notice
{
ssssmy ($svr, @ex) = @_;
my ($svr, @ex) = @_;
# Ensure this is coming from a user rather than a server.
if ($ex[0] !~ m/!/xsm) { return; }
@@ -493,11 +493,11 @@ ssssmy ($svr, @ex) = @_;
shift @ex; shift @ex; shift @ex;
$ex[0] = substr $ex[0], 1;
$src{svr} = $svr;
ssss
# Send it off.
ssssAPI::Std::event_run("on_notice", (\%src, $target, @ex));
ssss
ssssreturn 1;
API::Std::event_run("on_notice", (\%src, $target, @ex));
return 1;
}
# Parse: PART
@@ -529,33 +529,33 @@ sub part
# Parse: PRIVMSG
sub privmsg
{
ssssmy ($svr, @ex) = @_;
my ($svr, @ex) = @_;
my %data = API::IRC::usrc(substr($ex[0], 1));
# Ensure this is coming from a user rather than a server.
if ($ex[0] !~ m/!/xsm) { return; }
my @argv;
ssssfor (my $i = 4; $i < scalar(@ex); $i++) {
ssss push(@argv, $ex[$i]);
ssss}
ssss$data{svr} = $svr;
ssss
ssssmy ($cmd, $cprefix, $rprefix);
ssss# Check if it's to a channel or to us.
ssssif (lc($ex[2]) eq lc($botnick{$svr}{nick})) {
ssss # It is coming to us in a private message.
for (my $i = 4; $i < scalar(@ex); $i++) {
push(@argv, $ex[$i]);
}
$data{svr} = $svr;
my ($cmd, $cprefix, $rprefix);
# Check if it's to a channel or to us.
if (lc($ex[2]) eq lc($botnick{$svr}{nick})) {
# It is coming to us in a private message.
# Ensure it's a valid length.
if (length($ex[3]) > 1) {
ssss $cmd = uc(substr($ex[3], 1));
ssss if (defined $API::Std::CMDS{$cmd}) {
$cmd = uc(substr($ex[3], 1));
if (defined $API::Std::CMDS{$cmd}) {
# If this is indeed a command, continue.
ssss if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) {
if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) {
# Ensure the level is private or all.
if (API::Std::ratelimit_check(%data)) {
# Continue if the user has not passed the ratelimit amount.
ssss if ($API::Std::CMDS{$cmd}{priv}) {
if ($API::Std::CMDS{$cmd}{priv}) {
# If this command requires a privilege...
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
# Make sure they have it.
@@ -575,26 +575,26 @@ ssss if ($API::Std::CMDS{$cmd}{priv}) {
# Send them a notice about their bad deed.
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
}
ssss }
ssss }
}
}
}
ssss # Trigger event on_uprivmsg.
# Trigger event on_uprivmsg.
shift @ex; shift @ex; shift @ex;
$ex[0] = substr $ex[0], 1;
ssss API::Std::event_run("on_uprivmsg", (\%data, @ex));
ssss}
sssselse {
ssss # It is coming to us in a channel message.
ssss $data{chan} = $ex[2];
API::Std::event_run("on_uprivmsg", (\%data, @ex));
}
else {
# It is coming to us in a channel message.
$data{chan} = $ex[2];
# Ensure it's a valid length before continuing.
ssss if (length($ex[3]) > 1) {
if (length($ex[3]) > 1) {
$cprefix = (conf_get("fantasy_pf"))[0][0];
ssss $rprefix = substr($ex[3], 1, 1);
ssss $cmd = uc(substr($ex[3], 2));
ssss if (defined $API::Std::CMDS{$cmd} and $rprefix eq $cprefix) {
$rprefix = substr($ex[3], 1, 1);
$cmd = uc(substr($ex[3], 2));
if (defined $API::Std::CMDS{$cmd} and $rprefix eq $cprefix) {
# If this is indeed a command, continue.
ssss if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) {
if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) {
# Ensure the level is public or all.
if (API::Std::ratelimit_check(%data)) {
# Continue if the user has not passed the ratelimit amount.
@@ -641,24 +641,24 @@ ssss if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2
}
}
}
ssss }
}
}
ssss # Trigger event on_cprivmsg.
# Trigger event on_cprivmsg.
my $target = $ex[2]; delete $data{chan};
shift @ex; shift @ex; shift @ex;
$ex[0] = substr $ex[0], 1;
ssss API::Std::event_run("on_cprivmsg", (\%data, $target, @ex));
ssss}
ssss
ssssreturn 1;
API::Std::event_run("on_cprivmsg", (\%data, $target, @ex));
}
return 1;
}
# Parse: QUIT
sub quit
{
my ($svr, @ex) = @_;
ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
my %src = API::IRC::usrc(substr($ex[0], 1));
# Set $msg to the quit message.
my $msg = 0;
@@ -680,23 +680,23 @@ ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
# Parse: TOPIC
sub topic
{
ssssmy ($svr, @ex) = @_;
ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
ssss
ssss# Ignore it if it's coming from us.
ssssif (lc($src{nick}) ne lc($botnick{$svr}{nick})) {
ssss $src{chan} = $ex[2];
ssss my (@argv);
ssss $argv[0] = substr($ex[3], 1);
ssss if (defined $ex[4]) {
ssss for (my $i = 4; $i < scalar(@ex); $i++) {
ssss push(@argv, $ex[$i]);
ssss }
ssss }
ssss API::Std::event_run("on_topic", ($svr, \%src, @argv));
ssss}
ssss
ssssreturn 1;
my ($svr, @ex) = @_;
my %src = API::IRC::usrc(substr($ex[0], 1));
# Ignore it if it's coming from us.
if (lc($src{nick}) ne lc($botnick{$svr}{nick})) {
$src{chan} = $ex[2];
my (@argv);
$argv[0] = substr($ex[3], 1);
if (defined $ex[4]) {
for (my $i = 4; $i < scalar(@ex); $i++) {
push(@argv, $ex[$i]);
}
}
API::Std::event_run("on_topic", ($svr, \%src, @argv));
}
return 1;
}
+50 -50
View File
@@ -10,56 +10,56 @@ use API::Log qw(dbug alog);
# Parser.
sub parse
{
ssssmy ($lang) = @_;
ssss
ssss# Check that the language file exists.
ssssunless (-e "$Auto::Bin/../lang/$lang.alf") {
ssss # Otherwise, use English.
ssss dbug "Language '$lang' not found. Using English.";
ssss alog "Language '$lang' not found. Using English.";
ssss $lang = "en";
ssss}
ssss
ssss# Open, read and close the file.
ssssopen(my $FALF, q{<}, "$Auto::Bin/../lang/$lang.alf") or return 0;
ssssmy @fbuf = <$FALF>;
ssssclose $FALF;
ssss
ssss# Iterate the file buffer.
ssssforeach my $buff (@fbuf) {
ssss if (defined $buff) {
ssss # Space buffer.
ssss my @sbuf = split(' ', $buff);
ssss
ssss # Check for all required values.
ssss if (!defined $sbuf[0] or !defined $sbuf[1] or !defined $sbuf[2]) {
ssss # Missing a value.
ssss next;
ssss }
ssss
ssss # Make sure the first value is "msge".
ssss if ($sbuf[0] ne "msge") {
ssss # It isn't.
ssss next;
ssss }
ssss
ssss my $id = $sbuf[1];
ssss my $val = $sbuf[2];
ssss
ssss # If the translation is multi-word, continue to parse.
ssss if (defined $sbuf[3]) {
ssss for (my $i = 3; $i < scalar(@sbuf); $i++) {
ssss $val .= " ".$sbuf[$i];
ssss }
ssss }
ssss
ssss # Save to memory.
ssss $id =~ s/"//g;
ssss $val =~ s/"//g;
ssss $API::Std::LANGE{$id} = $val;
ssss }
ssss}
ssssreturn 1;
my ($lang) = @_;
# Check that the language file exists.
unless (-e "$Auto::Bin/../lang/$lang.alf") {
# Otherwise, use English.
dbug "Language '$lang' not found. Using English.";
alog "Language '$lang' not found. Using English.";
$lang = "en";
}
# Open, read and close the file.
open(my $FALF, q{<}, "$Auto::Bin/../lang/$lang.alf") or return 0;
my @fbuf = <$FALF>;
close $FALF;
# Iterate the file buffer.
foreach my $buff (@fbuf) {
if (defined $buff) {
# Space buffer.
my @sbuf = split(' ', $buff);
# Check for all required values.
if (!defined $sbuf[0] or !defined $sbuf[1] or !defined $sbuf[2]) {
# Missing a value.
next;
}
# Make sure the first value is "msge".
if ($sbuf[0] ne "msge") {
# It isn't.
next;
}
my $id = $sbuf[1];
my $val = $sbuf[2];
# If the translation is multi-word, continue to parse.
if (defined $sbuf[3]) {
for (my $i = 3; $i < scalar(@sbuf); $i++) {
$val .= " ".$sbuf[$i];
}
}
# Save to memory.
$id =~ s/"//g;
$val =~ s/"//g;
$API::Std::LANGE{$id} = $val;
}
}
return 1;
}