3 # BorkNet Services Core
7 # Copyright (C) 2004 Ozafy - ozafy@borknet.org - http://www.borknet.org
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 import java
.util
.regex
.*;
28 import borknet_services
.core
.*;
31 * Class to load configuration files.
32 * @author Ozafy - ozafy@borknet.org - http://www.borknet.org
34 public class Hello
implements Command
38 * @param debug If we're running in debug.
44 public void parse_command(Core C
, Q Bot
, DBControl dbc
, String numeric
, String botnum
, String target
, String username
, String params
)
46 String nick
= Bot
.get_nick();
47 String host
= Bot
.get_host();
48 if(Bot
.getDefCon() < 5)
50 C
.cmd_notice(numeric
, botnum
, "Defcon "+Bot
.getDefCon()+" enabled: "+nick
+" will not accept any new registrations, we apologize for any inconvenience caused.");
53 String
[] result
= params
.split("\\s");
56 String mail1
= result
[1];
57 String mail2
= result
[2];
58 //for typo purposes we check if the user has entered the same mail 2ce
59 if(mail1
.equals(mail2
))
62 if (!mail1
.contains("@") || !mail1
.contains(".") || mail1
.startsWith("<"))
64 C
.cmd_notice(numeric
, botnum
, username
, "Invalid address.");
67 if (dbc
.isMailBlocked(mail1
))
69 C
.cmd_notice(numeric
, botnum
, username
, "This mail has been blocked and cannot be used to register an account with "+nick
+".");
72 String userinfo
[] = dbc
.getUserRow(username
);
73 //he's not authed yet, yay
74 if(userinfo
[4].equals("0"))
77 if(!userinfo
[1].matches("[A-Za-z0-9-]*"))
79 C
.cmd_notice(numeric
, botnum
, username
, "Your nick may not contain odd characters like \\ or `");
83 //he's allready authed, authed people don't need extra accounts >:(
86 C
.cmd_notice(numeric
, botnum
, username
, "You are allready AUTH'd!");
89 //someone allready holds this authnick
90 if(dbc
.authExists(userinfo
[1]))
92 C
.cmd_notice(numeric
, botnum
, username
, "Someone allready AUTH'd with that nick");
95 //the chars to be used in password generating
96 String chars
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
98 //make the password (length 7)
99 for(int i
=0 ; i
<7 ;i
++)
101 Random generator
= new Random();
102 int g
= generator
.nextInt(60);
103 userpass
+= chars
.substring(g
,g
+1);
105 String pass
= dbc
.encrypt(userpass
);
106 //the actual message, you can easely add/change it
107 //use the tag to indicate a space, \n for a newline
108 if(Bot
.getSendmail())
110 String subj
= "Your " + nick
+ " account!";
111 String mesg
= "Your login/password is:\n";
112 mesg
+= "Login: " + userinfo
[1] + "\n";
113 mesg
+= "Password: " + userpass
+ "\n";
115 mesg
+= "To AUTH yourself type the following command:\n";
116 mesg
+= "/msg " + nick
+ "@" + host
+ " AUTH " + userinfo
[1] + " " + userpass
+ "\n";
117 mesg
+= "or you can use the challenge-repsonse method\n";
119 mesg
+= "You can use the newpass command to change your password:\n";
120 mesg
+= "/msg " + nick
+ " newpass " + userpass
+ " newpassword newpassword\n";
121 mesg
+= "would change your password in newpassword.\n";
123 mesg
+= "NB: Save this email for future reference.\n";
124 //call the external thread to send the mail, and not hog recources
125 C
.send_mail(subj
, mail1
, mesg
,nick
,host
);
126 //well, we hope it's sent
127 C
.cmd_notice(numeric
, botnum
, username
, "Mail Sent to " + mail1
+ "!");
131 C
.cmd_notice(numeric
, botnum
, username
, "Account created successfully, your new password is: " + userpass
+ "!");
133 //we add his info to the active authed array
134 dbc
.addAuth(userinfo
[1],pass
,mail1
,1,false,Long
.parseLong(C
.get_time()),"0","0","0");
137 //he made a typo in an address, or is retarded
140 C
.cmd_notice(numeric
, botnum
, username
, "Adresses don't match.");
144 catch(ArrayIndexOutOfBoundsException e
)
146 C
.cmd_notice(numeric
, botnum
, username
, "/msg " + nick
+ " hello <your@mail.here> <your@mail.here>");
151 public void parse_help(Core C
, Q Bot
, String numeric
, String botnum
, String username
, int lev
)
153 C
.cmd_notice(numeric
, botnum
, username
, "/msg " + Bot
.get_nick() + " hello <your@mail.here> <your@mail.here>");
154 C
.cmd_notice(numeric
, botnum
, username
, "Will get you an account with your current nick.");
155 C
.cmd_notice(numeric
, botnum
, username
, "eg: /msg " + Bot
.get_nick() + " hello ozafy@borknet.org ozafy@borknet.org");
157 public void showcommand(Core C
, Q Bot
, String numeric
, String botnum
, String username
, int lev
)
159 C
.cmd_notice(numeric
, botnum
, username
, "HELLO Creates an account with the bot.");