Removing hard tabs.

This commit is contained in:
Elijah Perrault committed 2011-03-18 13:55:50 -06:00
1 parent 502cda97ed
commit 374b04fddc
3 files changed
+139 -139

No files matched your search

+8 -8
View File
@@ -60,10 +60,10 @@ sub cpart {
my ($svr, $chan, $reason) = @_; my ($svr, $chan, $reason) = @_;
if (defined $reason) { if (defined $reason) {
Auto::socksnd($svr, "PART $chan :$reason"); Auto::socksnd($svr, "PART $chan :$reason");
} }
else { else {
Auto::socksnd($svr, "PART $chan :Leaving"); Auto::socksnd($svr, "PART $chan :Leaving");
} }
return 1; return 1;
@@ -173,10 +173,10 @@ sub quit {
my ($svr, $reason) = @_; my ($svr, $reason) = @_;
if (defined $reason) { if (defined $reason) {
Auto::socksnd($svr, "QUIT :$reason"); Auto::socksnd($svr, "QUIT :$reason");
} }
else { else {
Auto::socksnd($svr, 'QUIT :Leaving'); Auto::socksnd($svr, 'QUIT :Leaving');
} }
# Trigger on_disconnect. # Trigger on_disconnect.
@@ -202,9 +202,9 @@ sub usrc {
my @sii = split m/[@]/xsm, $si[1]; my @sii = split m/[@]/xsm, $si[1];
return ( return (
nick => $si[0], nick => $si[0],
user => $sii[0], user => $sii[0],
host => $sii[1] host => $sii[1]
); );
} }
@@ -220,7 +220,7 @@ sub match_mask {
# Let's grep the user's mask. # Let's grep the user's mask.
if ($mu =~ m/$mh/xsm) { if ($mu =~ m/$mh/xsm) {
return 1; return 1;
} }
return; return;
+19 -19
View File
@@ -21,7 +21,7 @@ sub println
my ($out) = @_; my ($out) = @_;
if (!defined $out) { if (!defined $out) {
print $RS; print $RS;
} }
else { else {
print $out.$RS; print $out.$RS;
@@ -36,8 +36,8 @@ sub dbug
my ($out) = @_; my ($out) = @_;
if ($Auto::DEBUG) { if ($Auto::DEBUG) {
# We're in debug mode; print it out. # We're in debug mode; print it out.
say $out; say $out;
} }
return 1; return 1;
@@ -57,7 +57,7 @@ sub alog
# Create var/ if it doesn't exist. # Create var/ if it doesn't exist.
if (!-d "$Auto::bin{var}") { if (!-d "$Auto::bin{var}") {
mkdir "$Auto::bin{var}", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) mkdir "$Auto::bin{var}", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
} }
# Open the logfile, print the log message to it and close it. # Open the logfile, print the log message to it and close it.
@@ -76,29 +76,29 @@ sub expire_logs
# Check for invalid values. # Check for invalid values.
if ($celog =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($celog =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
# Must be numbers only. # Must be numbers only.
return; return;
} }
elsif (!$celog) { elsif (!$celog) {
# No expire. # No expire.
return; return;
} }
# Iterate through each logfile. # Iterate through each logfile.
foreach my $file (glob fpfmt("$Auto::bin{var}/*")) { foreach my $file (glob fpfmt("$Auto::bin{var}/*")) {
my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit) my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit)
# Convert filename to UNIX time. # Convert filename to UNIX time.
my $yyyy = substr $file, 0, 4; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) my $yyyy = substr $file, 0, 4; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
my $mm = substr $file, 4, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) my $mm = substr $file, 4, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
$mm = $mm - 1; $mm = $mm - 1;
my $dd = substr $file, 6, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) my $dd = substr $file, 6, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy); my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy);
# If it's older than <config_value> days, delete it. # If it's older than <config_value> days, delete it.
if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers) if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
unlink "$Auto::bin{var}/$file"; unlink "$Auto::bin{var}/$file";
} }
} }
return 1; return 1;
+112 -112
View File
@@ -11,8 +11,8 @@ use base qw(Exporter);
our (%LANGE, %MODULE, %EVENTS, %HOOKS, %CMDS, %RAWHOOKS); our (%LANGE, %MODULE, %EVENTS, %HOOKS, %CMDS, %RAWHOOKS);
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 cmd_del hook_add hook_del rchook_add rchook_del match_user
has_priv mod_exists ratelimit_check fpfmt); has_priv mod_exists ratelimit_check fpfmt);
# Initialize a module. # Initialize a module.
@@ -26,35 +26,35 @@ sub mod_init {
# Check if this module is compatible with this version of Auto. # Check if this module is compatible with this version of Auto.
if ($autover !~ m/^3\.0\.0a(7|8)$/xsm) { if ($autover !~ m/^3\.0\.0a(7|8)$/xsm) {
API::Log::dbug('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.'); 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.'); 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; return;
} }
# Run the module's _init sub. # 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) { if ($mi) {
# If successful, add to hash. # If successful, add to hash.
$MODULE{$name}{name} = $name; $MODULE{$name}{name} = $name;
$MODULE{$name}{version} = $version; $MODULE{$name}{version} = $version;
$MODULE{$name}{author} = $author; $MODULE{$name}{author} = $author;
$MODULE{$name}{pkg} = $pkg; $MODULE{$name}{pkg} = $pkg;
API::Log::dbug('MODULES: '.$name.' successfully loaded.'); API::Log::dbug('MODULES: '.$name.' successfully loaded.');
API::Log::alog('MODULES: '.$name.' successfully loaded.'); 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; return 1;
} }
else { else {
# Otherwise, return a failed to load message. # Otherwise, return a failed to load message.
API::Log::dbug('MODULES: Failed to load '.$name.q{.}); API::Log::dbug('MODULES: Failed to load '.$name.q{.});
API::Log::alog('MODULES: Failed to load '.$name.q{.}); 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; return;
} }
} }
@@ -78,30 +78,30 @@ sub mod_void {
# Check if this module exists. # Check if this module exists.
if (!defined $MODULE{$module}) { if (!defined $MODULE{$module}) {
API::Log::dbug('MODULES: Failed to unload '.$module.'. No such module?'); API::Log::dbug('MODULES: Failed to unload '.$module.'. No such module?');
API::Log::alog('MODULES: Failed to unload '.$module.'. No such module?'); 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; return;
} }
# Run the module's _void sub. # 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) { if ($mi) {
# If successful, delete class from program and delete module from hash. # If successful, delete class from program and delete module from hash.
Class::Unload->unload($MODULE{$module}{pkg}); Class::Unload->unload($MODULE{$module}{pkg});
delete $MODULE{$module}; delete $MODULE{$module};
API::Log::dbug('MODULES: Successfully unloaded '.$module.q{.}); API::Log::dbug('MODULES: Successfully unloaded '.$module.q{.});
API::Log::alog('MODULES: Successfully unloaded '.$module.q{.}); 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; return 1;
} }
else { else {
# Otherwise, return a failed to unload message. # Otherwise, return a failed to unload message.
API::Log::dbug('MODULES: Failed to unload '.$module.q{.}); API::Log::dbug('MODULES: Failed to unload '.$module.q{.});
API::Log::alog('MODULES: Failed to unload '.$module.q{.}); 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; return;
} }
} }
@@ -128,10 +128,10 @@ sub cmd_del {
$cmd = uc $cmd; $cmd = uc $cmd;
if (defined $API::Std::CMDS{$cmd}) { if (defined $API::Std::CMDS{$cmd}) {
delete $API::Std::CMDS{$cmd}; delete $API::Std::CMDS{$cmd};
} }
else { else {
return; return;
} }
return 1; return 1;
@@ -142,12 +142,12 @@ sub event_add {
my ($name) = @_; my ($name) = @_;
if (!defined $EVENTS{lc $name}) { if (!defined $EVENTS{lc $name}) {
$EVENTS{lc $name} = 1; $EVENTS{lc $name} = 1;
return 1; return 1;
} }
else { else {
API::Log::dbug('DEBUG: Attempt to add a pre-existing event ('.lc $name.')! Ignoring...'); API::Log::dbug('DEBUG: Attempt to add a pre-existing event ('.lc $name.')! Ignoring...');
return; return;
} }
} }
@@ -156,13 +156,13 @@ sub event_del {
my ($name) = @_; my ($name) = @_;
if (defined $EVENTS{lc $name}) { if (defined $EVENTS{lc $name}) {
delete $EVENTS{lc $name}; delete $EVENTS{lc $name};
delete $HOOKS{lc $name}; delete $HOOKS{lc $name};
return 1; return 1;
} }
else { else {
API::Log::dbug('DEBUG: Attempt to delete a non-existing event ('.lc $name.')! Ignoring...'); API::Log::dbug('DEBUG: Attempt to delete a non-existing event ('.lc $name.')! Ignoring...');
return; return;
} }
} }
@@ -171,10 +171,10 @@ sub event_run {
my ($event, @args) = @_; my ($event, @args) = @_;
if (defined $EVENTS{lc $event} and defined $HOOKS{lc $event}) { if (defined $EVENTS{lc $event} and defined $HOOKS{lc $event}) {
foreach my $hk (keys %{ $HOOKS{lc $event} }) { foreach my $hk (keys %{ $HOOKS{lc $event} }) {
my $ri = &{ $HOOKS{lc $event}{$hk} }(@args); my $ri = &{ $HOOKS{lc $event}{$hk} }(@args);
if ($ri == -1) { last; } if ($ri == -1) { last; }
} }
} }
return 1; return 1;
@@ -185,16 +185,16 @@ sub hook_add {
my ($event, $name, $sub) = @_; my ($event, $name, $sub) = @_;
if (!defined $API::Std::HOOKS{lc $name}) { if (!defined $API::Std::HOOKS{lc $name}) {
if (defined $API::Std::EVENTS{lc $event}) { if (defined $API::Std::EVENTS{lc $event}) {
$API::Std::HOOKS{lc $event}{lc $name} = $sub; $API::Std::HOOKS{lc $event}{lc $name} = $sub;
return 1; return 1;
} }
else { else {
return; return;
} }
} }
else { else {
return; return;
} }
} }
@@ -203,11 +203,11 @@ sub hook_del {
my ($event, $name) = @_; my ($event, $name) = @_;
if (defined $API::Std::HOOKS{lc $event}{lc $name}) { if (defined $API::Std::HOOKS{lc $event}{lc $name}) {
delete $API::Std::HOOKS{lc $event}{lc $name}; delete $API::Std::HOOKS{lc $event}{lc $name};
return 1; return 1;
} }
else { else {
return; return;
} }
} }
@@ -218,18 +218,18 @@ sub timer_add {
# Check for invalid type/time. # Check for invalid type/time.
if ($type =~ m/[^1-2]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($type =~ m/[^1-2]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; return;
} }
if ($time =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($time =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; return;
} }
if (!defined $Auto::TIMERS{$name}) { if (!defined $Auto::TIMERS{$name}) {
$Auto::TIMERS{$name}{type} = $type; $Auto::TIMERS{$name}{type} = $type;
$Auto::TIMERS{$name}{time} = time + $time; $Auto::TIMERS{$name}{time} = time + $time;
if ($type == 2) { $Auto::TIMERS{$name}{secs} = $time; } if ($type == 2) { $Auto::TIMERS{$name}{secs} = $time; }
$Auto::TIMERS{$name}{sub} = $sub; $Auto::TIMERS{$name}{sub} = $sub;
return 1; return 1;
} }
return 1; return 1;
@@ -241,8 +241,8 @@ sub timer_del {
$name = lc $name; $name = lc $name;
if (defined $Auto::TIMERS{$name}) { if (defined $Auto::TIMERS{$name}) {
delete $Auto::TIMERS{$name}; delete $Auto::TIMERS{$name};
return 1; return 1;
} }
return; return;
@@ -285,10 +285,10 @@ sub conf_get {
# Create an array out of the value. # Create an array out of the value.
my @val; my @val;
if ($value =~ m/:/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($value =~ m/:/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
@val = split m/[:]/sm, $value; ## no critic qw(RegularExpressions::RequireExtendedFormatting) @val = split m/[:]/sm, $value; ## no critic qw(RegularExpressions::RequireExtendedFormatting)
} }
else { else {
@val = ($value); @val = ($value);
} }
# Undefine this as it's unnecessary now. # Undefine this as it's unnecessary now.
undef $value; undef $value;
@@ -298,31 +298,31 @@ sub conf_get {
# Return the requested configuration value(s). # Return the requested configuration value(s).
if ($count == 1) { if ($count == 1) {
if (ref $Auto::SETTINGS{$val[0]} eq 'HASH') { if (ref $Auto::SETTINGS{$val[0]} eq 'HASH') {
return %{ $Auto::SETTINGS{$val[0]} }; return %{ $Auto::SETTINGS{$val[0]} };
} }
else { else {
return $Auto::SETTINGS{$val[0]}; return $Auto::SETTINGS{$val[0]};
} }
} }
elsif ($count == 2) { elsif ($count == 2) {
if (ref $Auto::SETTINGS{$val[0]}{$val[1]} eq 'HASH') { if (ref $Auto::SETTINGS{$val[0]}{$val[1]} eq 'HASH') {
return %{ $Auto::SETTINGS{$val[0]}{$val[1]} }; return %{ $Auto::SETTINGS{$val[0]}{$val[1]} };
} }
else { else {
return $Auto::SETTINGS{$val[0]}{$val[1]}; return $Auto::SETTINGS{$val[0]}{$val[1]};
} }
} }
elsif ($count == 3) { elsif ($count == 3) {
if (ref $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} eq 'HASH') { if (ref $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} eq 'HASH') {
return %{ $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} }; return %{ $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]} };
} }
else { else {
return $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]}; return $Auto::SETTINGS{$val[0]}{$val[1]}{$val[2]};
} }
} }
else { else {
return; return;
} }
} }
@@ -332,11 +332,11 @@ sub trans {
$id =~ s/ /_/gsm; $id =~ s/ /_/gsm;
if (defined $API::Std::LANGE{$id}) { if (defined $API::Std::LANGE{$id}) {
return sprintf $API::Std::LANGE{$id}, @_; return sprintf $API::Std::LANGE{$id}, @_;
} }
else { else {
$id =~ s/_/ /gsm; $id =~ s/_/ /gsm;
return $id; return $id;
} }
} }
@@ -349,12 +349,12 @@ sub match_user {
my %uhp = conf_get('user'); my %uhp = conf_get('user');
foreach my $userkey (keys %uhp) { foreach my $userkey (keys %uhp) {
# For each user block. # For each user block.
my %ulhp = %{ $uhp{$userkey} }; my %ulhp = %{ $uhp{$userkey} };
foreach my $uhk (keys %ulhp) { foreach my $uhk (keys %ulhp) {
# For each user. # For each user.
if ($uhk eq 'net') { 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.
@@ -363,13 +363,13 @@ sub match_user {
} }
} }
elsif ($uhk eq 'mask') { elsif ($uhk eq 'mask') {
# Put together the user information. # Put together the user information.
my $mask = $user{nick}.q{!}.$user{user}.q{@}.$user{host}; my $mask = $user{nick}.q{!}.$user{user}.q{@}.$user{host};
if (API::IRC::match_mask($mask, ($ulhp{$uhk})[0][0])) { if (API::IRC::match_mask($mask, ($ulhp{$uhk})[0][0])) {
# We've got a host match. # We've got a host match.
return $userkey; return $userkey;
} }
} }
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];
@@ -390,7 +390,7 @@ sub match_user {
} }
} }
} }
} }
} }
return; return;
@@ -401,13 +401,13 @@ sub has_priv {
my ($cuser, $cpriv) = @_; my ($cuser, $cpriv) = @_;
if (conf_get("user:$cuser:privs")) { if (conf_get("user:$cuser:privs")) {
my $cups = (conf_get("user:$cuser:privs"))[0][0]; my $cups = (conf_get("user:$cuser:privs"))[0][0];
if (defined $Auto::PRIVILEGES{$cups}) { if (defined $Auto::PRIVILEGES{$cups}) {
foreach (@{ $Auto::PRIVILEGES{$cups} }) { foreach (@{ $Auto::PRIVILEGES{$cups} }) {
if ($_ eq $cpriv or $_ eq 'ALL') { return 1; } if ($_ eq $cpriv or $_ eq 'ALL') { return 1; }
} }
} }
} }
return; return;
@@ -451,19 +451,19 @@ sub err { ## no critic qw(Subroutines::ProhibitBuiltinHomonyms)
# Check for an invalid level. # Check for an invalid level.
if ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; return;
} }
if ($fatal =~ m/[^0-1]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($fatal =~ m/[^0-1]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; return;
} }
# Level 1: Print to screen. # Level 1: Print to screen.
if ($lvl >= 1) { if ($lvl >= 1) {
say "ERROR: $msg"; say "ERROR: $msg";
} }
# Level 2: Log to file. # Level 2: Log to file.
if ($lvl >= 2) { if ($lvl >= 2) {
API::Log::alog("ERROR: $msg"); API::Log::alog("ERROR: $msg");
} }
# Level 3: Log to IRC. # Level 3: Log to IRC.
if ($lvl >= 3) { if ($lvl >= 3) {
@@ -485,7 +485,7 @@ sub awarn {
# Check for an invalid level. # Check for an invalid level.
if ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting) if ($lvl =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
return; return;
} }
# Level 1: Print to screen. # Level 1: Print to screen.
@@ -494,7 +494,7 @@ sub awarn {
} }
# Level 2: Log to file. # Level 2: Log to file.
if ($lvl >= 2) { if ($lvl >= 2) {
API::Log::alog("WARNING: $msg"); API::Log::alog("WARNING: $msg");
} }
# Level 3: Log to IRC. # Level 3: Log to IRC.
if ($lvl >= 3) { if ($lvl >= 3) {