1: <?php
2:
3: namespace Budabot\Core\Modules;
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:
33:
34: global $configFile;
35:
36: function read_input ($output = "") {
37: echo $output;
38: return trim(fgets(STDIN));
39: }
40:
41: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
42: echo " ***************************************************\n";
43: echo " You will need to provide some information\n";
44: echo " regarding the basic configuration of the bot.\n";
45: echo " ***************************************************\n";
46: echo " \n\n\n\n\n\n\n\n\n";
47: $msg = "Press enter to continue. \n";
48: $answer = strtolower(read_input($msg));
49:
50: do {
51: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
52: echo " ***************************************************\n";
53: echo " Enter the account username that contains the\n";
54: echo " character the bot will run on. \n";
55: echo " Remember this name is case-sensitive!\n";
56: echo " ***************************************************\n";
57: echo " \n\n\n\n\n\n\n\n\n";
58: $msg = "Enter the account username (case-senstitive): \n";
59: $vars["login"] = read_input($msg);
60: } while ($vars["login"] == "");
61:
62: do {
63: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
64: echo " ************************************************\n";
65: echo " Enter the Password for the account.\n";
66: echo " Remember this is also case-sensitive!\n";
67: echo " ************************************************\n";
68: echo " \n\n\n\n\n\n\n\n\n";
69: $msg = "Enter the account password (case-senstitive): \n";
70: $vars["password"] = read_input($msg);
71: } while ($vars["password"] == "");
72:
73: do {
74: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
75: echo " **************************************************\n";
76: echo " Enter the dimension that the bot will run on.\n";
77: echo " **************************************************\n";
78: echo " \n\n\n\n\n\n\n\n\n";
79: $msg = "Choose a Dimension (5 = Rubi-Ka, 4 = Test): \n";
80: $vars["dimension"] = read_input($msg);
81: } while ($vars["dimension"] != 4 && $vars["dimension"] != 5);
82:
83: do {
84: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
85: echo " *******************************************************\n";
86: echo " Enter the character the bot will run on.\n";
87: echo " If the character does not already exist, close this\n";
88: echo " and create the character and then start the bot again.\n";
89: echo " Make sure the bot toon is not currently logged on\n";
90: echo " or the bot will not be able to log on.\n";
91: echo " *******************************************************\n";
92: echo " \n\n\n\n\n\n\n\n";
93: $msg = "Enter the Character the bot will run as: \n";
94: $vars["name"] = read_input($msg);
95: } while ($vars["name"] == "");
96:
97: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
98: echo " ***************************************************\n";
99: echo " To run the bot as a raid bot, leave this setting blank.\n";
100: echo " To run the bot as an org bot, enter the organization name.\n";
101: echo " The organization name must match exactly including case\n";
102: echo " and punctuation!\n";
103: echo " ***************************************************\n";
104: echo " \n\n\n\n\n\n\n\n\n";
105: $msg = "Enter your Guild (leave blank if this will be a raid bot): \n";
106: $vars["my_guild"] = read_input($msg);
107:
108: do {
109: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
110: echo " ********************************************************\n";
111: echo " Who should be the Administrator for this bot?\n";
112: echo " This is the character that has access to all commands\n";
113: echo " and settings for this bot.\n";
114: echo " ********************************************************\n";
115: echo " \n\n\n\n\n\n\n\n\n";
116: $msg = "Enter the Administrator for this bot: \n";
117:
118: $vars["SuperAdmin"] = read_input($msg);
119: } while ($vars["SuperAdmin"] == "");
120:
121: do {
122: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
123: echo " *********************************************************\n";
124: echo " Now we are coming to the 'heart' of this bot,\n";
125: echo " the database system where nearly everything is\n";
126: echo " stored. You have 2 options now. Either you can\n";
127: echo " set it up manually or leave the default setting.\n";
128: echo " The default setting is recommended for normal\n";
129: echo " users. If you choose to set it up manually\n";
130: echo " you will be able to choose between\n";
131: echo " Mysql and Sqlite.\n";
132: echo " *********************************************************\n";
133: echo " \n\n\n\n\n\n\n";
134: $msg = "Do you want to setup the database manually (yes/no - Recommended): \n";
135: $mansetupdb = strtolower(read_input($msg));
136: } while ($mansetupdb != "no" && $mansetupdb != "yes");
137:
138: if (strtolower($mansetupdb) == "yes") {
139: do {
140: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
141: echo " *********************************************************\n";
142: echo " The bot is able to use 2 different Database Types.\n";
143: echo " 1 = Sqlite. It is the easiest way to go and provides\n";
144: echo " faster bot startup than MySQL.\n";
145: echo " 2 = MySQL. An Open-Source Database.\n";
146: echo " You need to install and setup it manually\n";
147: echo " http://www.mysql.com/\n";
148: echo " Be aware that when you set it up incorrectly\n";
149: echo " it can be slower than Sqlite!\n";
150: echo " *********************************************************\n";
151: echo " \n\n\n\n\n\n\n";
152: $msg = "Choose a Database system (1 = Sqlite - Recommended, 2 = MySQL): \n";
153: $vars["DB Type"] = read_input($msg);
154: } while (strtolower($vars["DB Type"]) != "1" && strtolower($vars["DB Type"]) != "2");
155:
156: switch($vars["DB Type"]) {
157: case "1":
158: $vars["DB Type"] = "sqlite";
159: break;
160: case "2":
161: $vars["DB Type"] = "mysql";
162: break;
163: }
164: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
165: echo " *********************************************************\n";
166: echo " What is the name of the database that you\n";
167: echo " wannna use?\n";
168: if ($vars["DB Type"] == "sqlite") {
169: echo " (This is the filename of the database)\n";
170: echo " (Default: budabot.db)\n";
171: } else {
172: echo " (Default: budabot)\n";
173: }
174: echo " *********************************************************\n";
175: echo " \n\n\n\n\n\n\n\n";
176: $msg = "Enter the Databasename(leave blank for default setting): \n";
177: $vars["DB Name"] = read_input($msg);
178:
179: if ($vars["DB Name"] == "" && $vars["DB Type"] == "sqlite") {
180: $vars["DB Name"] = "budabot.db";
181: } else if ($vars["DB Name"] == "" && $vars["DB Type"] == "mysql") {
182: $vars["DB Name"] = "budabot";
183: }
184:
185: if ($vars["DB Type"] == "mysql") {
186: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
187: echo " **********************************************\n";
188: echo " On what Host is the Database running?\n";
189: echo " If it is running on this PC use:\n";
190: echo " localhost or 127.0.0.1\n";
191: echo " otherwise insert Hostname or IP\n";
192: echo " (Default: localhost)\n";
193: echo " **********************************************\n";
194: echo " \n\n\n\n\n\n\n\n\n";
195: $msg = "Enter the Hostname for the Database (leave blank for default setting): \n";
196: $vars["DB Host"] = read_input($msg);
197:
198: if ($vars["DB Host"] == "") {
199: $vars["DB Host"] = "localhost";
200: }
201: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
202: echo " **********************************************\n";
203: echo " What is the username for the MySQL Database?\n";
204: echo " If you did not specify a username when you installed\n";
205: echo " the Database then it will be 'root'\n";
206: echo " (Default: root)\n";
207: echo " **********************************************\n";
208: echo " \n\n\n\n\n\n\n\n";
209: $msg = "Enter username for the Database (leave blank for default setting): \n";
210: $vars["DB username"] = read_input($msg);
211:
212: if ($vars["DB username"] == "") {
213: $vars["DB username"] = "root";
214: }
215:
216: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
217: echo " **********************************************\n";
218: echo " What is the password for the MySQL Database?\n";
219: echo " if you did not specify a username when you installed\n";
220: echo " the Database then it will be blank (none)\n";
221: echo " (Default: <blank>)\n";
222: echo " **********************************************\n";
223: echo " \n\n\n\n\n\n\n\n\n";
224: $msg = "Enter password for the Database (leave blank for default setting): \n";
225: $vars["DB password"] = read_input($msg);
226: } else {
227: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n";
228: echo " **********************************************\n";
229: echo " Where is the Sqlite Database stored?\n";
230: echo " You may leave this setting blank to use the default\n";
231: echo " location which is the Data dir of your bot folder.\n";
232: echo " The Database will be created if it does\n";
233: echo " not already exists.\n";
234: echo " (Default: ./data/)\n";
235: echo " **********************************************\n";
236: echo " \n\n\n\n\n\n\n";
237: $msg = "Enter the path for the Database (leave blank for default setting): \n";
238: $vars["DB Host"] = read_input($msg);
239:
240: if ($vars["DB Host"] == "") {
241: $vars["DB Host"] = "./data/";
242: }
243: }
244: }
245:
246: do {
247: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n";
248: echo " **********************************************\n";
249: echo " Do you want to have all modules/commands enabled\n";
250: echo " by default?\n";
251: echo " This is usefull when you are using this bot the\n";
252: echo " first time so that all commands are available\n";
253: echo " from the beginning. If you say 'no' to this question\n";
254: echo " you will need to enable the commands manually.\n";
255: echo " (Recommended: yes)\n";
256: echo " **********************************************\n";
257: echo " \n\n\n\n\n\n\n";
258:
259: $msg = "Should all modules be enabled ? (yes - Recommended/no): \n";
260: $vars["default_module_status"] = strtolower(read_input($msg));
261: } while ($vars["default_module_status"] != "yes" && $vars["default_module_status"] != "no");
262:
263: if ($vars["default_module_status"] == "yes") {
264: $vars["default_module_status"] = 1;
265: }
266: if ($vars["default_module_status"] == "no") {
267: $vars["default_module_status"] = 0;
268: }
269:
270: echo " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
271: echo " **********************************************\n";
272: echo " If you have entered everything correctly \n";
273: echo " the bot should start.\n";
274: echo " ----------------------------------------------\n";
275: echo " We would appreciate any feedback you have.\n";
276: echo " Comments and suggestions are more than welcome!\n";
277: echo " www.budabot.com\n";
278: echo " ----------------------------------------------\n";
279: echo " Have a good day on Rubi-Ka.\n";
280: echo " To rerun this setup simply delete your\n";
281: echo " config file: {$configFile->getFilePath()}\n";
282: echo " **********************************************\n";
283: echo " \n\n\n\n\n";
284: $msg = "Press [Enter] to start the bot.\n";
285: read_input($msg);
286:
287:
288: $configFile->insertVars($vars);
289: $configFile->save();
290:
291: die("Restarting bot");
292: