#define KEY_NICK "nick"
#define KEY_DB_BADCHANS "badchans"
#define KEY_HELP_CHANNEL "help_channel"
+#define KEY_PUBLIC_CHANNEL "public_channel"
#define KEY_PAGE_DEST "page_dest"
#define KEY_CMDWORD "cmdword"
#define KEY_PERSIST_LENGTH "persist_length"
#define KEY_PRIVMSG_ONLY "privmsg_only"
#define KEY_REQ_ON_JOIN "req_on_join"
#define KEY_AUTO_VOICE "auto_voice"
+#define KEY_AUTO_JOIN "auto_join"
#define KEY_AUTO_DEVOICE "auto_devoice"
#define KEY_LAST_ACTIVE "last_active"
{ "HSMSG_SET_PRIVMSGONLY", "$bPrivmsgOnly $b %s" },
{ "HSMSG_SET_REQONJOIN", "$bReqOnJoin $b %s" },
{ "HSMSG_SET_AUTOVOICE", "$bAutoVoice $b %s" },
+ { "HSMSG_SET_AUTOJOIN", "$bAutoJoin $b %s" },
{ "HSMSG_SET_AUTODEVOICE", "$bAutoDevoice $b %s" },
+ { "HSMSG_SET_PUBLICCHAN", "$bPublicChan $b %s" },
{ "HSMSG_PAGE_NOTICE", "notice" },
{ "HSMSG_PAGE_PRIVMSG", "privmsg" },
{ "HSMSG_PAGE_ONOTICE", "onotice" },
struct userNode *helpserv;
struct chanNode *helpchan;
+ struct chanNode *publicchan;
struct chanNode *page_targets[PGSRC_COUNT];
enum page_type page_types[PGSRC_COUNT];
unsigned int privmsg_only : 1;
unsigned int req_on_join : 1;
unsigned int auto_voice : 1;
+ unsigned int auto_join : 1;
unsigned int auto_devoice : 1;
unsigned int helpchan_empty : 1;
helpserv_msguser(user, "HSMSG_USERCMD_NO_REQUEST");
return;
}
- if ((hs->persist_lengths[PERSIST_T_REQUEST] == PERSIST_PART) && !GetUserMode(hs->helpchan, user)) {
- helpserv_msguser(user, "HSMSG_REQ_YOU_NOT_IN_HELPCHAN_OPEN", hs->helpchan->name);
+ if ((hs->persist_lengths[PERSIST_T_REQUEST] == PERSIST_PART) && !GetUserMode(hs->helpchan, user) && (!hs->publicchan || (hs->publicchan && !GetUserMode(hs->publicchan, user)))) {
+ if(hs->publicchan)
+ helpserv_msguser(user, "HSMSG_REQ_YOU_NOT_IN_HELPCHAN_OPEN", hs->publicchan->name);
+ else
+ helpserv_msguser(user, "HSMSG_REQ_YOU_NOT_IN_HELPCHAN_OPEN", hs->helpchan->name);
return;
}
req->helper = GetHSUser(hs, user->handle_info);
assert(req->helper);
req->assigned = now;
-
+
+ if (req->user && hs->auto_join) {
+ irc_svsjoin(hs->helpserv,req->user,hs->helpchan);
+ }
+
if (old_helper) {
helpserv_notice(user, "HSMSG_REQ_REASSIGNED", req->id, old_helper->handle->handle);
req->helper->reassigned_to[0]++;
if ((change.args[0].u.member = GetUserMode(hs->helpchan, req->user)))
mod_chanmode_announce(hs->helpserv, hs->helpchan, &change);
}
-
+
return 1;
}
dict_insert(helpserv_bots_bychan_dict, hs->helpchan->name, botlist);
}
helpserv_botlist_append(botlist, hs);
-
return hs;
}
char *nick, *helpchan, reason[MAXLEN];
struct handle_info *handle;
- REQUIRE_PARMS(4);
+ REQUIRE_PARMS(3);
nick = argv[1];
if (!is_valid_nick(nick)) {
helpserv_notice(user, "HSMSG_ILLEGAL_NICK", nick);
}
static void helpserv_unregister(struct helpserv_bot *bot, const char *quit_fmt, const char *global_fmt, const char *actor) {
- char reason[MAXLEN], channame[CHANNELLEN], botname[NICKLEN];
+ char reason[MAXLEN], channame[CHANNELLEN], *botname;
struct helpserv_botlist *botlist;
size_t len;
helpserv_botlist_remove(botlist, bot);
if (!botlist->used)
dict_remove(helpserv_bots_bychan_dict, bot->helpchan->name);
- len = strlen(bot->helpserv->nick) + 1;
- safestrncpy(botname, bot->helpserv->nick, len);
+ botname=bot->helpserv->nick;
len = strlen(bot->helpchan->name) + 1;
safestrncpy(channame, bot->helpchan->name, len);
snprintf(reason, sizeof(reason), quit_fmt, actor);
OPTION_BINARY(hs->auto_voice, "HSMSG_SET_AUTOVOICE");
}
+static HELPSERV_OPTION(opt_auto_join) {
+ OPTION_BINARY(hs->auto_join, "HSMSG_SET_AUTOJOIN");
+}
+
static HELPSERV_OPTION(opt_auto_devoice) {
OPTION_BINARY(hs->auto_devoice, "HSMSG_SET_AUTODEVOICE");
}
+static HELPSERV_OPTION(opt_publicchan) {
+ char *publicchan;
+ int changed=0;
+ if (argc > 0) {
+ publicchan = argv[0];
+ if(strcmp(publicchan, "*")) {
+ if (!IsChannelName(publicchan)) {
+ helpserv_notice(user, "HSMSG_ILLEGAL_CHANNEL", publicchan);
+ HELPSERV_SYNTAX();
+ return 0;
+ }
+ if (opserv_bad_channel(publicchan)) {
+ helpserv_notice(user, "HSMSG_ILLEGAL_CHANNEL", publicchan);
+ return 0;
+ }
+ }
+ if (!hs->publicchan || (hs->publicchan && irccasecmp(hs->publicchan->name, publicchan))) {
+ if(hs->publicchan) {
+ //there is another public chan o.O
+ //part
+ DelChannelUser(hs->helpserv, hs->publicchan, "unregistered.", 0);
+ hs->publicchan = NULL;
+ }
+ changed = 1;
+ if(strcmp(publicchan, "*")) {
+ if (!(hs->publicchan = GetChannel(publicchan))) {
+ hs->publicchan = AddChannel(publicchan, now, NULL, NULL);
+ AddChannelUser(hs->helpserv, hs->publicchan)->modes |= MODE_CHANOP;
+ } else {
+ struct mod_chanmode change;
+ mod_chanmode_init(&change);
+ change.argc = 1;
+ change.args[0].mode = MODE_CHANOP;
+ change.args[0].u.member = AddChannelUser(hs->helpserv, hs->publicchan);
+ mod_chanmode_announce(hs->helpserv, hs->publicchan, &change);
+ }
+ }
+ }
+ } else {
+ changed = 0;
+ }
+ helpserv_notice(user, "HSMSG_SET_PUBLICCHAN", (hs->publicchan) ? hs->publicchan->name : user_find_message(user,"MSG_NONE")); \
+ return changed;
+}
+
static HELPSERV_FUNC(cmd_set) {
helpserv_option_func_t *opt;
if (argc < 2) {
unsigned int i;
helpserv_option_func_t *display[] = {
- opt_pagetarget_command, opt_pagetarget_alert, opt_pagetarget_status,
+ opt_publicchan, opt_pagetarget_command, opt_pagetarget_alert, opt_pagetarget_status,
opt_pagetype, opt_alert_page_type, opt_status_page_type,
opt_greeting, opt_req_opened, opt_req_assigned, opt_req_closed,
opt_idle_delay, opt_whine_delay, opt_whine_interval,
opt_empty_interval, opt_stale_delay, opt_request_persistence,
opt_helper_persistence, opt_notification, opt_id_wrap,
- opt_req_maxlen, opt_privmsg_only, opt_req_on_join, opt_auto_voice,
+ opt_req_maxlen, opt_privmsg_only, opt_req_on_join, opt_auto_voice, opt_auto_join,
opt_auto_devoice
};
/* Other settings and state */
saxdb_write_string(ctx, KEY_HELP_CHANNEL, hs->helpchan->name);
+ if(hs->publicchan) saxdb_write_string(ctx, KEY_PUBLIC_CHANNEL, hs->publicchan->name);
slist = alloc_string_list(PGSRC_COUNT);
for (pagesrc=0; pagesrc<PGSRC_COUNT; pagesrc++) {
struct chanNode *target = hs->page_targets[pagesrc];
saxdb_write_int(ctx, KEY_PRIVMSG_ONLY, hs->privmsg_only);
saxdb_write_int(ctx, KEY_REQ_ON_JOIN, hs->req_on_join);
saxdb_write_int(ctx, KEY_AUTO_VOICE, hs->auto_voice);
+ saxdb_write_int(ctx, KEY_AUTO_JOIN, hs->auto_join);
saxdb_write_int(ctx, KEY_AUTO_DEVOICE, hs->auto_devoice);
saxdb_write_int(ctx, KEY_LAST_ACTIVE, hs->last_active);
static int helpserv_bot_read(const char *key, void *data, UNUSED_ARG(void *extra)) {
struct record_data *br = data, *raw_record;
struct helpserv_bot *hs;
- char *registrar, *helpchannel_name, *str;
+ char *registrar, *helpchannel_name, *publicchannel_name, *str;
dict_t users, requests;
enum page_source pagesrc;
enum message_type msgtype;
hs = register_helpserv(key, helpchannel_name, registrar);
+ publicchannel_name = database_get_data(GET_RECORD_OBJECT(br), KEY_PUBLIC_CHANNEL, RECDB_QSTRING);
+ if (publicchannel_name) {
+ if(!IsChannelName(publicchannel_name)) {
+ log_module(HS_LOG, LOG_ERROR, "%s has an invalid channel name.", key);
+ return 0;
+ } else {
+ if (!(hs->publicchan = GetChannel(publicchannel_name))) {
+ hs->publicchan = AddChannel(publicchannel_name, now, NULL, NULL);
+ AddChannelUser(hs->helpserv, hs->publicchan)->modes |= MODE_CHANOP;
+ } else {
+ struct mod_chanmode change;
+ mod_chanmode_init(&change);
+ change.argc = 1;
+ change.args[0].mode = MODE_CHANOP;
+ change.args[0].u.member = AddChannelUser(hs->helpserv, hs->publicchan);
+ mod_chanmode_announce(hs->helpserv, hs->publicchan, &change);
+ }
+ }
+ }
raw_record = dict_find(GET_RECORD_OBJECT(br), KEY_PAGE_DEST, NULL);
switch (raw_record ? raw_record->type : RECDB_INVALID) {
case RECDB_QSTRING:
hs->req_on_join = str ? enabled_string(str) : 0;
str = database_get_data(GET_RECORD_OBJECT(br), KEY_AUTO_VOICE, RECDB_QSTRING);
hs->auto_voice = str ? enabled_string(str) : 0;
+ str = database_get_data(GET_RECORD_OBJECT(br), KEY_AUTO_JOIN, RECDB_QSTRING);
+ hs->auto_join = str ? enabled_string(str) : 0;
str = database_get_data(GET_RECORD_OBJECT(br), KEY_AUTO_DEVOICE, RECDB_QSTRING);
hs->auto_devoice = str ? enabled_string(str) : 0;
str = database_get_data(GET_RECORD_OBJECT(br), KEY_LAST_ACTIVE, RECDB_QSTRING);
struct helpserv_request *req = iter_data(it);
if (mn->user != req->user)
+ continue;
+ if (GetUserMode(hs->helpchan, mn->user)) //publicchan
continue;
if (req->text->used) {
helpserv_message(hs, mn->user, MSGTYPE_REQ_DROPPED);
if (!nicknewest || (nicknewest->opened < req->opened))
nicknewest = req;
+
if (hs->auto_voice && req->helper)
{
struct mod_chanmode change;
if ((force_greet && nicknewest) || (newest && (nicknewest == newest))) {
/* Let the user know. Either the user is forced to be greeted, or the
* above has changed which request will get their next message. */
- helpserv_msguser(user, "HSMSG_GREET_EXISTING_REQ", hs->helpchan->name, nicknewest->id);
+ //helpserv_msguser(user, "HSMSG_GREET_EXISTING_REQ", hs->helpchan->name, nicknewest->id);
}
}
helpserv_define_option("PRIVMSGONLY", opt_privmsg_only);
helpserv_define_option("REQONJOIN", opt_req_on_join);
helpserv_define_option("AUTOVOICE", opt_auto_voice);
+ helpserv_define_option("AUTOJOIN", opt_auto_join);
helpserv_define_option("AUTODEVOICE", opt_auto_devoice);
+ helpserv_define_option("PUBLICCHAN", opt_publicchan);
helpserv_usercmd_dict = dict_new();
dict_insert(helpserv_usercmd_dict, "WAIT", usercmd_wait);