{ "HSMSG_EXPIRATION_DONE", "%d eligible HelpServ bots have retired." },
{ "HSMSG_BAD_WEEKDAY", "I do not know which day of the week $b%s$b is." },
{ "HSMSG_WEEK_STARTS", "$b%s$b's weeks start on $b%s$b." },
+ { "HSMSG_MODSTATS_BAD_FIELD", "The specified field does not exist." },
+ { "HSMSG_MODSTATS_BAD_WEEK", "The specified week is invalid." },
+ { "HSMSG_MODSTATS_NEGATIVE", "This modification would result in a negative value." },
+ { "HSMSG_MODSTATS_SUCCESS", "$b%s$b's stats have been modified successfully." },
/* Registration */
{ "HSMSG_ILLEGAL_NICK", "$b%s$b is an illegal nick; cannot use it." },
const char *reqlogfile;
unsigned long db_backup_frequency;
unsigned int expire_age;
+ unsigned long modstats_level;
char user_escape;
} helpserv_conf;
return changed;
}
+static HELPSERV_FUNC(cmd_modstats) {
+ struct handle_info *hi;
+ struct helpserv_user *victim;
+ const char *field_name;
+ int week, mod;
+ unsigned int *field = NULL;
+ char *errptr;
+
+ REQUIRE_PARMS(5);
+ if (!oper_has_access(user, (from_opserv ? opserv : hs->helpserv), helpserv_conf.modstats_level, 0))
+ return 0;
+ if (!(hi = helpserv_get_handle_info(user, argv[1])))
+ return 0;
+ if (!(victim = GetHSUser(hs, hi))) {
+ helpserv_notice(user, "HSMSG_NOT_IN_USERLIST", hi->handle, hs->helpserv->nick);
+ return 0;
+ }
+
+ field_name = argv[2];
+ if (!strcasecmp(argv[3], "total"))
+ week = 4;
+ else if(!strcasecmp(argv[3], "current"))
+ week = 0;
+ else {
+ week = strtoul(argv[3], &errptr, 0);
+ if (*errptr != '\0') {
+ helpserv_notice(user, "HSMSG_MODSTATS_BAD_WEEK");
+ return 0;
+ }
+ }
+ mod = strtol(argv[4], NULL, 0);
+
+ if (week < 0 || week > 4) {
+ helpserv_notice(user, "HSMSG_MODSTATS_BAD_WEEK");
+ return 0;
+ }
+
+ if (!strcasecmp(field_name, "time")) {
+ if (victim->join_time && (week == 0 || week == 4)) {
+ victim->time_per_week[0] += now - victim->join_time;
+ victim->time_per_week[4] += now - victim->join_time;
+ victim->join_time = now;
+ }
+ field = victim->time_per_week;
+ }
+ else if (!strcasecmp(field_name, "picked") || !strcasecmp(field_name, "picked_up") || !strcasecmp(field_name, "reqs"))
+ field = victim->picked_up;
+ else if (!strcasecmp(field_name, "closed"))
+ field = victim->closed;
+ else if (!strcasecmp(field_name, "ra_from") || !strcasecmp(field_name, "reassigned_from"))
+ field = victim->reassigned_from;
+ else if (!strcasecmp(field_name, "ra_to") || !strcasecmp(field_name, "reassigned_to"))
+ field = victim->reassigned_to;
+ else {
+ helpserv_notice(user, "HSMSG_MODSTATS_BAD_FIELD");
+ return 0;
+ }
+
+ if (mod < 0 && abs(mod) > field[week]) {
+ helpserv_notice(user, "HSMSG_MODSTATS_NEGATIVE");
+ return 0;
+ }
+
+ field[week] += mod;
+ helpserv_notice(user, "HSMSG_MODSTATS_SUCCESS", victim->handle->handle);
+
+ return (mod != 0);
+}
+
static void set_page_target(struct helpserv_bot *hs, enum page_source idx, const char *target) {
struct chanNode *new_target, *old_target;
str = database_get_data(conf_node, "expiration", RECDB_QSTRING);
helpserv_conf.expire_age = ParseInterval(str ? str : "60d");
+ str = database_get_data(conf_node, "modstats_level", RECDB_QSTRING);
+ helpserv_conf.modstats_level = str ? strtoul(str, NULL, 0) : 850;
str = database_get_data(conf_node, "user_escape", RECDB_QSTRING);
helpserv_conf.user_escape = str ? str[0] : '@';
helpserv_define_func("BOTS", cmd_bots, HlOper, CMD_FROM_OPSERV_ONLY|CMD_IGNORE_EVENT);
helpserv_define_func("EXPIRE", cmd_expire, HlOper, CMD_FROM_OPSERV_ONLY);
helpserv_define_func("WEEKSTART", cmd_weekstart, HlTrial, CMD_NEED_BOT);
+ helpserv_define_func("MODSTATS", cmd_modstats, HlOwner, CMD_NEED_BOT);
helpserv_option_dict = dict_new();
helpserv_define_option("PAGETARGET", opt_pagetarget_command);
" UNREGISTER Unregister a HelpServ bot",
" BOTS List registered HelpServ instances",
" EXPIRE Expire inactive channels",
+ " MODSTATS Modify the stats of a user",
" READHELP Re-read help file");
"COMMANDS" "${index}";
"/msg $S CLOSE <reqid|nick|*account> [reason]",
"Closes out the specified request. The optional [reason] is included in the request log file.");
"CLVL" ("$bCLVL$b",
- "/msg $S CLVL <user|*nick> <new-level>",
+ "/msg $S CLVL <nick|*account> <new-level>",
"Allows an owner or manager to change a user's access with $S.",
"$uSee also:$u addtrial, addhelper, addmanager, deluser, helpers");
"DELOWNER" ("$bDELOWNER$b",
"\"assigned\" means that a helper has picked up the request or been assigned to handle it.",
"\"me\" means to only show requests assigned to you.",
"$uSee also:$u next, pickup");
+"MODSTATS" ("$bMODSTATS$b",
+ "/msg $S MODSTATS <user|*nick> <field> <week> <mod>",
+ "Allows an oper to modify a user's $S stats.",
+ "<field> can be one of $btime$b, $bpicked_up$b, $bclosed$b, $breassigned_from$b, $breassigned_to$b",
+ "<week> can be a number from $b0$b to $b4$b with 0 being the current week and 4 being the total.",
+ "Instead of 0 and 4, $bcurrent$b and $btotal$b may also be used.",
+ "<mod> can be any positive/negative number.",
+ "Note that the total is not automatically changed if you update another week.");
"MOVE" ("$bMOVE$b",
"/msg $O HELPSERV MOVE <bot-nick> <new-nick|#new-channel>",
"Makes the HelpServ bot use a different nick or channel.");