]> jfr.im git - irc/borknet/trunk.git/blame - core/modules/q/Hello.java
Q: Removed the '!' at the end of the line directly giving the userpassword
[irc/borknet/trunk.git] / core / modules / q / Hello.java
CommitLineData
b1d4498c 1/**\r
2#\r
3# BorkNet Services Core\r
4#\r
5\r
6#\r
7# Copyright (C) 2004 Ozafy - ozafy@borknet.org - http://www.borknet.org\r
8#\r
9# This program is free software; you can redistribute it and/or\r
10# modify it under the terms of the GNU General Public License\r
11# as published by the Free Software Foundation; either version 2\r
12# of the License, or (at your option) any later version.\r
13#\r
14# This program is distributed in the hope that it will be useful,\r
15# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
17# GNU General Public License for more details.\r
18#\r
19# You should have received a copy of the GNU General Public License\r
20# along with this program; if not, write to the Free Software\r
21# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
22#\r
b1d4498c 23*/\r
24import java.io.*;\r
25import java.util.*;\r
26import java.text.*;\r
27import java.util.regex.*;\r
28import borknet_services.core.*;\r
29\r
30/**\r
31 * Class to load configuration files.\r
32 * @author Ozafy - ozafy@borknet.org - http://www.borknet.org\r
33 */\r
34public class Hello implements Command\r
35{\r
36 /**\r
37 * Constructs a Loader\r
38 * @param debug If we're running in debug.\r
39 */\r
40 public Hello()\r
41 {\r
42 }\r
43\r
44 public void parse_command(Core C, Q Bot, DBControl dbc, String numeric, String botnum, String target, String username, String params)\r
45 {\r
46 String nick = Bot.get_nick();\r
47 String host = Bot.get_host();\r
48 if(Bot.getDefCon() < 5)\r
49 {\r
50 C.cmd_notice(numeric, botnum, "Defcon "+Bot.getDefCon()+" enabled: "+nick+" will not accept any new registrations, we apologize for any inconvenience caused.");\r
51 return;\r
52 }\r
53 String[] result = params.split("\\s");\r
54 try\r
55 {\r
56 String mail1 = result[1];\r
57 String mail2 = result[2];\r
58 //for typo purposes we check if the user has entered the same mail 2ce\r
59 if(mail1.equals(mail2))\r
60 {\r
61 //retards\r
62 if (!mail1.contains("@") || !mail1.contains(".") || mail1.startsWith("<"))\r
63 {\r
64 C.cmd_notice(numeric, botnum, username, "Invalid address.");\r
65 return;\r
66 }\r
67 if (dbc.isMailBlocked(mail1))\r
68 {\r
69 C.cmd_notice(numeric, botnum, username, "This mail has been blocked and cannot be used to register an account with "+nick+".");\r
70 return;\r
71 }\r
72 String userinfo[] = dbc.getUserRow(username);\r
73 //he's not authed yet, yay\r
74 if(userinfo[4].equals("0"))\r
75 {\r
76 //check for bad chars\r
77 if(!userinfo[1].matches("[A-Za-z0-9-]*"))\r
78 {\r
79 C.cmd_notice(numeric, botnum, username, "Your nick may not contain odd characters like \\ or `");\r
80 return;\r
81 }\r
82 }\r
83 //he's allready authed, authed people don't need extra accounts >:(\r
84 else\r
85 {\r
86 C.cmd_notice(numeric, botnum, username, "You are allready AUTH'd!");\r
87 return;\r
88 }\r
89 //someone allready holds this authnick\r
90 if(dbc.authExists(userinfo[1]))\r
91 {\r
92 C.cmd_notice(numeric, botnum, username, "Someone allready AUTH'd with that nick");\r
93 return;\r
94 }\r
95 //the chars to be used in password generating\r
96 String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";\r
97 String userpass = "";\r
98 //make the password (length 7)\r
99 for(int i=0 ; i<7 ;i++)\r
100 {\r
101 Random generator = new Random();\r
102 int g = generator.nextInt(60);\r
103 userpass += chars.substring(g,g+1);\r
104 }\r
105 String pass = dbc.encrypt(userpass);\r
106 //the actual message, you can easely add/change it\r
ac6b717f 107 //use the tag to indicate a space, \n for a newline\r
cb67c259
O
108 if(Bot.getSendmail())\r
109 {\r
110 String subj = "Your " + nick + " account!";\r
ac6b717f 111 String mesg = "Your login/password is:\n";\r
112 mesg += "Login: " + userinfo[1] + "\n";\r
113 mesg += "Password: " + userpass + "\n";\r
114 mesg += "\n";\r
115 mesg += "To AUTH yourself type the following command:\n";\r
116 mesg += "/msg " + nick + "@" + host + " AUTH " + userinfo[1] + " " + userpass + "\n";\r
117 mesg += "or you can use the challenge-repsonse method\n";\r
118 mesg += "\n";\r
119 mesg += "You can use the newpass command to change your password:\n";\r
120 mesg += "/msg " + nick + " newpass " + userpass + " newpassword newpassword\n";\r
121 mesg += "would change your password in newpassword.\n";\r
122 mesg += "\n";\r
123 mesg += "NB: Save this email for future reference.\n";\r
cb67c259
O
124 //call the external thread to send the mail, and not hog recources\r
125 C.send_mail(subj, mail1, mesg,nick,host);\r
126 //well, we hope it's sent\r
127 C.cmd_notice(numeric, botnum, username, "Mail Sent to " + mail1 + "!");\r
128 }\r
129 else\r
130 {\r
27d60a0f 131 C.cmd_notice(numeric, botnum, username, "Account created successfully, your new password is: " + userpass);\r
cb67c259 132 }\r
b1d4498c 133 //we add his info to the active authed array\r
cb67c259 134 dbc.addAuth(userinfo[1],pass,mail1,1,false,Long.parseLong(C.get_time()),"0","0","0");\r
b1d4498c 135 return;\r
136 }\r
137 //he made a typo in an address, or is retarded\r
138 else\r
139 {\r
140 C.cmd_notice(numeric, botnum, username, "Adresses don't match.");\r
141 return;\r
142 }\r
143 }\r
144 catch(ArrayIndexOutOfBoundsException e)\r
145 {\r
146 C.cmd_notice(numeric, botnum, username, "/msg " + nick + " hello <your@mail.here> <your@mail.here>");\r
147 return;\r
148 }\r
149 }\r
150\r
151 public void parse_help(Core C, Q Bot, String numeric, String botnum, String username, int lev)\r
152 {\r
153 C.cmd_notice(numeric, botnum, username, "/msg " + Bot.get_nick() + " hello <your@mail.here> <your@mail.here>");\r
154 C.cmd_notice(numeric, botnum, username, "Will get you an account with your current nick.");\r
bf5f32d5 155 C.cmd_notice(numeric, botnum, username, "eg: /msg " + Bot.get_nick() + " hello ozafy@borknet.org ozafy@borknet.org");\r
b1d4498c 156 }\r
157 public void showcommand(Core C, Q Bot, String numeric, String botnum, String username, int lev)\r
158 {\r
cb67c259 159 C.cmd_notice(numeric, botnum, username, "HELLO Creates an account with the bot.");\r
b1d4498c 160 }\r
161}