Getting rid of tabs.

This commit is contained in:
Elijah Perrault committed 2011-02-20 20:46:10 -07:00
1 parent ad799a32a2
commit cc1c8fd5bc
20 files changed
+1279 -1277

No files matched your search

+27 -27
View File
@@ -8,46 +8,46 @@ PID=bin/auto.pid
MODS="Class::Unload DBI" MODS="Class::Unload DBI"
if [ "$1" = "start" ] ; then if [ "$1" = "start" ] ; then
if [ -e $PID ]; then ssssif [ -e $PID ]; then
if [ "$2" = "force" ]; then ssss if [ "$2" = "force" ]; then
echo "Starting Auto. . ." ssss echo "Starting Auto. . ."
bin/auto ssss bin/auto
sleep 2 ssss sleep 2
if [ ! -r $PID ]; then ssss if [ ! -r $PID ]; then
echo "Possible failed startup... check Auto logs for more information." ssss echo "Possible failed startup... check Auto logs for more information."
fi ssss fi
else else
echo "Auto appears to be running already. Run ./auto start force to start anyway." echo "Auto appears to be running already. Run ./auto start force to start anyway."
fi fi
else sssselse
echo "Starting Auto. . ." ssss echo "Starting Auto. . ."
bin/auto ssss bin/auto
sleep 2 ssss sleep 2
if [ ! -r $PID ]; then ssss if [ ! -r $PID ]; then
echo "Possible failed startup... check Auto logs for more information" ssss echo "Possible failed startup... check Auto logs for more information"
fi ssss fi
fi ssssfi
elif [ "$1" = "stop" ]; then elif [ "$1" = "stop" ]; then
echo "Stopping Auto. . ." ssssecho "Stopping Auto. . ."
kill -TERM `cat $PID` sssskill -TERM `cat $PID`
elif [ "$1" = "rehash" ]; then elif [ "$1" = "rehash" ]; then
echo "Rehashing Auto. . ." ssssecho "Rehashing Auto. . ."
kill -HUP `cat $PID` sssskill -HUP `cat $PID`
elif [ "$1" = "status" ]; then elif [ "$1" = "status" ]; then
if [ -e $PID ]; then ssssif [ -e $PID ]; then
echo "Status: Auto appears to be running." ssss echo "Status: Auto appears to be running."
else sssselse
echo "Status: Auto appears to not be running." ssss echo "Status: Auto appears to not be running."
fi ssssfi
elif [ "$1" = "getmodules" ]; then elif [ "$1" = "getmodules" ]; then
cpan -i $MODS sssscpan -i $MODS
else else
echo "Usage: auto (start|stop|rehash|status|getmodules)" ssssecho "Usage: auto (start|stop|rehash|status|getmodules)"
fi fi
# vim: set ai sw=4 ts=4: # vim: set ai sw=4 ts=4:
+151 -151
View File
@@ -23,11 +23,11 @@ BEGIN {
# Set version information. # Set version information.
use constant { ## no critic qw(ValuesAndExpressions::ProhibitConstantPragma) use constant { ## no critic qw(ValuesAndExpressions::ProhibitConstantPragma)
NAME => 'Auto IRC Bot', ssss NAME => 'Auto IRC Bot',
VER => 3, ssss VER => 3,
SVER => 0, ssss SVER => 0,
REV => 0, ssss REV => 0,
RSTAGE => 'd', ssss RSTAGE => 'd',
GR => substr `cat $Bin/../.git/refs/heads/indev`, 0, 7 GR => substr `cat $Bin/../.git/refs/heads/indev`, 0, 7
}; };
} }
@@ -46,7 +46,7 @@ local $PROGRAM_NAME = 'auto';
# Check for build files. # Check for build files.
if (!-e "$Bin/../build/os" or !-e "$Bin/../build/perl" or !-e "$Bin/../build/time" or !-e "$Bin/../build/ver") { if (!-e "$Bin/../build/os" or !-e "$Bin/../build/perl" or !-e "$Bin/../build/time" or !-e "$Bin/../build/ver") {
say 'Missing build file(s). Please build Auto before running it.' and exit; sssssay 'Missing build file(s). Please build Auto before running it.' and exit;
} }
# Check build OS. # Check build OS.
@@ -54,7 +54,7 @@ open my $BFOS, '<', "$Bin/../build/os" or say 'Cannot start: Broken build.' and
my @BFOS = <$BFOS>; my @BFOS = <$BFOS>;
close $BFOS or say 'Cannot start: Broken build.' and exit; close $BFOS or say 'Cannot start: Broken build.' and exit;
if ($BFOS[0] ne $OSNAME."\n") { if ($BFOS[0] ne $OSNAME."\n") {
say 'Cannot start: Broken build.' and exit; sssssay 'Cannot start: Broken build.' and exit;
} }
undef @BFOS; undef @BFOS;
@@ -71,7 +71,7 @@ open my $BFPERL, '<', "$Bin/../build/perl" or say 'Cannot start: Broken build.'
my @BFPERL = <$BFPERL>; my @BFPERL = <$BFPERL>;
close $BFPERL or say 'Cannot start: Broken build.' and exit; close $BFPERL or say 'Cannot start: Broken build.' and exit;
if ($BFPERL[0] ne $]."\n") { if ($BFPERL[0] ne $]."\n") {
say 'Cannot start: Broken build.' and exit; sssssay 'Cannot start: Broken build.' and exit;
} }
undef @BFPERL; undef @BFPERL;
@@ -80,7 +80,7 @@ open my $BFVER, '<', "$Bin/../build/ver" or say 'Cannot start: Broken build.' an
my @BFVER = <$BFVER>; my @BFVER = <$BFVER>;
close $BFVER or say 'Cannot start: Broken build.' and exit; close $BFVER or say 'Cannot start: Broken build.' and exit;
if ($BFVER[0] ne VER.q{.}.SVER.q{.}.REV.RSTAGE."\n") { if ($BFVER[0] ne VER.q{.}.SVER.q{.}.REV.RSTAGE."\n") {
say 'Cannot start: Broken build.' and exit; sssssay 'Cannot start: Broken build.' and exit;
} }
undef @BFVER; undef @BFVER;
@@ -112,8 +112,8 @@ our ($APID, %TIMERS);
our $DEBUG = 0; our $DEBUG = 0;
our $NUC = 0; our $NUC = 0;
if (defined $ARGV[0]) { if (defined $ARGV[0]) {
foreach (@ARGV) { ssssforeach (@ARGV) {
given ($_) { ssss given ($_) {
when ('-d') { $DEBUG = 1; } when ('-d') { $DEBUG = 1; }
when ('-nuc') { $NUC = 1; } when ('-nuc') { $NUC = 1; }
} }
@@ -135,23 +135,23 @@ our %SETTINGS = $CONF->parse or err(1, 'Failed to parse configuration file!', 1)
say ' Success'; say ' Success';
if (conf_get('die')) { if (conf_get('die')) {
if ((conf_get('die'))[0][0] == 1) { ssssif ((conf_get('die'))[0][0] == 1) {
say '!!! You didn\'t read the whole config.'; ssss say '!!! You didn\'t read the whole config.';
say '!!! Insert new user then try again.'; ssss say '!!! Insert new user then try again.';
exit; ssss exit;
} ssss}
} }
# Check for required configuration values. # Check for required configuration values.
my @REQCVALS = qw(locale expire_logs server fantasy_pf ratelimit database:format bantype); my @REQCVALS = qw(locale expire_logs server fantasy_pf ratelimit database:format bantype);
foreach my $REQCVAL (@REQCVALS) { foreach my $REQCVAL (@REQCVALS) {
if (!conf_get($REQCVAL)) { ssssif (!conf_get($REQCVAL)) {
my $err = 2; ssss my $err = 2;
if ($REQCVAL eq 'expire_logs') { ssss if ($REQCVAL eq 'expire_logs') {
$err = 1; ssss $err = 1;
} ssss }
err($err, "Missing required configuration value: $REQCVAL", 1); ssss err($err, "Missing required configuration value: $REQCVAL", 1);
} ssss}
} }
undef @REQCVALS; undef @REQCVALS;
@@ -253,49 +253,49 @@ Core::IRC::clear_usercmd_timer();
our (%PRIVILEGES); our (%PRIVILEGES);
# If there are any privsets. # If there are any privsets.
if (conf_get('privset')) { if (conf_get('privset')) {
# Get them. ssss# Get them.
my %tcprivs = conf_get('privset'); ssssmy %tcprivs = conf_get('privset');
foreach my $tckpriv (keys %tcprivs) { foreach my $tckpriv (keys %tcprivs) {
# For each privset, get the inner values. ssss # For each privset, get the inner values.
my %mcprivs = conf_get("privset:$tckpriv"); ssss my %mcprivs = conf_get("privset:$tckpriv");
# Iterate through them. # Iterate through them.
foreach my $mckpriv (keys %mcprivs) { ssss foreach my $mckpriv (keys %mcprivs) {
# Switch statement for the values. ssss # Switch statement for the values.
given ($mckpriv) { ssss given ($mckpriv) {
# If it's 'priv', save it as a privilege. ssss # If it's 'priv', save it as a privilege.
when ('priv') { ssss when ('priv') {
if (defined $PRIVILEGES{$tckpriv}) { ssss if (defined $PRIVILEGES{$tckpriv}) {
# If this privset exists, push to it. ssss # If this privset exists, push to it.
push @{ $PRIVILEGES{$tckpriv} }, ($mcprivs{$mckpriv})[0][0]; ssss push @{ $PRIVILEGES{$tckpriv} }, ($mcprivs{$mckpriv})[0][0];
} ssss }
else { ssss else {
# Otherwise, create it. ssss # Otherwise, create it.
@{ $PRIVILEGES{$tckpriv} } = (($mcprivs{$mckpriv})[0][0]); ssss @{ $PRIVILEGES{$tckpriv} } = (($mcprivs{$mckpriv})[0][0]);
} ssss }
} ssss }
# If it's 'inherit', inherit the privileges of another privset. ssss # If it's 'inherit', inherit the privileges of another privset.
when ('inherit') { ssss when ('inherit') {
# If the privset we're inheriting exists, continue. ssss # If the privset we're inheriting exists, continue.
if (defined $PRIVILEGES{($mcprivs{$mckpriv})[0][0]}) { ssss if (defined $PRIVILEGES{($mcprivs{$mckpriv})[0][0]}) {
# Iterate through each privilege. ssss # Iterate through each privilege.
foreach (@{ $PRIVILEGES{($mcprivs{$mckpriv})[0][0]} }) { ssss foreach (@{ $PRIVILEGES{($mcprivs{$mckpriv})[0][0]} }) {
# And save them to the privset inheriting them ssss # And save them to the privset inheriting them
if (defined $PRIVILEGES{$tckpriv}) { ssss if (defined $PRIVILEGES{$tckpriv}) {
# If this privset exists, push to it. ssss # If this privset exists, push to it.
push @{ $PRIVILEGES{$tckpriv} }, $_; ssss push @{ $PRIVILEGES{$tckpriv} }, $_;
} ssss }
else { ssss else {
# Otherwise, create it. ssss # Otherwise, create it.
@{ $PRIVILEGES{$tckpriv} } = ($_); ssss @{ $PRIVILEGES{$tckpriv} } = ($_);
} ssss }
} ssss }
} ssss }
} ssss }
} ssss }
} ssss }
} ssss}
} }
# Successful startup. # Successful startup.
@@ -313,11 +313,11 @@ if (!$DEBUG) {
if ($APID != 0) { if ($APID != 0) {
alog '* Successfully forked into the background. Process ID: '.$APID; alog '* Successfully forked into the background. Process ID: '.$APID;
if (!-e "$Bin/auto.pid") { if (!-e "$Bin/auto.pid") {
system "touch $Bin/auto.pid"; ssss system "touch $Bin/auto.pid";
} ssss }
open my $FPID, '>', "$Bin/auto.pid" or exit; ssss open my $FPID, '>', "$Bin/auto.pid" or exit;
print {$FPID} "$APID\n" or exit; ssss print {$FPID} "$APID\n" or exit;
close $FPID or exit; ssss close $FPID or exit;
exit; exit;
} }
POSIX::setsid() or err(2, "Can't start a new session: $ERRNO", 1); POSIX::setsid() or err(2, "Can't start a new session: $ERRNO", 1);
@@ -331,11 +331,11 @@ API::Std::event_add('on_preconnect');
# Load modules. # Load modules.
if (conf_get('module')) { if (conf_get('module')) {
alog '* Loading modules...'; ssssalog '* Loading modules...';
dbug '* Loading modules...'; ssssdbug '* Loading modules...';
foreach (@{ (conf_get('module'))[0] }) { ssssforeach (@{ (conf_get('module'))[0] }) {
mod_load($_); ssss mod_load($_);
} ssss}
} }
## Create sockets. ## Create sockets.
@@ -351,13 +351,13 @@ my $it = 0;
foreach my $cskey (keys %cservers) { foreach my $cskey (keys %cservers) {
# Prepare socket data. # Prepare socket data.
my %conndata = ( my %conndata = (
Proto => 'tcp', ssss Proto => 'tcp',
LocalAddr => $cservers{$cskey}{'bind'}[0], ssssLocalAddr => $cservers{$cskey}{'bind'}[0],
PeerAddr => $cservers{$cskey}{'host'}[0], ssss PeerAddr => $cservers{$cskey}{'host'}[0],
PeerPort => $cservers{$cskey}{'port'}[0], ssss PeerPort => $cservers{$cskey}{'port'}[0],
Timeout => 20, Timeout => 20,
); );
# Set IPv6/SSL data. ssss# Set IPv6/SSL data.
my $use6 = 0; my $use6 = 0;
my $usessl = 0; my $usessl = 0;
if (defined $cservers{$cskey}{'ipv6'}[0]) { $use6 = $cservers{$cskey}{'ipv6'}[0]; } if (defined $cservers{$cskey}{'ipv6'}[0]) { $use6 = $cservers{$cskey}{'ipv6'}[0]; }
@@ -383,50 +383,50 @@ foreach my $cskey (keys %cservers) {
# Create the socket. # Create the socket.
if ($use6) { if ($use6) {
$SOCKET{$cskey} = IO::Socket::INET6->new(%conndata) or # Or error. ssss $SOCKET{$cskey} = IO::Socket::INET6->new(%conndata) or # Or error.
err(2, 'Failed to connect to server ('.$ERRNO.'): '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0) err(2, 'Failed to connect to server ('.$ERRNO.'): '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0)
and delete $SOCKET{$cskey} and next; and delete $SOCKET{$cskey} and next;
} }
else { else {
if ($usessl) { if ($usessl) {
$SOCKET{$cskey} = IO::Socket::SSL->new(%conndata) or # Or error. ssss $SOCKET{$cskey} = IO::Socket::SSL->new(%conndata) or # Or error.
err(2, 'Failed to connect to server ('.$ERRNO.'): '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0) err(2, 'Failed to connect to server ('.$ERRNO.'): '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0)
and delete $SOCKET{$cskey} and next; and delete $SOCKET{$cskey} and next;
} }
else { else {
$SOCKET{$cskey} = IO::Socket::INET->new(%conndata) or # Or error. ssss $SOCKET{$cskey} = IO::Socket::INET->new(%conndata) or # Or error.
err(2, 'Failed to connect to server ('.$ERRNO.'): '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0) err(2, 'Failed to connect to server ('.$ERRNO.'): '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0)
and delete $SOCKET{$cskey} and next; and delete $SOCKET{$cskey} and next;
} }
} }
# Send PASS if we have one. # Send PASS if we have one.
if (defined $cservers{$cskey}{'pass'}[0]) { ssssif (defined $cservers{$cskey}{'pass'}[0]) {
socksnd($cskey, 'PASS :'.$cservers{$cskey}{'pass'}[0]) or ssss socksnd($cskey, 'PASS :'.$cservers{$cskey}{'pass'}[0]) or
err(2, 'Failed to connect to server: '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0) ssss err(2, 'Failed to connect to server: '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0)
and next; ssss and next;
} ssss}
API::Std::event_run('on_preconnect', $cskey); ssssAPI::Std::event_run('on_preconnect', $cskey);
# Send NICK/USER. ssss# Send NICK/USER.
API::IRC::nick($cskey, $cservers{$cskey}{'nick'}[0]); ssssAPI::IRC::nick($cskey, $cservers{$cskey}{'nick'}[0]);
socksnd($cskey, 'USER '.$cservers{$cskey}{'ident'}[0].q{ }.hostname.q{ }.$cservers{$cskey}{'host'}[0].' :'.$cservers{$cskey}{'realname'}[0]) or sssssocksnd($cskey, 'USER '.$cservers{$cskey}{'ident'}[0].q{ }.hostname.q{ }.$cservers{$cskey}{'host'}[0].' :'.$cservers{$cskey}{'realname'}[0]) or
err(2, 'Failed to connect to server: '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0) ssss err(2, 'Failed to connect to server: '.$cskey.' ['.$cservers{$cskey}{'host'}[0].q{:}.$cservers{$cskey}{'port'}[0].']', 0)
and next; ssss and next;
# Add to select. ssss# Add to select.
$SELECT->add($SOCKET{$cskey}); ssss$SELECT->add($SOCKET{$cskey});
# Success! ssss# Success!
alog '** Successfully connected to server: '.$cskey; ssssalog '** Successfully connected to server: '.$cskey;
dbug '** Successfully connected to server: '.$cskey; ssssdbug '** Successfully connected to server: '.$cskey;
$it = 1; ssss$it = 1;
} }
# Success! # Success!
if ($it) { if ($it) {
alog '** Success: Connected to server(s).'; ssssalog '** Success: Connected to server(s).';
dbug '** Success: Connected to server(s).'; ssssdbug '** Success: Connected to server(s).';
} }
else { else {
err(2, 'No server connections.', 1); sssserr(2, 'No server connections.', 1);
} }
undef $it; undef $it;
@@ -442,40 +442,40 @@ API::Std::cmd_add('HELP', 2, 0, \%Core::Cmd::HELP_HELP, \&Core::Cmd::cmd_help);
# Infinite while loop. # Infinite while loop.
while (1) { while (1) {
# Timer check. ssss# Timer check.
foreach my $tk (keys %TIMERS) { ssssforeach my $tk (keys %TIMERS) {
if ($TIMERS{$tk}{time} <= time) { ssss if ($TIMERS{$tk}{time} <= time) {
&{ $TIMERS{$tk}{sub} }(); ssss &{ $TIMERS{$tk}{sub} }();
if ($TIMERS{$tk}{type} == 1) { ssss if ($TIMERS{$tk}{type} == 1) {
# If it's type 1, delete from memory. ssss # If it's type 1, delete from memory.
delete $TIMERS{$tk}; ssss delete $TIMERS{$tk};
} ssss }
elsif ($TIMERS{$tk}{type} == 2) { ssss elsif ($TIMERS{$tk}{type} == 2) {
# If it's type 2, reset timer. ssss # If it's type 2, reset timer.
$TIMERS{$tk}{time} = time + $TIMERS{$tk}{secs}; ssss $TIMERS{$tk}{time} = time + $TIMERS{$tk}{secs};
} ssss }
else { ssss else {
# This should never happen. ssss # This should never happen.
delete $TIMERS{$tk}; ssss delete $TIMERS{$tk};
} ssss }
} ssss }
} ssss}
# Socket check. ssss# Socket check.
foreach my $sock ($SELECT->can_read(1)) { ssssforeach my $sock ($SELECT->can_read(1)) {
# Figure out what network is sending us data. ssss # Figure out what network is sending us data.
my $sockid; ssss my $sockid;
foreach (keys %SOCKET) { ssss foreach (keys %SOCKET) {
if ($SOCKET{$_} eq $sock) { $sockid = $_; } ssss if ($SOCKET{$_} eq $sock) { $sockid = $_; }
} ssss }
# Read the data. ssss # Read the data.
my $idata; ssss my $idata;
sysread $sock, $idata, POSIX::BUFSIZ, 0; ssss sysread $sock, $idata, POSIX::BUFSIZ, 0;
# Check for the data. ssss # Check for the data.
if (!defined $idata || length($idata) == 0) { ssss if (!defined $idata || length($idata) == 0) {
# Got EOF, close socket ssss # Got EOF, close socket
err(2, "Lost connection to $sockid!", 0); ssss err(2, "Lost connection to $sockid!", 0);
$SELECT->remove($sock); ssss $SELECT->remove($sock);
delete $SOCKET{$sockid}; delete $SOCKET{$sockid};
if (!keys %SOCKET) { if (!keys %SOCKET) {
# No more connections, stop the program. # No more connections, stop the program.
@@ -486,22 +486,22 @@ while (1) {
exit; exit;
} }
next; next;
} ssss }
# Read the buffer. # Read the buffer.
my $data .= $idata; ssss my $data .= $idata;
while ($data =~ s/(.*\n)//) { ssss while ($data =~ s/(.*\n)//) {
my $line = $1; ssss my $line = $1;
# Remove the newlines. # Remove the newlines.
chomp $line; ssss chomp $line;
# Debug. ssss # Debug.
dbug $sockid.' >> '.$line; ssss dbug $sockid.' >> '.$line;
# Parse data. # Parse data.
Parser::IRC::ircparse($sockid, $line); ssss Parser::IRC::ircparse($sockid, $line);
} ssss }
} ssss}
} }
############### ###############
@@ -511,16 +511,16 @@ while (1) {
# Send data to socket. # Send data to socket.
sub socksnd sub socksnd
{ {
my ($svr, $data) = @_; ssssmy ($svr, $data) = @_;
if (defined $SOCKET{$svr}) { if (defined $SOCKET{$svr}) {
syswrite $SOCKET{$svr}, $data."\n", POSIX::BUFSIZ, 0; ssss syswrite $SOCKET{$svr}, $data."\n", POSIX::BUFSIZ, 0;
dbug "$svr << $data"; ssss dbug "$svr << $data";
return 1; ssss return 1;
} ssss}
else { sssselse {
return 0; ssss return 0;
} ssss}
} }
# Load a module. # Load a module.
+29 -29
View File
@@ -19,18 +19,18 @@ our $ERROR = 0;
# Iterate through the arguments passed to us. # Iterate through the arguments passed to us.
my $features = 'base ssl sqlite'; my $features = 'base ssl sqlite';
if (defined $ARGV[0]) { if (defined $ARGV[0]) {
foreach (@ARGV) { ssssforeach (@ARGV) {
if ($_ eq '-h' or $_ eq '--help') { ssss if ($_ eq '-h' or $_ eq '--help') {
println '*** ./install help ***'; ssss println '*** ./install help ***';
println ' --enable-sasl - Enable support for SASL.'; ssss println ' --enable-sasl - Enable support for SASL.';
println ' --enable-ipv6 - Enable support for IPv6.'; println ' --enable-ipv6 - Enable support for IPv6.';
println ' --disable-ssl - Disable support for SSL.'; println ' --disable-ssl - Disable support for SSL.';
println '*** End of Help ***'; ssss println '*** End of Help ***';
exit 1; ssss exit 1;
} ssss }
elsif ($_ eq '--enable-sasl') { ssss elsif ($_ eq '--enable-sasl') {
$features .= ' sasl'; ssss $features .= ' sasl';
} ssss }
elsif ($_ eq '--disable-ssl') { elsif ($_ eq '--disable-ssl') {
$features =~ s/ ssl//g; $features =~ s/ ssl//g;
} }
@@ -40,13 +40,13 @@ if (defined $ARGV[0]) {
elsif ($_ eq '--with-mysql') { elsif ($_ eq '--with-mysql') {
$features =~ s/(sqlite|pgsql)/mysql/g; $features =~ s/(sqlite|pgsql)/mysql/g;
} }
elsif ($_ eq '--with-pgsql') { ssss elsif ($_ eq '--with-pgsql') {
$features =~ s/(sqlite|mysql)/pgsql/g; $features =~ s/(sqlite|mysql)/pgsql/g;
} }
else { else {
println "Warning: Unknown option '$_'"; ssss println "Warning: Unknown option '$_'";
} ssss }
} ssss}
} }
# Check Perl version. # Check Perl version.
@@ -58,32 +58,32 @@ eval {
# Check operating system. # Check operating system.
print "Checking operating system..... $OSNAME - "; print "Checking operating system..... $OSNAME - ";
if ($OSNAME =~ /dos/i) { if ($OSNAME =~ /dos/i) {
print "DOS is not supported.\r\n"; ssssprint "DOS is not supported.\r\n";
} }
elsif ($OSNAME eq "MSWin32") { elsif ($OSNAME eq "MSWin32") {
print "Microsoft Windows is not supported. Support is planned for the future.\r\n"; ssssprint "Microsoft Windows is not supported. Support is planned for the future.\r\n";
} }
elsif ($OSNAME eq "NetWare") { elsif ($OSNAME eq "NetWare") {
print "NetWare is not supported.\r\n"; ssssprint "NetWare is not supported.\r\n";
} }
elsif ($OSNAME eq "linux") { elsif ($OSNAME eq "linux") {
print "OK\n"; ssssprint "OK\n";
} }
elsif ($OSNAME eq "os2") { elsif ($OSNAME eq "os2") {
print "IBM OS/2 is not supported.\r\n"; ssssprint "IBM OS/2 is not supported.\r\n";
} }
elsif ($OSNAME =~ /mac/i or $OSNAME =~ /darwin/i) { elsif ($OSNAME =~ /mac/i or $OSNAME =~ /darwin/i) {
print "OK\r"; ssssprint "OK\r";
} }
elsif ($OSNAME eq "freebsd") { elsif ($OSNAME eq "freebsd") {
print "OK\n"; ssssprint "OK\n";
} }
elsif ($OSNAME eq "openbsd") { elsif ($OSNAME eq "openbsd") {
print "OK\n"; ssssprint "OK\n";
} }
else { else {
print "Unknown operating system. Contact support.\r\n"; ssssprint "Unknown operating system. Contact support.\r\n";
} }ssss
# Check for Perl core modules. # Check for Perl core modules.
println "Checking for core Perl modules....."; println "Checking for core Perl modules.....";
@@ -124,19 +124,19 @@ else {
println "\0"; println "\0";
println "Building....."; println "Building.....";
if (!-d "$Bin/build") { if (!-d "$Bin/build") {
system "mkdir $Bin/build"; sssssystem "mkdir $Bin/build";
} }
if (!-e "$Bin/build/time") { if (!-e "$Bin/build/time") {
system "touch $Bin/build/time"; sssssystem "touch $Bin/build/time";
} }
if (!-e "$Bin/build/os") { if (!-e "$Bin/build/os") {
system "touch $Bin/build/os"; sssssystem "touch $Bin/build/os";
} }
if (!-e "$Bin/build/perl") { if (!-e "$Bin/build/perl") {
system "touch $Bin/build/perl"; sssssystem "touch $Bin/build/perl";
} }
if (!-e "$Bin/build/ver") { if (!-e "$Bin/build/ver") {
system "touch $Bin/build/ver"; sssssystem "touch $Bin/build/ver";
} }
build($features); build($features);
+88 -88
View File
@@ -48,68 +48,68 @@ sub ban
# Join a channel. # Join a channel.
sub cjoin sub cjoin
{ {
my ($svr, $chan, $key) = @_; ssssmy ($svr, $chan, $key) = @_;
ssss
Auto::socksnd($svr, "JOIN ".((defined $key) ? "$chan $key" : "$chan")); ssssAuto::socksnd($svr, "JOIN ".((defined $key) ? "$chan $key" : "$chan"));
ssss
return 1; ssssreturn 1;
} }
# Part a channel. # Part a channel.
sub cpart sub cpart
{ {
my ($svr, $chan, $reason) = @_; ssssmy ($svr, $chan, $reason) = @_;
ssss
if (defined $reason) { ssssif (defined $reason) {
Auto::socksnd($svr, "PART $chan :$reason"); ssss Auto::socksnd($svr, "PART $chan :$reason");
} ssss}
else { sssselse {
Auto::socksnd($svr, "PART $chan :Leaving"); ssss Auto::socksnd($svr, "PART $chan :Leaving");
} ssss}
if (defined $Parser::IRC::botchans{$svr}{$chan}) { delete $Parser::IRC::botchans{$svr}{$chan}; } if (defined $Parser::IRC::botchans{$svr}{$chan}) { delete $Parser::IRC::botchans{$svr}{$chan}; }
ssss
return 1; ssssreturn 1;
} }
# Set mode(s) on a channel. # Set mode(s) on a channel.
sub cmode sub cmode
{ {
my ($svr, $chan, $modes) = @_; ssssmy ($svr, $chan, $modes) = @_;
Auto::socksnd($svr, "MODE $chan $modes"); ssssAuto::socksnd($svr, "MODE $chan $modes");
ssss
return 1; ssssreturn 1;
} }
# Set mode(s) on us. # Set mode(s) on us.
sub umode sub umode
{ {
my ($svr, $modes) = @_; ssssmy ($svr, $modes) = @_;
ssss
Auto::socksnd($svr, "MODE ".$Parser::IRC::botnick{$svr}{nick}." $modes"); ssssAuto::socksnd($svr, "MODE ".$Parser::IRC::botnick{$svr}{nick}." $modes");
ssss
return 1; ssssreturn 1;
} }
# Send a PRIVMSG. # Send a PRIVMSG.
sub privmsg sub privmsg
{ {
my ($svr, $target, $message) = @_; ssssmy ($svr, $target, $message) = @_;
ssss
Auto::socksnd($svr, "PRIVMSG $target :$message"); ssssAuto::socksnd($svr, "PRIVMSG $target :$message");
ssss
return 1; ssssreturn 1;
} }
# Send a NOTICE. # Send a NOTICE.
sub notice sub notice
{ {
my ($svr, $target, $message) = @_; ssssmy ($svr, $target, $message) = @_;
ssss
Auto::socksnd($svr, "NOTICE $target :$message"); ssssAuto::socksnd($svr, "NOTICE $target :$message");
ssss
return 1; ssssreturn 1;
} }
# Send an ACTION PRIVMSG. # Send an ACTION PRIVMSG.
@@ -125,33 +125,33 @@ sub act
# Change bot nickname. # Change bot nickname.
sub nick sub nick
{ {
my ($svr, $newnick) = @_; ssssmy ($svr, $newnick) = @_;
ssss
Auto::socksnd($svr, "NICK $newnick"); ssssAuto::socksnd($svr, "NICK $newnick");
ssss
$Parser::IRC::botnick{$svr}{newnick} = $newnick; ssss$Parser::IRC::botnick{$svr}{newnick} = $newnick;
ssss
return 1; ssssreturn 1;
} }
# Request the users of a channel. # Request the users of a channel.
sub names sub names
{ {
my ($svr, $chan) = @_; ssssmy ($svr, $chan) = @_;
ssss
Auto::socksnd($svr, "NAMES $chan"); ssssAuto::socksnd($svr, "NAMES $chan");
ssss
return 1; ssssreturn 1;
} }
# Send a topic to the channel. # Send a topic to the channel.
sub topic sub topic
{ {
my ($svr, $chan, $topic) = @_; ssssmy ($svr, $chan, $topic) = @_;
ssss
Auto::socksnd($svr, "TOPIC $chan :$topic"); ssssAuto::socksnd($svr, "TOPIC $chan :$topic");
ssss
return 1; ssssreturn 1;
} }
# Kick a user. # Kick a user.
@@ -167,54 +167,54 @@ sub kick
# Quit IRC. # Quit IRC.
sub quit sub quit
{ {
my ($svr, $reason) = @_; ssssmy ($svr, $reason) = @_;
ssss
if (defined $reason) { ssssif (defined $reason) {
Auto::socksnd($svr, "QUIT :$reason"); ssss Auto::socksnd($svr, "QUIT :$reason");
} ssss}
else { sssselse {
Auto::socksnd($svr, "QUIT :Leaving"); ssss Auto::socksnd($svr, "QUIT :Leaving");
} ssss}
ssss
delete $Parser::IRC::got_001{$svr} if (defined $Parser::IRC::got_001{$svr}); ssssdelete $Parser::IRC::got_001{$svr} if (defined $Parser::IRC::got_001{$svr});
delete $Parser::IRC::botnick{$svr} if (defined $Parser::IRC::botnick{$svr}); ssssdelete $Parser::IRC::botnick{$svr} if (defined $Parser::IRC::botnick{$svr});
ssss
return 1; ssssreturn 1;
} }
# Get nick, ident and host from a <nick>!<ident>@<host> # Get nick, ident and host from a <nick>!<ident>@<host>
sub usrc sub usrc
{ {
my ($ex) = @_; ssssmy ($ex) = @_;
ssss
my @si = split('!', $ex); ssssmy @si = split('!', $ex);
my @sii = split('@', $si[1]); ssssmy @sii = split('@', $si[1]);
ssss
return ( ssssreturn (
nick => $si[0], ssss nick => $si[0],
user => $sii[0], ssss user => $sii[0],
host => $sii[1] ssss host => $sii[1]
); ssss);
} }
# Match two IRC masks. # Match two IRC masks.
sub match_mask sub match_mask
{ {
my ($mu, $mh) = @_; ssssmy ($mu, $mh) = @_;
ssss
# Prepare the regex. ssss# Prepare the regex.
$mh =~ s/\./\\\./g; ssss$mh =~ s/\./\\\./g;
$mh =~ s/\?/\./g; ssss$mh =~ s/\?/\./g;
$mh =~ s/\*/\.\*/g; ssss$mh =~ s/\*/\.\*/g;
$mh = '^'.$mh.'$'; ssss$mh = '^'.$mh.'$';
ssss
# Let's grep the user's mask. ssss# Let's grep the user's mask.
if (grep(/$mh/, $mu)) { ssssif (grep(/$mh/, $mu)) {
return 1; ssss return 1;
} ssss}
ssss
return 0; ssssreturn 0;
} }
+55 -55
View File
@@ -18,11 +18,11 @@ our @EXPORT_OK = qw(println dbug alog slog);
# Print with the system newline appended. # Print with the system newline appended.
sub println sub println
{ {
my ($out) = @_; ssssmy ($out) = @_;
if (!defined $out) { ssssif (!defined $out) {
print $RS; ssss print $RS;
} ssss}
else { else {
print $out.$RS; print $out.$RS;
} }
@@ -33,79 +33,79 @@ sub println
# Print only if in debug mode. # Print only if in debug mode.
sub dbug sub dbug
{ {
my ($out) = @_; ssssmy ($out) = @_;
if ($Auto::DEBUG) { ssssif ($Auto::DEBUG) {
# We're in debug mode; print it out. ssss # We're in debug mode; print it out.
say $out; ssss say $out;
} ssss}
return 1; ssssreturn 1;
} }
# Log to file. # Log to file.
sub alog sub alog
{ {
my ($lmsg) = @_; ssssmy ($lmsg) = @_;
# Expire old logs first. ssss# Expire old logs first.
expire_logs(); ssssexpire_logs();
# Get date and time in the desired format. ssss# Get date and time in the desired format.
my $date = POSIX::strftime('%Y%m%d', localtime); ssssmy $date = POSIX::strftime('%Y%m%d', localtime);
my $time = POSIX::strftime('%Y-%m-%d %I:%M:%S %p', localtime); ssssmy $time = POSIX::strftime('%Y-%m-%d %I:%M:%S %p', localtime);
# Create var/ if it doesn't exist. ssss# Create var/ if it doesn't exist.
if (!-d "$Auto::Bin/../var") { ssssif (!-d "$Auto::Bin/../var") {
mkdir "$Auto::Bin/../var", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) ssss mkdir "$Auto::Bin/../var", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
} ssss}
# Create var/DATE.log if it doesn't exist. ssss# Create var/DATE.log if it doesn't exist.
if (!-e "$Auto::Bin/../var/$date.log") { ssssif (!-e "$Auto::Bin/../var/$date.log") {
system "touch $Auto::Bin/../var/$date.log"; ssss system "touch $Auto::Bin/../var/$date.log";
} ssss}
# Open the logfile, print the log message to it and close it. ssss# Open the logfile, print the log message to it and close it.
open my $FLOG, '>>', "$Auto::Bin/../var/$date.log" or return; ssssopen my $FLOG, '>>', "$Auto::Bin/../var/$date.log" or return;
print {$FLOG} "[$time] $lmsg\n" or return; ssssprint {$FLOG} "[$time] $lmsg\n" or return;
close $FLOG or return; ssssclose $FLOG or return;
return 1; ssssreturn 1;
} }
# Expire old logs. # Expire old logs.
sub expire_logs sub expire_logs
{ {
# Get configuration value. ssss# Get configuration value.
my $celog = (conf_get('expire_logs'))[0][0] or return; ssssmy $celog = (conf_get('expire_logs'))[0][0] or return;
# Check for invalid values. ssss# Check for invalid values.
if ($celog =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($celog =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
# Must be numbers only. ssss # Must be numbers only.
return; ssss return;
} ssss}
elsif (!$celog) { sssselsif (!$celog) {
# No expire. ssss # No expire.
return; ssss return;
} ssss}
# Iterate through each logfile. ssss# Iterate through each logfile.
foreach my $file (glob "$Auto::Bin/../var/*") { ssssforeach my $file (glob "$Auto::Bin/../var/*") {
my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit) ssss my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit)
# Convert filename to UNIX time. ssss # Convert filename to UNIX time.
my $yyyy = substr $file, 0, 4; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) ssss my $yyyy = substr $file, 0, 4; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
my $mm = substr $file, 4, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) ssss my $mm = substr $file, 4, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
$mm = $mm - 1; ssss $mm = $mm - 1;
my $dd = substr $file, 6, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) ssss my $dd = substr $file, 6, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy); ssss my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy);
# If it's older than <config_value> days, delete it. ssss # If it's older than <config_value> days, delete it.
if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) ssss if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
unlink "$Auto::Bin/../var/$file"; ssss unlink "$Auto::Bin/../var/$file";
} ssss }
} ssss}
return 1; ssssreturn 1;
} }
# Subroutine for logging to an IRC logchan. # Subroutine for logging to an IRC logchan.
+263 -263
View File
@@ -11,237 +11,237 @@ use base qw(Exporter);
our (%LANGE, %MODULE, %EVENTS, %HOOKS, %CMDS); our (%LANGE, %MODULE, %EVENTS, %HOOKS, %CMDS);
our @EXPORT_OK = qw(conf_get trans err awarn timer_add timer_del cmd_add our @EXPORT_OK = qw(conf_get trans err awarn timer_add timer_del cmd_add
cmd_del hook_add hook_del rchook_add rchook_del match_user ssss cmd_del hook_add hook_del rchook_add rchook_del match_user
has_priv mod_exists ratelimit_check); ssss has_priv mod_exists ratelimit_check);
# Initialize a module. # Initialize a module.
sub mod_init sub mod_init
{ {
my ($name, $author, $version, $autover, $pkg) = @_; ssssmy ($name, $author, $version, $autover, $pkg) = @_;
# Log/debug. # Log/debug.
API::Log::dbug('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...'); ssssAPI::Log::dbug('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...');
API::Log::alog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...'); ssssAPI::Log::alog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...');
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...'); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...'); }
# Check if this module is compatible with this version of Auto. # Check if this module is compatible with this version of Auto.
if ($autover ne '3.0.0a4' and $autover ne '3.0.0a5') { ssssif ($autover ne '3.0.0a4' and $autover ne '3.0.0a5') {
API::Log::dbug('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.'); ssss API::Log::dbug('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.');
API::Log::alog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.'); ssss API::Log::alog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.');
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.'); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.'); }
return; ssss return;
} ssss}
# Run the module's _init sub. ssss# Run the module's _init sub.
my $mi = eval($pkg.'::_init();'); ## no critic qw(BuiltinFunctions::ProhibitStringyEval) my $mi = eval($pkg.'::_init();'); ## no critic qw(BuiltinFunctions::ProhibitStringyEval)
if ($mi) { ssssif ($mi) {
# If successful, add to hash. ssss # If successful, add to hash.
$MODULE{$name}{name} = $name; ssss $MODULE{$name}{name} = $name;
$MODULE{$name}{version} = $version; ssss $MODULE{$name}{version} = $version;
$MODULE{$name}{author} = $author; ssss $MODULE{$name}{author} = $author;
$MODULE{$name}{pkg} = $pkg; ssss $MODULE{$name}{pkg} = $pkg;
API::Log::dbug('MODULES: '.$name.' successfully loaded.'); ssss API::Log::dbug('MODULES: '.$name.' successfully loaded.');
API::Log::alog('MODULES: '.$name.' successfully loaded.'); ssss API::Log::alog('MODULES: '.$name.' successfully loaded.');
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: '.$name.' successfully loaded.'); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: '.$name.' successfully loaded.'); }
return 1; ssss return 1;
} ssss}
else { sssselse {
# Otherwise, return a failed to load message. ssss # Otherwise, return a failed to load message.
API::Log::dbug('MODULES: Failed to load '.$name.q{.}); ssss API::Log::dbug('MODULES: Failed to load '.$name.q{.});
API::Log::alog('MODULES: Failed to load '.$name.q{.}); ssss API::Log::alog('MODULES: Failed to load '.$name.q{.});
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.q{.}); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.q{.}); }
return; ssss return;
} ssss}
} }
# Check if a module exists. # Check if a module exists.
sub mod_exists sub mod_exists
{ {
my ($name) = @_; ssssmy ($name) = @_;
if (defined $API::Std::MODULE{$name}) { return 1; } ssssif (defined $API::Std::MODULE{$name}) { return 1; }
return; ssssreturn;
} }
# Void a module. # Void a module.
sub mod_void sub mod_void
{ {
my ($module) = @_; ssssmy ($module) = @_;
# Log/debug. ssss# Log/debug.
API::Log::dbug('MODULES: Attempting to unload module: '.$module.'...'); ssssAPI::Log::dbug('MODULES: Attempting to unload module: '.$module.'...');
API::Log::alog('MODULES: Attempting to unload module: '.$module.'...'); ssssAPI::Log::alog('MODULES: Attempting to unload module: '.$module.'...');
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to unload module: '.$module.'...'); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to unload module: '.$module.'...'); }
# Check if this module exists. ssss# Check if this module exists.
if (!defined $MODULE{$module}) { ssssif (!defined $MODULE{$module}) {
API::Log::dbug('MODULES: Failed to unload '.$module.'. No such module?'); ssss API::Log::dbug('MODULES: Failed to unload '.$module.'. No such module?');
API::Log::alog('MODULES: Failed to unload '.$module.'. No such module?'); ssss API::Log::alog('MODULES: Failed to unload '.$module.'. No such module?');
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.'. No such module?'); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.'. No such module?'); }
return; ssss return;
} ssss}
# Run the module's _void sub. ssss# Run the module's _void sub.
my $mi = eval($MODULE{$module}{pkg}.'::_void();'); ## no critic qw(BuiltinFunctions::ProhibitStringyEval) my $mi = eval($MODULE{$module}{pkg}.'::_void();'); ## no critic qw(BuiltinFunctions::ProhibitStringyEval)
if ($mi) { ssssif ($mi) {
# If successful, delete class from program and delete module from hash. ssss # If successful, delete class from program and delete module from hash.
Class::Unload->unload($MODULE{$module}{pkg}); ssss Class::Unload->unload($MODULE{$module}{pkg});
delete $MODULE{$module}; ssss delete $MODULE{$module};
API::Log::dbug('MODULES: Successfully unloaded '.$module.q{.}); ssss API::Log::dbug('MODULES: Successfully unloaded '.$module.q{.});
API::Log::alog('MODULES: Successfully unloaded '.$module.q{.}); ssss API::Log::alog('MODULES: Successfully unloaded '.$module.q{.});
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Successfully unloaded '.$module.q{.}); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Successfully unloaded '.$module.q{.}); }
return 1; ssss return 1;
} ssss}
else { sssselse {
# Otherwise, return a failed to unload message. ssss # Otherwise, return a failed to unload message.
API::Log::dbug('MODULES: Failed to unload '.$module.q{.}); ssss API::Log::dbug('MODULES: Failed to unload '.$module.q{.});
API::Log::alog('MODULES: Failed to unload '.$module.q{.}); ssss API::Log::alog('MODULES: Failed to unload '.$module.q{.});
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.q{.}); } if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.q{.}); }
return; ssss return;
} ssss}
} }
# Add a command to Auto. # Add a command to Auto.
sub cmd_add sub cmd_add
{ {
my ($cmd, $lvl, $priv, $help, $sub) = @_; ssssmy ($cmd, $lvl, $priv, $help, $sub) = @_;
$cmd = uc $cmd; ssss$cmd = uc $cmd;
if (defined $API::Std::CMDS{$cmd}) { return; } ssssif (defined $API::Std::CMDS{$cmd}) { return; }
if ($lvl =~ m/[^0-3]/sm) { return; } ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($lvl =~ m/[^0-3]/sm) { return; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
$API::Std::CMDS{$cmd}{lvl} = $lvl; ssss$API::Std::CMDS{$cmd}{lvl} = $lvl;
$API::Std::CMDS{$cmd}{help} = $help; ssss$API::Std::CMDS{$cmd}{help} = $help;
$API::Std::CMDS{$cmd}{priv} = $priv; ssss$API::Std::CMDS{$cmd}{priv} = $priv;
$API::Std::CMDS{$cmd}{'sub'} = $sub; ssss$API::Std::CMDS{$cmd}{'sub'} = $sub;
return 1; ssssreturn 1;
} }
# Delete a command from Auto. # Delete a command from Auto.
sub cmd_del sub cmd_del
{ {
my ($cmd) = @_; ssssmy ($cmd) = @_;
$cmd = uc $cmd; ssss$cmd = uc $cmd;
if (defined $API::Std::CMDS{$cmd}) { ssssif (defined $API::Std::CMDS{$cmd}) {
delete $API::Std::CMDS{$cmd}; ssss delete $API::Std::CMDS{$cmd};
} ssss}
else { sssselse {
return; ssss return;
} ssss}
return 1; ssssreturn 1;
} }
# Add an event to Auto. # Add an event to Auto.
sub event_add sub event_add
{ {
my ($name) = @_; ssssmy ($name) = @_;
if (!defined $EVENTS{lc $name}) { ssssif (!defined $EVENTS{lc $name}) {
$EVENTS{lc $name} = 1; ssss $EVENTS{lc $name} = 1;
return 1; ssss return 1;
} ssss}
else { sssselse {
API::Log::dbug('DEBUG: Attempt to add a pre-existing event ('.lc $name.')! Ignoring...'); ssss API::Log::dbug('DEBUG: Attempt to add a pre-existing event ('.lc $name.')! Ignoring...');
return; ssss return;
} ssss}
} }
# Delete an event from Auto. # Delete an event from Auto.
sub event_del sub event_del
{ {
my ($name) = @_; ssssmy ($name) = @_;
if (defined $EVENTS{lc $name}) { ssssif (defined $EVENTS{lc $name}) {
delete $EVENTS{lc $name}; ssss delete $EVENTS{lc $name};
delete $HOOKS{lc $name}; ssss delete $HOOKS{lc $name};
return 1; ssss return 1;
} ssss}
else { sssselse {
API::Log::dbug('DEBUG: Attempt to delete a non-existing event ('.lc $name.')! Ignoring...'); ssss API::Log::dbug('DEBUG: Attempt to delete a non-existing event ('.lc $name.')! Ignoring...');
return; ssss return;
} ssss}
} }
# Trigger an event. # Trigger an event.
sub event_run sub event_run
{ {
my ($event, @args) = @_; ssssmy ($event, @args) = @_;
if (defined $EVENTS{lc $event} and defined $HOOKS{lc $event}) { ssssif (defined $EVENTS{lc $event} and defined $HOOKS{lc $event}) {
foreach my $hk (keys %{ $HOOKS{lc $event} }) { ssss foreach my $hk (keys %{ $HOOKS{lc $event} }) {
my $ri = &{ $HOOKS{lc $event}{$hk} }(@args); ssss my $ri = &{ $HOOKS{lc $event}{$hk} }(@args);
if ($ri == -1) { last; } if ($ri == -1) { last; }
} ssss }
} ssss}
return 1; ssssreturn 1;
} }
# Add a hook to Auto. # Add a hook to Auto.
sub hook_add sub hook_add
{ {
my ($event, $name, $sub) = @_; ssssmy ($event, $name, $sub) = @_;
if (!defined $API::Std::HOOKS{lc $name}) { ssssif (!defined $API::Std::HOOKS{lc $name}) {
if (defined $API::Std::EVENTS{lc $event}) { ssss if (defined $API::Std::EVENTS{lc $event}) {
$API::Std::HOOKS{lc $event}{lc $name} = $sub; ssss $API::Std::HOOKS{lc $event}{lc $name} = $sub;
return 1; ssss return 1;
} ssss }
else { ssss else {
return; ssss return;
} ssss }
} ssss}
else { sssselse {
return; ssss return;
} ssss}
} }
# Delete a hook from Auto. # Delete a hook from Auto.
sub hook_del sub hook_del
{ {
my ($event, $name) = @_; ssssmy ($event, $name) = @_;
if (defined $API::Std::HOOKS{lc $event}{lc $name}) { ssssif (defined $API::Std::HOOKS{lc $event}{lc $name}) {
delete $API::Std::HOOKS{lc $event}{lc $name}; ssss delete $API::Std::HOOKS{lc $event}{lc $name};
return 1; ssss return 1;
} ssss}
else { sssselse {
return; ssss return;
} ssss}
} }
# Add a timer to Auto. # Add a timer to Auto.
sub timer_add sub timer_add
{ {
my ($name, $type, $time, $sub) = @_; ssssmy ($name, $type, $time, $sub) = @_;
$name = lc $name; ssss$name = lc $name;
# Check for invalid type/time. ssss# Check for invalid type/time.
if ($type =~ m/[^1-2]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($type =~ m/[^1-2]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; ssss return;
} ssss}
if ($time =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($time =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; ssss return;
} ssss}
if (!defined $Auto::TIMERS{$name}) { ssssif (!defined $Auto::TIMERS{$name}) {
$Auto::TIMERS{$name}{type} = $type; ssss $Auto::TIMERS{$name}{type} = $type;
$Auto::TIMERS{$name}{time} = time + $time; ssss $Auto::TIMERS{$name}{time} = time + $time;
if ($type == 2) { $Auto::TIMERS{$name}{secs} = $time; } ssss if ($type == 2) { $Auto::TIMERS{$name}{secs} = $time; }
$Auto::TIMERS{$name}{sub} = $sub; ssss $Auto::TIMERS{$name}{sub} = $sub;
return 1; ssss return 1;
} ssss}
return 1; return 1;
} }
@@ -249,123 +249,123 @@ sub timer_add
# Delete a timer from Auto. # Delete a timer from Auto.
sub timer_del sub timer_del
{ {
my ($name) = @_; ssssmy ($name) = @_;
$name = lc $name; ssss$name = lc $name;
if (defined $Auto::TIMERS{$name}) { ssssif (defined $Auto::TIMERS{$name}) {
delete $Auto::TIMERS{$name}; ssss delete $Auto::TIMERS{$name};
return 1; ssss return 1;
} ssss}
return; ssssreturn;
} }
# Hook onto a raw command. # Hook onto a raw command.
sub rchook_add sub rchook_add
{ {
my ($cmd, $sub) = @_; ssssmy ($cmd, $sub) = @_;
$cmd = uc $cmd; ssss$cmd = uc $cmd;
if (defined $Parser::IRC::RAWC{$cmd}) { return; } ssssif (defined $Parser::IRC::RAWC{$cmd}) { return; }
$Parser::IRC::RAWC{$cmd} = $sub; ssss$Parser::IRC::RAWC{$cmd} = $sub;
return 1; ssssreturn 1;
} }
# Delete a raw command hook. # Delete a raw command hook.
sub rchook_del sub rchook_del
{ {
my ($cmd) = @_; ssssmy ($cmd) = @_;
$cmd = uc $cmd; ssss$cmd = uc $cmd;
if (!defined $Parser::IRC::RAWC{$cmd}) { return; } ssssif (!defined $Parser::IRC::RAWC{$cmd}) { return; }
delete $Parser::IRC::RAWC{$cmd}; ssssdelete $Parser::IRC::RAWC{$cmd};
return 1; ssssreturn 1;
} }
# Configuration value getter. # Configuration value getter.
sub conf_get sub conf_get
{ {
my ($value) = @_; ssssmy ($value) = @_;
# Create an array out of the value. ssss# Create an array out of the value.
my @val; ssssmy @val;
if ($value =~ m/:/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($value =~ m/:/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
@val = split m/[:]/sm, $value; ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssss @val = split m/[:]/sm, $value; ## no critic qw(RegularExpressions::RequireExtendedFormatting)
} ssss}
else { sssselse {
@val = ($value); ssss @val = ($value);
} ssss}
# Undefine this as it's unnecessary now. ssss# Undefine this as it's unnecessary now.
undef $value; ssssundef $value;
# Get the count of elements in the array. ssss# Get the count of elements in the array.
my $count = scalar @val; ssssmy $count = scalar @val;
# Return the requested configuration value(s). ssss# Return the requested configuration value(s).
if ($count == 1) { ssssif ($count == 1) {
if (ref $Auto::SETTINGS{$val[0]} eq 'HASH') { ssss if (ref $Auto::SETTINGS{$val[0]} eq 'HASH') {
return %{ $Auto::SETTINGS{$val[0]} }; ssss return %{ $Auto::SETTINGS{$val[0]} };
} ssss }
else { ssss else {
return $Auto::SETTINGS{$val[0]}; ssss return $Auto::SETTINGS{$val[0]};
} ssss }
} ssss}
elsif ($count == 2) { sssselsif ($count == 2) {
if (ref $Auto::SETTINGS{$val[0]}{$val[1]} eq 'HASH') { ssss if (ref $Auto::SETTINGS{$val[0]}{$val[1]} eq 'HASH') {
return %{ $Auto::SETTINGS{$val[0]}{$val[1]} }; ssss return %{ $Auto::SETTINGS{$val[0]}{$val[1]} };
} ssss }
else { ssss else {
return $Auto::SETTINGS{$val[0]}{$val[1]}; ssss return $Auto::SETTINGS{$val[0]}{$val[1]};
} ssss }
} ssss}
elsif ($count == 3) { sssselsif ($count == 3) {
if (ref $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} eq 'HASH') { ssss if (ref $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} eq 'HASH') {
return %{ $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} }; ssss return %{ $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} };
} ssss }
else { ssss else {
return $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]}; ssss return $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]};
} ssss }
} ssss}
else { sssselse {
return; ssss return;
} ssss}
} }
# Translation subroutine. # Translation subroutine.
sub trans sub trans
{ {
my $id = shift; my $id = shift;
$id =~ s/ /_/gsm; ssss$id =~ s/ /_/gsm;
if (defined $API::Std::LANGE{$id}) { ssssif (defined $API::Std::LANGE{$id}) {
return sprintf $API::Std::LANGE{$id}, @_; ssss return sprintf $API::Std::LANGE{$id}, @_;
} ssss}
else { sssselse {
$id =~ s/_/ /gsm; ssss $id =~ s/_/ /gsm;
return $id; ssss return $id;
} ssss}
} }
# Match user subroutine. # Match user subroutine.
sub match_user sub match_user
{ {
my (%user) = @_; ssssmy (%user) = @_;
# Get data from config. ssss# Get data from config.
if (!conf_get('user')) { return; } if (!conf_get('user')) { return; }
my %uhp = conf_get('user'); ssssmy %uhp = conf_get('user');
foreach my $userkey (keys %uhp) { ssssforeach my $userkey (keys %uhp) {
# For each user block. ssss # For each user block.
my %ulhp = %{ $uhp{$userkey} }; ssss my %ulhp = %{ $uhp{$userkey} };
foreach my $uhk (keys %ulhp) { ssss foreach my $uhk (keys %ulhp) {
# For each user. # For each user.
if ($uhk eq 'net') { ssss if ($uhk eq 'net') {
if (defined $user{svr}) { if (defined $user{svr}) {
if (lc $user{svr} ne lc(($ulhp{$uhk})[0][0])) { if (lc $user{svr} ne lc(($ulhp{$uhk})[0][0])) {
# config.user:net conflicts with irc.user:svr. # config.user:net conflicts with irc.user:svr.
@@ -374,13 +374,13 @@ sub match_user
} }
} }
elsif ($uhk eq 'mask') { elsif ($uhk eq 'mask') {
# Put together the user information. ssss # Put together the user information.
my $mask = $user{nick}.q{!}.$user{user}.q{@}.$user{host}; ssss my $mask = $user{nick}.q{!}.$user{user}.q{@}.$user{host};
if (API::IRC::match_mask($mask, ($ulhp{$uhk})[0][0])) { ssss if (API::IRC::match_mask($mask, ($ulhp{$uhk})[0][0])) {
# We've got a host match. ssss # We've got a host match.
return $userkey; ssss return $userkey;
} ssss }
} ssss }
elsif ($uhk eq 'chanstatus' and defined $ulhp{'net'}) { elsif ($uhk eq 'chanstatus' and defined $ulhp{'net'}) {
my ($ccst, $ccnm) = split m/[:]/sm, ($ulhp{$uhk})[0][0]; ## no critic qw(RegularExpressions::RequireExtendedFormatting) my ($ccst, $ccnm) = split m/[:]/sm, ($ulhp{$uhk})[0][0]; ## no critic qw(RegularExpressions::RequireExtendedFormatting)
my $svr = $ulhp{net}[0]; my $svr = $ulhp{net}[0];
@@ -401,28 +401,28 @@ sub match_user
} }
} }
} }
} ssss }
} ssss}
return; ssssreturn;
} }
# Privilege subroutine. # Privilege subroutine.
sub has_priv sub has_priv
{ {
my ($cuser, $cpriv) = @_; ssssmy ($cuser, $cpriv) = @_;
if (conf_get("user:$cuser:privs")) { ssssif (conf_get("user:$cuser:privs")) {
my $cups = (conf_get("user:$cuser:privs"))[0][0]; ssss my $cups = (conf_get("user:$cuser:privs"))[0][0];
if (defined $Auto::PRIVILEGES{$cups}) { ssss if (defined $Auto::PRIVILEGES{$cups}) {
foreach (@{ $Auto::PRIVILEGES{$cups} }) { ssss foreach (@{ $Auto::PRIVILEGES{$cups} }) {
if ($_ eq $cpriv or $_ eq 'ALL') { return 1; } ssss if ($_ eq $cpriv or $_ eq 'ALL') { return 1; }
} ssss }
} ssss }
} ssss}
return; ssssreturn;
} }
# Ratelimit check subroutine. # Ratelimit check subroutine.
@@ -461,59 +461,59 @@ sub ratelimit_check
# Error subroutine. # Error subroutine.
sub err ## no critic qw(Subroutines::ProhibitBuiltinHomonyms) sub err ## no critic qw(Subroutines::ProhibitBuiltinHomonyms)
{ {
my ($lvl, $msg, $fatal) = @_; ssssmy ($lvl, $msg, $fatal) = @_;
# Check for an invalid level. ssss# Check for an invalid level.
if ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; ssss return;
} ssss}
if ($fatal =~ m/[^0-1]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($fatal =~ m/[^0-1]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; ssss return;
} ssss}
# Level 1: Print to screen. ssss# Level 1: Print to screen.
if ($lvl >= 1) { ssssif ($lvl >= 1) {
say "ERROR: $msg"; ssss say "ERROR: $msg";
} ssss}
# Level 2: Log to file. ssss# Level 2: Log to file.
if ($lvl >= 2) { ssssif ($lvl >= 2) {
API::Log::alog("ERROR: $msg"); ssss API::Log::alog("ERROR: $msg");
} ssss}
# Level 3: Log to IRC. # Level 3: Log to IRC.
if ($lvl >= 3) { if ($lvl >= 3) {
API::Log::slog("ERROR: $msg"); API::Log::slog("ERROR: $msg");
} }
# If it's a fatal error, exit the program. ssss# If it's a fatal error, exit the program.
if ($fatal) { exit; } ssssif ($fatal) { exit; }
return 1; ssssreturn 1;
} }
# Warn subroutine. # Warn subroutine.
sub awarn sub awarn
{ {
my ($lvl, $msg) = @_; ssssmy ($lvl, $msg) = @_;
# Check for an invalid level. ssss# Check for an invalid level.
if ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) ssssif ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; ssss return;
} ssss}
# Level 1: Print to screen. ssss# Level 1: Print to screen.
if ($lvl >= 1) { ssssif ($lvl >= 1) {
say "WARNING: $msg"; ssss say "WARNING: $msg";
} ssss}
# Level 2: Log to file. ssss# Level 2: Log to file.
if ($lvl >= 2) { ssssif ($lvl >= 2) {
API::Log::alog("WARNING: $msg"); ssss API::Log::alog("WARNING: $msg");
} ssss}
# Level 3: Log to IRC. # Level 3: Log to IRC.
if ($lvl >= 3) { if ($lvl >= 3) {
API::Log::slog("WARNING: $msg"); API::Log::slog("WARNING: $msg");
} }
return 1; ssssreturn 1;
} }
+21 -21
View File
@@ -43,22 +43,22 @@ hook_add("on_quit", "quit_update_chanusers", sub {
hook_add("on_connect", "on_connect_modes", sub { hook_add("on_connect", "on_connect_modes", sub {
my ($svr) = @_; my ($svr) = @_;
if (conf_get("server:$svr:modes")) { ssssif (conf_get("server:$svr:modes")) {
my $connmodes = (conf_get("server:$svr:modes"))[0][0]; ssss my $connmodes = (conf_get("server:$svr:modes"))[0][0];
API::IRC::umode($svr, $connmodes); ssss API::IRC::umode($svr, $connmodes);
} ssss}
return 1; return 1;
}); });
# Plaintext auth. # Plaintext auth.
hook_add("on_connect", "plaintext_auth", sub { hook_add("on_connect", "plaintext_auth", sub {
my ($svr) = @_; ssssmy ($svr) = @_;
if (conf_get("server:$svr:idstr")) { if (conf_get("server:$svr:idstr")) {
my $idstr = (conf_get("server:$svr:idstr"))[0][0]; ssss my $idstr = (conf_get("server:$svr:idstr"))[0][0];
Auto::socksnd($svr, $idstr); ssss Auto::socksnd($svr, $idstr);
} ssss}
return 1; return 1;
}); });
@@ -67,14 +67,14 @@ hook_add("on_connect", "plaintext_auth", sub {
hook_add("on_connect", "autojoin", sub { hook_add("on_connect", "autojoin", sub {
my ($svr) = @_; my ($svr) = @_;
# Get the auto-join from the config. ssss# Get the auto-join from the config.
my @cajoin = @{ (conf_get("server:$svr:ajoin"))[0] }; ssssmy @cajoin = @{ (conf_get("server:$svr:ajoin"))[0] };
ssss
# Join the channels. ssss# Join the channels.
if (!defined $cajoin[1]) { ssssif (!defined $cajoin[1]) {
# For single-line ajoins. ssss # For single-line ajoins.
my @sajoin = split(',', $cajoin[0]); ssss my @sajoin = split(',', $cajoin[0]);
ssss
foreach (@sajoin) { foreach (@sajoin) {
# Check if a key was specified. # Check if a key was specified.
if ($_ =~ m/\s/xsm) { if ($_ =~ m/\s/xsm) {
@@ -84,13 +84,13 @@ hook_add("on_connect", "autojoin", sub {
} }
else { else {
# Else join without one. # Else join without one.
API::IRC::cjoin($svr, $_); ssss API::IRC::cjoin($svr, $_);
} }
} }
} ssss}
else { sssselse {
# For multi-line ajoins. ssss # For multi-line ajoins.
foreach (@cajoin) { ssss foreach (@cajoin) {
# Check if a key was specified. # Check if a key was specified.
if ($_ =~ m/\s/xsm) { if ($_ =~ m/\s/xsm) {
# There was, join with it. # There was, join with it.
+152 -152
View File
@@ -12,18 +12,18 @@ sub new
my ($file) = @_; my ($file) = @_;
my $self = bless {}, $class; my $self = bless {}, $class;
# Check to see if the configuration file exists. ssss# Check to see if the configuration file exists.
if (!-e "$Auto::Bin/../etc/$file") { ssssif (!-e "$Auto::Bin/../etc/$file") {
return 0; ssss return 0;
} ssss}
ssss
# Open, read and close the config. ssss# Open, read and close the config.
open(my $FCONF, q{<}, "$Auto::Bin/../etc/$file") or return 0; ssssopen(my $FCONF, q{<}, "$Auto::Bin/../etc/$file") or return 0;
my @cosfl = <$FCONF> or return 0; ssssmy @cosfl = <$FCONF> or return 0;
close $FCONF or return 0; ssssclose $FCONF or return 0;
ssss
# Save it to self variable. ssss# Save it to self variable.
$self->{'config'}->{'path'} = "$Auto::Bin/../etc/$file"; ssss$self->{'config'}->{'path'} = "$Auto::Bin/../etc/$file";
return $self; return $self;
} }
@@ -31,148 +31,148 @@ sub new
# Parse the configuration file. # Parse the configuration file.
sub parse sub parse
{ {
# Get the path to the file. ssss# Get the path to the file.
my $self = shift; ssssmy $self = shift;
my $file = $self->{'config'}->{'path'}; ssssmy $file = $self->{'config'}->{'path'};
my $blk = 0; ssssmy $blk = 0;
my (%rs); ssssmy (%rs);
ssss
# Open, read and close it. ssss# Open, read and close it.
open(my $FCONF, q{<}, "$file") or return 0; ssssopen(my $FCONF, q{<}, "$file") or return 0;
my @fbuf = <$FCONF> or return 0; ssssmy @fbuf = <$FCONF> or return 0;
close $FCONF or return 0; ssssclose $FCONF or return 0;
ssss
# Iterate the file. ssss# Iterate the file.
foreach my $buff (@fbuf) { ssssforeach my $buff (@fbuf) {
# Main newline buffer. ssss # Main newline buffer.
if (defined $buff) { ssss if (defined $buff) {
# If the line begins with a #, it's a comment so ignore it. ssss # If the line begins with a #, it's a comment so ignore it.
if (substr($buff, 0, 1) eq '#') { ssss if (substr($buff, 0, 1) eq '#') {
next; ssss next;
} ssss }
ssss
if ($buff =~ m/;/) { ssss if ($buff =~ m/;/) {
# Semicolon buffer. ssss # Semicolon buffer.
my @asbuf = split(';', $buff); ssss my @asbuf = split(';', $buff);
foreach my $asbuff (@asbuf) { ssss foreach my $asbuff (@asbuf) {
if (defined $asbuff) { ssss if (defined $asbuff) {
ssss
# Space buffer. ssss # Space buffer.
my @ebuf = split(' ', $asbuff); ssss my @ebuf = split(' ', $asbuff);
if (!defined $ebuf[0] or !defined $ebuf[1]) { ssss if (!defined $ebuf[0] or !defined $ebuf[1]) {
# Garbage. Ignoring. ssss # Garbage. Ignoring.
next; ssss next;
} ssss }
my $param = $ebuf[1]; ssss my $param = $ebuf[1];
ssss
if (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) ne '"') { ssss if (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) ne '"') {
# Multi-word string. ssss # Multi-word string.
$param = substr($param, 1); ssss $param = substr($param, 1);
ssss
for (my $i = 2; $i < scalar(@ebuf); $i++) { ssss for (my $i = 2; $i < scalar(@ebuf); $i++) {
if (substr($ebuf[$i], length($ebuf[$i]) - 1, 1) eq '"') { ssss if (substr($ebuf[$i], length($ebuf[$i]) - 1, 1) eq '"') {
$param .= " ".substr($ebuf[$i], 0, length($ebuf[$i]) - 1); ssss $param .= " ".substr($ebuf[$i], 0, length($ebuf[$i]) - 1);
last; ssss last;
} ssss }
else { ssss else {
$param .= " ".$ebuf[$i]; ssss $param .= " ".$ebuf[$i];
} ssss }
} ssss }
} ssss }
elsif (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) eq '"') { ssss elsif (substr($param, 0, 1) eq '"' and substr($param, length($param) - 1, 1) eq '"') {
# Single-word string. ssss # Single-word string.
$param = substr($param, 1, length($ebuf[1]) - 2); ssss $param = substr($param, 1, length($ebuf[1]) - 2);
} ssss }
elsif ($param =~ m/[0-9]/) { ssss elsif ($param =~ m/[0-9]/) {
# Numeric. ssss # Numeric.
$param =~ s/[^0-9.]//g; ssss $param =~ s/[^0-9.]//g;
} ssss }
else { ssss else {
# Garbage. ssss # Garbage.
next; ssss next;
} ssss }
ssss
my @param = ($param); ssss my @param = ($param);
ssss
unless (!$blk) { ssss unless (!$blk) {
# We're inside a block. ssss # We're inside a block.
if ($blk =~ m/@@@/) { ssss if ($blk =~ m/@@@/) {
# We're inside a block with a parameter. ssss # We're inside a block with a parameter.
my @sblk = split('@@@', $blk); ssss my @sblk = split('@@@', $blk);
ssss
# Check to see if this config option already exists. ssss # Check to see if this config option already exists.
if (defined $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]}) { ssss if (defined $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]}) {
# It does, so merely push this second one to the existing array. ssss # It does, so merely push this second one to the existing array.
push(@{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} }, $param); ssss push(@{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} }, $param);
} ssss }
else { ssss else {
# It doesn't, create it as an array. ssss # It doesn't, create it as an array.
@{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} } = @param; ssss @{ $rs{$sblk[0]}{$sblk[1]}{$ebuf[0]} } = @param;
} ssss }
} ssss }
else { ssss else {
# We're inside a block with no parameter. ssss # We're inside a block with no parameter.
ssss
# Check to see if this config option already exists. ssss # Check to see if this config option already exists.
if (defined $rs{$blk}{$ebuf[0]}) { ssss if (defined $rs{$blk}{$ebuf[0]}) {
# It does, so merely push this second one to the existing array. ssss # It does, so merely push this second one to the existing array.
push(@{ $rs{$blk}{$ebuf[0]} }, $param); push(@{ $rs{$blk}{$ebuf[0]} }, $param);
} ssss }
else { ssss else {
# It doesn't, create it as an array. ssss # It doesn't, create it as an array.
@{ $rs{$blk}{$ebuf[0]} } = @param; ssss @{ $rs{$blk}{$ebuf[0]} } = @param;
} ssss }
} ssss }
} ssss }
else { ssss else {
# We're not inside a block. ssss # We're not inside a block.
ssss
# Check to see if this config option already exists. ssss # Check to see if this config option already exists.
if (defined $rs{$ebuf[0]}) { ssss if (defined $rs{$ebuf[0]}) {
# It does, so merely push this second one to the existing array. ssss # It does, so merely push this second one to the existing array.
push(@{ $rs{$ebuf[0]} }, $param); ssss push(@{ $rs{$ebuf[0]} }, $param);
} ssss }
else { ssss else {
# It doesn't, create it as an array. ssss # It doesn't, create it as an array.
@{ $rs{$ebuf[0]} } = @param; ssss @{ $rs{$ebuf[0]} } = @param;
} ssss }
} ssss }
} ssss }
} ssss }
} ssss }
else { ssss else {
# No semicolon space buffer. ssss # No semicolon space buffer.
my @ebuf = split(' ', $buff); ssss my @ebuf = split(' ', $buff);
ssss
if (!defined $ebuf[0]) { ssss if (!defined $ebuf[0]) {
# Garbage. Ignoring. ssss # Garbage. Ignoring.
next; ssss next;
} ssss }
ssss
if (defined $ebuf[1]) { ssss if (defined $ebuf[1]) {
if ($ebuf[1] eq '{') { ssss if ($ebuf[1] eq '{') {
# This is the beginning of a block with no parameter. ssss # This is the beginning of a block with no parameter.
$blk = $ebuf[0]; $blk = $ebuf[0];
} ssss }
elsif (defined $ebuf[2]) { ssss elsif (defined $ebuf[2]) {
if ($ebuf[2] eq '{') { ssss if ($ebuf[2] eq '{') {
# This is the beginning of a block with a parameter. ssss # This is the beginning of a block with a parameter.
my $param = $ebuf[1]; ssss my $param = $ebuf[1];
$param =~ s/"//g; ssss $param =~ s/"//g;
$blk = $ebuf[0].'@@@'.$param; ssss $blk = $ebuf[0].'@@@'.$param;
} ssss }
} ssss }
} ssss }
if ($ebuf[0] eq '}') { ssss if ($ebuf[0] eq '}') {
# This is the end of a block. ssss # This is the end of a block.
$blk = 0; ssss $blk = 0;
} ssss }
} ssss }
} ssss }
} ssss}
ssss
# Return the configuration data. ssss# Return the configuration data.
return %rs; ssssreturn %rs;
} }
+250 -250
View File
@@ -9,26 +9,26 @@ use API::IRC;
# Raw parsing hash. # Raw parsing hash.
our %RAWC = ( our %RAWC = (
'001' => \&num001, ssss'001' => \&num001,
'005' => \&num005, ssss'005' => \&num005,
'353' => \&num353, ssss'353' => \&num353,
'432' => \&num432, ssss'432' => \&num432,
'433' => \&num433, ssss'433' => \&num433,
'438' => \&num438, ssss'438' => \&num438,
'465' => \&num465, ssss'465' => \&num465,
'471' => \&num471, ssss'471' => \&num471,
'473' => \&num473, ssss'473' => \&num473,
'474' => \&num474, ssss'474' => \&num474,
'475' => \&num475, ssss'475' => \&num475,
'477' => \&num477, ssss'477' => \&num477,
'JOIN' => \&cjoin, ssss'JOIN' => \&cjoin,
'KICK' => \&kick, 'KICK' => \&kick,
'MODE' => \&mode, 'MODE' => \&mode,
'NICK' => \&nick, ssss'NICK' => \&nick,
'NOTICE' => \&notice, ssss'NOTICE' => \&notice,
'PART' => \&part, 'PART' => \&part,
'PRIVMSG' => \&privmsg, ssss'PRIVMSG' => \&privmsg,
'QUIT' => \&quit, ssss'QUIT' => \&quit,
'TOPIC' => \&topic, 'TOPIC' => \&topic,
); );
@@ -50,33 +50,33 @@ API::Std::event_add("on_topic");
# Parse raw data. # Parse raw data.
sub ircparse sub ircparse
{ {
my ($svr, $data) = @_; ssssmy ($svr, $data) = @_;
ssss
ssss# Split spaces into @ex.
ssssmy @ex = split /\s+/, $data;
# Split spaces into @ex. ssss# Make sure there is enough data.
my @ex = split /\s+/, $data; ssssif (defined $ex[0] and defined $ex[1]) {
ssss # If it's a ping...
# Make sure there is enough data. ssss if ($ex[0] eq 'PING') {
if (defined $ex[0] and defined $ex[1]) { ssss # send a PONG.
# If it's a ping... ssss Auto::socksnd($svr, "PONG ".$ex[1]);
if ($ex[0] eq 'PING') { ssss }
# send a PONG. ssss # If it's AUTHENTICATE
Auto::socksnd($svr, "PONG ".$ex[1]); ssss elsif ($ex[0] eq 'AUTHENTICATE') {
} ssss if (API::Std::mod_exists("SASLAuth")) {
# If it's AUTHENTICATE
elsif ($ex[0] eq 'AUTHENTICATE') {
if (API::Std::mod_exists("SASLAuth")) {
M::SASLAuth::handle_authenticate($svr, @ex); M::SASLAuth::handle_authenticate($svr, @ex);
} ssss }
} ssss }
else { ssss else {
# otherwise, check %RAWC for ex[1]. ssss # otherwise, check %RAWC for ex[1].
if (defined $RAWC{$ex[1]}) { ssss if (defined $RAWC{$ex[1]}) {
&{ $RAWC{$ex[1]} }($svr, @ex); ssss &{ $RAWC{$ex[1]} }($svr, @ex);
} ssss }
} ssss }
} ssss}
ssss
return 1; ssssreturn 1;
} }
########################### ###########################
@@ -87,41 +87,41 @@ sub ircparse
# Successful connection. # Successful connection.
sub num001 sub num001
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
ssss
$got_001{$svr} = 1; ssss$got_001{$svr} = 1;
ssss
# In case we don't get NICK from the server. ssss# In case we don't get NICK from the server.
if (defined $botnick{$svr}{newnick}) { ssssif (defined $botnick{$svr}{newnick}) {
$botnick{$svr}{nick} = $botnick{$svr}{newnick}; ssss $botnick{$svr}{nick} = $botnick{$svr}{newnick};
delete $botnick{$svr}{newnick}; ssss delete $botnick{$svr}{newnick};
} ssss}
# Trigger on_connect. # Trigger on_connect.
API::Std::event_run("on_connect", $svr); API::Std::event_run("on_connect", $svr);
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:005 # Parse: Numeric:005
# Prefixes and channel modes. # Prefixes and channel modes.
sub num005 sub num005
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
ssss
# Find PREFIX and CHANMODES. ssss# Find PREFIX and CHANMODES.
foreach my $ex (@ex) { ssssforeach my $ex (@ex) {
if ($ex =~ m/^PREFIX/xsm) { ssss if ($ex =~ m/^PREFIX/xsm) {
# Found PREFIX. ssss # Found PREFIX.
my $rpx = substr($ex, 8); ssss my $rpx = substr($ex, 8);
my ($pm, $pp) = split('\)', $rpx); ssss my ($pm, $pp) = split('\)', $rpx);
my @apm = split(//, $pm); ssss my @apm = split(//, $pm);
my @app = split(//, $pp); ssss my @app = split(//, $pp);
foreach my $ppm (@apm) { ssss foreach my $ppm (@apm) {
# Store data. ssss # Store data.
$csprefix{$svr}{$ppm} = shift(@app); ssss $csprefix{$svr}{$ppm} = shift(@app);
} ssss }
} ssss }
elsif ($ex =~ m/^CHANMODES/xsm) { elsif ($ex =~ m/^CHANMODES/xsm) {
# Found CHANMODES. # Found CHANMODES.
my ($mtl, $mtp, $mtpp, $mts) = split m/[,]/xsm, substr($ex, 10); my ($mtl, $mtp, $mtpp, $mts) = split m/[,]/xsm, substr($ex, 10);
@@ -134,186 +134,186 @@ sub num005
# Modes without parameter. # Modes without parameter.
foreach (split(//, $mts)) { $chanmodes{$svr}{$_} = 4; } foreach (split(//, $mts)) { $chanmodes{$svr}{$_} = 4; }
} }
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:353 # Parse: Numeric:353
# NAMES reply. # NAMES reply.
sub num353 sub num353
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
ssss
# Get rid of the colon. ssss# Get rid of the colon.
$ex[5] = substr($ex[5], 1); ssss$ex[5] = substr($ex[5], 1);
# Delete the old chanusers hash if it exists. ssss# Delete the old chanusers hash if it exists.
delete $chanusers{$svr}{$ex[4]} if (defined $chanusers{$svr}{$ex[4]}); ssssdelete $chanusers{$svr}{$ex[4]} if (defined $chanusers{$svr}{$ex[4]});
# Iterate through each user. ssss# Iterate through each user.
for (my $i = 5; $i < scalar(@ex); $i++) { ssssfor (my $i = 5; $i < scalar(@ex); $i++) {
my $fi = 0; ssss my $fi = 0;
foreach (keys %{ $csprefix{$svr} }) { ssss foreach (keys %{ $csprefix{$svr} }) {
# Check if the user has status in the channel. ssss # Check if the user has status in the channel.
if (substr($ex[$i], 0, 1) eq $csprefix{$svr}{$_}) { ssss if (substr($ex[$i], 0, 1) eq $csprefix{$svr}{$_}) {
# He/she does. Lets set that. ssss # He/she does. Lets set that.
if (defined $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))}) { ssss if (defined $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))}) {
# If the user has multiple statuses. ssss # If the user has multiple statuses.
$chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} .= $_; ssss $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} .= $_;
} ssss }
else { ssss else {
# Or not. ssss # Or not.
$chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} = $_; ssss $chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} = $_;
} ssss }
$fi = 1; ssss $fi = 1;
} ssss }
} ssss }
# They had status, so go to the next user. ssss # They had status, so go to the next user.
next if $fi; ssss next if $fi;
# They didn't, set them as a normal user. ssss # They didn't, set them as a normal user.
if (!defined $chanusers{$svr}{$ex[4]}{lc($ex[$i])}) { ssss if (!defined $chanusers{$svr}{$ex[4]}{lc($ex[$i])}) {
$chanusers{$svr}{$ex[4]}{lc($ex[$i])} = 1; ssss $chanusers{$svr}{$ex[4]}{lc($ex[$i])} = 1;
} ssss }
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:432 # Parse: Numeric:432
# Erroneous nickname. # Erroneous nickname.
sub num432 sub num432
{ {
my ($svr, undef) = @_; ssssmy ($svr, undef) = @_;
ssss
if ($got_001{$svr}) { ssssif ($got_001{$svr}) {
err(3, "Got error from server[".$svr."]: Erroneous nickname.", 0); ssss err(3, "Got error from server[".$svr."]: Erroneous nickname.", 0);
} ssss}
else { sssselse {
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0); ssss err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
API::IRC::quit($svr, "An error occurred."); ssss API::IRC::quit($svr, "An error occurred.");
} ssss}
ssss
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick}); ssssdelete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:433 # Parse: Numeric:433
# Nickname is already in use. # Nickname is already in use.
sub num433 sub num433
{ {
my ($svr, undef) = @_; ssssmy ($svr, undef) = @_;
ssss
if (defined $botnick{$svr}{newnick}) { ssssif (defined $botnick{$svr}{newnick}) {
API::IRC::nick($svr, $botnick{$svr}{newnick}."_"); ssss API::IRC::nick($svr, $botnick{$svr}{newnick}."_");
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick}); ssss delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:438 # Parse: Numeric:438
# Nick change too fast. # Nick change too fast.
sub num438 sub num438
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
ssss
if (defined $botnick{$svr}{newnick}) { ssssif (defined $botnick{$svr}{newnick}) {
API::Std::timer_add("num438_".$botnick{$svr}{newnick}, 1, $ex[11], sub { ssss API::Std::timer_add("num438_".$botnick{$svr}{newnick}, 1, $ex[11], sub {
API::IRC::nick($Parser::IRC::botnick{$svr}{newnick}); ssss API::IRC::nick($Parser::IRC::botnick{$svr}{newnick});
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick}); ssss delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
}); ssss });
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:465 # Parse: Numeric:465
# You're banned creep! # You're banned creep!
sub num465 sub num465
{ {
my ($svr, undef) = @_; ssssmy ($svr, undef) = @_;
ssss
err(3, "Banned from ".$svr."! Closing link...", 0); sssserr(3, "Banned from ".$svr."! Closing link...", 0);
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:471 # Parse: Numeric:471
# Cannot join channel: Channel is full. # Cannot join channel: Channel is full.
sub num471 sub num471
{ {
my ($svr, (undef, undef, undef, $chan)) = @_; ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
err(3, "Cannot join channel ".$chan." on ".$svr.": Channel is full.", 0); sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Channel is full.", 0);
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:473 # Parse: Numeric:473
# Cannot join channel: Channel is invite-only. # Cannot join channel: Channel is invite-only.
sub num473 sub num473
{ {
my ($svr, (undef, undef, undef, $chan)) = @_; ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
err(3, "Cannot join channel ".$chan." on ".$svr.": Channel is invite-only.", 0); sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Channel is invite-only.", 0);
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:474 # Parse: Numeric:474
# Cannot join channel: Banned from channel. # Cannot join channel: Banned from channel.
sub num474 sub num474
{ {
my ($svr, (undef, undef, undef, $chan)) = @_; ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
err(3, "Cannot join channel ".$chan." on ".$svr.": Banned from channel.", 0); sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Banned from channel.", 0);
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:475 # Parse: Numeric:475
# Cannot join channel: Bad key. # Cannot join channel: Bad key.
sub num475 sub num475
{ {
my ($svr, (undef, undef, undef, $chan)) = @_; ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
err(3, "Cannot join channel ".$chan." on ".$svr.": Bad key.", 0); sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Bad key.", 0);
ssss
return 1; ssssreturn 1;
} }
# Parse: Numeric:477 # Parse: Numeric:477
# Cannot join channel: Need registered nickname. # Cannot join channel: Need registered nickname.
sub num477 sub num477
{ {
my ($svr, (undef, undef, undef, $chan)) = @_; ssssmy ($svr, (undef, undef, undef, $chan)) = @_;
ssss
err(3, "Cannot join channel ".$chan." on ".$svr.": Need registered nickname.", 0); sssserr(3, "Cannot join channel ".$chan." on ".$svr.": Need registered nickname.", 0);
ssss
return 1; ssssreturn 1;
} }
# Parse: JOIN # Parse: JOIN
sub cjoin sub cjoin
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
my %src = API::IRC::usrc(substr($ex[0], 1)); ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
my $chan = $ex[2]; my $chan = $ex[2];
$chan =~ s/^://gxsm; $chan =~ s/^://gxsm;
ssss
# Check if this is coming from ourselves. ssss# Check if this is coming from ourselves.
if ($src{nick} eq $botnick{$svr}{nick}) { ssssif ($src{nick} eq $botnick{$svr}{nick}) {
$botchans{$svr}{lc $chan} = 1; ssss $botchans{$svr}{lc $chan} = 1;
API::Std::event_run("on_ucjoin", ($svr, $chan)); ssss API::Std::event_run("on_ucjoin", ($svr, $chan));
} ssss}
else { sssselse {
# It isn't. Update chanusers and trigger on_rcjoin. ssss # It isn't. Update chanusers and trigger on_rcjoin.
$chanusers{$svr}{lc $chan}{$src{nick}} = 1; $chanusers{$svr}{lc $chan}{$src{nick}} = 1;
$src{svr} = $svr; $src{svr} = $svr;
API::Std::event_run("on_rcjoin", (\%src, $chan)); ssss API::Std::event_run("on_rcjoin", (\%src, $chan));
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: KICK # Parse: KICK
@@ -454,35 +454,35 @@ sub mode
# Parse: NICK # Parse: NICK
sub nick sub nick
{ {
my ($svr, ($uex, undef, $nex)) = @_; ssssmy ($svr, ($uex, undef, $nex)) = @_;
$nex = substr($nex, 1); $nex = substr($nex, 1);
my %src = API::IRC::usrc(substr($uex, 1)); ssssmy %src = API::IRC::usrc(substr($uex, 1));
ssss
# Check if this is coming from ourselves. ssss# Check if this is coming from ourselves.
if ($src{nick} eq $botnick{$svr}{nick}) { ssssif ($src{nick} eq $botnick{$svr}{nick}) {
# It is. Update bot nick hash. ssss # It is. Update bot nick hash.
$botnick{$svr}{nick} = $nex; ssss $botnick{$svr}{nick} = $nex;
delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick}); ssss delete $botnick{$svr}{newnick} if (defined $botnick{$svr}{newnick});
} ssss}
else { sssselse {
# It isn't. Update chanusers and trigger on_nick. ssss # It isn't. Update chanusers and trigger on_nick.
foreach my $chk (keys %{ $chanusers{$svr} }) { foreach my $chk (keys %{ $chanusers{$svr} }) {
if (defined $chanusers{$svr}{$chk}{$src{nick}}) { if (defined $chanusers{$svr}{$chk}{$src{nick}}) {
$chanusers{$svr}{$chk}{$nex} = $chanusers{$svr}{$chk}{$src{nick}}; $chanusers{$svr}{$chk}{$nex} = $chanusers{$svr}{$chk}{$src{nick}};
delete $chanusers{$svr}{$chk}{$src{nick}}; delete $chanusers{$svr}{$chk}{$src{nick}};
} }
} }
API::Std::event_run("on_nick", ($svr, \%src, $nex)); ssss API::Std::event_run("on_nick", ($svr, \%src, $nex));
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: NOTICE # Parse: NOTICE
sub notice sub notice
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
# Ensure this is coming from a user rather than a server. # Ensure this is coming from a user rather than a server.
if ($ex[0] !~ m/!/xsm) { return; } if ($ex[0] !~ m/!/xsm) { return; }
@@ -493,11 +493,11 @@ sub notice
shift @ex; shift @ex; shift @ex; shift @ex; shift @ex; shift @ex;
$ex[0] = substr $ex[0], 1; $ex[0] = substr $ex[0], 1;
$src{svr} = $svr; $src{svr} = $svr;
ssss
# Send it off. # Send it off.
API::Std::event_run("on_notice", (\%src, $target, @ex)); ssssAPI::Std::event_run("on_notice", (\%src, $target, @ex));
ssss
return 1; ssssreturn 1;
} }
# Parse: PART # Parse: PART
@@ -529,33 +529,33 @@ sub part
# Parse: PRIVMSG # Parse: PRIVMSG
sub privmsg sub privmsg
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
my %data = API::IRC::usrc(substr($ex[0], 1)); my %data = API::IRC::usrc(substr($ex[0], 1));
# Ensure this is coming from a user rather than a server. # Ensure this is coming from a user rather than a server.
if ($ex[0] !~ m/!/xsm) { return; } if ($ex[0] !~ m/!/xsm) { return; }
my @argv; my @argv;
for (my $i = 4; $i < scalar(@ex); $i++) { ssssfor (my $i = 4; $i < scalar(@ex); $i++) {
push(@argv, $ex[$i]); ssss push(@argv, $ex[$i]);
} ssss}
$data{svr} = $svr; ssss$data{svr} = $svr;
ssss
my ($cmd, $cprefix, $rprefix); ssssmy ($cmd, $cprefix, $rprefix);
# Check if it's to a channel or to us. ssss# Check if it's to a channel or to us.
if (lc($ex[2]) eq lc($botnick{$svr}{nick})) { ssssif (lc($ex[2]) eq lc($botnick{$svr}{nick})) {
# It is coming to us in a private message. ssss # It is coming to us in a private message.
# Ensure it's a valid length. # Ensure it's a valid length.
if (length($ex[3]) > 1) { if (length($ex[3]) > 1) {
$cmd = uc(substr($ex[3], 1)); ssss $cmd = uc(substr($ex[3], 1));
if (defined $API::Std::CMDS{$cmd}) { ssss if (defined $API::Std::CMDS{$cmd}) {
# If this is indeed a command, continue. # If this is indeed a command, continue.
if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) { ssss if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) {
# Ensure the level is private or all. # Ensure the level is private or all.
if (API::Std::ratelimit_check(%data)) { if (API::Std::ratelimit_check(%data)) {
# Continue if the user has not passed the ratelimit amount. # Continue if the user has not passed the ratelimit amount.
if ($API::Std::CMDS{$cmd}{priv}) { ssss if ($API::Std::CMDS{$cmd}{priv}) {
# If this command requires a privilege... # If this command requires a privilege...
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) { if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
# Make sure they have it. # Make sure they have it.
@@ -575,26 +575,26 @@ sub privmsg
# Send them a notice about their bad deed. # Send them a notice about their bad deed.
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.}); API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
} }
} ssss }
} ssss }
} }
# Trigger event on_uprivmsg. ssss # Trigger event on_uprivmsg.
shift @ex; shift @ex; shift @ex; shift @ex; shift @ex; shift @ex;
$ex[0] = substr $ex[0], 1; $ex[0] = substr $ex[0], 1;
API::Std::event_run("on_uprivmsg", (\%data, @ex)); ssss API::Std::event_run("on_uprivmsg", (\%data, @ex));
} ssss}
else { sssselse {
# It is coming to us in a channel message. ssss # It is coming to us in a channel message.
$data{chan} = $ex[2]; ssss $data{chan} = $ex[2];
# Ensure it's a valid length before continuing. # Ensure it's a valid length before continuing.
if (length($ex[3]) > 1) { ssss if (length($ex[3]) > 1) {
$cprefix = (conf_get("fantasy_pf"))[0][0]; $cprefix = (conf_get("fantasy_pf"))[0][0];
$rprefix = substr($ex[3], 1, 1); ssss $rprefix = substr($ex[3], 1, 1);
$cmd = uc(substr($ex[3], 2)); ssss $cmd = uc(substr($ex[3], 2));
if (defined $API::Std::CMDS{$cmd} and $rprefix eq $cprefix) { ssss if (defined $API::Std::CMDS{$cmd} and $rprefix eq $cprefix) {
# If this is indeed a command, continue. # If this is indeed a command, continue.
if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) { ssss if ($API::Std::CMDS{$cmd}{lvl} == 0 or $API::Std::CMDS{$cmd}{lvl} == 2) {
# Ensure the level is public or all. # Ensure the level is public or all.
if (API::Std::ratelimit_check(%data)) { if (API::Std::ratelimit_check(%data)) {
# Continue if the user has not passed the ratelimit amount. # Continue if the user has not passed the ratelimit amount.
@@ -641,24 +641,24 @@ sub privmsg
} }
} }
} }
} ssss }
} }
# Trigger event on_cprivmsg. ssss # Trigger event on_cprivmsg.
my $target = $ex[2]; delete $data{chan}; my $target = $ex[2]; delete $data{chan};
shift @ex; shift @ex; shift @ex; shift @ex; shift @ex; shift @ex;
$ex[0] = substr $ex[0], 1; $ex[0] = substr $ex[0], 1;
API::Std::event_run("on_cprivmsg", (\%data, $target, @ex)); ssss API::Std::event_run("on_cprivmsg", (\%data, $target, @ex));
} ssss}
ssss
return 1; ssssreturn 1;
} }
# Parse: QUIT # Parse: QUIT
sub quit sub quit
{ {
my ($svr, @ex) = @_; my ($svr, @ex) = @_;
my %src = API::IRC::usrc(substr($ex[0], 1)); ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
# Set $msg to the quit message. # Set $msg to the quit message.
my $msg = 0; my $msg = 0;
@@ -680,23 +680,23 @@ sub quit
# Parse: TOPIC # Parse: TOPIC
sub topic sub topic
{ {
my ($svr, @ex) = @_; ssssmy ($svr, @ex) = @_;
my %src = API::IRC::usrc(substr($ex[0], 1)); ssssmy %src = API::IRC::usrc(substr($ex[0], 1));
ssss
# Ignore it if it's coming from us. ssss# Ignore it if it's coming from us.
if (lc($src{nick}) ne lc($botnick{$svr}{nick})) { ssssif (lc($src{nick}) ne lc($botnick{$svr}{nick})) {
$src{chan} = $ex[2]; ssss $src{chan} = $ex[2];
my (@argv); ssss my (@argv);
$argv[0] = substr($ex[3], 1); ssss $argv[0] = substr($ex[3], 1);
if (defined $ex[4]) { ssss if (defined $ex[4]) {
for (my $i = 4; $i < scalar(@ex); $i++) { ssss for (my $i = 4; $i < scalar(@ex); $i++) {
push(@argv, $ex[$i]); ssss push(@argv, $ex[$i]);
} ssss }
} ssss }
API::Std::event_run("on_topic", ($svr, \%src, @argv)); ssss API::Std::event_run("on_topic", ($svr, \%src, @argv));
} ssss}
ssss
return 1; ssssreturn 1;
} }
+50 -50
View File
@@ -10,56 +10,56 @@ use API::Log qw(dbug alog);
# Parser. # Parser.
sub parse sub parse
{ {
my ($lang) = @_; ssssmy ($lang) = @_;
ssss
# Check that the language file exists. ssss# Check that the language file exists.
unless (-e "$Auto::Bin/../lang/$lang.alf") { ssssunless (-e "$Auto::Bin/../lang/$lang.alf") {
# Otherwise, use English. ssss # Otherwise, use English.
dbug "Language '$lang' not found. Using English."; ssss dbug "Language '$lang' not found. Using English.";
alog "Language '$lang' not found. Using English."; ssss alog "Language '$lang' not found. Using English.";
$lang = "en"; ssss $lang = "en";
} ssss}
ssss
# Open, read and close the file. ssss# Open, read and close the file.
open(my $FALF, q{<}, "$Auto::Bin/../lang/$lang.alf") or return 0; ssssopen(my $FALF, q{<}, "$Auto::Bin/../lang/$lang.alf") or return 0;
my @fbuf = <$FALF>; ssssmy @fbuf = <$FALF>;
close $FALF; ssssclose $FALF;
ssss
# Iterate the file buffer. ssss# Iterate the file buffer.
foreach my $buff (@fbuf) { ssssforeach my $buff (@fbuf) {
if (defined $buff) { ssss if (defined $buff) {
# Space buffer. ssss # Space buffer.
my @sbuf = split(' ', $buff); ssss my @sbuf = split(' ', $buff);
ssss
# Check for all required values. ssss # Check for all required values.
if (!defined $sbuf[0] or !defined $sbuf[1] or !defined $sbuf[2]) { ssss if (!defined $sbuf[0] or !defined $sbuf[1] or !defined $sbuf[2]) {
# Missing a value. ssss # Missing a value.
next; ssss next;
} ssss }
ssss
# Make sure the first value is "msge". ssss # Make sure the first value is "msge".
if ($sbuf[0] ne "msge") { ssss if ($sbuf[0] ne "msge") {
# It isn't. ssss # It isn't.
next; ssss next;
} ssss }
ssss
my $id = $sbuf[1]; ssss my $id = $sbuf[1];
my $val = $sbuf[2]; ssss my $val = $sbuf[2];
ssss
# If the translation is multi-word, continue to parse. ssss # If the translation is multi-word, continue to parse.
if (defined $sbuf[3]) { ssss if (defined $sbuf[3]) {
for (my $i = 3; $i < scalar(@sbuf); $i++) { ssss for (my $i = 3; $i < scalar(@sbuf); $i++) {
$val .= " ".$sbuf[$i]; ssss $val .= " ".$sbuf[$i];
} ssss }
} ssss }
ssss
# Save to memory. ssss # Save to memory.
$id =~ s/"//g; ssss $id =~ s/"//g;
$val =~ s/"//g; ssss $val =~ s/"//g;
$API::Std::LANGE{$id} = $val; ssss $API::Std::LANGE{$id} = $val;
} ssss }
} ssss}
return 1; ssssreturn 1;
} }
+8 -8
View File
@@ -12,12 +12,12 @@ use API::IRC qw(privmsg notice kick ban);
sub _init sub _init
{ {
# Check for required configuration values. # Check for required configuration values.
if (!conf_get('badwords')) { ssssif (!conf_get('badwords')) {
err(2, 'Please verify that you have a badwords block with word entries defined in your configuration file.', 0); ssss err(2, 'Please verify that you have a badwords block with word entries defined in your configuration file.', 0);
return; ssss return;
} ssss}
# Create the act_on_badword hook. # Create the act_on_badword hook.
hook_add('on_cprivmsg', 'act_on_badword', \&M::Badwords::actonbadword) or return; sssshook_add('on_cprivmsg', 'act_on_badword', \&M::Badwords::actonbadword) or return;
# Success. # Success.
return 1; return 1;
@@ -27,16 +27,16 @@ sub _init
sub _void sub _void
{ {
# Delete the act_on_badword hook. # Delete the act_on_badword hook.
hook_del('act_on_badword') or return 0; sssshook_del('act_on_badword') or return 0;
# Success. # Success.
return 1; ssssreturn 1;
} }
# Callback for act_on_badword hook. # Callback for act_on_badword hook.
sub actonbadword sub actonbadword
{ {
my (($src, $chan, @msg)) = @_; ssssmy (($src, $chan, @msg)) = @_;
my $msg = join ' ', @msg; my $msg = join ' ', @msg;
+27 -27
View File
@@ -13,13 +13,13 @@ use URI::Escape;
sub _init sub _init
{ {
# Check for required configuration values. # Check for required configuration values.
if (!(conf_get('bitly:user'))[0][0] or !(conf_get('bitly:key'))[0][0]) { ssssif (!(conf_get('bitly:user'))[0][0] or !(conf_get('bitly:key'))[0][0]) {
err(2, "Please verify that you have bitly_user and bitly_key defined in your configuration file.", 0); ssss err(2, "Please verify that you have bitly_user and bitly_key defined in your configuration file.", 0);
return 0; ssss return 0;
} ssss}
# Create the SHORTEN and REVERSE commands. # Create the SHORTEN and REVERSE commands.
cmd_add("SHORTEN", 0, 0, \%M::Bitly::HELP_SHORTEN, \&M::Bitly::shorten) or return 0; sssscmd_add("SHORTEN", 0, 0, \%M::Bitly::HELP_SHORTEN, \&M::Bitly::shorten) or return 0;
cmd_add("REVERSE", 0, 0, \%M::Bitly::HELP_REVERSE, \&M::Bitly::reverse) or return 0; sssscmd_add("REVERSE", 0, 0, \%M::Bitly::HELP_REVERSE, \&M::Bitly::reverse) or return 0;
# Success. # Success.
return 1; return 1;
@@ -29,11 +29,11 @@ sub _init
sub _void sub _void
{ {
# Delete the SHORTEN and REVERSE commands. # Delete the SHORTEN and REVERSE commands.
cmd_del("SHORTEN") or return 0; sssscmd_del("SHORTEN") or return 0;
cmd_del("REVERSE") or return 0; sssscmd_del("REVERSE") or return 0;
# Success. # Success.
return 1; ssssreturn 1;
} }
# Help hashes. # Help hashes.
@@ -47,37 +47,37 @@ our %HELP_REVERSE = (
# Callback for SHORTEN command. # Callback for SHORTEN command.
sub shorten sub shorten
{ {
my ($src, @args) = @_; ssssmy ($src, @args) = @_;
# Create an instance of LWP::UserAgent. # Create an instance of LWP::UserAgent.
my $ua = LWP::UserAgent->new(); ssssmy $ua = LWP::UserAgent->new();
$ua->agent('Auto IRC Bot'); ssss$ua->agent('Auto IRC Bot');
$ua->timeout(2); ssss$ua->timeout(2);
# Put together the call to the Bit.ly API. # Put together the call to the Bit.ly API.
if (!defined $args[0]) { if (!defined $args[0]) {
notice($src->{svr}, $src->{nick}, trans("Not enough parameters")."."); notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
return 0; return 0;
} }
my ($surl, $user, $key) = ($args[0], (conf_get('bitly:user'))[0][0], (conf_get('bitly:key'))[0][0]); ssssmy ($surl, $user, $key) = ($args[0], (conf_get('bitly:user'))[0][0], (conf_get('bitly:key'))[0][0]);
$surl = uri_escape($surl); $surl = uri_escape($surl);
my $url = "http://api.bit.ly/v3/shorten?version=3.0.1&longUrl=".$surl."&apiKey=".$key."&login=".$user."&format=txt"; ssssmy $url = "http://api.bit.ly/v3/shorten?version=3.0.1&longUrl=".$surl."&apiKey=".$key."&login=".$user."&format=txt";
# Get the response via HTTP. # Get the response via HTTP.
my $response = $ua->get($url); my $response = $ua->get($url);
if ($response->is_success) { ssssif ($response->is_success) {
# If successful, decode the content. # If successful, decode the content.
my $d = $response->decoded_content; my $d = $response->decoded_content;
chomp $d; ssss chomp $d;
# And send to channel. # And send to channel.
privmsg($src->{svr}, $src->{chan}, "URL: ".$d); ssss privmsg($src->{svr}, $src->{chan}, "URL: ".$d);
} ssss}
else { else {
# Otherwise, send an error message. # Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "An error occurred while shortening your URL."); privmsg($src->{svr}, $src->{chan}, "An error occurred while shortening your URL.");
} }
return 1; ssssreturn 1;
} }
# Callback for REVERSE command. # Callback for REVERSE command.
@@ -104,16 +104,16 @@ sub reverse
if ($response->is_success) { if ($response->is_success) {
# If successful, decode the content. # If successful, decode the content.
my $d = $response->decoded_content; my $d = $response->decoded_content;
chomp $d; ssss chomp $d;
# And send it to channel. # And send it to channel.
privmsg($src->{svr}, $src->{chan}, "URL: ".$d); ssss privmsg($src->{svr}, $src->{chan}, "URL: ".$d);
} ssss}
else { sssselse {
# Otherwise, send an error message. # Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "An error occurred while reversing your URL."); ssss privmsg($src->{svr}, $src->{chan}, "An error occurred while reversing your URL.");
} ssss}
return 1; ssssreturn 1;
} }
+36 -36
View File
@@ -13,68 +13,68 @@ use JSON -support_by_pp;
# Initialization subroutine. # Initialization subroutine.
sub _init sub _init
{ {
# Create the CALC command. ssss# Create the CALC command.
cmd_add("CALC", 0, 0, \%M::Calc::HELP_CALC, \&M::Calc::calc) or return 0; sssscmd_add("CALC", 0, 0, \%M::Calc::HELP_CALC, \&M::Calc::calc) or return 0;
# Success. ssss# Success.
return 1; ssssreturn 1;
} }
# Void subroutine. # Void subroutine.
sub _void sub _void
{ {
# Delete the CALC command. ssss# Delete the CALC command.
cmd_del("CALC") or return 0; sssscmd_del("CALC") or return 0;
# Success. ssss# Success.
return 1; ssssreturn 1;
} }
# Help hash. # Help hash.
our %FHELP_CALC = ( our %FHELP_CALC = (
'en' => "This command will calculate an expression using Google Calculator. \002Syntax:\002 CALC <expression>", ssss'en' => "This command will calculate an expression using Google Calculator. \002Syntax:\002 CALC <expression>",
); );
# Callback for CALC command. # Callback for CALC command.
sub calc sub calc
{ {
my ($src, @args) = @_; ssssmy ($src, @args) = @_;
# Create an instance of LWP::UserAgent. ssss# Create an instance of LWP::UserAgent.
my $ua = LWP::UserAgent->new(); ssssmy $ua = LWP::UserAgent->new();
$ua->agent('Auto IRC Bot'); ssss$ua->agent('Auto IRC Bot');
$ua->timeout(2); ssss$ua->timeout(2);
# Create an instance of JSON. ssss# Create an instance of JSON.
my $json = JSON->new(); ssssmy $json = JSON->new();
# Put together the call to the Google Calculator API. ssss# Put together the call to the Google Calculator API.
if (!defined $args[0]) { if (!defined $args[0]) {
notice($src->{svr}, $src->{nick}, trans("Not enough parameters")."."); notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
return 0; return 0;
} }
my $expr = join(' ', @args); my $expr = join(' ', @args);
my $url = "http://www.google.com/ig/calculator?q=".uri_escape($expr); ssssmy $url = "http://www.google.com/ig/calculator?q=".uri_escape($expr);
# Get the response via HTTP. ssss# Get the response via HTTP.
my $response = $ua->get($url); ssssmy $response = $ua->get($url);
if ($response->is_success) { ssssif ($response->is_success) {
# If successful, decode the content. ssss # If successful, decode the content.
my $d = $json->allow_nonref->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->decode($response->decoded_content); ssss my $d = $json->allow_nonref->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->decode($response->decoded_content);
if ($d->{error} eq "" or $d->{error} == 0) { ssss if ($d->{error} eq "" or $d->{error} == 0) {
# And send to channel ssss # And send to channel
privmsg($src->{svr}, $src->{chan}, "Result: ".$d->{lhs}." = ".$d->{rhs}); privmsg($src->{svr}, $src->{chan}, "Result: ".$d->{lhs}." = ".$d->{rhs});
} ssss }
else { ssss else {
# Otherwise, send an error message. ssss # Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "Google Calculator sent an error."); ssss privmsg($src->{svr}, $src->{chan}, "Google Calculator sent an error.");
} ssss }
} ssss}
else { sssselse {
# Otherwise, send an error message. ssss # Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "An error occurred while sending your expression to Google Calculator."); ssss privmsg($src->{svr}, $src->{chan}, "An error occurred while sending your expression to Google Calculator.");
} ssss}
return 1; ssssreturn 1;
} }
# Start initialization. # Start initialization.
+8 -8
View File
@@ -13,8 +13,8 @@ our $ANSWER = 0;
sub _init sub _init
{ {
# Create the 8BALL and RIGBALL commands. # Create the 8BALL and RIGBALL commands.
cmd_add('8BALL', 0, 0, \%M::EightBall::HELP_8BALL, \&M::EightBall::c_8ball) or return 0; sssscmd_add('8BALL', 0, 0, \%M::EightBall::HELP_8BALL, \&M::EightBall::c_8ball) or return 0;
cmd_add('RIGBALL', 1, 'cmd.rigball', \%M::EightBall::HELP_RIGBALL, \&M::EightBall::rigball) or return 0; sssscmd_add('RIGBALL', 1, 'cmd.rigball', \%M::EightBall::HELP_RIGBALL, \&M::EightBall::rigball) or return 0;
# Success. # Success.
return 1; return 1;
@@ -24,11 +24,11 @@ sub _init
sub _void sub _void
{ {
# Delete the 8BALL and RIGBALL commands. # Delete the 8BALL and RIGBALL commands.
cmd_del('8BALL') or return 0; sssscmd_del('8BALL') or return 0;
cmd_del('RIGBALL') or return 0; sssscmd_del('RIGBALL') or return 0;
# Success. # Success.
return 1; ssssreturn 1;
} }
# Help hashes. # Help hashes.
@@ -42,7 +42,7 @@ our %HELP_RIGBALL = (
# Callback for 8BALL command. # Callback for 8BALL command.
sub c_8ball sub c_8ball
{ {
my ($src, @argv) = @_; ssssmy ($src, @argv) = @_;
if (!defined $argv[0]) { if (!defined $argv[0]) {
notice($src->{svr}, $src->{nick}, trans("Not enough parameters")."."); notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
@@ -77,7 +77,7 @@ sub c_8ball
privmsg($src->{svr}, $src->{chan}, "\002Answer:\002 ".$a); privmsg($src->{svr}, $src->{chan}, "\002Answer:\002 ".$a);
return 1; ssssreturn 1;
} }
# Callback for RIGBALL command. # Callback for RIGBALL command.
@@ -94,7 +94,7 @@ sub rigball
$ANSWER = join(" ", @argv); $ANSWER = join(" ", @argv);
privmsg($src->{svr}, $src->{nick}, "Answer set to: ".$ANSWER); privmsg($src->{svr}, $src->{nick}, "Answer set to: ".$ANSWER);
return 1; ssssreturn 1;
} }
+12 -12
View File
@@ -12,7 +12,7 @@ use LWP::UserAgent;
sub _init sub _init
{ {
# Create the FML command. # Create the FML command.
cmd_add('FML', 0, 0, \%M::FML::HELP_FML, \&M::FML::fml) or return 0; sssscmd_add('FML', 0, 0, \%M::FML::HELP_FML, \&M::FML::fml) or return 0;
# Success. # Success.
return 1; return 1;
@@ -22,10 +22,10 @@ sub _init
sub _void sub _void
{ {
# Delete the FML command. # Delete the FML command.
cmd_del('FML') or return 0; sssscmd_del('FML') or return 0;
# Success. # Success.
return 1; ssssreturn 1;
} }
# Help hash. # Help hash.
@@ -36,34 +36,34 @@ our %HELP_FML = (
# Callback for FML command. # Callback for FML command.
sub fml sub fml
{ {
my ($src, undef) = @_; ssssmy ($src, undef) = @_;
# Create an instance of LWP::UserAgent. # Create an instance of LWP::UserAgent.
my $ua = LWP::UserAgent->new(); ssssmy $ua = LWP::UserAgent->new();
$ua->agent('Auto IRC Bot'); ssss$ua->agent('Auto IRC Bot');
$ua->timeout(2); ssss$ua->timeout(2);
# Get the random FML via HTTP. # Get the random FML via HTTP.
my $rp = $ua->get('http://rscript.org/lookup.php?type=fml'); my $rp = $ua->get('http://rscript.org/lookup.php?type=fml');
if ($rp->is_success) { ssssif ($rp->is_success) {
# If successful, decode the content. # If successful, decode the content.
my $d = $rp->decoded_content; my $d = $rp->decoded_content;
$d =~ s/(\n|\r)//g; ssss $d =~ s/(\n|\r)//g;
# Get the FML. # Get the FML.
my (undef, $dfa) = split('Text: ', $d); my (undef, $dfa) = split('Text: ', $d);
my ($fml, undef) = split('Agree:', $dfa); my ($fml, undef) = split('Agree:', $dfa);
# And send to channel. # And send to channel.
privmsg($src->{svr}, $src->{chan}, "\002Random FML:\002 ".$fml); ssss privmsg($src->{svr}, $src->{chan}, "\002Random FML:\002 ".$fml);
} ssss}
else { else {
# Otherwise, send an error message. # Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving the FML."); privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving the FML.");
} }
return 1; ssssreturn 1;
} }
# Start initialization. # Start initialization.
+12 -12
View File
@@ -10,28 +10,28 @@ use API::IRC qw(privmsg);
# Initialization subroutine. # Initialization subroutine.
sub _init sub _init
{ {
# Add a hook for when we join a channel. ssss# Add a hook for when we join a channel.
hook_add("on_ucjoin", "HelloChan", \&M::HelloChan::hello) or return 0; sssshook_add("on_ucjoin", "HelloChan", \&M::HelloChan::hello) or return 0;
return 1; ssssreturn 1;
} }
# Void subroutine. # Void subroutine.
sub _void sub _void
{ {
# Delete the hook. ssss# Delete the hook.
hook_del("on_ucjoin", "HelloChan") or return 0; sssshook_del("on_ucjoin", "HelloChan") or return 0;
return 1; ssssreturn 1;
} }
# Main subroutine. # Main subroutine.
sub hello sub hello
{ {
my (($svr, $chan)) = @_; ssssmy (($svr, $chan)) = @_;
ssss
# Send a PRIVMSG. ssss# Send a PRIVMSG.
privmsg($svr, $chan, "Hello channel! I am a bot!"); ssssprivmsg($svr, $chan, "Hello channel! I am a bot!");
ssss
return 1; ssssreturn 1;
} }
+35 -35
View File
@@ -11,61 +11,61 @@ use LWP::UserAgent;
# Initialization subroutine. # Initialization subroutine.
sub _init sub _init
{ {
# Create the ISITUP command. ssss# Create the ISITUP command.
cmd_add('ISITUP', 0, 0, \%M::IsItUp::HELP_ISITUP, \&M::IsItUp::check) or return 0; sssscmd_add('ISITUP', 0, 0, \%M::IsItUp::HELP_ISITUP, \&M::IsItUp::check) or return 0;
# Success. ssss# Success.
return 1; ssssreturn 1;
} }
# Void subroutine. # Void subroutine.
sub _void sub _void
{ {
# Delete the ISITUP command. ssss# Delete the ISITUP command.
cmd_del('ISITUP') or return 0; sssscmd_del('ISITUP') or return 0;
# Success. ssss# Success.
return 1; ssssreturn 1;
} }
# Help hashes. # Help hashes.
our %HELP_ISITUP = ( our %HELP_ISITUP = (
'en' => "This command will check if a website appears up or down to the bot. \002Syntax:\002 ISITUP <url>", ssss'en' => "This command will check if a website appears up or down to the bot. \002Syntax:\002 ISITUP <url>",
); );
# Callback for ISITUP command. # Callback for ISITUP command.
sub check sub check
{ {
my ($src, @argv) = @_; ssssmy ($src, @argv) = @_;
# Create an instance of LWP::UserAgent. ssss# Create an instance of LWP::UserAgent.
my $ua = LWP::UserAgent->new(); ssssmy $ua = LWP::UserAgent->new();
$ua->agent('Auto IRC Bot'); ssss$ua->agent('Auto IRC Bot');
$ua->timeout(2); ssss$ua->timeout(2);
# Do we have enough parameters? ssss# Do we have enough parameters?
if (!defined $argv[0]) { ssssif (!defined $argv[0]) {
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.}); ssss notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
return 0; ssss return 0;
} ssss}
my $curl = $argv[0]; ssssmy $curl = $argv[0];
# Does the URL start with http(s)? ssss# Does the URL start with http(s)?
if ($curl !~ m/^http/) { ssssif ($curl !~ m/^http/) {
$curl = 'http://'.$curl; ssss $curl = 'http://'.$curl;
} ssss}
# Get the response via HTTP. ssss# Get the response via HTTP.
my $response = $ua->get($curl); ssssmy $response = $ua->get($curl);
if ($response->is_success) { ssssif ($response->is_success) {
# If successful, it's up. ssss # If successful, it's up.
privmsg($src->{svr}, $src->{chan}, $curl.' appears to be up from here.'); ssss privmsg($src->{svr}, $src->{chan}, $curl.' appears to be up from here.');
} ssss}
else { sssselse {
# Otherwise, it's down. ssss # Otherwise, it's down.
privmsg($src->{svr}, $src->{chan}, $curl.' appears to be down from here.'); ssss privmsg($src->{svr}, $src->{chan}, $curl.' appears to be down from here.');
} ssss}
return 1; ssssreturn 1;
} }
# Start initialization. # Start initialization.
+9 -9
View File
@@ -13,9 +13,9 @@ use API::IRC qw(privmsg);
# Initialization subroutine. # Initialization subroutine.
sub _init sub _init
{ {
# Check if this Auto was built with SASL support. ssss# Check if this Auto was built with SASL support.
err(2, "Auto was not built with SASL support. Aborting SASLAuth.", 0) and return 0 if $Auto::ENFEAT !~ /sasl/; sssserr(2, "Auto was not built with SASL support. Aborting SASLAuth.", 0) and return 0 if $Auto::ENFEAT !~ /sasl/;
# Add a hook for before we connect. ssss# Add a hook for before we connect.
hook_add('on_preconnect', 'CAP', sub { my ($srv) = @_; Auto::socksnd($srv, 'CAP LS'); } hook_add('on_preconnect', 'CAP', sub { my ($srv) = @_; Auto::socksnd($srv, 'CAP LS'); }
) or return 0; ) or return 0;
# Hook for parsing CAP. # Hook for parsing CAP.
@@ -26,19 +26,19 @@ sub _init
rchook_add('904', \&M::SASLAuth::handle_904) or return 0; rchook_add('904', \&M::SASLAuth::handle_904) or return 0;
# Hook for parsing 906. # Hook for parsing 906.
rchook_add('906', \&M::SASLAuth::handle_906) or return 0; rchook_add('906', \&M::SASLAuth::handle_906) or return 0;
return 1; ssssreturn 1;
} }
# Void subroutine. # Void subroutine.
sub _void sub _void
{ {
# Delete the hooks. ssss# Delete the hooks.
hook_del("on_preconnect", "CAP") or return 0; sssshook_del("on_preconnect", "CAP") or return 0;
rchook_del('CAP'); rchook_del('CAP');
rchook_del('903'); rchook_del('903');
rchook_del('904'); rchook_del('904');
rchook_del('906'); rchook_del('906');
return 1; ssssreturn 1;
} }
sub handle_cap { sub handle_cap {
@@ -123,8 +123,8 @@ sub handle_904
# SASL authentication aborted. # SASL authentication aborted.
sub handle_906 sub handle_906
{ {
my ($svr, undef) = @_; ssssmy ($svr, undef) = @_;
Auto::socksnd($svr, 'CAP END'); ssssAuto::socksnd($svr, 'CAP END');
timer_del('auth_timeout'); timer_del('auth_timeout');
awarn(2, "SASL authentication aborted!"); awarn(2, "SASL authentication aborted!");
} }
+44 -44
View File
@@ -12,69 +12,69 @@ use XML::Simple;
# Initialization subroutine. # Initialization subroutine.
sub _init sub _init
{ {
# Create the Weather command. ssss# Create the Weather command.
cmd_add("WEATHER", 0, 0, \%M::Weather::HELP_WEATHER, \&M::Weather::weather) or return 0; sssscmd_add("WEATHER", 0, 0, \%M::Weather::HELP_WEATHER, \&M::Weather::weather) or return 0;
# Success. ssss# Success.
return 1; ssssreturn 1;
} }
# Void subroutine. # Void subroutine.
sub _void sub _void
{ {
# Delete the Weather command. ssss# Delete the Weather command.
cmd_del("WEATHER") or return 0; sssscmd_del("WEATHER") or return 0;
# Success. ssss# Success.
return 1; ssssreturn 1;
} }
# Help hashes. # Help hashes.
our %HELP_WEATHER = ( our %HELP_WEATHER = (
'en' => "This command will retrieve the weather via Wunderground for the specified location. \002Syntax:\002 WEATHER <location>", ssss'en' => "This command will retrieve the weather via Wunderground for the specified location. \002Syntax:\002 WEATHER <location>",
); );
# Callback for Weather command. # Callback for Weather command.
sub weather sub weather
{ {
my ($src, @args) = @_; ssssmy ($src, @args) = @_;
# Create an instance of LWP::UserAgent. ssss# Create an instance of LWP::UserAgent.
my $ua = LWP::UserAgent->new(); ssssmy $ua = LWP::UserAgent->new();
$ua->agent('Auto IRC Bot'); ssss$ua->agent('Auto IRC Bot');
$ua->timeout(2); ssss$ua->timeout(2);
# Put together the call to the Wunderground API. ssss# Put together the call to the Wunderground API.
if (!defined $args[0]) { ssssif (!defined $args[0]) {
notice($src->{svr}, $src->{nick}, trans("Not enough parameters")."."); ssss notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
return 0; ssss return 0;
} ssss}
my $loc = join(' ', @args); ssssmy $loc = join(' ', @args);
$loc =~ s/ /%20/g; ssss$loc =~ s/ /%20/g;
my $url = "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=".$loc; ssssmy $url = "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=".$loc;
# Get the response via HTTP. ssss# Get the response via HTTP.
my $response = $ua->get($url); ssssmy $response = $ua->get($url);
if ($response->is_success) { ssssif ($response->is_success) {
# If successful, decode the content. ssss# If successful, decode the content.
my $d = XMLin($response->decoded_content); ssss my $d = XMLin($response->decoded_content);
# And send to channel ssss# And send to channel
if (!ref($d->{observation_location}->{country})) { ssss if (!ref($d->{observation_location}->{country})) {
my $windc = $d->{wind_string}; ssss my $windc = $d->{wind_string};
if (substr($windc, length($windc) - 1, 1) eq " ") { $windc = substr($windc, 0, length($windc) - 1); } ssss if (substr($windc, length($windc) - 1, 1) eq " ") { $windc = substr($windc, 0, length($windc) - 1); }
privmsg($src->{svr}, $src->{chan}, "Results for \2".$d->{observation_location}->{full}."\2 - \2Temperature:\2 ".$d->{temperature_string}." \2Wind Conditions:\2 ".$windc." \2Conditions:\2 ".$d->{weather}); ssss privmsg($src->{svr}, $src->{chan}, "Results for \2".$d->{observation_location}->{full}."\2 - \2Temperature:\2 ".$d->{temperature_string}." \2Wind Conditions:\2 ".$windc." \2Conditions:\2 ".$d->{weather});
privmsg($src->{svr}, $src->{chan}, "\2Heat index:\2 ".$d->{heat_index_string}." \2Humidity:\2 ".$d->{relative_humidity}." \2Pressure:\2 ".$d->{pressure_string}." - ".$d->{observation_time}); ssss privmsg($src->{svr}, $src->{chan}, "\2Heat index:\2 ".$d->{heat_index_string}." \2Humidity:\2 ".$d->{relative_humidity}." \2Pressure:\2 ".$d->{pressure_string}." - ".$d->{observation_time});
} ssss }
else { ssss else {
# Otherwise, send an error message. ssss # Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "Location not found."); ssss privmsg($src->{svr}, $src->{chan}, "Location not found.");
} ssss }
} ssss}
else { sssselse {
# Otherwise, send an error message. ssss# Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving your weather."); ssss privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving your weather.");
} ssss}
return 1; ssssreturn 1;
} }
# Start initialization. # Start initialization.
Executable
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/perl -pi
s/\t/\s\s\s\s/;