diff options
author | Janik Kleinhoff <ilbelkyr@shalture.org> | 2017-02-22 00:36:20 +0000 |
---|---|---|
committer | Janik Kleinhoff <ilbelkyr@shalture.org> | 2017-02-22 00:36:20 +0000 |
commit | 3660ffad11192fdb4c23ea71f23c9d39f2a20715 (patch) | |
tree | da376bebfbf0eb8aae955858f24a8a7d6e7632d3 | |
parent | d6aa209d1920ced98f4ef074c0ee09c35d203534 (diff) | |
download | antispammeta-3660ffad11192fdb4c23ea71f23c9d39f2a20715.tar.bz2 antispammeta-3660ffad11192fdb4c23ea71f23c9d39f2a20715.tar.xz antispammeta-3660ffad11192fdb4c23ea71f23c9d39f2a20715.tar.zst |
Misc. code cleanup
-rwxr-xr-x | bin/db_deploy | 24 | ||||
-rwxr-xr-x | bin/db_gen_schema_dump | 14 | ||||
-rwxr-xr-x | bin/db_legacy | 26 | ||||
-rwxr-xr-x | bin/db_upgrade | 24 | ||||
-rw-r--r-- | lib/ASM/Util.pm | 52 |
5 files changed, 67 insertions, 73 deletions
diff --git a/bin/db_deploy b/bin/db_deploy index eca393e..b5bdcb5 100755 --- a/bin/db_deploy +++ b/bin/db_deploy @@ -11,21 +11,19 @@ use ASM::DB; use Getopt::Long; use DBIx::Class::DeploymentHandler; -GetOptions( - 'config|c=s' => \$::cset, -); -if ($::cset eq '') { $::cset = 'config-default'; } -else { $::cset = "config-$::cset"; } +GetOptions( 'config|c=s' => \$::cset ); +if ( $::cset eq '' ) { $::cset = 'config-default'; } +else { $::cset = "config-$::cset"; } ASM::Config->readConfig(); -my $schema = ASM::DB->connect($::mysql->{dsn}, $::mysql->{user}, $::mysql->{pass}); +my $schema = ASM::DB->connect( $::mysql->{dsn}, $::mysql->{user}, $::mysql->{pass} ); -my $dh = DBIx::Class::DeploymentHandler->new({ - schema => $schema, - schema_version => '' . $schema->schema_version, - sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, - databases => [], - ignore_ddl => 1, - }); +my $dh = DBIx::Class::DeploymentHandler->new( { + schema => $schema, + schema_version => '' . $schema->schema_version, + sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, + databases => [], + ignore_ddl => 1, +} ); $dh->install; diff --git a/bin/db_gen_schema_dump b/bin/db_gen_schema_dump index 1e84dd3..b26989c 100755 --- a/bin/db_gen_schema_dump +++ b/bin/db_gen_schema_dump @@ -11,12 +11,12 @@ use DBIx::Class::DeploymentHandler; my $schema = ASM::DB->clone; -my $dh = DBIx::Class::DeploymentHandler->new({ - schema => $schema, - schema_version => '' . $schema->schema_version, - sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, - databases => [], - ignore_ddl => 1, - }); +my $dh = DBIx::Class::DeploymentHandler->new( { + schema => $schema, + schema_version => '' . $schema->schema_version, + sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, + databases => [], + ignore_ddl => 1, +} ); $dh->prepare_install; diff --git a/bin/db_legacy b/bin/db_legacy index 3206d33..705b04a 100755 --- a/bin/db_legacy +++ b/bin/db_legacy @@ -11,22 +11,20 @@ use ASM::DB; use Getopt::Long; use DBIx::Class::DeploymentHandler; -GetOptions( - 'config|c=s' => \$::cset, -); -if ($::cset eq '') { $::cset = 'config-default'; } -else { $::cset = "config-$::cset"; } +GetOptions( 'config|c=s' => \$::cset ); +if ( $::cset eq '' ) { $::cset = 'config-default'; } +else { $::cset = "config-$::cset"; } ASM::Config->readConfig(); -my $schema = ASM::DB->connect($::mysql->{dsn}, $::mysql->{user}, $::mysql->{pass}); +my $schema = ASM::DB->connect( $::mysql->{dsn}, $::mysql->{user}, $::mysql->{pass} ); -my $dh = DBIx::Class::DeploymentHandler->new({ - schema => $schema, - schema_version => '' . $schema->schema_version, - sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, - databases => [], - ignore_ddl => 1, - }); +my $dh = DBIx::Class::DeploymentHandler->new( { + schema => $schema, + schema_version => '' . $schema->schema_version, + sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, + databases => [], + ignore_ddl => 1, +} ); $dh->install_version_storage; -$dh->add_database_version({ version => 1 }); +$dh->add_database_version( { version => 1 } ); diff --git a/bin/db_upgrade b/bin/db_upgrade index fc424ae..b1cb133 100755 --- a/bin/db_upgrade +++ b/bin/db_upgrade @@ -11,21 +11,19 @@ use ASM::DB; use Getopt::Long; use DBIx::Class::DeploymentHandler; -GetOptions( - 'config|c=s' => \$::cset, -); -if ($::cset eq '') { $::cset = 'config-default'; } -else { $::cset = "config-$::cset"; } +GetOptions( 'config|c=s' => \$::cset ); +if ( $::cset eq '' ) { $::cset = 'config-default'; } +else { $::cset = "config-$::cset"; } ASM::Config->readConfig(); -my $schema = ASM::DB->connect($::mysql->{dsn}, $::mysql->{user}, $::mysql->{pass}); +my $schema = ASM::DB->connect( $::mysql->{dsn}, $::mysql->{user}, $::mysql->{pass} ); -my $dh = DBIx::Class::DeploymentHandler->new({ - schema => $schema, - schema_version => '' . $schema->schema_version, - sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, - databases => [], - ignore_ddl => 1, - }); +my $dh = DBIx::Class::DeploymentHandler->new( { + schema => $schema, + schema_version => '' . $schema->schema_version, + sql_translator_args => { add_drop_table => 0, quote_identifiers => 1 }, + databases => [], + ignore_ddl => 1, +} ); $dh->upgrade; diff --git a/lib/ASM/Util.pm b/lib/ASM/Util.pm index 0984a28..949a5c0 100644 --- a/lib/ASM/Util.pm +++ b/lib/ASM/Util.pm @@ -147,48 +147,48 @@ sub hostip { return gethostbyname($_[0]); } -# If $tgts="#antispammeta" that's fine, and if $tgts = ["#antispammeta", "##linux-ops"] that's cool too +# If $targets="#antispammeta" that's fine, and if $targets = ["#antispammeta", "##linux-ops"] that's cool too sub sendLongMsg { - my ($module, $conn, $tgts, $txtz) = @_; - if (length($txtz) <= 380) { - $conn->privmsg($tgts, $txtz); + my ($module, $conn, $targets, $message) = @_; + if (length($message) <= 380) { + $conn->privmsg($targets, $message); } else { - my $splitpart = rindex($txtz, " ", 380); - $conn->privmsg($tgts, substr($txtz, 0, $splitpart)); - $conn->privmsg($tgts, substr($txtz, $splitpart)); + my $splitpart = rindex($message, " ", 380); + $conn->privmsg($targets, substr($message, 0, $splitpart)); + $conn->privmsg($targets, substr($message, $splitpart)); } } sub getAlert { - my ($module, $c, $risk, $t) = @_; + my ($module, $channel, $risk, $type) = @_; my @disable = (); - my @x = (); - $c = lc $c; - $c =~ s/^[@+]//; + my @result = (); + $channel = lc $channel; + $channel =~ s/^[@+]//; foreach my $prisk ( keys %::RISKS) { if ( $::RISKS{$risk} >= $::RISKS{$prisk} ) { - if (defined $::channels->{channel}->{master}->{$t}->{$prisk}) { - foreach my $nick (@{$::channels->{channel}->{master}->{$t}->{$prisk}}) { + if (defined $::channels->{channel}->{master}->{$type}->{$prisk}) { + foreach my $nick (@{$::channels->{channel}->{master}->{$type}->{$prisk}}) { if ($nick =~ /^\$a:/) { - push @x, @{accountToNicks($module, $nick)}; + push @result, @{accountToNicks($module, $nick)}; } else { - push @x, $nick; + push @result, $nick; } } } - if (defined cs($module, $c)->{$t}->{$prisk}) { - foreach my $nick (@{cs($module, $c)->{$t}->{$prisk}}) { + if (defined cs($module, $channel)->{$type}->{$prisk}) { + foreach my $nick (@{cs($module, $channel)->{$type}->{$prisk}}) { if ($nick =~ /^\$a:/) { - push @x, @{accountToNicks($module, $nick)}; + push @result, @{accountToNicks($module, $nick)}; } else { - push @x, $nick; + push @result, $nick; } } } } } - if (defined $::channels->{channel}->{master}->{$t}->{disable}) { - foreach my $nick (@{$::channels->{channel}->{master}->{$t}->{disable}}) { + if (defined $::channels->{channel}->{master}->{$type}->{disable}) { + foreach my $nick (@{$::channels->{channel}->{master}->{$type}->{disable}}) { if ($nick =~ /^\$a:/) { push @disable, @{accountToNicks($module, $nick)}; } else { @@ -196,8 +196,8 @@ sub getAlert { } } } - if (defined cs($module, $c)->{$t}->{disable}) { - foreach my $nick (@{cs($module, $c)->{$t}->{disable}}) { + if (defined cs($module, $channel)->{$type}->{disable}) { + foreach my $nick (@{cs($module, $channel)->{$type}->{disable}}) { if ($nick =~ /^\$a:/) { push @disable, @{accountToNicks($module, $nick)}; } else { @@ -205,9 +205,9 @@ sub getAlert { } } } - @x = unique(@x); - @x = array_diff(@x, @disable); - return @x; + @result = unique(@result); + @result = array_diff(@result, @disable); + return @result; } sub commaAndify { |