src/cmd_global_die.c \
src/cmd_neonserv_nicklist.c \
src/cmd_global_setbot.c \
+ src/cmd_global_addbot.c \
+ src/cmd_global_delbot.c \
src/cmd_funcmds.c \
src/ConfigParser.c
{"NS_SETBOT_PRIORITY_INVALID", "`%s` is an invalid priority value."}, /* {ARGS: "-1"} */
{"NS_SETBOT_TRIGGER_INVALID", "`%s` is an invalid bot trigger."}, /* {ARGS: "tooLongTrigger"} */
{"NS_SETBOT_TRIGGER_NOTE", "Please note: This Setting will only affect new channels."},
+ {"NS_ADDBOT_EXISTING", "A bot with nick %s does already exist."}, /* {ARGS: "NeonServ"} */
+ {"NS_ADDBOT_DONE", "Added %s with BotID $b%d$b."}, /* {ARGS: "NeonServ", 2} */
+ {"NS_DELBOT_NOT_FOUND", "Bot with BotID / nick $b%s$b not found."}, /* {ARGS: "NeonServ"} */
+ {"NS_DELBOT_DONE", "Bot deleted."},
{NULL, NULL}
};
#include "EventLogger.h"
#include "bots.h"
+CMD_BIND(global_cmd_addbot);
CMD_BIND(global_cmd_bind);
CMD_BIND(global_cmd_bots);
CMD_BIND(global_cmd_command);
CMD_BIND(global_cmd_commands);
+CMD_BIND(global_cmd_delbot);
CMD_BIND(global_cmd_die);
CMD_BIND(global_cmd_emote);
CMD_BIND(global_cmd_god);
--- /dev/null
+/* cmd_global_addbot.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cmd_global.h"
+
+/*
+* argv[0] nick
+* argv[1] class
+*/
+
+CMD_BIND(global_cmd_addbot) {
+ MYSQL_RES *res;
+ int botid;
+ if((botid = resolve_botalias(argv[1])) != -1) {
+ reply(getTextBot(), user, "NS_SETBOT_INVALID_CLASS", argv[1]);
+ return;
+ }
+ printf_mysql_query("SELECT `id` FROM `bots` WHERE `nick` = '%s'", escape_string(argv[0]));
+ res = mysql_use();
+ if(mysql_fetch_row(res)) {
+ reply(getTextBot(), user, "NS_ADDBOT_EXISTING", argv[0]);
+ return;
+ }
+ printf_mysql_query("INSERT INTO `bots` (`nick`, `botclass`) VALUES ('%s', '%d')", escape_string(argv[0]), botid);
+ botid = (int) mysql_insert_id(mysql_conn);
+ reply(getTextBot(), user, "NS_ADDBOT_DONE", argv[0], botid);
+ logEvent(event);
+}
+
--- /dev/null
+/* cmd_global_delbot.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cmd_global.h"
+
+/*
+* argv[0] nick/botid
+*/
+
+CMD_BIND(global_cmd_delbot) {
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ printf_mysql_query("SELECT `id` FROM `bots` WHERE `nick` = '%s' OR `id` = '%s'", escape_string(argv[0]), escape_string(argv[0]));
+ res = mysql_use();
+ if((row = mysql_fetch_row(res)) == NULL) {
+ reply(getTextBot(), user, "NS_DELBOT_NOT_FOUND", argv[0]);
+ return;
+ }
+ int botid = atoi(row[0]);
+ printf_mysql_query("DELETE FROM `bots` WHERE `id` = '%s'", row[0]);
+ for(client = getBots(0, NULL); client; client = getBots(0, client)) {
+ if(client->clientid == botid) {
+ close_socket(client);
+ break;
+ }
+ }
+ reply(getTextBot(), user, "NS_DELBOT_DONE");
+ logEvent(event);
+}
OPER_COMMAND("restart", global_cmd_restart, 0, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
OPER_COMMAND("die", global_cmd_die, 0, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
OPER_COMMAND("setbot", global_cmd_setbot, 1, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
+ OPER_COMMAND("addbot", global_cmd_addbot, 2, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
+ OPER_COMMAND("delbot", global_cmd_delbot, 1, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
#undef OPER_COMMAND
//NeonServ Commands