{"NS_MDELUSER_DONE", "Deleted $b%d$b account(s) matching $b%s$b with access from $b%d$b to $b%d$b from the %s user list."}, /* {ARGS: 10, "Test*", 1, 200, "#TestChan"} */
{"NS_TRIM_DURATION_TOO_SHORT", "You must include a minimum inactivity duration of at least %d seconds to trim."},
{"NS_TRIM_DONE", "Trimmed $b%d users$b with access from %d to %d from the %s user list who were inactive for at least %s."}, /* {ARGS: 10, 1, 100, "#TestChan", "10 days"} */
+ {"NS_TRIM_BAN_DONE", "Trimmed $b%d bans$b from the %s ban list who were banned for at least %s."},
{"NS_GIVEOWNER_SELF", "You cannot give ownership to your own account."},
{"NS_GIVEOWNER_TIMEOUT", "You must wait %s before you can give ownership of $b%s$b to someone else."}, /* {ARGS: "5 hours", "#TestChan"} */
{"NS_GIVEOWNER_CONFIRM", "To really give ownership to $b%1$s$b, you must use 'giveownership *%1$s %2$s'."}, /* {ARGS: "TestUser", "abc123"} */
{NULL, NULL}
};
-/* TODO:
-trim bans
+/* TODO:
cmd_neonserv_open.c
set modelock
cmd_neonserv_modcmd.c
int chanuser_count = getChanUserCount();
float chanuser_memory = chanuser_count * sizeof(struct ChanUser);
float total_memory = channel_memory + channel_ban_memory + user_memory + chanuser_memory;
-
content[0] = get_language_string(user, "NS_NETINFO_CACHE");
sprintf(tmp, "%.2f kB (%.2f MB)", total_memory / 1024, total_memory / 1024 / 1024);
content[1] = tmp;
table_add(table, content);
-
content[0] = get_language_string(user, "NS_NETINFO_CHANNEL");
sprintf(tmp, "%d %.2f kB (%d * %u B = %.2f kB)", channel_count, channel_memory / 1024, channel_count, (unsigned int) sizeof(struct ChanNode), channel_memory / 1024);
content[1] = tmp;
table_add(table, content);
-
content[0] = get_language_string(user, "NS_NETINFO_CHANNEL_BAN");
sprintf(tmp, "%d %.2f kB (%d * %u B = %.2f kB)", channel_ban_count, channel_ban_memory / 1024, channel_ban_count, (unsigned int) sizeof(struct BanNode), channel_ban_memory / 1024);
content[1] = tmp;
table_add(table, content);
-
content[0] = get_language_string(user, "NS_NETINFO_USER");
sprintf(tmp, "%d %.2f kB (%d * %u B = %.2f kB)", user_count, user_memory / 1024, user_count, (unsigned int) sizeof(struct UserNode), user_memory / 1024);
content[1] = tmp;
table_add(table, content);
-
content[0] = get_language_string(user, "NS_NETINFO_CHANUSER");
sprintf(tmp, "%d %.2f kB (%d * %u B = %.2f kB)", chanuser_count, chanuser_memory / 1024, chanuser_count, (unsigned int) sizeof(struct ChanUser), chanuser_memory / 1024);
content[1] = tmp;
}
}
int min_access, max_access;
+ int duration = strToTime(user, argv[1]);
+ if(duration < 30) {
+ reply(getTextBot(), user, "NS_TRIM_DURATION_TOO_SHORT", 30);
+ return;
+ }
if(!stricmp(argv[0], "users")) {
min_access = 1;
max_access = getChannelAccess(user, chan, 0) - 1;
return;
}
}
- //TODO: TRIM BANS
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ char nameBuf[20];
+ printf_mysql_query("SELECT `ban_mask`, `ban_id`, `ban_timeout` FROM `bans` WHERE `ban_channel` = '%d' AND `ban_triggered` < %d", chan->channel_id, (int) (time(0) - duration));
+ res = mysql_use();
+ int bancount = mysql_num_rows(res);
+ struct ModeBuffer *modenode = initModeBuffer(client, chan);
+ while ((row = mysql_fetch_row(res)) != NULL) {
+ if(strcmp(row[2], "0")) {
+ sprintf(nameBuf, "ban_%s", row[1]);
+ timeq_del_name(nameBuf);
+ }
+ printf_mysql_query("DELETE FROM `bans` WHERE `ban_id` = '%s'", row[1]);
+ modeBufferUnban(modenode, row[0]);
+ }
+ freeModeBuffer(modenode);
+ char timeBuf[MAXLEN];
+ reply(getTextBot(), user, "NS_TRIM_BAN_DONE", bancount, chan->name, timeToStr(user, duration, 3, timeBuf));
+ if(bancount)
+ logEvent(event);
return;
} else {
char *seperator = strstr(argv[0], "-");
}
}
}
- //parse duration...
- int duration = strToTime(user, argv[1]);
- if(duration < 30) {
- reply(getTextBot(), user, "NS_TRIM_DURATION_TOO_SHORT", 30);
- return;
- }
struct neonserv_cmd_trim_cache *cache = malloc(sizeof(*cache));
if (!cache) {
perror("malloc() failed");