]> jfr.im git - irc/SurrealServices/srsv.git/blobdiff - branches/erry-devel/SrSv/User.pm
My work on this so far....
[irc/SurrealServices/srsv.git] / branches / erry-devel / SrSv / User.pm
index 5b0883c7e7f70c0d42b8d9b010020baba0c5a875..22cd87fe5aad127abaa1a39500873633401b392e 100644 (file)
@@ -27,7 +27,9 @@ SrSv::User - Track users
 =cut
 
 use strict;
-use SrSv::IRCd::UUID;
+use SrSv::Insp::UUID;
+use SrSv::Conf qw(main services sql);
+use SrSv::Conf2Consts qw(main services sql);
 use Exporter 'import';
 BEGIN {
        my %constants = (
@@ -100,7 +102,11 @@ import SrSv::MySQL::Stub {
        __flood_inc => ['NULL', "UPDATE user SET flood = flood + ? WHERE id=?"],
        __flood_expire => ['NULL', "UPDATE user SET flood = flood >> 1"], # shift is faster than mul
 };
+sub kill_user($$) {
+       my ($user, $reason) = @_;
 
+       ircd::irckill(get_user_agent($user) || main_conf_local, $user, $reason);
+}
 sub get_flood_level($) {
        my ($user) = @_;
 
@@ -146,7 +152,6 @@ sub flood_check($;$) {
 sub get_user_id($) {
        my ($user) = @_;
        my ($id, $n);
-       return undef if(is_agent($user->{NICK}) and not $enforcers{lc $user->{NICK}});
 
        unless(ref($user) eq 'HASH') {
                die("invalid get_user_nick call");
@@ -156,27 +161,22 @@ sub get_user_id($) {
                die("get_user_id called on empty string");
        }
        my $properId = ircd::getUuid ($user->{NICK});
+       print "!!!!!!!!!" . ($nick . " " . $properId) . "\n";
        if ($properId != "") {
-               print "Decoding $properId\n";
                $properId = decodeUUID($properId);
                return $user->{ID} = $properId;
        }
-       else { print "Null properId. User->id" . $user->{ID} . "\n"; }
-       if(exists($user->{ID})) { print "Returning user_>id " . $user->{ID} . "\n"; return $user->{ID}; }
-
-
-
+       return undef if(is_agent($user->{NICK}) and not $enforcers{lc $user->{NICK}});
+       if(exists($user->{ID})) {  return $user->{ID}; }
        # a cheat for isServer()
        if($user->{NICK} =~ /\./) {
                return $user->{ID} = undef;
        }
-
        my $nick2;
        while($n < 10 and !defined($id)) {
                $n++;
                $get_user_id->execute($nick);
                ($id) = $get_user_id->fetchrow_array;
-               print "Finally got id from query: $id\n";
                unless($id) {
                        $get_nickchg->execute($nick);
                        ($id, $nick2) = $get_nickchg->fetchrow_array;
@@ -189,7 +189,6 @@ sub get_user_id($) {
                $user->{OLDNICK} = $user->{NICK};
                $user->{NICK} = $nick2;
        }
-
        return $user->{ID} = $id;
 }
 
@@ -199,6 +198,11 @@ sub get_user_nick($) {
        unless(ref($user) eq 'HASH') {
                die("invalid get_user_nick call");
        }
+       if (exists($user->{ID})) {
+               if (my $nick = ircd::getRevUuid ($user->{ID})) {
+                       return $user->{NICK} = $nick;
+               }
+       }
        if(exists($user->{NICK}) and is_online($user->{NICK})) { 
                my $realnick = ircd::getRevUuid($user->{NICK});
                if ($realnick) {