added cmd_god
authorpk910 <philipp@zoelle1.de>
Sat, 17 Sep 2011 18:33:48 +0000 (20:33 +0200)
committerpk910 <philipp@zoelle1.de>
Sat, 17 Sep 2011 18:33:48 +0000 (20:33 +0200)
bot_NeonServ.c
cmd_neonserv_god.c [new file with mode: 0644]

index a1f19e82125d19aa9ac51929ea5af52a17f10e51..d22017aaf2a31f7e6ce940d3de58726122706800 100644 (file)
@@ -176,6 +176,8 @@ static const struct default_language_entry msgtab[] = {
     {"NS_MODE_ENFOPS", "You may not op or deop users on \002%s\002."},
     {"NS_MODE_ENFVOICE", "You may not voice or devoice users on \002%s\002."},
     {"NS_MODE_CANBAN", "You may not ban or unban users on \002%s\002."},
+    {"NS_GOD_ON", "Security override has been enabled."},
+    {"NS_GOD_OFF", "Security override has been disabled."},
     {NULL, NULL}
 };
 
@@ -245,7 +247,7 @@ INCLUDE ALL CMD's HERE
 #include "cmd_neonserv_recover.c"
 //#include "cmd_neonserv_allowregister.c"
 //#include "cmd_neonserv_noregister.c"
-//#include "cmd_neonserv_god.c"
+#include "cmd_neonserv_god.c"
 //#include "cmd_neonserv_expire.c"
 //#include "cmd_neonserv_csuspend.c"
 //#include "cmd_neonserv_cunsuspend.c"
@@ -415,6 +417,7 @@ void init_NeonServ() {
     register_command(BOTID, "emote",        neonserv_cmd_emote,     2, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG,              NULL,                   600);
     register_command(BOTID, "notice",       neonserv_cmd_notice,    2, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG,              NULL,                   600);
     register_command(BOTID, "raw",          neonserv_cmd_raw,       1, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG,                                   NULL,                   800);
+    register_command(BOTID, "god",          neonserv_cmd_god,       0, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG,                                   NULL,                   1);
     
     start_bots();
     bind_bot_ready(neonserv_bot_ready);
diff --git a/cmd_neonserv_god.c b/cmd_neonserv_god.c
new file mode 100644 (file)
index 0000000..54c6163
--- /dev/null
@@ -0,0 +1,35 @@
+
+/*
+* argv[0]    (optional) on/off
+*/
+
+static CMD_BIND(neonserv_cmd_god) {
+    if(argc > 0) {
+        if(!strcmp(argv[0], "0") || !stricmp(argv[0], "off") || !stricmp(argv[0], get_language_string(user, "NS_SET_OFF"))) {
+            if(isGodMode(user)) {
+                printf_mysql_query("UPDATE `users` SET `user_god` = '0' WHERE `user_user` = '%s'", escape_string(user->auth));
+                user->flags &= ~USERFLAG_GOD_MODE;
+            }
+            reply(getTextBot(), user, "NS_GOD_OFF");
+        } else if(!strcmp(argv[0], "1") || !stricmp(argv[0], "on") || !stricmp(argv[0], get_language_string(user, "NS_SET_ON"))) {
+            if(!isGodMode(user)) {
+                printf_mysql_query("UPDATE `users` SET `user_god` = '1' WHERE `user_user` = '%s'", escape_string(user->auth));
+                user->flags |= USERFLAG_GOD_MODE;
+            }
+            reply(getTextBot(), user, "NS_GOD_ON");
+        } else {
+            reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", argv[0]);
+            return;
+        }
+    } else {
+        if(isGodMode(user)) {
+            printf_mysql_query("UPDATE `users` SET `user_god` = '0' WHERE `user_user` = '%s'", escape_string(user->auth));
+            user->flags &= ~USERFLAG_GOD_MODE;
+            reply(getTextBot(), user, "NS_GOD_OFF");
+        } else {
+            printf_mysql_query("UPDATE `users` SET `user_god` = '1' WHERE `user_user` = '%s'", escape_string(user->auth));
+            user->flags |= USERFLAG_GOD_MODE;
+            reply(getTextBot(), user, "NS_GOD_ON");
+        }
+    }
+}
\ No newline at end of file