res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
-
user = addUser(row[0]);
strcpy(user->ident, row[1]);
strcpy(user->realname, row[2]);
client->botid = BOTID;
client->clientid = atoi(row[7]);
connect_socket(client);
- printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", client->botid);
- res2 = mysql_use();
- while ((row = mysql_fetch_row(res2)) != NULL) {
- if(bind_cmd_to_command(BOTID, row[0], row[1])) {
- if(row[2] && strcmp(row[2], "")) {
- bind_set_parameters(BOTID, row[0], row[2]);
- }
- if(row[3]) {
- bind_set_global_access(BOTID, row[0], atoi(row[3]));
- }
- if(row[4]) {
- bind_set_channel_access(BOTID, row[0], row[4]);
- }
+ }
+
+ printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
+ res2 = mysql_use();
+ while ((row = mysql_fetch_row(res2)) != NULL) {
+ if(bind_cmd_to_command(BOTID, row[0], row[1])) {
+ if(row[2] && strcmp(row[2], "")) {
+ bind_set_parameters(BOTID, row[0], row[2]);
+ }
+ if(row[3]) {
+ bind_set_global_access(BOTID, row[0], atoi(row[3]));
+ }
+ if(row[4]) {
+ bind_set_channel_access(BOTID, row[0], row[4]);
}
}
}
+ bind_unbound_required_functions(BOTID);
}
void init_DummyServ() {
// NAME FUNCTION PARAMS ACCS FLAGS
OPER_COMMAND("register", neonserv_cmd_register, 1, 200, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("unregister", neonserv_cmd_unregister,1, 200, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
- OPER_COMMAND("bind", neonserv_cmd_bind, 2, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
- OPER_COMMAND("unbind", neonserv_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
+ OPER_COMMAND("bind", neonserv_cmd_bind, 2, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
+ OPER_COMMAND("unbind", neonserv_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
OPER_COMMAND("say", neonserv_cmd_say, 2, 600, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("emote", neonserv_cmd_emote, 2, 600, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("notice", neonserv_cmd_notice, 2, 600, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
{"NS_RENAME_DONE", "Renamed $b%s$b to $b%s$b."},
{"NS_RENAME_FAIL", "Failed renaming $b%s$b."},
{"NS_FUN_DISABLED", "Fun commands are disabled in %s."},
+ {"NS_UNBIND_REQUIRED", "%1$s is a required function and there is no other command bound to %1$s. Bind anothjer command to %1$s first."}, /* {ARGS: bind} */
{NULL, NULL}
};
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
-
user = addUser(row[0]);
strcpy(user->ident, row[1]);
strcpy(user->realname, row[2]);
client->botid = BOTID;
client->clientid = atoi(row[7]);
connect_socket(client);
- printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", client->botid);
- res2 = mysql_use();
- while ((row = mysql_fetch_row(res2)) != NULL) {
- if(bind_cmd_to_command(BOTID, row[0], row[1])) {
- if(row[2] && strcmp(row[2], "")) {
- bind_set_parameters(BOTID, row[0], row[2]);
- }
- if(row[3]) {
- bind_set_global_access(BOTID, row[0], atoi(row[3]));
- }
- if(row[4]) {
- bind_set_channel_access(BOTID, row[0], row[4]);
- }
+ }
+
+ printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
+ res2 = mysql_use();
+ while ((row = mysql_fetch_row(res2)) != NULL) {
+ if(bind_cmd_to_command(BOTID, row[0], row[1])) {
+ if(row[2] && strcmp(row[2], "")) {
+ bind_set_parameters(BOTID, row[0], row[2]);
+ }
+ if(row[3]) {
+ bind_set_global_access(BOTID, row[0], atoi(row[3]));
+ }
+ if(row[4]) {
+ bind_set_channel_access(BOTID, row[0], row[4]);
}
}
}
+ bind_unbound_required_functions(BOTID);
}
void init_NeonServ() {
OPER_COMMAND("csuspend", neonserv_cmd_csuspend, 1, 100, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("cunsuspend", neonserv_cmd_cunsuspend,1, 100, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("move", neonserv_cmd_move, 2, 300, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
- OPER_COMMAND("bind", neonserv_cmd_bind, 2, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
- OPER_COMMAND("unbind", neonserv_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
+ OPER_COMMAND("bind", neonserv_cmd_bind, 2, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
+ OPER_COMMAND("unbind", neonserv_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
OPER_COMMAND("oplog", neonserv_cmd_oplog, 0, 1, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
OPER_COMMAND("search", neonserv_cmd_search, 1, 400, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
OPER_COMMAND("setaccess", neonserv_cmd_setaccess, 2, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
-
user = addUser(row[0]);
strcpy(user->ident, row[1]);
strcpy(user->realname, row[2]);
client->botid = BOTID;
client->clientid = atoi(row[7]);
connect_socket(client);
- printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", client->botid);
- res2 = mysql_use();
- while ((row = mysql_fetch_row(res2)) != NULL) {
- if(bind_cmd_to_command(BOTID, row[0], row[1])) {
- if(row[2] && strcmp(row[2], "")) {
- bind_set_parameters(BOTID, row[0], row[2]);
- }
- if(row[3]) {
- bind_set_global_access(BOTID, row[0], atoi(row[3]));
- }
- if(row[4]) {
- bind_set_channel_access(BOTID, row[0], row[4]);
- }
+ }
+
+ printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
+ res2 = mysql_use();
+ while ((row = mysql_fetch_row(res2)) != NULL) {
+ if(bind_cmd_to_command(BOTID, row[0], row[1])) {
+ if(row[2] && strcmp(row[2], "")) {
+ bind_set_parameters(BOTID, row[0], row[2]);
+ }
+ if(row[3]) {
+ bind_set_global_access(BOTID, row[0], atoi(row[3]));
+ }
+ if(row[4]) {
+ bind_set_channel_access(BOTID, row[0], row[4]);
}
}
}
+ bind_unbound_required_functions(BOTID);
}
char* convertNeonSpamSettingsToString(unsigned int flags, char *buffer) {
// NAME FUNCTION PARAMS ACCS FLAGS
OPER_COMMAND("register", neonserv_cmd_register, 1, 200, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("unregister", neonserv_cmd_unregister,1, 200, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
- OPER_COMMAND("bind", neonserv_cmd_bind, 2, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
- OPER_COMMAND("unbind", neonserv_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
+ OPER_COMMAND("bind", neonserv_cmd_bind, 2, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
+ OPER_COMMAND("unbind", neonserv_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED);
OPER_COMMAND("csuspend", neonserv_cmd_csuspend, 1, 100, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("cunsuspend", neonserv_cmd_cunsuspend,1, 100, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
OPER_COMMAND("say", neonserv_cmd_say, 2, 600, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_CHAN_PARAM | CMDFLAG_OPLOG);
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]));
+ printf_mysql_query("SELECT `function` 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;
}
+ struct cmd_function *function = find_cmd_function(client->botid, row[0]);
+ if(function && (function->flags & CMDFLAG_REQUIRED)) {
+ printf_mysql_query("SELECT `id` FROM `bot_binds` WHERE `botclass` = '%d' AND `function` = '%s'", client->botid, escape_string(function->name));
+ res = mysql_use();
+ if (mysql_num_rows(res) <= 1) {
+ reply(getTextBot(), user, "NS_UNBIND_REQUIRED", function->name);
+ 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]);
return NULL;
}
+void bind_unbound_required_functions(int botid) {
+ struct cmd_function *cmdfunc;
+ int i, found;
+ struct cmd_binding *cbind;
+ for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
+ if(cmdfunc->botid == botid && (cmdfunc->flags & CMDFLAG_REQUIRED)) {
+ found = 0;
+ for(i = 0; i < 27; i++) {
+ for(cbind = cmd_binds[i]; cbind; cbind = cbind->next) {
+ if(cbind->botid == botid && cbind->func == cmdfunc) {
+ found = 1;
+ break;
+ }
+ }
+ if(found)
+ break;
+ }
+ if(!found) {
+ bind_cmd_to_function(botid, cmdfunc->name, cmdfunc);
+ }
+ }
+ }
+}
+
#define CMDFLAG_LOG 0x0100
#define CMDFLAG_OPLOG 0x0200
#define CMDFLAG_EMPTY_ARGS 0x0400
+#define CMDFLAG_REQUIRED 0x0800
struct ClientSocket;
struct UserNode;
void bind_set_global_access(int botid, char *cmd, int gaccess);
void bind_set_channel_access(int botid, char *cmd, char *chanaccess);
struct cmd_binding *find_cmd_binding(int botid, char *cmd);
+void bind_unbound_required_functions(int botid);
#endif
\ No newline at end of file