fixed last commit
[NeonServV5.git] / bot_NeonServ.c
index 1263b4bab5f5714653d1e8d79f29787dedbd4e01..8621d92bd0a868dc6c6094d495d07c21606c765d 100644 (file)
@@ -2,17 +2,26 @@
 #include "bot_NeonServ.h"
 #include "modcmd.h"
 #include "IRCEvents.h"
+#include "IRCParser.h"
 #include "UserNode.h"
 #include "ChanNode.h"
 #include "ChanUser.h"
 #include "ClientSocket.h"
 #include "mysqlConn.h"
 #include "lang.h"
+#include "HandleInfoHandler.h"
+#include "WHOHandler.h"
 
 #define BOTID 1
-#define CLASSNAME "NeonServ"
 
 static const struct default_language_entry msgtab[] = {
+    {"NS_USER_UNKNOWN", "User with nick \002%s\002 does not exist."},
+    {"NS_AUTH_UNKNOWN", "Account \002%s\002 has not been registered."},
+    {"NS_USER_NEED_AUTH", "%s must first authenticate with \002AuthServ\002."},
+    {"NS_INVALID_ACCESS", "\002%d\002 is an invalid access level."},
+    {"NS_ADDUSER_ALREADY_ADDED", "%s is already on the \002%s\002 user list (with access %d)."},
+    {"NS_ADDUSER_DONE", "Added %s to the %s user list with access %d."},
+    
     {NULL, NULL}
 };
 
@@ -21,6 +30,7 @@ INCLUDE ALL CMD's HERE
 */
 #include "cmd_neonserv_users.c"
 #include "cmd_neonserv_modes.c"
+#include "cmd_neonserv_adduser.c"
 
 static void neonserv_bot_ready(struct ClientSocket *client) {
     MYSQL_RES *res;
@@ -51,7 +61,7 @@ static void start_bots() {
     MYSQL_RES *res, *res2;
     MYSQL_ROW row;
     
-    printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `whoisbot`, `id` FROM `bots` WHERE `botclass` = '%s' AND `active` = '1'", escape_string(CLASSNAME));
+    printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `whoisbot`, `id` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID);
     res = mysql_use();
     
     while ((row = mysql_fetch_row(res)) != NULL) {
@@ -86,6 +96,8 @@ void init_NeonServ() {
     register_command(BOTID, "users", neonserv_cmd_users, 1, CMDFLAG_REQUIRE_CHAN | CMDFLAG_REQUIRE_AUTH);
     register_command(BOTID, "modes", neonserv_cmd_modes, 1, CMDFLAG_REQUIRE_CHAN | CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
     
+    register_command(BOTID, "adduser", neonserv_cmd_adduser, 2, CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
+    
     start_bots();
     bind_bot_ready(neonserv_bot_ready);
     set_trigger_callback(BOTID, neonserv_trigger_callback);
@@ -98,4 +110,3 @@ void free_NeonServ() {
 }
 
 #undef BOTID
-#undef CLASSNAME