From 57134323940284d9e14e7a2860e5dae0a551c938 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sun, 24 Feb 2019 20:20:00 +0100 Subject: [PATCH] Move getpass to Usermgm --- Commands/Channel.pm | 41 ----------------------------------------- Commands/Usermgm.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Commands/Channel.pm b/Commands/Channel.pm index 62eae4f..2206072 100644 --- a/Commands/Channel.pm +++ b/Commands/Channel.pm @@ -114,45 +114,4 @@ command hostname => { } }; -command getpass => { - help => q(Gives new users a random password.), - type => q(pm) -}, class extends NDIRC::Command { - -########################################################### -# 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; - } - - method execute ($c,$msg) { - my $dbh = $c->model; - - my $password = generate_random_string 16; - my $update = $dbh->do(q{ -UPDATE users SET password = $1 -WHERE uid = $2 AND password IS NULL - },undef,$password,$c->uid); - 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; diff --git a/Commands/Usermgm.pm b/Commands/Usermgm.pm index a5e3abf..2b61760 100644 --- a/Commands/Usermgm.pm +++ b/Commands/Usermgm.pm @@ -549,4 +549,45 @@ ORDER BY amount*(metal+crystal+eonium)*CASE WHEN $1 = t1 THEN 1.0 ELSE 0.6 END D } }; +command getpass => { + help => q(Gives new users a random password.), + type => q(pm) +}, class extends NDIRC::Command { + +########################################################### +# 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; + } + + method execute ($c,$msg) { + my $dbh = $c->model; + + my $password = generate_random_string 16; + my $update = $dbh->do(q{ +UPDATE users SET password = $1 +WHERE uid = $2 AND password IS NULL + },undef,$password,$c->uid); + 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; -- 2.39.2