/* mod-helpserv.c - Support Helper assistant service
- * Copyright 2002-2003 srvx Development Team
+ * Copyright 2002-2003, 2006 srvx Development Team
*
* This file is part of srvx.
*
}
/* Handle a message from a user to a HelpServ bot. */
-static void helpserv_usermsg(struct userNode *user, struct helpserv_bot *hs, char *text) {
+static void helpserv_usermsg(struct userNode *user, struct helpserv_bot *hs, const char *text) {
const int from_opserv = 0; /* for helpserv_notice */
struct helpserv_request *req=NULL, *newest=NULL;
struct helpserv_reqlist *reqlist, *hand_reqlist;
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);
}
/* Handle messages direct to a HelpServ bot. */
-static void helpserv_botmsg(struct userNode *user, struct userNode *target, char *text, UNUSED_ARG(int server_qualified)) {
+static void helpserv_botmsg(struct userNode *user, struct userNode *target, const char *text, UNUSED_ARG(int server_qualified)) {
struct helpserv_bot *hs;
struct helpserv_cmd *cmd;
struct helpserv_user *hs_user;
char *argv[MAXNUMPARAMS];
+ char tmpline[MAXLEN];
int argc, argv_shift;
const int from_opserv = 0; /* for helpserv_notice */
}
argv_shift = 1;
- argc = split_line(text, false, ArrayLength(argv)-argv_shift, argv+argv_shift);
+ safestrncpy(tmpline, text, sizeof(tmpline));
+ argc = split_line(tmpline, false, ArrayLength(argv)-argv_shift, argv+argv_shift);
if (!argc)
return;
if (!cmd->func) {
helpserv_notice(user, "HSMSG_INTERNAL_COMMAND", argv[argv_shift]);
} else if (cmd->func(user, hs, 0, argc, argv+argv_shift)) {
- unsplit_string(argv+argv_shift, argc, text);
- log_audit(HS_LOG, LOG_COMMAND, user, hs->helpserv, hs->helpchan->name, 0, text);
+ unsplit_string(argv+argv_shift, argc, tmpline);
+ log_audit(HS_LOG, LOG_COMMAND, user, hs->helpserv, hs->helpchan->name, 0, tmpline);
}
}
return;
}
- for (other = req->hs->unhandled, pos = -1, count = 0;
+ for (other = req->hs->unhandled, pos = -1, count = 0;
other;
other = other->next_unhandled, ++count) {
if (other == req)
struct helpserv_user *owner=NULL;
bot = iter_data(it);
-
+
for (it2=dict_first(bot->users); it2; it2=iter_next(it2)) {
if (((struct helpserv_user *)iter_data(it2))->level == HlOwner) {
owner = iter_data(it2);
* it's a harmless default */
hs = calloc(1, sizeof(struct helpserv_bot));
- if (!(hs->helpserv = AddService(nick, "+iok", helpserv_conf.description, NULL))) {
+ if (!(hs->helpserv = AddLocalUser(nick, nick, NULL, helpserv_conf.description, NULL))) {
free(hs);
return NULL;
}
}
}
}
-
+
if (mn->user->handle_info && (userlist = dict_find(helpserv_users_byhand_dict, mn->user->handle_info->handle, NULL))) {
for (i=0; i < userlist->used; i++) {
struct helpserv_user *hs_user = userlist->list[i];
struct helpserv_request *newest=NULL, *nicknewest=NULL;
unsigned int i;
const int from_opserv = 0; /* For helpserv_notice */
-
+
if (!(user->handle_info && (hand_reqlist = dict_find(helpserv_reqs_byhand_dict, user->handle_info->handle, NULL))) && !force_greet) {
return;
}
if (IsLocal(user))
return 0;
-
+
if (!(botlist = dict_find(helpserv_bots_bychan_dict, chan->name, NULL)))
return 0;
for (i=0; i < userlist->used; i++)
dict_insert(userlist->list[i]->hs->users, handle->handle, userlist->list[i]);
}
-
+
if (reqlist) {
for (i=0; i < reqlist->used; i++) {
struct helpserv_request *req=reqlist->list[i];
helpserv_bots_dict = dict_new();
dict_set_free_data(helpserv_bots_dict, helpserv_free_bot);
-
+
helpserv_bots_bychan_dict = dict_new();
dict_set_free_data(helpserv_bots_bychan_dict, helpserv_botlist_free);