Large amounts of code cleanup.
This commit is contained in:
1 parent
f2deae219d
commit
3e1e2e98be
18 files changed
+286
-243
No files matched your search
+4
-4
@@ -22,10 +22,10 @@ sub ban {
|
||||
# Prepare the mask we're going to ban.
|
||||
my $mask;
|
||||
given ($cbt) {
|
||||
when (1) { $mask = '*!*@'.$user->{host}; }
|
||||
when (2) { $mask = $user->{nick}.'!*@*'; }
|
||||
when (3) { $mask = q{*!}.$user->{user}.q{@}.$user->{host}; }
|
||||
when (4) { $mask = $user->{nick}.q{!*}.$user->{user}.q{@}.$user->{host}; }
|
||||
when (1) { $mask = '*!*@'.$user->{host} }
|
||||
when (2) { $mask = $user->{nick}.'!*@*' }
|
||||
when (3) { $mask = q{*!}.$user->{user}.q{@}.$user->{host} }
|
||||
when (4) { $mask = $user->{nick}.q{!*}.$user->{user}.q{@}.$user->{host} }
|
||||
when (5) {
|
||||
my @hd = split m/[\.]/, $user->{host};
|
||||
shift @hd;
|
||||
|
||||
+19
-19
@@ -22,13 +22,13 @@ sub mod_init {
|
||||
# Log/debug.
|
||||
API::Log::dbug('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...');
|
||||
API::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.
|
||||
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::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;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ sub mod_init {
|
||||
|
||||
API::Log::dbug('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;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ sub mod_init {
|
||||
# Otherwise, return a failed to load message.
|
||||
API::Log::dbug('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;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ sub mod_init {
|
||||
sub mod_exists {
|
||||
my ($name) = @_;
|
||||
|
||||
if (defined $API::Std::MODULE{$name}) { return 1; }
|
||||
if (defined $API::Std::MODULE{$name}) { return 1 }
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -74,13 +74,13 @@ sub mod_void {
|
||||
# Log/debug.
|
||||
API::Log::dbug('MODULES: Attempting to unload module: '.$module.'...');
|
||||
API::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.
|
||||
if (!defined $MODULE{$module}) {
|
||||
API::Log::dbug('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;
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ sub mod_void {
|
||||
delete $MODULE{$module};
|
||||
API::Log::dbug('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;
|
||||
}
|
||||
else {
|
||||
# Otherwise, return a failed to unload message.
|
||||
API::Log::dbug('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;
|
||||
}
|
||||
}
|
||||
@@ -110,8 +110,8 @@ sub cmd_add {
|
||||
my ($cmd, $lvl, $priv, $help, $sub) = @_;
|
||||
$cmd = uc $cmd;
|
||||
|
||||
if (defined $API::Std::CMDS{$cmd}) { return; }
|
||||
if ($lvl =~ m/[^0-3]/sm) { return; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
if (defined $API::Std::CMDS{$cmd}) { return }
|
||||
if ($lvl =~ m/[^0-3]/sm) { return } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
|
||||
$API::Std::CMDS{$cmd}{lvl} = $lvl;
|
||||
$API::Std::CMDS{$cmd}{help} = $help;
|
||||
@@ -173,7 +173,7 @@ sub event_run {
|
||||
if (defined $EVENTS{lc $event} and defined $HOOKS{lc $event}) {
|
||||
foreach my $hk (keys %{ $HOOKS{lc $event} }) {
|
||||
my $ri = &{ $HOOKS{lc $event}{$hk} }(@args);
|
||||
if ($ri == -1) { last; }
|
||||
if ($ri == -1) { last }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ sub timer_add {
|
||||
if (!defined $Auto::TIMERS{$name}) {
|
||||
$Auto::TIMERS{$name}{type} = $type;
|
||||
$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;
|
||||
return 1;
|
||||
}
|
||||
@@ -345,7 +345,7 @@ sub match_user {
|
||||
my (%user) = @_;
|
||||
|
||||
# Get data from config.
|
||||
if (!conf_get('user')) { return; }
|
||||
if (!conf_get('user')) { return }
|
||||
my %uhp = conf_get('user');
|
||||
|
||||
foreach my $userkey (keys %uhp) {
|
||||
@@ -376,14 +376,14 @@ sub match_user {
|
||||
if (defined $Auto::SOCKET{$svr}) {
|
||||
if ($ccnm eq 'CURRENT' and defined $user{chan}) {
|
||||
if (defined $State::IRC::chanusers{$svr}{$user{chan}}{$user{nick}}) {
|
||||
if ($State::IRC::chanusers{$svr}{$user{chan}}{$user{nick}} =~ m/($ccst)/sm) { return $userkey; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
if ($State::IRC::chanusers{$svr}{$user{chan}}{$user{nick}} =~ m/($ccst)/sm) { return $userkey } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach my $bcj (keys %{ $Proto::IRC::botchans{$svr} }) {
|
||||
if (API::IRC::match_mask($bcj, $ccnm)) {
|
||||
if (defined $State::IRC::chanusers{$svr}{$bcj}{$user{nick}}) {
|
||||
if ($State::IRC::chanusers{$svr}{$bcj}{$user{nick}} =~ m/($ccst)/sm) { return $userkey; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
if ($State::IRC::chanusers{$svr}{$bcj}{$user{nick}} =~ m/($ccst)/sm) { return $userkey } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,7 +405,7 @@ sub has_priv {
|
||||
|
||||
if (defined $Auto::PRIVILEGES{$cups}) {
|
||||
foreach (@{ $Auto::PRIVILEGES{$cups} }) {
|
||||
if ($_ eq $cpriv or $_ eq 'ALL') { return 1; }
|
||||
if ($_ eq $cpriv or $_ eq 'ALL') { return 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -508,8 +508,8 @@ sub awarn {
|
||||
sub fpfmt {
|
||||
my ($path) = @_;
|
||||
|
||||
if ($path =~ m/\s/xsm) { return "\"$path\""; }
|
||||
else { return $path; }
|
||||
if ($path =~ m/\s/xsm) { return "\"$path\"" }
|
||||
else { return $path }
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-5
@@ -33,7 +33,7 @@ hook_add("on_quit", "quit_update_chanusers", sub {
|
||||
|
||||
# Delete the user from all channels.
|
||||
foreach my $ccu (keys %{ $State::IRC::chanusers{$src{svr}}}) {
|
||||
if (defined $State::IRC::chanusers{$src{svr}}{$ccu}{$src{nick}}) { delete $State::IRC::chanusers{$src{svr}}{$ccu}{$src{nick}}; }
|
||||
if (defined $State::IRC::chanusers{$src{svr}}{$ccu}{$src{nick}}) { delete $State::IRC::chanusers{$src{svr}}{$ccu}{$src{nick}} }
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -158,13 +158,13 @@ hook_add('on_isupport', 'core.prefixchanmode.getdata', sub {
|
||||
# Found CHANMODES.
|
||||
my ($mtl, $mtp, $mtpp, $mts) = split m/[,]/xsm, substr($ex, 10);
|
||||
# List modes.
|
||||
foreach (split(//, $mtl)) { $Proto::IRC::chanmodes{$svr}{$_} = 1; }
|
||||
foreach (split(//, $mtl)) { $Proto::IRC::chanmodes{$svr}{$_} = 1 }
|
||||
# Modes with parameter.
|
||||
foreach (split(//, $mtp)) { $Proto::IRC::chanmodes{$svr}{$_} = 2; }
|
||||
foreach (split(//, $mtp)) { $Proto::IRC::chanmodes{$svr}{$_} = 2 }
|
||||
# Modes with parameter when +.
|
||||
foreach (split(//, $mtpp)) { $Proto::IRC::chanmodes{$svr}{$_} = 3; }
|
||||
foreach (split(//, $mtpp)) { $Proto::IRC::chanmodes{$svr}{$_} = 3 }
|
||||
# Modes without parameter.
|
||||
foreach (split(//, $mts)) { $Proto::IRC::chanmodes{$svr}{$_} = 4; }
|
||||
foreach (split(//, $mts)) { $Proto::IRC::chanmodes{$svr}{$_} = 4 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ hook_add('on_kick', 'ircusers.onkick', sub {
|
||||
my $ri = 0;
|
||||
foreach my $chan (keys %{$State::IRC::chanusers{$src->{svr}}}) {
|
||||
if ($chan ne $kchan) {
|
||||
if (defined $State::IRC::chanusers{$src->{svr}}{$chan}{lc $user}) { $ri++; last; }
|
||||
if (defined $State::IRC::chanusers{$src->{svr}}{$chan}{lc $user}) { $ri++; last }
|
||||
}
|
||||
}
|
||||
if (!$ri) {
|
||||
@@ -102,7 +102,7 @@ hook_add('on_part', 'ircusers.onpart', sub {
|
||||
my $ri = 0;
|
||||
foreach my $chan (keys %{$State::IRC::chanusers{$src->{svr}}}) {
|
||||
if ($chan ne $pchan) {
|
||||
if (defined $State::IRC::chanusers{$src->{svr}}{$chan}{lc $src->{nick}}) { $ri++; last; }
|
||||
if (defined $State::IRC::chanusers{$src->{svr}}{$chan}{lc $src->{nick}}) { $ri++; last }
|
||||
}
|
||||
}
|
||||
if (!$ri) {
|
||||
|
||||
+13
-13
@@ -123,7 +123,7 @@ sub rehash
|
||||
if (conf_get('module')) {
|
||||
alog '* Loading modules...';
|
||||
foreach (@{ (conf_get('module'))[0] }) {
|
||||
if (!API::Std::mod_exists($_)) { Auto::mod_load($_); }
|
||||
if (!API::Std::mod_exists($_)) { Auto::mod_load($_) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,15 +166,15 @@ sub ircsock {
|
||||
# Set IPv6/SSL data.
|
||||
my $use6 = 0;
|
||||
my $usessl = 0;
|
||||
if (defined $cdata->{'ipv6'}[0]) { $use6 = $cdata->{'ipv6'}[0]; }
|
||||
if (defined $cdata->{'ssl'}[0]) { $usessl = $cdata->{'ssl'}[0]; }
|
||||
if (defined $cdata->{'ipv6'}[0]) { $use6 = $cdata->{'ipv6'}[0] }
|
||||
if (defined $cdata->{'ssl'}[0]) { $usessl = $cdata->{'ssl'}[0] }
|
||||
|
||||
# Check for appropriate build data.
|
||||
if ($usessl) {
|
||||
if ($Auto::ENFEAT !~ m/ssl/ixsm) { err(2, '** Auto not built with SSL support: Aborting connection to '.$svrname, 0); return; }
|
||||
if ($Auto::ENFEAT !~ m/ssl/ixsm) { err(2, '** Auto not built with SSL support: Aborting connection to '.$svrname, 0); return }
|
||||
}
|
||||
if ($use6) {
|
||||
if ($Auto::ENFEAT !~ m/ipv6/ixsm) { err(2, '** Auto not built with IPv6 support: Aborting connection to '.$svrname, 0); return; }
|
||||
if ($Auto::ENFEAT !~ m/ipv6/ixsm) { err(2, '** Auto not built with IPv6 support: Aborting connection to '.$svrname, 0); return }
|
||||
}
|
||||
|
||||
# CertFP.
|
||||
@@ -189,7 +189,7 @@ sub ircsock {
|
||||
$conndata{'SSL_key_file'} = "$Auto::bin{etc}/certs/".$cdata->{'certfp_key'}[0];
|
||||
}
|
||||
if (defined $cdata->{'certfp_pass'}[0]) {
|
||||
$conndata{'SSL_passwd_cb'} = sub { return $cdata->{'certfp_pass'}[0]; };
|
||||
$conndata{'SSL_passwd_cb'} = sub { return $cdata->{'certfp_pass'}[0] };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,9 +238,9 @@ sub ircsock {
|
||||
|
||||
# Shutdown.
|
||||
hook_add('on_shutdown', 'shutdown.core_cleanup', sub {
|
||||
if (defined $Auto::DB) { $Auto::DB->disconnect; }
|
||||
if ($Auto::UPREFIX) { if (-e "$Auto::bin{cwd}/auto.pid") { unlink "$Auto::bin{cwd}/auto.pid"; } }
|
||||
else { if (-e "$Auto::Bin/auto.pid") { unlink "$Auto::Bin/auto.pid"; } }
|
||||
if (defined $Auto::DB) { $Auto::DB->disconnect }
|
||||
if ($Auto::UPREFIX) { if (-e "$Auto::bin{cwd}/auto.pid") { unlink "$Auto::bin{cwd}/auto.pid" } }
|
||||
else { if (-e "$Auto::Bin/auto.pid") { unlink "$Auto::Bin/auto.pid" } }
|
||||
return 1;
|
||||
});
|
||||
|
||||
@@ -253,7 +253,7 @@ sub signal_term
|
||||
{
|
||||
API::Std::event_run('on_sigterm');
|
||||
API::Std::event_run('on_shutdown');
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGTERM'); }
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGTERM') }
|
||||
dbug '!!! Caught SIGTERM; terminating...';
|
||||
alog '!!! Caught SIGTERM; terminating...';
|
||||
sleep 1;
|
||||
@@ -265,7 +265,7 @@ sub signal_int
|
||||
{
|
||||
API::Std::event_run('on_sigint');
|
||||
API::Std::event_run('on_shutdown');
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGINT'); }
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGINT') }
|
||||
dbug '!!! Caught SIGINT; terminating...';
|
||||
alog '!!! Caught SIGINT; terminating...';
|
||||
sleep 1;
|
||||
@@ -288,7 +288,7 @@ sub signal_perlwarn
|
||||
my ($warnmsg) = @_;
|
||||
$warnmsg =~ s/(\n|\r)//xsmg;
|
||||
alog 'Perl Warning: '.$warnmsg;
|
||||
if ($Auto::DEBUG) { say 'Perl Warning: '.$warnmsg; }
|
||||
if ($Auto::DEBUG) { say 'Perl Warning: '.$warnmsg }
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ sub signal_perldie
|
||||
|
||||
return if $EXCEPTIONS_BEING_CAUGHT;
|
||||
alog 'Perl Fatal: '.$diemsg.' -- Terminating program!';
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'A fatal error occurred!'); }
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'A fatal error occurred!') }
|
||||
API::Std::event_run('on_shutdown');
|
||||
sleep 1;
|
||||
say 'FATAL: '.$diemsg;
|
||||
|
||||
+6
-6
@@ -318,7 +318,7 @@ sub cap {
|
||||
}
|
||||
|
||||
# Send CAP REQ/CAP END based on what both we and the server support.
|
||||
if (!$capout) { Auto::socksnd($svr, 'CAP END'); }
|
||||
if (!$capout) { Auto::socksnd($svr, 'CAP END') }
|
||||
else {
|
||||
$capout = substr $capout, 1;
|
||||
Auto::socksnd($svr, "CAP REQ :$capout");
|
||||
@@ -406,7 +406,7 @@ sub kick {
|
||||
}
|
||||
else {
|
||||
# We weren't. Update chanusers and trigger on_kick.
|
||||
if (defined $State::IRC::chanusers{$svr}{$ex[2]}{$ex[3]}) { delete $State::IRC::chanusers{$svr}{$ex[2]}{$ex[3]}; }
|
||||
if (defined $State::IRC::chanusers{$svr}{$ex[2]}{$ex[3]}) { delete $State::IRC::chanusers{$svr}{$ex[2]}{$ex[3]} }
|
||||
API::Std::event_run("on_kick", (\%src, $ex[2], $ex[3], $msg));
|
||||
}
|
||||
|
||||
@@ -490,9 +490,9 @@ sub mode {
|
||||
else {
|
||||
# It is not. Lets adjust arguments accordingly.
|
||||
if (defined $chanmodes{$svr}{$maf}) {
|
||||
if ($chanmodes{$svr}{$maf} == 1 || $chanmodes{$svr}{$maf} == 2) { shift @ex; }
|
||||
if ($chanmodes{$svr}{$maf} == 1 || $chanmodes{$svr}{$maf} == 2) { shift @ex }
|
||||
if ($chanmodes{$svr}{$maf} == 3) {
|
||||
if ($op == 1) { shift @ex; }
|
||||
if ($op == 1) { shift @ex }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +543,7 @@ sub notice {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
# Ensure this is coming from a user rather than a server.
|
||||
if ($ex[0] !~ m/!/xsm) { return; }
|
||||
if ($ex[0] !~ m/!/xsm) { return }
|
||||
|
||||
# Prepare all the data.
|
||||
my %src = API::IRC::usrc(substr $ex[0], 1);
|
||||
@@ -568,7 +568,7 @@ sub part {
|
||||
# Check if it's from us or someone else.
|
||||
if ($src{nick} eq $botinfo{$svr}{nick}) {
|
||||
# Delete this channel from botchans.
|
||||
if ($botchans{$svr}{$ex[2]}) { delete $botchans{$svr}{$ex[2]}; }
|
||||
if ($botchans{$svr}{$ex[2]}) { delete $botchans{$svr}{$ex[2]} }
|
||||
# Trigger on_upart.
|
||||
API::Std::event_run('on_upart', ($svr, $ex[2]));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user