MYSQL_ROW row, defaults = NULL;
int i, arg, add = 1, skip = 0;
unsigned int modetype;
- int db_canop, db_canvoice, db_canban, db_enfmodes, db_getop, db_getvoice;
+ int db_canop, db_canhalfop, db_canvoice, db_canban, db_enfmodes, db_getop, db_gethalfop, db_getvoice;
struct ModeNode *modelock = createModeNode(NULL);
struct ModeBuffer *modeBuf;
struct UserNode *cuser;
struct ChanUser *chanuser;
+ int with_halfops = get_int_field("General.have_halfop");
modeBuf = initModeBuffer(client, chan);
- printf_mysql_query("SELECT `channel_canop`, `channel_canvoice`, `channel_canban`, `channel_enfmodes`, `channel_modes`, `channel_getop`, `channel_getvoice` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
+ printf_mysql_query("SELECT `channel_canop`, `channel_canvoice`, `channel_canban`, `channel_enfmodes`, `channel_modes`, `channel_getop`, `channel_getvoice`, `channel_gethalfop`, `channel_canhalfop` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
row = mysql_fetch_row(mysql_use());
- if(row[0] == NULL || row[1] == NULL || row[2] == NULL || row[3] == NULL || row[4] == NULL || row[5] == NULL || row[6] == NULL) {
- printf_mysql_query("SELECT `channel_canop`, `channel_canvoice`, `channel_canban`, `channel_enfmodes`, `channel_modes`, `channel_getop`, `channel_getvoice` FROM `channels` WHERE `channel_name` = 'defaults'");
+ if(row[0] == NULL || row[1] == NULL || row[2] == NULL || row[3] == NULL || row[4] == NULL || row[5] == NULL || row[6] == NULL || (row[7] == NULL && with_halfops) || (row[8] == NULL && with_halfops)) {
+ printf_mysql_query("SELECT `channel_canop`, `channel_canvoice`, `channel_canban`, `channel_enfmodes`, `channel_modes`, `channel_getop`, `channel_getvoice`, `channel_gethalfop`, `channel_canhalfop` FROM `channels` WHERE `channel_name` = 'defaults'");
defaults = mysql_fetch_row(mysql_use());
}
db_canop = atoi((row[0] ? row[0] : defaults[0]));
db_enfmodes = atoi((row[3] ? row[3] : defaults[3]));
db_getop = atoi((row[5] ? row[5] : defaults[5]));
db_getvoice = atoi((row[6] ? row[6] : defaults[6]));
+ db_gethalfop = (with_halfops ? atoi((row[7] ? row[7] : defaults[7])) : 0);
+ db_canhalfop = (with_halfops ? atoi((row[8] ? row[8] : defaults[8])) : 0);
if(row[4])
parseModeString(modelock, row[4]);
else if(defaults[4])
add = 0;
break;
case 'o':
+ case 'h':
case 'v':
if(arg == argc) {
break;
//someone deopped the bot???
requestOp(client->user, chan);
}
- if(modes[i] == 'o' && !(add && isBot(cuser))) {
+ if((modes[i] == 'o' || (modes[i] == 'h' && !with_halfops)) && !(add && isBot(cuser))) {
if(uaccess < db_canop) {
reply(textclient, user, "NS_MODE_ENFOPS", chan->name);
db_canop = -1;
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
- } else if(modes[i] == 'v') {
+ } else if(modes[i] == 'h' && with_halfops && !(add && isBot(cuser))) {
+ if(uaccess < db_canhalfop) {
+ reply(textclient, user, "NS_MODE_ENFOPS", chan->name);
+ db_canhalfop = -1;
+ if(uaccess < db_gethalfop)
+ deop_user = 1;
+ }
+ if(db_canhalfop == -1 && caccess < db_gethalfop) {
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ modeBufferSet(modeBuf, !add, modes[i], carg);
+ break;
+ }
+ } else if(modes[i] == 'v' && !(add && isBot(cuser))) {
if(uaccess < db_canvoice) {
reply(textclient, user, "NS_MODE_ENFVOICE", chan->name);
db_canvoice = -1;
//BOTWAR!
chanuser->changeTime = time(0);
if(chanuser->chageEvents > 0) {
- putsock(client, "NOTICE @%s :%s %s", chan->name, get_language_string(user, "NS_BOTWAR_DETECTED"), (BOTWAR_ALERT_CHAN ? get_language_string(user, "NS_BOTWAR_REPORTED") : ""));
- if(BOTWAR_ALERT_CHAN) {
- struct ChanNode *alertchan = getChanByName(BOTWAR_ALERT_CHAN);
+ char *alertchan = get_string_field("General.alertchan");
+ putsock(client, "NOTICE @%s :%s %s", chan->name, get_language_string(user, "NS_BOTWAR_DETECTED"), (alertchan ? get_language_string(user, "NS_BOTWAR_REPORTED") : ""));
+ if(alertchan) {
+ struct ChanNode *alertchan_chan = getChanByName(alertchan);
struct ClientSocket *alertclient;
- if(alertchan && (alertclient = getBotForChannel(chan)) != NULL) {
+ if(alertchan_chan && (alertclient = getBotForChannel(chan)) != NULL) {
char msgBuf[MAXLEN];
- putsock(alertclient, "PRIVMSG %s :%s", alertchan->name, build_language_string(NULL, msgBuf, "NS_BOTWAR_ALERT", chan->name, user->nick));
+ putsock(alertclient, "PRIVMSG %s :%s", alertchan_chan->name, build_language_string(NULL, msgBuf, "NS_BOTWAR_ALERT", chan->name, user->nick));
}
}
}