diff options
| author | 2007-06-29 02:21:38 +0000 | |
|---|---|---|
| committer | 2007-06-29 02:21:38 +0000 | |
| commit | f52c9bd6e6e018ff0c45f1dea4ded2aeb4ae1427 (patch) | |
| tree | 395c0133072d89da4a936e0a180e836997c1cb56 /modules/util.pl | |
| parent | 6907da0a5da3d45a91c3ac4893e5b890200b27eb (diff) | |
lots of modularization done, needs testing and is unstable
Diffstat (limited to 'modules/util.pl')
| -rw-r--r-- | modules/util.pl | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/modules/util.pl b/modules/util.pl index fb10356..f13c854 100644 --- a/modules/util.pl +++ b/modules/util.pl @@ -1,5 +1,4 @@ -#warning: if you add a function, put it into killsub! - +package ASM::Util; use warnings; use strict; @@ -15,6 +14,14 @@ my %oq; 'high' => 50, 'opalert'=> 9001 #OVER NINE THOUSAND!!! ); +sub new +{ + my $module = shift; + my $self = {}; + bless ($self); + return $self; +} + #leaves room for more levels if for some reason we end up needing more #theoretically, you should be able to change those numbers without any damage @@ -27,7 +34,7 @@ sub maxlen { #cs: returns the xml settings for the specified chan, or default if there aren't any settings for that chan sub cs { - my ($chan) = @_; + my ($module, $chan) = @_; $chan = lc $chan; return $::channels->{channel}->{$chan} if ( defined($::channels->{channel}->{$chan}) ); return $::channels->{channel}->{default}; @@ -88,19 +95,20 @@ sub flood_process { } sub getAlert { - my ($c, $risk, $t) = @_; + my ($module, $c, $risk, $t) = @_; @_ = (); $c = lc $c; foreach my $prisk ( keys %::RISKS) { if ( $::RISKS{$risk} >= $::RISKS{$prisk} ) { push( @_, @{$::channels->{channel}->{master}->{$t}->{$prisk}} ) if defined $::channels->{channel}->{master}->{$t}->{$prisk}; - push( @_, @{cs($c)->{$t}->{$prisk}} ) if defined cs($c)->{$t}->{$prisk}; + push( @_, @{cs($module, $c)->{$t}->{$prisk}} ) if defined cs($module, $c)->{$t}->{$prisk}; } } return @_; } sub commaAndify { + my $module = shift; my @seq = @_; my $len = ($#seq); my $last = $seq[$len]; @@ -110,32 +118,6 @@ sub commaAndify { return join( ', ', splice(@seq,0,$len) ) . ', and ' . $last; } -sub parse_modes -{ - my ( $n ) = @_; - my @args = @{$n}; - my @modes = split '', shift @args; - my @new_modes=(); - my $t; - foreach my $c ( @modes ) { - if (($c eq '-') || ($c eq '+')) { - $t=$c; - } - else { - if ( defined( grep( /[abdefhIJkloqv]/,($c) ) ) ) { #modes that take args - push (@new_modes, [$t.$c, shift @args]); - } - elsif ( defined( grep( /[cgijLmnpPQrRstz]/, ($c) ) ) ) { - push (@new_modes, [$t.$c]); - } - else { - die "Unknown mode $c !\n"; - } - } - } - return \@new_modes; -} - sub leq { my ($s1, $s2) = @_; return (lc $s1 eq lc $s2); @@ -148,18 +130,4 @@ sub seq { return ($n1 eq $n2); } -sub Util::killsub { - undef &cs; - undef &hostip; - undef &o_send; - undef &doQueue; - undef &flood_add; - undef &flood_process; - undef &getAlert; - undef &commaAndify; - undef &parse_modes; - undef ≤ - undef &seq; -} - return 1; |
