X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/a32da4c70ca85b879f8162469ae37ffeca500b99..7b0150f8ee4d699706369f3f1d1304bcd20e7f06:/src/mod-helpserv.c diff --git a/src/mod-helpserv.c b/src/mod-helpserv.c index 5e8a513..2557458 100644 --- a/src/mod-helpserv.c +++ b/src/mod-helpserv.c @@ -1,9 +1,9 @@ /* mod-helpserv.c - Support Helper assistant service * Copyright 2002-2003 srvx Development Team * - * This file is part of srvx. + * This file is part of x3. * - * srvx is free software; you can redistribute it and/or modify + * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. @@ -218,6 +218,7 @@ static const struct message_entry msgtab[] = { { "HSMSG_REQ_PERSIST_PART", "Everything you tell me until you are helped (or you leave %s) will be recorded. If you part %s, your request will be lost." }, { "HSMSG_REQ_PERSIST_HANDLE", "Everything you tell me until you are helped will be recorded." }, { "HSMSG_REQ_MAXLEN", "Sorry, but your request has reached the maximum number of lines. Please wait to be assigned to a helper and continue explaining your request to them." }, + { "HSMSQ_REQ_TEXT_ADDED", "Message from $b%s:$b %s" }, { "HSMSG_REQ_FOUND_ANOTHER", "Request ID#%lu has been closed. $S detected that you also have request ID#%lu open. If you send $S a message, it will be associated with that request." }, /* Messages that are inserted into request text */ @@ -1072,7 +1073,7 @@ static void helpserv_usermsg(struct userNode *user, struct helpserv_bot *hs, cha if (user->handle_info) helpserv_notify(req->helper, "HSMSG_PAGE_UPD_REQUEST_AUTHED", req->id, user->nick, user->handle_info->handle, timestr, updatestr); else - helpserv_notify(req->helper, "HSMSG_PAGE_UPD_REQUESTNOT_AUTHED", req->id, user->nick, timestr, updatestr); + helpserv_notify(req->helper, "HSMSG_PAGE_UPD_REQUEST_NOT_AUTHED", req->id, user->nick, timestr, updatestr); else if (user->handle_info) helpserv_page(PGSRC_STATUS, "HSMSG_PAGE_UPD_REQUEST_AUTHED", req->id, user->nick, user->handle_info->handle, timestr, updatestr); @@ -1085,7 +1086,22 @@ static void helpserv_usermsg(struct userNode *user, struct helpserv_bot *hs, cha req->updated = now; if (!hs->req_maxlen || req->text->used < hs->req_maxlen) + { string_list_append(req->text, strdup(text)); + + struct userNode *likely_helper; + /* Find somebody likely to be the helper */ + if (!req->helper) + likely_helper = NULL; + else if ((likely_helper = req->helper->handle->users) && !likely_helper->next_authed) { + /* only one user it could be :> */ + } else for (likely_helper = req->helper->handle->users; likely_helper; likely_helper = likely_helper->next_authed) + if (GetUserMode(hs->helpchan, likely_helper)) + break; + + if(likely_helper) + send_target_message(1, likely_helper->nick, hs->helpserv, "HSMSQ_REQ_TEXT_ADDED", user->nick, text); + } else helpserv_msguser(user, "HSMSG_REQ_MAXLEN"); } @@ -1392,7 +1408,7 @@ static int show_helper_range(struct userNode *user, struct helpserv_bot *hs, int struct helpfile_table tbl; struct helpserv_user *hs_user; dict_iterator_t it; - enum helpserv_level last_level; +/* enum helpserv_level last_level; Zoot style */ unsigned int ii; users.used = 0; @@ -1413,7 +1429,8 @@ static int show_helper_range(struct userNode *user, struct helpserv_bot *hs, int } qsort(users.list, users.used, sizeof(users.list[0]), helpserv_user_comp); switch (user->handle_info->userlist_style) { - case HI_STYLE_DEF: + default: + case HI_STYLE_NORMAL: tbl.length = users.used + 1; tbl.width = 3; tbl.flags = TABLE_NO_FREE; @@ -1431,6 +1448,7 @@ static int show_helper_range(struct userNode *user, struct helpserv_bot *hs, int } table_send((from_opserv ? opserv : hs->helpserv), user->nick, 0, NULL, tbl); break; + /* case HI_STYLE_ZOOT: default: last_level = HlNone; tbl.length = 0; @@ -1454,6 +1472,7 @@ static int show_helper_range(struct userNode *user, struct helpserv_bot *hs, int helpserv_notice(user, "HSMSG_USERLIST_ZOOT_LVL", hs->helpserv->nick, helpserv_level_names[last_level]); table_send((from_opserv ? opserv : hs->helpserv), user->nick, 0, NULL, tbl); } + */ } return 1; } @@ -1550,7 +1569,7 @@ static void free_request(void *data) { /* Logging */ if (shutting_down && (req->hs->persist_types[PERSIST_T_REQUEST] != PERSIST_CLOSE || !req->handle)) { - helpserv_log_request(req, "srvx shutdown"); + helpserv_log_request(req, "X3 shutdown"); } /* Clean up from the unhandled queue */ @@ -2197,7 +2216,7 @@ static HELPSERV_FUNC(cmd_move) { REQUIRE_PARMS(2); if (is_valid_nick(argv[1])) { - char *newnick = argv[1], oldnick[NICKLEN], reason[MAXLEN]; + char *newnick = argv[1], oldnick[NICKLEN]; strcpy(oldnick, hs->helpserv->nick); @@ -2212,8 +2231,8 @@ static HELPSERV_FUNC(cmd_move) { helpserv_notice(user, "HSMSG_RENAMED", oldnick, newnick); - snprintf(reason, MAXLEN, "HelpServ bot %s (in %s) renamed to %s by %s.", oldnick, hs->helpchan->name, newnick, user->nick); - global_message(MESSAGE_RECIPIENT_OPERS, reason); + global_message_args(MESSAGE_RECIPIENT_OPERS, "HSMSG_BOT_RENAMED", oldnick, + hs->helpchan->name, newnick, user->nick); return 1; } else if (IsChannelName(argv[1])) { @@ -2246,7 +2265,7 @@ static HELPSERV_FUNC(cmd_move) { } if (!(hs->helpchan = GetChannel(newchan))) { - hs->helpchan = AddChannel(newchan, now, NULL, NULL); + hs->helpchan = AddChannel(newchan, now, NULL, NULL, NULL); AddChannelUser(hs->helpserv, hs->helpchan)->modes |= MODE_CHANOP; } else if (!helpserv_in_channel(hs, old_helpchan)) { struct mod_chanmode change; @@ -2263,8 +2282,8 @@ static HELPSERV_FUNC(cmd_move) { } helpserv_botlist_append(botlist, hs); - snprintf(reason, MAXLEN, "HelpServ %s (%s) moved to %s by %s.", hs->helpserv->nick, oldchan, newchan, user->nick); - global_message(MESSAGE_RECIPIENT_OPERS, reason); + global_message_args(MESSAGE_RECIPIENT_OPERS, "HSMSG_BOT_MOVED", hs->helpserv->nick, + oldchan, newchan, user->nick); return 1; } else { @@ -2607,7 +2626,7 @@ static struct helpserv_bot *register_helpserv(const char *nick, const char *help reg_privmsg_func(hs->helpserv, helpserv_botmsg); if (!(hs->helpchan = GetChannel(help_channel))) { - hs->helpchan = AddChannel(help_channel, now, NULL, NULL); + hs->helpchan = AddChannel(help_channel, now, NULL, NULL, NULL); AddChannelUser(hs->helpserv, hs->helpchan)->modes |= MODE_CHANOP; } else { struct mod_chanmode change; @@ -2640,7 +2659,7 @@ static struct helpserv_bot *register_helpserv(const char *nick, const char *help } static HELPSERV_FUNC(cmd_register) { - char *nick, *helpchan, reason[MAXLEN]; + char *nick, *helpchan; struct handle_info *handle; REQUIRE_PARMS(4); @@ -2676,9 +2695,9 @@ static HELPSERV_FUNC(cmd_register) { helpserv_notice(user, "HSMSG_REG_SUCCESS", handle->handle, nick); - snprintf(reason, MAXLEN, "HelpServ %s (%s) registered to %s by %s.", nick, hs->helpchan->name, handle->handle, user->nick); /* Not sent to helpers, since they can't register HelpServ */ - global_message(MESSAGE_RECIPIENT_OPERS, reason); + global_message_args(MESSAGE_RECIPIENT_OPERS, "HSMSG_BOT_REGISTERED", nick, + hs->helpchan->name, handle->handle, user->nick); return 1; } @@ -2719,8 +2738,7 @@ static void helpserv_unregister(struct helpserv_bot *bot, const char *quit_fmt, snprintf(reason, sizeof(reason), quit_fmt, actor); DelUser(bot->helpserv, NULL, 1, reason); dict_remove(helpserv_bots_dict, botname); - snprintf(reason, sizeof(reason), global_fmt, botname, channame, actor); - global_message(MESSAGE_RECIPIENT_OPERS, reason); + global_message_args(MESSAGE_RECIPIENT_OPERS, global_fmt, botname, channame, actor); } static HELPSERV_FUNC(cmd_unregister) { @@ -2732,7 +2750,7 @@ static HELPSERV_FUNC(cmd_unregister) { log_audit(HS_LOG, LOG_COMMAND, user, hs->helpserv, hs->helpchan->name, 0, "unregister CONFIRM"); } - helpserv_unregister(hs, "Unregistered by %s", "HelpServ %s (%s) unregistered by %s.", user->nick); + helpserv_unregister(hs, "Unregistered by %s", "HSMSG_BOT_UNREGISTERED", user->nick); return from_opserv; } @@ -2748,7 +2766,7 @@ static HELPSERV_FUNC(cmd_expire) { next = iter_next(it); if ((unsigned int)(now - bot->last_active) < helpserv_conf.expire_age) continue; - helpserv_unregister(bot, "Registration expired due to inactivity", "HelpServ %s (%s) expired at request of %s.", user->nick); + helpserv_unregister(bot, "Registration expired due to inactivity", "HSMSG_BOT_EXPIRED", user->nick); count++; } helpserv_notice(user, "HSMSG_EXPIRATION_DONE", count); @@ -2854,7 +2872,7 @@ static void set_page_target(struct helpserv_bot *hs, enum page_source idx, const } new_target = GetChannel(target); if (!new_target) { - new_target = AddChannel(target, now, NULL, NULL); + new_target = AddChannel(target, now, NULL, NULL, NULL); AddChannelUser(hs->helpserv, new_target); } } else { @@ -3648,7 +3666,7 @@ static void helpserv_conf_read(void) { helpserv_conf.db_backup_frequency = str ? ParseInterval(str) : 7200; str = database_get_data(conf_node, "description", RECDB_QSTRING); - helpserv_conf.description = str; + helpserv_conf.description = str ? str : "Help Queue Manager"; str = database_get_data(conf_node, "reqlogfile", RECDB_QSTRING); if (str && strlen(str))