tried to reorder the program structure and build process
[NeonServV5.git] / src / cmd_neonserv_unbind.c
diff --git a/src/cmd_neonserv_unbind.c b/src/cmd_neonserv_unbind.c
new file mode 100644 (file)
index 0000000..bc67b83
--- /dev/null
@@ -0,0 +1,21 @@
+
+#include "cmd_neonserv.h"
+
+/*
+* argv[0]   command name
+*/
+
+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);
+}