]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
a) some whitespace cleanups. i can't say i care for 4 space tabs
authortabris <redacted>
Sun, 25 Mar 2012 22:00:01 +0000 (22:00 +0000)
committertabris <redacted>
Sun, 25 Mar 2012 22:00:01 +0000 (22:00 +0000)
b) a few renames

Nothing in here should be changing anything significant
that stuff comes later.

git-svn-id: http://svn.tabris.net/repos/srsv@3586 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.4.3/modules/serviceslibs/chanserv.pm

index fc8d283e1bacf9c82b14c9f4b8efed2223c7f8b5..de72f8ed64e87f09c23f2a0aa05bc3a56883e73b 100644 (file)
@@ -552,7 +552,7 @@ sub check_expired_bans() {
        add_timer('ChanServ Expire', 10, __PACKAGE__, 'chanserv::check_expired_bans');
        $get_expired_bans->execute();
 
-    while (my ($cn, $ban) = $get_expired_bans->fetchrow_array()) {
+       while (my ($cn, $ban) = $get_expired_bans->fetchrow_array()) {
                my $chan = {CHAN=>$cn};
                ircd::setmode(agent($chan), $cn, '-b', $ban);
                ircd::flushmodes();
@@ -561,14 +561,14 @@ sub check_expired_bans() {
 sub tempban($$;$) {
        my ($chan, $bansref, $expiresref) = @_;
        
-    my $cn = $chan->{CHAN};    
-    my @bans = @$bansref;
-    my @expires = @$expiresref;
+       my $cn = $chan->{CHAN}; 
+       my @bans = @$bansref;
+       my @expires = @$expiresref;
 
-    foreach my $ban (@bans) {
-        my $expiry = shift @expires;
-        $add_tempban->execute($cn, $ban, $expiry);
-    }
+       foreach my $ban (@bans) {
+       my $expiry = shift @expires;
+               $add_tempban->execute($cn, $ban, $expiry);
+       }
 
     ircd::ban_list(agent($chan), $cn, +1, 'b', @bans) if (scalar(@bans));
 }
@@ -583,13 +583,13 @@ sub clones_exist ($$) {
        my $nick = $user->{NICK};
        $get_host_inchan->execute(get_user_id($user), $cn);
        my ($joined) = $get_host_inchan->fetchrow_array;
-    $get_host_inchan->finish();
+       $get_host_inchan->finish();
 
-    if ($joined) {
+       if ($joined) {
                return $joined;
        }
-       
-    return 0;
+
+       return 0;
 }
 sub dispatch($$$) {
        my ($src, $dst, $msg) = @_;
@@ -619,17 +619,15 @@ sub dispatch($$$) {
                }
        }
        elsif ($cmd =~ /^t((e)?mp)?b(an)?$/i) {
-        my @args = split (/\s+/, $msg, 2);
-        
-        my (undef, $args) = @args;
+               my @args = split (/\s+/, $msg, 2);
+
+               my (undef, $args) = @args;
                cs_tempban ($user, $args);
        }
-               
-               
        elsif($cmd =~ /^(?:[uvhas]op|co?f(ounder)?)$/i) {
                my ($cn, $cmd2) = splice(@args, 0, 2);
                my $chan = { CHAN => $cn };
-               
+
                if($cmd2 =~ /^add$/i) {
                        if(@args == 1) {
                                cs_xop_add($user, $chan, $cmd, $args[0]);
@@ -2345,176 +2343,175 @@ sub cs_drop($$) {
        undef($enforcers{lc $cn});
        botserv::bot_part_if_needed(undef(), $chan, "Channel dropped.");
 }
-#my ($bansref, $unbansref, $expires) = get_bans ($user, $chan, '', @targets, 1, $default_expiry);
-#my ($bansref, $unbansref, $expires) = get_bans ($user, $chan, '', @targets, 1, $expiry);
-sub get_bans($$$$;$$) {
-    my ($user, $chan, $type, $targetsref, $temp, $expiry) = (@_);
-    my (@bans, @unbans, @expires);
-    my ($nick, $override);
 
-    my @targets = @$targetsref;
-    my $cn = $chan->{CHAN};
-    my $src = get_user_nick($user);
-    my $srclevel = get_best_acc($user, $chan);
-    
-    ($nick, $override) = can_do($chan, 'BAN', $user, { ACC => $srclevel });    
-    return unless $nick;
-    
-    my @errors = (
+#my ($bansref, $unbansref, $expires) = parse_bans ($user, $chan, '', @targets, 1, $default_expiry);
+#my ($bansref, $unbansref, $expires) = parse_bans ($user, $chan, '', @targets, 1, $expiry);
+sub parse_bans($$$$;$$) {
+       my ($user, $chan, $type, $targetsref, $temp, $expiry) = (@_);
+       my (@bans, @unbans, @expires);
+       my ($nick, $override);
+
+       my @targets = @$targetsref;
+       my $cn = $chan->{CHAN};
+       my $src = get_user_nick($user);
+       my $srclevel = get_best_acc($user, $chan);
+
+       ($nick, $override) = can_do($chan, 'BAN', $user, { ACC => $srclevel }); 
+       return unless $nick;
+
+       my @errors = (
                ["I'm sorry, $src, I'm afraid I can't do that."],
                ["They are not in \002$cn\002."],
                [$err_deny],
                ["User not found"],
        );
 
-    foreach my $target (@targets) {
-        my $tuser;
-
-        if ($target =~ /\+/ && $temp) {
-            $expiry = $target;
-            next;
-        }        
-        if(ref($target)) {
-            $tuser = $target;
-        }
-        elsif($target =~ /\,/) {
-            push @targets, split(',', $target);
-            next;
-        }
-        elsif($target eq '') {
-            # Should never happen
-            # but it could, given the split above
-            next;
-        }
-        elsif($target =~ /^-/) {
-            $target =~ s/^\-//;
-            push @unbans, $target;
-            next;
-        }
-        elsif($target =~ /[!@]+/) {
-            $target = normalize_hostmask($target);
-            push @bans, $target;
-            if ($temp) {
-                push @expires, $expiry;
-            }
-            next;
-        }
-        elsif(valid_nick($target)) {
-            $tuser = { NICK => $target };
-        }
-        elsif($target = validate_ban($target)) {
-            push @bans, $target;
-            if ($temp) {
-                push @expires, $expiry;
-            }
-            next;
-        } else {
-            notice($user, "Not a valid ban target: $target");
-            next;
-        }
-        my $targetlevel = get_best_acc($tuser, $chan);
-
-        if(lc $target eq lc agent($chan) or adminserv::is_service($tuser)) {
-            push @{$errors[0]}, get_user_nick($tuser);
-            next;
-        }
-
-        unless(get_user_id($tuser)) {
-            push @{$errors[1]}, get_user_nick($tuser);
-            next;
-        }
-        
-        if( $srclevel <= $targetlevel and not ($override && check_override($user, 'BAN', "BAN $cn $target")) ) {
-            push @{$errors[2]}, $target;
-            next;
-        }
-
-        push @bans, make_banmask($chan, $tuser, $type);
-        if ($temp) {
-            push @expires, $expiry;
-        }
-    }
-
-    if (!is_registered($chan)) {
-        notice ($user,
-            "$cn is not registered"
-        );
-        return;
-    }
-
-    foreach my $errlist (@errors) {
-        if(@$errlist > 1) {
-            my $msg = shift @$errlist;
-            
-            foreach my $e (@$errlist) { $e = "\002$e\002" }
-        
-            notice($user,
-                "Cannot ban ".
-                enum("or", @$errlist).
-                ": $msg"
-            );
-        }
-    }
-
-    return (\@bans, \@unbans, \@expires, $chan);
+       foreach my $target (@targets) {
+               my $tuser;
+
+               if ($target =~ /\+/ && $temp) {
+                       $expiry = $target;
+                       next;
+               }
+               if(ref($target)) {
+                       $tuser = $target;
+               }
+               elsif($target =~ /\,/) {
+                       push @targets, split(',', $target);
+                       next;
+               }
+               elsif($target eq '') {
+                       # Should never happen
+                       # but it could, given the split above
+                       next;
+               }
+               elsif($target =~ /^-/) {
+                       $target =~ s/^\-//;
+                       push @unbans, $target;
+                       next;
+               }
+               elsif($target =~ /[!@]+/) {
+                       $target = normalize_hostmask($target);
+                       push @bans, $target;
+                       if ($temp) {
+                               push @expires, $expiry;
+                       }
+                       next;
+               }
+               elsif(valid_nick($target)) {
+                       $tuser = { NICK => $target };
+               }
+               elsif($target = validate_ban($target)) {
+                       push @bans, $target;
+                       if ($temp) {
+                               push @expires, $expiry;
+                       }
+                       next;
+               } else {
+                       notice($user, "Not a valid ban target: $target");
+                       next;
+               }
+
+               my $targetlevel = get_best_acc($tuser, $chan);
+
+               if(lc $target eq lc agent($chan) or adminserv::is_service($tuser)) {
+                       push @{$errors[0]}, get_user_nick($tuser);
+                       next;
+               }
+
+               unless(get_user_id($tuser)) {
+                       push @{$errors[1]}, get_user_nick($tuser);
+                       next;
+               }
+
+               if( $srclevel <= $targetlevel and not ($override && check_override($user, 'BAN', "BAN $cn $target")) ) {
+                       push @{$errors[2]}, $target;
+                       next;
+               }
+
+               push @bans, make_banmask($chan, $tuser, $type);
+               if ($temp) {
+                       push @expires, $expiry;
+               }
+       }
+
+       if (!is_registered($chan)) {
+               notice ($user,
+                       "$cn is not registered"
+               );
+               return;
+       }
+
+       foreach my $errlist (@errors) {
+               if(@$errlist > 1) {
+                       my $msg = shift @$errlist;
+
+                       foreach my $e (@$errlist) { $e = "\002$e\002" }
+
+                       notice($user,
+                               "Cannot ban ".
+                               enum("or", @$errlist).
+                               ": $msg"
+                       );
+               }
+       }
+
+       return (\@bans, \@unbans, \@expires, $chan);
 }
 
 sub cs_tempban($$) {
-    my ($user, $args) = @_;
-    my ( $expiry, $cn, $chan ); 
-
-    my @args = split(/ /, $args);
-    my $length = @args;
-
-    for (my $i = 0; $i < $length; $i++) {
-        if ($args[$i] =~ /\#/) {
-            $cn = $args[$i];
-            $chan = { CHAN => $cn };
-            splice (@args, $i, 1);
-        }
-    }
-
-    if ($chan eq '') {
-        notice ($user, "No channel given. The channel name \002must\002 include the # character.");
-        return;
-    }
-
-    if ($args[-1] =~ /\+/) { #expire time is last arguement
-        $expiry = pop @args;
-        $expiry = parse_time($expiry);
-    } else { #expire time is somewhere else (if given), get default expiry for now. 
-           $get_bantime->execute($cn);
-        ($expiry) = $get_bantime->fetchrow_array();
-           $get_bantime->finish();
-    }
-
-    my @targets;
-
-    foreach my $arg (@args) {
-        if ($arg =~ /\,/) {
-               push @targets, split(/\,/, $arg);
-            next;
-        } else {
-            push @targets, $arg;
-        }
-    }
-    
-    my $src = get_user_nick($user);
-    
-    my ($bansref, $unbansref, $expires, $chan) = get_bans ($user, $chan, '', \@targets, 1, $expiry);
-  
-    if (!$bansref && !$unbansref) {
-        return;
-    }
-
-    my (@bans, @unbans) = (@$bansref, @$unbansref);
-
-    tempban ($chan, $bansref, $expires);
-
-    ircd::notice(agent($chan), $cn, "$src used TEMPBAN ".join(' ', @bans))
-        if (lc $user->{AGENT} eq lc $csnick) and (cr_chk_flag($chan, CRF_VERBOSE) and scalar(@bans));
-    cs_unban($user, $chan, @unbans) if scalar(@unbans);
+       my ($user, $args) = @_;
+       my ( $expiry, $cn, $chan ); 
+
+       my @args = split(/ /, $args);
+       my $length = @args;
+
+       for (my $i = 0; $i < $length; $i++) {
+               if ($args[$i] =~ /\#/) {
+                       $cn = $args[$i];
+                       $chan = { CHAN => $cn };
+                       splice (@args, $i, 1);
+               }
+       }
+
+       if ($chan eq '') {
+               notice ($user, "No channel given. The channel name \002must\002 include the # character.");
+               return;
+       }
+
+       if ($args[-1] =~ /\+/) { #expire time is last arguement
+               $expiry = pop @args;
+               $expiry = parse_time($expiry);
+       } else { #expire time is somewhere else (if given), get default expiry for now. 
+               $get_bantime->execute($cn);
+               ($expiry) = $get_bantime->fetchrow_array();
+               $get_bantime->finish();
+       }
+
+       my @targets;
+
+       foreach my $arg (@args) {
+               if ($arg =~ /\,/) {
+                       push @targets, split(/\,/, $arg);
+                       next;
+               } else {
+                       push @targets, $arg;
+               }
+       }
+
+       my $src = get_user_nick($user);
+
+       my ($bansref, $unbansref, $expires, $chan) = parse_bans ($user, $chan, '', \@targets, 1, $expiry);
+
+       if (!$bansref && !$unbansref) {
+               return;
+       }
+
+       tempban ($chan, $bansref, $expires);
+
+       ircd::notice(agent($chan), $cn, "$src used TEMPBAN ".join(' ', @$bansref))
+               if (lc $user->{AGENT} eq lc $csnick) and (cr_chk_flag($chan, CRF_VERBOSE) and scalar(@$bansref));
+       cs_unban($user, $chan, @$unbansref) if scalar(@$unbansref);
 }
 
 sub cs_kick($$$;$$) {
@@ -2522,8 +2519,8 @@ sub cs_kick($$$;$$) {
 
        my $cmd = ($ban ? 'KICKBAN' : 'KICK');
        my $perm = ($ban ? 'BAN' : 'KICK');
-       
-    if(ref($chan) ne 'HASH' || !defined($chan->{CHAN})) {
+
+       if(ref($chan) ne 'HASH' || !defined($chan->{CHAN})) {
                notice($user, "Invalid $cmd command, no channel specified");
                return;
        }
@@ -2623,19 +2620,19 @@ sub cs_kickmask($$$;$$) {
 sub cs_ban($$$@) {
        my ($user, $chan, $type, @targets) = @_;
 
-    my $src = get_user_nick ($user);
+       my $src = get_user_nick ($user);
 
-    my $cn = $chan->{CHAN};
-    
-    my ($bansref, $unbansref) = get_bans ($user, $chan, $type, \@targets);
-    
-    if (!$bansref && !$unbansref) {
-        return;
-    }
-    
-    my (@bans, @unbans) = (@$bansref, @$unbansref);
+       my $cn = $chan->{CHAN};
        
-    ircd::ban_list(agent($chan), $cn, +1, 'b', @bans) if (scalar(@bans));
+       my ($bansref, $unbansref) = parse_bans ($user, $chan, $type, \@targets);
+       
+       if (!$bansref && !$unbansref) {
+       return;
+       }
+       
+       my (@bans, @unbans) = (@$bansref, @$unbansref);
+       
+       ircd::ban_list(agent($chan), $cn, +1, 'b', @bans) if (scalar(@bans));
        ircd::notice(agent($chan), $cn, "$src used BAN ".join(' ', @bans))
                if (lc $user->{AGENT} eq lc $csnick) and (cr_chk_flag($chan, CRF_VERBOSE) and scalar(@bans));
        cs_unban($user, $chan, @unbans) if scalar(@unbans);
@@ -2952,12 +2949,12 @@ sub cs_welcome_del($$$) {
 }
 
 sub cs_alist($$;$) {
-        my ($user, $chan, $mask) = @_;
+       my ($user, $chan, $mask) = @_;
        my $cn = $chan->{CHAN};
 
        chk_registered($user, $chan) or return;
 
-        my $slevel = get_best_acc($user, $chan);
+       my $slevel = get_best_acc($user, $chan);
 
        can_do($chan, 'ACCLIST', $user, { ACC => $slevel }) or return;
 
@@ -3294,7 +3291,7 @@ sub cs_copy($$@) {
                } elsif(!(get_op($user, $chan2) & ($opmodes{o} | $opmodes{a} | $opmodes{q}))) {
                        # This would be preferred to be a 'opmode_mask' or something
                        # However that might be misleading due to hop not being enough to register
-                       notice($user, "You must have channel operator status to register \002$cn2\002.");
+                       notice($user, "You must have channel operator status to register \002$cn2\002.");
                        return;
                } else {
                        cs_copy_chan_all($user, $chan1, $chan2);