]> ruin.nu Git - NDIRC.git/blobdiff - Commands/Channel.pm
Update to new database structure
[NDIRC.git] / Commands / Channel.pm
index edd1146f446313f9f9ec617cf499d23c6186184b..ad627b3d835e37f9891c670405375faf70755db5 100644 (file)
@@ -71,10 +71,8 @@ sub invite
 
        my @channels;
        if ($channel && $c->check_user_roles('irc_masterinvite')){
-               print "master $channel";
                push @channels,$channel;
        }else{
-               print "master $channel";
                my @access = ('auto_invite');
                push @access, 'invite' if $channel;
                my $channels = $c->model->prepare(q{
@@ -92,7 +90,6 @@ WHERE u.hostmask ILIKE $1 AND COALESCE(c.name = $2,TRUE)
                }
        }
        for (@channels){
-               print;
                $c->server->command("invite ". $c->nick ." $_");
        }
 }
@@ -105,4 +102,43 @@ sub hostname
        $c->reply('Your hostname is: '.$c->host);
 }
 
+###########################################################
+# Written by Guy Malachi http://guymal.com
+# 18 August, 2002
+###########################################################
+sub generate_random_string
+{
+       my $length_of_randomstring=shift;# the length of
+                        # the random string to generate
+
+       my @chars=('a'..'z','A'..'Z','0'..'9','_');
+       my $random_string;
+       foreach (1..$length_of_randomstring)
+       {
+               # rand @chars will generate a random
+               # number between 0 and scalar @chars
+               $random_string .= $chars[rand @chars];
+       }
+       return $random_string;
+}
+
+sub getpass
+       : Help(Gives new users a random password.)
+       : Type(pm)
+{
+       my ($self,$c,$msg) = @_;
+       my $dbh = $c->model;
+
+       my $password = generate_random_string 10;
+       my $update = $dbh->do(q{
+UPDATE users SET password = MD5( ? )
+WHERE hostmask ILIKE ? AND password =''
+               },undef,$password,$c->host);
+       if ($update > 0){
+               $c->reply("Password set to: $password (you can change it on webbie)");
+       }else{
+               $c->reply("Couldn't set password. Either it has already been set or you don't have an account");
+       }
+}
+
 1;