added cmd_bind & cmd_unbind
[NeonServV5.git] / cmd_neonserv_unbind.c
diff --git a/cmd_neonserv_unbind.c b/cmd_neonserv_unbind.c
new file mode 100644 (file)
index 0000000..db91274
--- /dev/null
@@ -0,0 +1,19 @@
+
+/*
+* argv[0]   command name
+*/
+
+static CMD_BIND(neonserv_cmd_unbind) {
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    printf_mysql_query("SELECT `id` FROM `bot_binds` WHERE `botclass` = '%d' AND `command` = '%s'", client->botid, escape_string(argv[0]));
+    res = mysql_use();
+    if ((row = mysql_fetch_row(res)) == NULL) {
+        reply(getTextBot(), user, "NS_UNBIND_NOT_FOUND", argv[0]);
+        return;
+    }
+    unbind_cmd(client->botid, argv[0]);
+    printf_mysql_query("DELETE FROM `bot_binds` WHERE `id` = '%s'", row[0]);
+    reply(getTextBot(), user, "NS_UNBIND_DONE", argv[0]);
+    logEvent(event);
+}