* argv[2] value
*/
-static int global_cmd_setbot_active(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_nick(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_ident(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_realname(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_server(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_port(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_bind(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_ssl(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_serverpass(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_class(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_queue(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_prefered(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_maxchan(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_priority(struct UserNode *user, MYSQL_ROW bot, char *value);
-static int global_cmd_setbot_trigger(struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_active(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_nick(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_ident(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_realname(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_server(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_port(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_bind(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_ssl(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_serverpass(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_class(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_queue(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_prefered(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_maxchan(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_priority(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_trigger(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
CMD_BIND(global_cmd_setbot) {
MYSQL_RES *res;
printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `bind`, `ident`, `realname`, `ssl`, `id` FROM `bots` WHERE `id` = '%d'", botid);
res = mysql_use();
if(!(row = mysql_fetch_row(res))) {
- reply(getTextBot(), user, "NS_SETBOT_UNKNOWN", botid);
+ reply(textclient, user, "NS_SETBOT_UNKNOWN", botid);
return;
}
if(argc > 1) {
} else
value = NULL;
int log_event = 0;
- if(!stricmp(argv[1], "active")) log_event = global_cmd_setbot_active(user, row, value);
- else if(!stricmp(argv[1], "nick")) log_event = global_cmd_setbot_nick(user, row, value);
- else if(!stricmp(argv[1], "ident")) log_event = global_cmd_setbot_ident(user, row, value);
- else if(!stricmp(argv[1], "realname")) log_event = global_cmd_setbot_realname(user, row, value);
- else if(!stricmp(argv[1], "server")) log_event = global_cmd_setbot_server(user, row, value);
- else if(!stricmp(argv[1], "port")) log_event = global_cmd_setbot_port(user, row, value);
- else if(!stricmp(argv[1], "bind")) log_event = global_cmd_setbot_bind(user, row, value);
- else if(!stricmp(argv[1], "ssl")) log_event = global_cmd_setbot_ssl(user, row, value);
- else if(!stricmp(argv[1], "serverpass")) log_event = global_cmd_setbot_serverpass(user, row, value);
- else if(!stricmp(argv[1], "botclass")) log_event = global_cmd_setbot_class(user, row, value);
- else if(!stricmp(argv[1], "queue")) log_event = global_cmd_setbot_queue(user, row, value);
- else if(!stricmp(argv[1], "prefered")) log_event = global_cmd_setbot_prefered(user, row, value);
- else if(!stricmp(argv[1], "maxchan")) log_event = global_cmd_setbot_maxchan(user, row, value);
- else if(!stricmp(argv[1], "priority")) log_event = global_cmd_setbot_priority(user, row, value);
- else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_trigger(user, row, value);
+ if(!stricmp(argv[1], "active")) log_event = global_cmd_setbot_active(textclient, user, row, value);
+ else if(!stricmp(argv[1], "nick")) log_event = global_cmd_setbot_nick(textclient, user, row, value);
+ else if(!stricmp(argv[1], "ident")) log_event = global_cmd_setbot_ident(textclient, user, row, value);
+ else if(!stricmp(argv[1], "realname")) log_event = global_cmd_setbot_realname(textclient, user, row, value);
+ else if(!stricmp(argv[1], "server")) log_event = global_cmd_setbot_server(textclient, user, row, value);
+ else if(!stricmp(argv[1], "port")) log_event = global_cmd_setbot_port(textclient, user, row, value);
+ else if(!stricmp(argv[1], "bind")) log_event = global_cmd_setbot_bind(textclient, user, row, value);
+ else if(!stricmp(argv[1], "ssl")) log_event = global_cmd_setbot_ssl(textclient, user, row, value);
+ else if(!stricmp(argv[1], "serverpass")) log_event = global_cmd_setbot_serverpass(textclient, user, row, value);
+ else if(!stricmp(argv[1], "botclass")) log_event = global_cmd_setbot_class(textclient, user, row, value);
+ else if(!stricmp(argv[1], "queue")) log_event = global_cmd_setbot_queue(textclient, user, row, value);
+ else if(!stricmp(argv[1], "prefered")) log_event = global_cmd_setbot_prefered(textclient, user, row, value);
+ else if(!stricmp(argv[1], "maxchan")) log_event = global_cmd_setbot_maxchan(textclient, user, row, value);
+ else if(!stricmp(argv[1], "priority")) log_event = global_cmd_setbot_priority(textclient, user, row, value);
+ else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_trigger(textclient, user, row, value);
else {
- reply(getTextBot(), user, "NS_SETBOT_SETTING", argv[1]);
+ reply(textclient, user, "NS_SETBOT_SETTING", argv[1]);
}
if(log_event) {
if(!stricmp(argv[1], "serverpass") && value) { //censor server password
logEvent(event);
}
} else {
- reply(getTextBot(), user, "NS_SETBOT_HEADER", botid);
- global_cmd_setbot_active(user, row, NULL);
- global_cmd_setbot_nick(user, row, NULL);
- global_cmd_setbot_ident(user, row, NULL);
- global_cmd_setbot_realname(user, row, NULL);
- global_cmd_setbot_server(user, row, NULL);
- global_cmd_setbot_port(user, row, NULL);
- global_cmd_setbot_bind(user, row, NULL);
- global_cmd_setbot_ssl(user, row, NULL);
- global_cmd_setbot_serverpass(user, row, NULL);
- global_cmd_setbot_class(user, row, NULL);
- global_cmd_setbot_queue(user, row, NULL);
- global_cmd_setbot_prefered(user, row, NULL);
- global_cmd_setbot_maxchan(user, row, NULL);
- global_cmd_setbot_priority(user, row, NULL);
- global_cmd_setbot_trigger(user, row, NULL);
+ reply(textclient, user, "NS_SETBOT_HEADER", botid);
+ global_cmd_setbot_active(textclient, user, row, NULL);
+ global_cmd_setbot_nick(textclient, user, row, NULL);
+ global_cmd_setbot_ident(textclient, user, row, NULL);
+ global_cmd_setbot_realname(textclient, user, row, NULL);
+ global_cmd_setbot_server(textclient, user, row, NULL);
+ global_cmd_setbot_port(textclient, user, row, NULL);
+ global_cmd_setbot_bind(textclient, user, row, NULL);
+ global_cmd_setbot_ssl(textclient, user, row, NULL);
+ global_cmd_setbot_serverpass(textclient, user, row, NULL);
+ global_cmd_setbot_class(textclient, user, row, NULL);
+ global_cmd_setbot_queue(textclient, user, row, NULL);
+ global_cmd_setbot_prefered(textclient, user, row, NULL);
+ global_cmd_setbot_maxchan(textclient, user, row, NULL);
+ global_cmd_setbot_priority(textclient, user, row, NULL);
+ global_cmd_setbot_trigger(textclient, user, row, NULL);
}
}
-static int global_cmd_setbot_active(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_active(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = ((bot[0] && !strcmp(bot[0], "1")) ? 1 : 0);
int ret = 0;
if(value) {
} else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
val = 1;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", value);
return 0;
}
if(val != ((bot[0] && !strcmp(bot[0], "1")) ? 1 : 0)) {
ret = 1;
}
}
- reply(getTextBot(), user, "\002ACTIVE \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
+ reply(textclient, user, "\002ACTIVE \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
return ret;
}
-static int global_cmd_setbot_nick(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_nick(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[1];
int ret = 0;
if(value) {
if(!is_valid_nick(value)) {
- reply(getTextBot(), user, "NS_SETBOT_NICK_INVALID", value);
+ reply(textclient, user, "NS_SETBOT_NICK_INVALID", value);
return 0;
}
//rename the bot
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002NICK \002 %s", val);
+ reply(textclient, user, "\002NICK \002 %s", val);
return ret;
}
-static int global_cmd_setbot_ident(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_ident(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[12];
int ret = 0;
if(value) {
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002IDENT \002 %s", val);
+ reply(textclient, user, "\002IDENT \002 %s", val);
return ret;
}
-static int global_cmd_setbot_realname(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_realname(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[13];
int ret = 0;
if(value) {
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002REALNAME \002 %s", val);
+ reply(textclient, user, "\002REALNAME \002 %s", val);
return ret;
}
-static int global_cmd_setbot_server(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_server(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[2];
int ret = 0;
if(value) {
free(client->host);
client->host = strdup(value);
if(client->flags & SOCKET_FLAG_READY)
- reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
+ reply(textclient, user, "NS_SETBOT_NEED_RESTART");
break;
}
}
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002SERVER \002 %s", val);
+ reply(textclient, user, "\002SERVER \002 %s", val);
return ret;
}
-static int global_cmd_setbot_port(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_port(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = atoi(bot[3]);
int ret = 0;
if(value) {
val = atoi(value);
if(val <= 0 || val > 65534) {
- reply(getTextBot(), user, "NS_SETBOT_PORT_INVALID", value);
+ reply(textclient, user, "NS_SETBOT_PORT_INVALID", value);
return 0;
}
struct ClientSocket *client;
if(client->clientid == atoi(bot[15])) {
client->port = val;
if(client->flags & SOCKET_FLAG_READY)
- reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
+ reply(textclient, user, "NS_SETBOT_NEED_RESTART");
break;
}
}
printf_mysql_query("UPDATE `bots` SET `port` = '%d' WHERE `id` = '%s'", val, bot[15]);
ret = 1;
}
- reply(getTextBot(), user, "\002PORT \002 %d", val);
+ reply(textclient, user, "\002PORT \002 %d", val);
return ret;
}
-static int global_cmd_setbot_bind(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_bind(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[11];
int ret = 0;
if(value) {
free(client->bind);
client->bind = (value ? strdup(value) : NULL);
if(client->flags & SOCKET_FLAG_READY)
- reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
+ reply(textclient, user, "NS_SETBOT_NEED_RESTART");
break;
}
}
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002BIND \002 %s", val);
+ reply(textclient, user, "\002BIND \002 %s", val);
return ret;
}
-static int global_cmd_setbot_ssl(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_ssl(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = (strcmp(bot[14], "0") ? 1 : 0);
int ret = 0;
if(value) {
} else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
val = 1;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", value);
return 0;
}
struct ClientSocket *client;
else
client->flags &= ~SOCKET_FLAG_SSL;
if(client->flags & SOCKET_FLAG_READY)
- reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
+ reply(textclient, user, "NS_SETBOT_NEED_RESTART");
break;
}
}
printf_mysql_query("UPDATE `bots` SET `ssl` = '%d' WHERE `id` = '%s'", val, bot[15]);
ret = 1;
}
- reply(getTextBot(), user, "\002SSL \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
+ reply(textclient, user, "\002SSL \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
return ret;
}
-static int global_cmd_setbot_serverpass(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_serverpass(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[4];
int ret = 0;
if(value) {
free(client->pass);
client->pass = (value ? strdup(value) : NULL);
if(client->flags & SOCKET_FLAG_READY)
- reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
+ reply(textclient, user, "NS_SETBOT_NEED_RESTART");
break;
}
}
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002SERVERPASS \002 %s", val);
+ reply(textclient, user, "\002SERVERPASS \002 %s", val);
return ret;
}
-static int global_cmd_setbot_class(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_class(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = atoi(bot[5]);
int ret = 0;
if(value) {
if((val = resolve_botalias(value)) == -1) {
- reply(getTextBot(), user, "NS_SETBOT_INVALID_CLASS", value);
+ reply(textclient, user, "NS_SETBOT_INVALID_CLASS", value);
return 0;
}
if(val != atoi(bot[5])) {
ret = 1;
}
}
- reply(getTextBot(), user, "\002BOTCLASS \002 %s", resolve_botid(val));
+ reply(textclient, user, "\002BOTCLASS \002 %s", resolve_botid(val));
return ret;
}
-static int global_cmd_setbot_queue(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_queue(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = (strcmp(bot[7], "0") ? 1 : 0);
int ret = 0;
if(value) {
} else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
val = 1;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", value);
return 0;
}
struct ClientSocket *client;
printf_mysql_query("UPDATE `bots` SET `queue` = '%d' WHERE `id` = '%s'", val, bot[15]);
ret = 1;
}
- reply(getTextBot(), user, "\002QUEUE \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
+ reply(textclient, user, "\002QUEUE \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
return ret;
}
-static int global_cmd_setbot_prefered(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_prefered(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = (strcmp(bot[6], "0") ? 1 : 0);
int ret = 0;
if(value) {
} else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
val = 1;
} else {
- reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
+ reply(textclient, user, "NS_SET_INVALID_BOOLEAN", value);
return 0;
}
struct ClientSocket *client;
printf_mysql_query("UPDATE `bots` SET `textbot` = '%d' WHERE `id` = '%s'", val, bot[15]);
ret = 1;
}
- reply(getTextBot(), user, "\002PREFERED \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
+ reply(textclient, user, "\002PREFERED \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
return ret;
}
-static int global_cmd_setbot_maxchan(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_maxchan(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = atoi(bot[9]);
int ret = 0;
if(value) {
val = atoi(value);
if(val < 0 || val > 99999) {
- reply(getTextBot(), user, "NS_SETBOT_MAXCHAN_INVALID", value);
+ reply(textclient, user, "NS_SETBOT_MAXCHAN_INVALID", value);
return 0;
}
printf_mysql_query("UPDATE `bots` SET `max_channels` = '%d' WHERE `id` = '%s'", val, bot[15]);
ret = 1;
}
- reply(getTextBot(), user, "\002MAXCHAN \002 %d", val);
+ reply(textclient, user, "\002MAXCHAN \002 %d", val);
return ret;
}
-static int global_cmd_setbot_priority(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_priority(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
int val = atoi(bot[10]);
int ret = 0;
if(value) {
val = atoi(value);
if(val < 0 || val > 99) {
- reply(getTextBot(), user, "NS_SETBOT_PRIORITY_INVALID", value);
+ reply(textclient, user, "NS_SETBOT_PRIORITY_INVALID", value);
return 0;
}
printf_mysql_query("UPDATE `bots` SET `register_priority` = '%d' WHERE `id` = '%s'", val, bot[15]);
ret = 1;
}
- reply(getTextBot(), user, "\002PRIORITY \002 %d", val);
+ reply(textclient, user, "\002PRIORITY \002 %d", val);
return ret;
}
-static int global_cmd_setbot_trigger(struct UserNode *user, MYSQL_ROW bot, char *value) {
+static int global_cmd_setbot_trigger(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
char *val = bot[8];
int ret = 0;
if(value) {
if(!*value || strlen(value) > 10) {
- reply(getTextBot(), user, "NS_SETBOT_TRIGGER_INVALID", value);
+ reply(textclient, user, "NS_SETBOT_TRIGGER_INVALID", value);
return 0;
}
printf_mysql_query("UPDATE `bots` SET `defaulttrigger` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
flush_trigger_cache(atoi(bot[5]), atoi(bot[15]));
- reply(getTextBot(), user, "NS_SETBOT_TRIGGER_NOTE");
+ reply(textclient, user, "NS_SETBOT_TRIGGER_NOTE");
val = value;
ret = 1;
}
- reply(getTextBot(), user, "\002TRIGGER \002 %s", val);
+ reply(textclient, user, "\002TRIGGER \002 %s", val);
return ret;
}