X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/ff3b058ac51e9caf5cf1fd310b8a401a97a85582..63637aea5429a07497cdda236ac2de5e22c9d4b6:/src/chanserv.c diff --git a/src/chanserv.c b/src/chanserv.c index 74f9898..258e76a 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -21,9 +21,13 @@ #include "chanserv.h" #include "conf.h" #include "global.h" +#include "gline.h" +#include "ioset.h" #include "modcmd.h" #include "opserv.h" /* for opserv_bad_channel() */ +#include "nickserv.h" /* for oper_outranks() */ #include "saxdb.h" +#include "shun.h" #include "spamserv.h" #include "timeq.h" @@ -39,7 +43,7 @@ #define KEY_ADJUST_DELAY "adjust_delay" #define KEY_CHAN_EXPIRE_FREQ "chan_expire_freq" #define KEY_CHAN_EXPIRE_DELAY "chan_expire_delay" -#define KEY_DNR_EXPIRE_FREQ "dnr_expire_freq" +#define KEY_DNR_EXPIRE_FREQ "dnr_expire_freq" #define KEY_BAN_TIMEOUT_FREQ "ban_timeout_freq" #define KEY_MAX_CHAN_USERS "max_chan_users" #define KEY_MAX_CHAN_BANS "max_chan_bans" @@ -57,6 +61,7 @@ #define KEY_NODELETE_LEVEL "nodelete_level" #define KEY_MAX_USERINFO_LENGTH "max_userinfo_length" #define KEY_GIVEOWNERSHIP_PERIOD "giveownership_timeout" +#define KEY_VALID_CHANNEL_REGEX "valid_channel_regex" /* ChanServ database */ #define KEY_VERSION_CONTROL "version_control" @@ -112,6 +117,7 @@ #define KEY_NOTES "notes" #define KEY_TOPIC_MASK "topic_mask" #define KEY_OWNER_TRANSFER "owner_transfer" +#define KEY_MAXSETINFO "maxsetinfo" /* User data */ #define KEY_LEVEL "level" @@ -152,8 +158,8 @@ static const struct message_entry msgtab[] = { /* Do-not-register channels */ { "CSMSG_NOT_DNR", "$b%s$b is not a valid channel name or *account." }, { "CSMSG_DNR_SEARCH_RESULTS", "$bDo-Not-Register Channels$b" }, - { "CSMSG_DNR_INFO", "$b%s$b (set by $b%s$b): %s" }, - { "CSMSG_DNR_INFO_SET", "$b%s$b (set %s ago by $b%s$b): %s" }, + { "CSMSG_DNR_INFO", "$b%s$b is do-not-register (by $b%s$b): %s" }, + { "CSMSG_DNR_INFO_SET", "$b%s$b is do-not-register (set %s by $b%s$b): %s" }, { "CSMSG_DNR_INFO_SET_EXPIRES", "$b%s$b is do-not-register (set %s by $b%s$b; expires %s): %s" }, { "CSMSG_MORE_DNRS", "%d more do-not-register entries skipped." }, { "CSMSG_DNR_CHANNEL", "Only network staff may register $b%s$b." }, @@ -199,7 +205,9 @@ static const struct message_entry msgtab[] = { { "CSMSG_ALREADY_VOICED", "You are already voiced in $b%s$b." }, { "CSMSG_ALREADY_DOWN", "You are not opped, halfopped, or voiced in $b%s$b." }, { "CSMSG_ALREADY_OPCHANNED", "There has been no net.join since the last opchan in $b%s$b." }, + { "CSMSG_OUT_OF_CHANNEL", "For some reason I don't seem to be in $b%s$b." }, { "CSMSG_OPCHAN_DONE", "I have (re-)opped myself in $b%s$b." }, + { "CSMSG_NOT_IN_CHANNEL", "I am not in %s." }, /* Removing yourself from a channel. */ { "CSMSG_NO_OWNER_DELETEME", "You cannot delete your owner access in $b%s$b." }, @@ -231,8 +239,8 @@ static const struct message_entry msgtab[] = { { "CSMSG_MULTIPLE_OWNERS", "There is more than one owner in %s; please use $bCLVL$b, $bDELOWNER$b and/or $bADDOWNER$b instead." }, { "CSMSG_NO_OWNER", "There is no owner for %s; please use $bCLVL$b and/or $bADDOWNER$b instead." }, { "CSMSG_TRANSFER_WAIT", "You must wait %s before you can give ownership of $b%s$b to someone else." }, - { "CSMSG_CONFIRM_GIVEOWNERSHIP", "To really give ownership to $b%1$s$b, you must use 'giveownership *%1$s %2$s'." }, { "CSMSG_NO_TRANSFER_SELF", "You cannot give ownership to your own account." }, + { "CSMSG_CONFIRM_GIVEOWNERSHIP", "To really give ownership to $b%1$s$b, you must use 'giveownership *%1$s %2$s'." }, { "CSMSG_OWNERSHIP_GIVEN", "Ownership of $b%s$b has been transferred to account $b%s$b." }, /* Ban management */ @@ -253,6 +261,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_NO_MATCHING_USERS", "No one in $b%s$b has a hostmask matching $b%s$b." }, { "CSMSG_BAN_NOT_FOUND", "Sorry, no ban or LAMER found: $b%s$b." }, { "CSMSG_BANLIST_FULL", "The $b%s$b channel ban list is $bfull$b." }, + { "CSMSG_BAD_BAN", "The given ban $b%s$b is invalid." }, { "CSMSG_INVALID_TRIM", "$b%s$b isn't a valid trim target." }, @@ -287,6 +296,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_SET_USERGREETING", "$bUserGreeting$b %s" }, { "CSMSG_SET_MODES", "$bModes $b %s" }, { "CSMSG_SET_NODELETE", "$bNoDelete $b %s" }, + { "CSMSG_SET_UNREVIEWED", "$bUnreviewed $b %s" }, { "CSMSG_SET_DYNLIMIT", "$bDynLimit $b %s - +l joinflood protection." }, { "CSMSG_SET_OFFCHANNEL", "$bOffChannel $b %s" }, { "CSMSG_SET_USERINFO", "$bUserInfo $b %d - and above userinfos are shown." }, @@ -303,9 +313,9 @@ static const struct message_entry msgtab[] = { { "CSMSG_SET_TOYS", "$bToys $b %d - %s" }, { "CSMSG_SET_CTCPREACTION", "$bCTCPReaction$b %d - %s" }, { "CSMSG_SET_TOPICREFRESH", "$bTopicRefresh$b %d - %s" }, - { "CSMSG_SET_UNREVIEWED", "$bUnreviewed $b %s" }, { "CSMSG_SET_RESYNC", "$bResync $b %d - %s" }, { "CSMSG_SET_BANTIMEOUT", "$bBanTimeout $b %d - %s" }, + { "CSMSG_SET_MAXSETINFO", "$bMaxSetInfo $b %d - maximum characters in a setinfo line." }, { "CSMSG_USET_AUTOOP", "$bAutoOp $b %s" }, { "CSMSG_USET_AUTOVOICE", "$bAutoVoice $b %s" }, @@ -326,7 +336,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_DEVOICED_USERS", "Devoiced users in $b%s$b." }, { "CSMSG_AUTOMODE_NONE", "Noone will be automatically oped, half-oped, or voiced." }, - { "CSMSG_AUTOMODE_NORMAL", "Give voice to peons, half-op to halfops, and op to ops." }, + { "CSMSG_AUTOMODE_NORMAL", "Give voice to pals, half-op to halfops, and op to ops." }, { "CSMSG_AUTOMODE_VOICE", "#1 plus give voice to everyone." }, { "CSMSG_AUTOMODE_HOP", "#1 plus give halfops to everyone." }, { "CSMSG_AUTOMODE_OP", "#1 plus give ops to everyone (not advised)" }, @@ -372,7 +382,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_CANNOT_INVITE", "You cannot invite %s to %s." }, { "CSMSG_ALREADY_PRESENT", "%s is already in $b%s$b." }, { "CSMSG_YOU_ALREADY_PRESENT", "You are already in $b%s$b." }, - { "CSMSG_LOW_CHANNEL_ACCESS", "You lack sufficient access in %s to use this command." }, + { "CSMSG_LOW_CHANNEL_ACCESS", "You lack sufficient access in %s for $S to invite you." }, { "CSMSG_INFOLINE_TOO_LONG", "Your infoline may not exceed %u characters." }, { "CSMSG_BAD_INFOLINE", "You may not use the character \\%03o in your infoline." }, @@ -529,6 +539,30 @@ static const struct message_entry msgtab[] = { { "CSMSG_DIE_ROLL", "A $b%lu$b shows on the %lu-sided die." }, { "CSMSG_HUGGLES_HIM", "\001ACTION huggles %s\001" }, { "CSMSG_HUGGLES_YOU", "\001ACTION huggles you\001" }, + { "CSMSG_ROULETTE_LOADS", "\001ACTION loads the gun and sets it on the table\001" }, + { "CSMSG_ROULETTE_NEW", "Please type %croulette to start a new round" } , + { "CSMSG_ROULETTE_BETTER_LUCK", "Better luck next time, %s" }, + { "CSMSG_ROULETTE_BANG", "Bang!!!" } , + { "CSMSG_ROULETTE_CLICK", "Click" } , + + { "CSMSG_SPIN_WHEEL1", "\001ACTION spins the wheel of misfortune for: %s\001" } , + { "CSMSG_SPIN_WHEEL2", "Round and round she goes, where she stops, nobody knows...!" } , + { "CSMSG_SPIN_WHEEL3", "The wheel of misfortune has stopped on..." } , + + { "CSMSG_SPIN_PEER", "Peer: Peer's gonna eat you!!!!" } , + { "CSMSG_SPIN_PARTALL", "Part all: Part all channels" } , + { "CSMSG_SPIN_Gline", "Gline: /gline for random amount of time" } , + { "CSMSG_SPIN_SHUN", "Shun: /shun for random amount of time" } , + { "CSMSG_SPIN_NOTHING", "Nothing: Absolutely nothing" } , + { "CSMSG_SPIN_RANDJOIN", "Random join: Join a bunch of random channels, then /part all of 'em several times" } , + { "CSMSG_SPIN_ABUSEWHOIS", "Abuse whois: Abuse line added to /whois info" } , + { "CSMSG_SPIN_KICKALL", "Kick all: /kick from each channel you're in" } , + { "CSMSG_SPIN_NICKCHANGE", "Nick change: Random Nick Change" } , + { "CSMSG_SPIN_KILL", "Kill: /kill" } , + { "CSMSG_SPIN_SVSIGNORE", "Ignore: Services ignore for random amount of time" } , + { "CSMSG_SPIN_SVSIGNORE_OPER", "Ignore: I'm trying REALLY hard to ignore you, but your IRCOp smell is overwhelming!" } , + { "CSMSG_SPIN_KICKBANALL", "Kickban all: /kick and ban from each channel your're in" } , + { "CSMSG_SPIN_UNKNOWN", "Error: I don't know how to '%s' you, so you live for now..." }, /* Other things */ { "CSMSG_EVENT_SEARCH_RESULTS", "$bChannel Events for %s$b" }, @@ -561,7 +595,7 @@ static const struct message_entry msgtab[] = { return 0; } DECLARE_LIST(dnrList, struct do_not_register *); -DEFINE_LIST(dnrList, struct do_not_register *); +DEFINE_LIST(dnrList, struct do_not_register *) static int eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, char *argv[], struct svccmd *cmd, int action); @@ -582,8 +616,8 @@ static struct unsigned long db_backup_frequency; unsigned long channel_expire_frequency; - unsigned long dnr_expire_frequency; unsigned long ban_timeout_frequency; + unsigned long dnr_expire_frequency; long info_delay; unsigned int adjust_delay; @@ -601,10 +635,14 @@ static struct unsigned int max_chan_users; unsigned int max_chan_bans; /* lamers */ unsigned int max_userinfo_length; + unsigned int valid_channel_regex_set : 1; + + regex_t valid_channel_regex; struct string_list *set_shows; struct string_list *eightball; struct string_list *old_ban_names; + struct string_list *wheel; const char *ctcp_short_ban_duration; const char *ctcp_long_ban_duration; @@ -640,6 +678,9 @@ enum note_visible_type NOTE_VIS_PRIVILEGED }; +struct io_fd *socket_io_fd; +extern struct cManagerNode cManager; + struct note_type { enum note_access_type set_access_type; @@ -669,6 +710,7 @@ static const struct { unsigned short level; char ch; } accessLevels[] = { /* MUST be orderd less to most! */ + { "pal", "Pal", UL_PEON, '+' }, { "peon", "Peon", UL_PEON, '+' }, { "halfop", "HalfOp", UL_HALFOP, '%' }, { "op", "Op", UL_OP, '@' }, @@ -774,6 +816,28 @@ unsigned int chanserv_read_version = 0; /* db version control */ #define GetChannelAccess(channel, handle) _GetChannelUser(channel, handle, 0, 0) #define GetTrueChannelAccess(channel, handle) _GetChannelUser(channel, handle, 0, 1) +void sputsock(const char *text, ...) PRINTF_LIKE(1, 2); + +void +sputsock(const char *text, ...) +{ + va_list arg_list; + char buffer[MAXLEN]; + int pos; + + if (!cManager.uplink || cManager.uplink->state == DISCONNECTED) return; + buffer[0] = '\0'; + va_start(arg_list, text); + pos = vsnprintf(buffer, MAXLEN - 2, text, arg_list); + va_end(arg_list); + if (pos < 0 || pos > (MAXLEN - 2)) pos = MAXLEN - 2; + buffer[pos] = 0; + log_replay(MAIN_LOG, true, buffer); + buffer[pos++] = '\n'; + buffer[pos] = 0; + ioset_write(socket_io_fd, buffer, pos); +} + unsigned short user_level_from_name(const char *name, unsigned short clamp_level) { @@ -796,7 +860,7 @@ user_level_name_from_level(int level) highest = "None"; if(level >= 1) - highest = "Peon"; + highest = "Pal"; for(ii = 0; (ii < ArrayLength(accessLevels)); ii++) if(level >= accessLevels[ii].level) highest = accessLevels[ii].title; @@ -930,7 +994,7 @@ scan_user_presence(struct userData *uData, struct userNode *user) } static void -chanserv_ctcp_check(struct userNode *user, struct chanNode *channel, const char *text, UNUSED_ARG(struct userNode *bot)) +chanserv_ctcp_check(struct userNode *user, struct chanNode *channel, const char *text, UNUSED_ARG(struct userNode *bot), UNUSED_ARG(unsigned int is_notice), UNUSED_ARG(void *extra)) { unsigned int eflags, argc; char *argv[4]; @@ -1256,18 +1320,18 @@ register_channel(struct chanNode *cNode, char *registrar) } static struct userData* -add_channel_user(struct chanData *channel, struct handle_info *handle, unsigned short access, time_t seen, const char *info, time_t accessexpiry) +add_channel_user(struct chanData *channel, struct handle_info *handle, unsigned short access_level, time_t seen, const char *info, time_t accessexpiry) { struct userData *ud; - if(access > UL_OWNER) + if(access_level > UL_OWNER) return NULL; ud = calloc(1, sizeof(*ud)); ud->channel = channel; ud->handle = handle; ud->seen = seen; - ud->access = access; + ud->access = access_level; ud->info = info ? strdup(info) : NULL; ud->accessexpiry = accessexpiry ? accessexpiry : 0; ud->clvlexpiry = 0; @@ -1768,29 +1832,29 @@ expire_channels(UNUSED_ARG(void *data)) static void expire_dnrs(UNUSED_ARG(void *data)) { - dict_iterator_t it; + dict_iterator_t it, next; struct do_not_register *dnr; - for(it = dict_first(handle_dnrs); it; it = iter_next(it)) + for(it = dict_first(handle_dnrs); it; it = next) { dnr = iter_data(it); - if(!dnr->expires || dnr->expires > now) - continue; - dict_remove(handle_dnrs, dnr->chan_name + 1); + next = iter_next(it); + if(dnr->expires && dnr->expires <= now) + dict_remove(handle_dnrs, dnr->chan_name + 1); } - for(it = dict_first(plain_dnrs); it; it = iter_next(it)) + for(it = dict_first(plain_dnrs); it; it = next) { dnr = iter_data(it); - if(!dnr->expires || dnr->expires > now) - continue; - dict_remove(plain_dnrs, dnr->chan_name); + next = iter_next(it); + if(dnr->expires && dnr->expires <= now) + dict_remove(plain_dnrs, dnr->chan_name + 1); } - for(it = dict_first(mask_dnrs); it; it = iter_next(it)) + for(it = dict_first(mask_dnrs); it; it = next) { dnr = iter_data(it); - if(!dnr->expires || dnr->expires > now) - continue; - dict_remove(mask_dnrs, dnr->chan_name); + next = iter_next(it); + if(dnr->expires && dnr->expires <= now) + dict_remove(mask_dnrs, dnr->chan_name + 1); } if(chanserv_conf.dnr_expire_frequency) @@ -1964,18 +2028,17 @@ chanserv_find_dnrs(const char *chan_name, const char *handle, unsigned int max) { if(dnr->expires && dnr->expires <= now) dict_remove(handle_dnrs, handle); - else if(list.used < max) - dnrList_append(&list, dnr); + else if (list.used < max) + dnrList_append(&list, dnr); } if(chan_name && (dnr = dict_find(plain_dnrs, chan_name, NULL))) { if(dnr->expires && dnr->expires <= now) dict_remove(plain_dnrs, chan_name); - else if(list.used < max) - dnrList_append(&list, dnr); + else if (list.used < max) + dnrList_append(&list, dnr); } - if(chan_name) { for(it = dict_first(mask_dnrs); it && list.used < max; it = next) @@ -1990,7 +2053,6 @@ chanserv_find_dnrs(const char *chan_name, const char *handle, unsigned int max) dnrList_append(&list, dnr); } } - return list; } @@ -2026,7 +2088,6 @@ chanserv_show_dnrs(struct userNode *user, struct svccmd *cmd, const char *chan_n list = chanserv_find_dnrs(chan_name, handle, UINT_MAX); for(ii = 0; (ii < list.used) && (ii < 10); ++ii) dnr_print_func(list.list[ii], user); - if(ii < list.used) reply("CSMSG_MORE_DNRS", list.used - ii); free(list.list); @@ -2042,7 +2103,6 @@ chanserv_is_dnr(const char *chan_name, struct handle_info *handle) list = chanserv_find_dnrs(chan_name, handle ? handle->handle : NULL, 1); dnr = list.used ? list.list[0] : NULL; free(list.list); - return dnr; } @@ -2071,6 +2131,7 @@ static unsigned int send_dnrs(struct userNode *user, dict_t dict) static CHANSERV_FUNC(cmd_noregister) { const char *target; + const char *reason; time_t expiry, duration; unsigned int matches; @@ -2113,7 +2174,8 @@ static CHANSERV_FUNC(cmd_noregister) return 0; } - const char *reason = unsplit_string(argv + 3, argc - 3, NULL); + reason = unsplit_string(argv + 3, argc - 3, NULL); + if((*target == '*') && !get_handle_info(target + 1)) { reply("MSG_HANDLE_UNKNOWN", target + 1); @@ -2125,6 +2187,8 @@ static CHANSERV_FUNC(cmd_noregister) } reply("CSMSG_DNR_SEARCH_RESULTS"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); if(*target == '*') matches = chanserv_show_dnrs(user, cmd, NULL, target + 1); else @@ -2164,8 +2228,10 @@ dnr_search_matches(const struct do_not_register *dnr, const struct dnr_search *s { return !((dnr->set < search->min_set) || (dnr->set > search->max_set) - || (dnr->expires && ((dnr->expires < search->min_expires) - || (dnr->expires > search->max_expires))) + || (dnr->expires < search->min_expires) + || (search->max_expires + && ((dnr->expires == 0) + || (dnr->expires > search->max_expires))) || (search->chan_mask && !match_ircglob(dnr->chan_name, search->chan_mask)) || (search->setter_mask @@ -2186,7 +2252,6 @@ dnr_search_create(struct userNode *user, struct svccmd *cmd, unsigned int argc, discrim->setter_mask = NULL; discrim->reason_mask = NULL; discrim->max_set = INT_MAX; - discrim->max_expires = INT_MAX; discrim->limit = 50; for(ii=0; iilimit) && dsf(dnr, data)) break; } + /* Do the same for channel DNRs. */ for(it = dict_first(plain_dnrs); it; it = next) { @@ -2532,8 +2598,21 @@ static CHANSERV_FUNC(cmd_register) } */ + if (chanserv_conf.valid_channel_regex_set) { + int err = regexec(&chanserv_conf.valid_channel_regex, chan_name, 0, 0, 0); + if (err) { + char buff[256]; + buff[regerror(err, &chanserv_conf.valid_channel_regex, buff, sizeof(buff))] = 0; + log_module(CS_LOG, LOG_INFO, "regexec error: %s (%d)", buff, err); + } + if(err == REG_NOMATCH) { + reply("CSMSG_ILLEGAL_CHANNEL", chan_name); + return 0; + } + } + if(new_channel) - channel = AddChannel(argv[1], now, NULL, NULL, NULL); + channel = AddChannel(chan_name, now, NULL, NULL, NULL); cData = register_channel(channel, user->handle_info->handle); scan_user_presence(add_channel_user(cData, handle, UL_OWNER, 0, NULL, 0), NULL); @@ -2556,6 +2635,7 @@ static CHANSERV_FUNC(cmd_register) /* Initialize the channel's max user record. */ cData->max = channel->members.used; + cData->maxsetinfo = chanserv_conf.max_userinfo_length; if(handle != user->handle_info) reply("CSMSG_PROXY_SUCCESS", handle->handle, channel->name); @@ -2953,6 +3033,7 @@ static CHANSERV_FUNC(cmd_merge) struct userData *target_user; struct chanNode *target; char reason[MAXLEN]; + int nodelete = 0; REQUIRE_PARAMS(2); @@ -2964,6 +3045,11 @@ static CHANSERV_FUNC(cmd_merge) return 0; } + if (argc > 2) { + if (!irccasecmp("nodelete", argv[2])) + nodelete = 1; + } + if(!target->channel_info) { reply("CSMSG_NOT_REGISTERED", target->name); @@ -2999,7 +3085,8 @@ static CHANSERV_FUNC(cmd_merge) merge_channel(channel->channel_info, target->channel_info); spamserv_cs_move_merge(user, channel, target, 0); sprintf(reason, "merged into %s by %s.", target->name, user->handle_info->handle); - unregister_channel(channel->channel_info, reason); + if (!nodelete) + unregister_channel(channel->channel_info, reason); reply("CSMSG_MERGE_SUCCESS", target->name); return 1; } @@ -3012,11 +3099,20 @@ static CHANSERV_FUNC(cmd_opchan) reply("CSMSG_ALREADY_OPCHANNED", channel->name); return 0; } + if(!IsInChannel(channel,chanserv)) { + reply("CSMSG_NOT_IN_CHANNEL", channel->name); + return 0; + } channel->channel_info->may_opchan = 0; mod_chanmode_init(&change); change.argc = 1; change.args[0].mode = MODE_CHANOP; change.args[0].u.member = GetUserMode(channel, chanserv); + if(!change.args[0].u.member) + { + reply("CSMSG_OUT_OF_CHANNEL", channel->name); + return 0; + } mod_chanmode_announce(chanserv, channel, &change); reply("CSMSG_OPCHAN_DONE", channel->name); return 1; @@ -3025,9 +3121,10 @@ static CHANSERV_FUNC(cmd_opchan) static CHANSERV_FUNC(cmd_adduser) { struct userData *actee; - struct userData *actor, *real_actor;; - struct handle_info *handle; - unsigned short access, override = 0; + struct userData *actor, *real_actor; + struct handle_info *handle = NULL; + struct adduserPending *tmp; + unsigned short access_level, override = 0; REQUIRE_PARAMS(3); @@ -3037,29 +3134,29 @@ static CHANSERV_FUNC(cmd_adduser) return 0; } - access = user_level_from_name(argv[2], UL_OWNER); - if(!access) + access_level = user_level_from_name(argv[2], UL_OWNER); + if(!access_level) { reply("CSMSG_INVALID_ACCESS", argv[2]); return 0; } actor = GetChannelUser(channel->channel_info, user->handle_info); - real_actor = GetChannelAccess(channel->channel_info, user->handle_info); + real_actor = GetTrueChannelAccess(channel->channel_info, user->handle_info); - if(actor->access <= access) + if(actor->access <= access_level) { reply("CSMSG_NO_BUMP_ACCESS"); return 0; } - /* Trying to add someone with equal/more access? */ - if (!real_actor || real_actor->access <= access) + /* Trying to add someone with equal/more access */ + if (!real_actor || real_actor->access <= access_level) override = CMD_LOG_OVERRIDE; if(!(handle = modcmd_get_handle_info(user, argv[1]))) { - // 'kevin must first authenticate with AuthServ.' is sent to user + /* 'kevin must first authenticate with AuthServ'. is sent to user */ struct userNode *unode; unode = GetUserH(argv[1]); /* find user struct by nick */ if(unode) @@ -3070,7 +3167,7 @@ static CHANSERV_FUNC(cmd_adduser) else { if(IsInChannel(channel, unode)) { reply("CSMSG_ADDUSER_PENDING"); - add_adduser_pending(channel, unode, access); + tmp = add_adduser_pending(channel, unode, access_level); send_message_type(1,unode, chanserv, "CSMSG_ADDUSER_PENDING_TARGET", user->nick, channel->name); } /* this results in user must auth AND not in chan errors. too confusing.. @@ -3096,13 +3193,13 @@ static CHANSERV_FUNC(cmd_adduser) accessexpiry = now + duration; } - actee = add_channel_user(channel->channel_info, handle, access, 0, NULL, accessexpiry); + actee = add_channel_user(channel->channel_info, handle, access_level, 0, NULL, accessexpiry); scan_user_presence(actee, NULL); if (duration > 0) timeq_add(accessexpiry, chanserv_expire_tempuser, actee); - reply("CSMSG_ADDED_USER", handle->handle, channel->name, user_level_name_from_level(access), access); + reply("CSMSG_ADDED_USER", handle->handle, channel->name, user_level_name_from_level(access_level), access_level); return 1 | override; } @@ -3172,19 +3269,17 @@ static CHANSERV_FUNC(cmd_clvl) timeq_add(clvlexpiry, chanserv_expire_tempclvl, victim); } - /* Trying to clvl a equal/higher user? */ + /* Trying to clvl a equal/higher user */ if(!real_actor || (real_actor->access <= victim->access && handle != user->handle_info)) override = CMD_LOG_OVERRIDE; - /* Trying to clvl someone to equal/higher access? */ + /* Trying to clvl someone to equal/higher access */ if(!real_actor || new_access >= real_actor->access) override = CMD_LOG_OVERRIDE; /* Helpers clvling themselves get caught by the "clvl someone to equal/higher access" check. - * If they lower their own access it's not a big problem. + * If they lower their own access it's not a big problem. */ - victim->access = new_access; reply("CSMSG_CHANGED_ACCESS", handle->handle, user_level_name_from_level(new_access), new_access, channel->name); - return 1 | override; } @@ -3193,14 +3288,14 @@ static CHANSERV_FUNC(cmd_deluser) struct handle_info *handle; struct userData *victim; struct userData *actor, *real_actor; - unsigned short access, override = 0; + unsigned short access_level, override = 0; char *chan_name; REQUIRE_PARAMS(2); actor = GetChannelUser(channel->channel_info, user->handle_info); real_actor = GetChannelAccess(channel->channel_info, user->handle_info); - + if(!(handle = modcmd_get_handle_info(user, argv[argc-1]))) return 0; @@ -3212,9 +3307,9 @@ static CHANSERV_FUNC(cmd_deluser) if(argc > 2) { - access = user_level_from_name(argv[1], UL_OWNER); + access_level = user_level_from_name(argv[1], UL_OWNER); char *useraccess = user_level_name_from_level(victim->access); - if(!access) + if(!access_level) { reply("CSMSG_INVALID_ACCESS", argv[1]); return 0; @@ -3227,7 +3322,7 @@ static CHANSERV_FUNC(cmd_deluser) } else { - access = victim->access; + access_level = victim->access; } if((actor->access <= victim->access) && !IsHelping(user)) @@ -3236,17 +3331,14 @@ static CHANSERV_FUNC(cmd_deluser) return 0; } - /* If people delete themselves it is an override, but they - * could've used deleteme so we don't log it as an override - */ + /* If people delete themselves it is an override, but they could've used deleteme so we don't log it as an override */ if(!real_actor || (real_actor->access <= victim->access && real_actor != victim)) override = CMD_LOG_OVERRIDE; chan_name = strdup(channel->name); del_channel_user(victim, 1); - reply("CSMSG_DELETED_USER", handle->handle, access, chan_name); + reply("CSMSG_DELETED_USER", handle->handle, access_level, chan_name); free(chan_name); - return 1 | override; } @@ -3258,7 +3350,7 @@ cmd_mdel_user(struct userNode *user, struct chanNode *channel, unsigned short mi actor = GetChannelUser(channel->channel_info, user->handle_info); real_actor = GetChannelAccess(channel->channel_info, user->handle_info); - + if(min_access > max_access) { reply("CSMSG_BAD_RANGE", min_access, max_access); @@ -3285,7 +3377,6 @@ cmd_mdel_user(struct userNode *user, struct chanNode *channel, unsigned short mi } reply("CSMSG_DELETED_USERS", mask, min_access, max_access, channel->name); - return 1 | override; } @@ -3319,6 +3410,10 @@ static CHANSERV_FUNC(cmd_mdelpeon) return cmd_mdel_user(user, channel, UL_PEON, UL_HALFOP-1, argv[1], cmd); } +static CHANSERV_FUNC(cmd_mdelpal) +{ + return cmd_mdel_user(user, channel, UL_PEON, UL_HALFOP-1, argv[1], cmd); +} static CHANSERV_FUNC(cmd_levels) { @@ -3421,9 +3516,7 @@ cmd_trim_users(struct svccmd *cmd, struct userNode *user, struct chanNode *chann unsigned int count; time_t limit; - actor = GetChannelUser(channel->channel_info, user->handle_info); actor = GetChannelAccess(channel->channel_info, user->handle_info); - if(min_access > max_access) { reply("CSMSG_BAD_RANGE", min_access, max_access); @@ -3688,6 +3781,7 @@ static int bad_channel_ban(struct chanNode *channel, struct userNode *user, const char *ban, unsigned int *victimCount, struct modeNode **victims) { unsigned int ii; + int b = 0; if(victimCount) *victimCount = 0; @@ -3698,7 +3792,10 @@ bad_channel_ban(struct chanNode *channel, struct userNode *user, const char *ban if(IsService(mn->user)) continue; - if(!user_matches_glob(mn->user, ban, MATCH_USENICK | MATCH_VISIBLE)) + b = user_matches_glob(mn->user, ban, MATCH_USENICK | MATCH_VISIBLE, 0); + if (b == -1) + return -1; + else if (b == 0) continue; if(protect_user(mn->user, user, channel->channel_info, false)) @@ -3716,6 +3813,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c struct userNode *victim; struct modeNode **victims; unsigned int offset, n, victimCount, duration = 0; + int b = 0; char *reason = "Bye.", *ban, *name; char interval[INTERVALLEN]; @@ -3785,10 +3883,15 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c snprintf(banmask, sizeof(banmask), "*!*@%s.*", hi->handle); victims = alloca(sizeof(victims[0]) * channel->members.used); - if(bad_channel_ban(channel, user, banmask, &victimCount, victims)) + b = bad_channel_ban(channel, user, banmask, &victimCount, victims); + if(b == 1) { reply("CSMSG_MASK_PROTECTED", banmask); return 0; + }else if(b == -1) + { + reply("CSMSG_BAD_BAN", banmask); + return 0; } if((action == ACTION_KICK) && (victimCount == 0)) @@ -3810,10 +3913,13 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c victims = alloca(sizeof(victims[0]) * channel->members.used); - if(bad_channel_ban(channel, user, argv[1], &victimCount, victims)) - { - if(cmd) - reply("CSMSG_MASK_PROTECTED", argv[1]); + b = bad_channel_ban(channel, user, argv[1], &victimCount, victims); + if(cmd && (b == 1)) { + reply("CSMSG_MASK_PROTECTED", argv[1]); + return 0; + } + else if(cmd && (b == -1)) { + reply("CSMSG_BAD_BAN", argv[1]); return 0; } /* If i want to ban *.nl and theres 5 of them, what is it to the bot?!? @@ -3841,7 +3947,8 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c /* Truncate the ban in place if necessary; we must ensure that 'ban' is a valid ban mask before sanitizing it. */ - sanitize_ircmask(ban); + if (*ban != '~') + sanitize_ircmask(ban); if(action & ACTION_ADD_LAMER) { @@ -4100,7 +4207,7 @@ find_matching_bans(struct banList *bans, struct userNode *actee, const char *mas for(ii = count = 0; ii < bans->used; ++ii) { match[ii] = user_matches_glob(actee, bans->list[ii]->ban, - MATCH_USENICK | MATCH_VISIBLE); + MATCH_USENICK | MATCH_VISIBLE, 0); if(match[ii]) count++; } @@ -4211,13 +4318,13 @@ unban_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c mask = strdup(banmask); } else if(!is_ircmask(argv[1])) - { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; + { + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; } else { - mask = strdup(argv[1]); + mask = strdup(argv[1]); } } @@ -4247,7 +4354,7 @@ unban_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c while(ban) { if(actee) - for( ; ban && !user_matches_glob(actee, ban->mask, MATCH_USENICK | MATCH_VISIBLE); + for( ; ban && !user_matches_glob(actee, ban->mask, MATCH_USENICK | MATCH_VISIBLE, 0); ban = ban->next); else for( ; ban && !match_ircglobs(mask, ban->mask); @@ -4348,13 +4455,17 @@ static CHANSERV_FUNC(cmd_myaccess) if(argc < 2) target_handle = user->handle_info; - else if(!(target_handle = modcmd_get_handle_info(user, argv[1]))) - return 0; - else if(!IsHelping(user) && target_handle != user->handle_info) + else if(!IsStaff(user)) { reply("CSMSG_MYACCESS_SELF_ONLY", argv[0]); return 0; } + else if(!(target_handle = modcmd_get_handle_info(user, argv[1]))) + return 0; + + if(!oper_outranks(user, target_handle)) + return 0; + if(!target_handle->channels) { reply("CSMSG_SQUAT_ACCESS", target_handle->handle); @@ -4753,9 +4864,10 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg ary[i++] = "Expiry"; for(matches = 1; matches < lData.table.length; ++matches) { - struct userData *uData = lData.users[matches-1]; char seen[INTERVALLEN]; + + uData = lData.users[matches-1]; i = 0; ary = malloc(lData.table.width*sizeof(**lData.table.contents)); lData.table.contents[matches] = ary; @@ -4886,7 +4998,7 @@ static CHANSERV_FUNC(cmd_lamers) search = NULL; else if(strchr(search = argv[1], '!')) { - search = argv[1]; + search = argv[1]; search_wilds = search[strcspn(search, "?*")]; } else if(!(search_u = GetUserH(search))) @@ -4900,10 +5012,10 @@ static CHANSERV_FUNC(cmd_lamers) { if(search_u) { - if(!user_matches_glob(search_u, ban->mask, MATCH_USENICK | MATCH_VISIBLE)) - continue; + if(!user_matches_glob(search_u, ban->mask, MATCH_USENICK | MATCH_VISIBLE, 0)) + continue; } - else if(search) + else if(search) { if(search_wilds ? !match_ircglobs(search, ban->mask) : !match_ircglob(search, ban->mask)) continue; @@ -5204,7 +5316,7 @@ static CHANSERV_FUNC(cmd_invite) if (invite->handle_info && invite->handle_info->ignores->used && (argc > 1)) { unsigned int i; for (i=0; i < invite->handle_info->ignores->used; i++) { - if (user_matches_glob(user, invite->handle_info->ignores->list[i], MATCH_USENICK)) { + if (user_matches_glob(user, invite->handle_info->ignores->list[i], MATCH_USENICK, 0)) { reply("CSMSG_CANNOT_INVITE", argv[1], channel->name); return 0; } @@ -5951,6 +6063,23 @@ static CHANSERV_FUNC(cmd_say) msg = unsplit_string(argv + 1, argc - 1, NULL); send_channel_message(channel, cmd->parent->bot, "%s", msg); } + else if(*argv[1] == '*' && argv[1][1] != '\0') + { + struct handle_info *hi; + struct userNode *authed; + + REQUIRE_PARAMS(3); + msg = unsplit_string(argv + 2, argc - 2, NULL); + + if (!(hi = get_handle_info(argv[1] + 1))) + { + reply("MSG_HANDLE_UNKNOWN", argv[1] + 1); + return 0; + } + + for (authed = hi->users; authed; authed = authed->next_authed) + send_target_message(5, authed->nick, cmd->parent->bot, "%s", msg); + } else if(GetUserH(argv[1])) { REQUIRE_PARAMS(3); @@ -5975,6 +6104,23 @@ static CHANSERV_FUNC(cmd_emote) msg = unsplit_string(argv + 1, argc - 1, NULL); send_channel_message(channel, cmd->parent->bot, "\001ACTION %s\001", msg); } + else if(*argv[1] == '*' && argv[1][1] != '\0') + { + struct handle_info *hi; + struct userNode *authed; + + REQUIRE_PARAMS(3); + msg = unsplit_string(argv + 2, argc - 2, NULL); + + if (!(hi = get_handle_info(argv[1] + 1))) + { + reply("MSG_HANDLE_UNKNOWN", argv[1] + 1); + return 0; + } + + for (authed = hi->users; authed; authed = authed->next_authed) + send_target_message(5, authed->nick, cmd->parent->bot, "\001ACTION %s\001", msg); + } else if(GetUserH(argv[1])) { msg = unsplit_string(argv + 2, argc - 2, NULL); @@ -6007,17 +6153,32 @@ chanserv_expire_suspension(void *data) { struct suspended *suspended = data; struct chanNode *channel; + unsigned int ii; + /* Update the channel registration data structure. */ if(!suspended->expires || (now < suspended->expires)) suspended->revoked = now; channel = suspended->cData->channel; suspended->cData->channel = channel; suspended->cData->flags &= ~CHANNEL_SUSPENDED; + + /* If appropriate, re-join ChanServ to the channel. */ if(!IsOffChannel(suspended->cData)) { spamserv_cs_suspend(channel, 0, 0, NULL); ss_cs_join_channel(channel, 1); } + + /* Mark everyone currently in the channel as present. */ + for(ii = 0; ii < channel->members.used; ++ii) + { + struct userData *uData = GetChannelAccess(suspended->cData, channel->members.list[ii]->user->handle_info); + if(uData) + { + uData->present = 1; + uData->seen = now; + } + } } static CHANSERV_FUNC(cmd_csuspend) @@ -6329,10 +6490,10 @@ static MODCMD_FUNC(chan_opt_unreviewed) else if(disabled_string(argv[1])) new_value = 0; else - { - reply("MSG_INVALID_BINARY", argv[1]); - return 0; - } + { + reply("MSG_INVALID_BINARY", argv[1]); + return 0; + } if (new_value != value) { @@ -6483,6 +6644,20 @@ static MODCMD_FUNC(chan_opt_usergreeting) return opt_greeting_common(user, cmd, argc, argv, "CSMSG_SET_USERGREETING", &channel->channel_info->user_greeting); } +static MODCMD_FUNC(chan_opt_maxsetinfo) +{ + unsigned int charmax; + + if(argc > 1) { + charmax = atoi(argv[1]); + if ((charmax > 0) && (charmax < chanserv_conf.max_userinfo_length)) + channel->channel_info->maxsetinfo = charmax; + } + + reply("CSMSG_SET_MAXSETINFO", channel->channel_info->maxsetinfo); + return 1; +} + static MODCMD_FUNC(chan_opt_modes) { struct mod_chanmode *new_modes; @@ -6583,6 +6758,16 @@ static MODCMD_FUNC(chan_opt_nodelete) static MODCMD_FUNC(chan_opt_dynlimit) { + struct mod_chanmode change; + + if (argc > 1) { + if (disabled_string(argv[1])) { + mod_chanmode_init(&change); + change.modes_clear |= MODE_LIMIT; + mod_chanmode_announce(chanserv, channel, &change); + } + } + CHANNEL_BINARY_OPTION("CSMSG_SET_DYNLIMIT", CHANNEL_DYNAMIC_LIMIT); } @@ -6775,31 +6960,31 @@ static int channel_multiple_option(enum charOption option, struct userNode *user, struct chanNode *channel, int argc, char *argv[], struct svccmd *cmd) { struct chanData *cData = channel->channel_info; - int count = charOptions[option].count, index; + int count = charOptions[option].count, idx; if(argc > 1) { - index = atoi(argv[1]); + idx = atoi(argv[1]); - if(!isdigit(argv[1][0]) || (index < 0) || (index >= count)) + if(!isdigit(argv[1][0]) || (idx < 0) || (idx >= count)) { - reply("CSMSG_INVALID_NUMERIC", index); + reply("CSMSG_INVALID_NUMERIC", idx); /* Show possible values. */ - for(index = 0; index < count; index++) - reply(charOptions[option].format_name, index, user_find_message(user, charOptions[option].values[index].format_name)); + for(idx = 0; idx < count; idx++) + reply(charOptions[option].format_name, idx, user_find_message(user, charOptions[option].values[idx].format_name)); return 0; } - cData->chOpts[option] = charOptions[option].values[index].value; + cData->chOpts[option] = charOptions[option].values[idx].value; } else { /* Find current option value. */ find_value: - for(index = 0; - (index < count) && (cData->chOpts[option] != charOptions[option].values[index].value); - index++); - if(index == count) + for(idx = 0; + (idx < count) && (cData->chOpts[option] != charOptions[option].values[idx].value); + idx++); + if(idx == count) { /* Somehow, the option value is corrupt; reset it to the default. */ cData->chOpts[option] = charOptions[option].default_value; @@ -6807,12 +6992,16 @@ channel_multiple_option(enum charOption option, struct userNode *user, struct ch } } - reply(charOptions[option].format_name, index, user_find_message(user, charOptions[option].values[index].format_name)); + reply(charOptions[option].format_name, idx, user_find_message(user, charOptions[option].values[idx].format_name)); return 1; } static MODCMD_FUNC(chan_opt_automode) { + if(check_user_level(channel, user, lvlInviteMe, 1, 0)) + { + reply("CSMSG_LOW_CHANNEL_ACCESS", channel->name); + } return channel_multiple_option(chAutomode, CSFUNC_ARGS); } @@ -6913,7 +7102,6 @@ static CHANSERV_FUNC(cmd_set) argv[0] = ""; argv[1] = buf; - return subcmd->command->func(user, channel, argc - 1, argv + 1, subcmd); } @@ -6969,6 +7157,10 @@ static MODCMD_FUNC(user_opt_autoop) static MODCMD_FUNC(user_opt_autoinvite) { + if((argc > 1) && !check_user_level(channel, user, lvlInviteMe, 1, 0)) + { + reply("CSMSG_LOW_CHANNEL_ACCESS", channel->name); + } return user_binary_option("CSMSG_USET_AUTOINVITE", USER_AUTO_INVITE, CSFUNC_ARGS); } @@ -6997,9 +7189,9 @@ static MODCMD_FUNC(user_opt_info) { size_t bp; infoline = unsplit_string(argv + 1, argc - 1, NULL); - if(strlen(infoline) > chanserv_conf.max_userinfo_length) + if(strlen(infoline) > channel->channel_info->maxsetinfo) { - reply("CSMSG_INFOLINE_TOO_LONG", chanserv_conf.max_userinfo_length); + reply("CSMSG_INFOLINE_TOO_LONG", channel->channel_info->maxsetinfo); return 0; } bp = strcspn(infoline, "\001"); @@ -7085,8 +7277,8 @@ static CHANSERV_FUNC(cmd_giveownership) struct userData *invoker; struct chanData *cData = channel->channel_info; struct do_not_register *dnr; - const char *confirm; struct giveownership *giveownership; + const char *confirm; unsigned int force, override; unsigned short co_access, new_owner_old_access; char transfer_reason[MAXLEN]; @@ -7221,20 +7413,20 @@ chanserv_expire_user_suspension(void *data) static CHANSERV_FUNC(cmd_suspend) { struct handle_info *hi; - struct userData *self, *real_self, *target; + struct userData *actor, *real_actor, *target; unsigned int override = 0; time_t expiry; REQUIRE_PARAMS(3); if(!(hi = modcmd_get_handle_info(user, argv[1]))) return 0; - self = GetChannelUser(channel->channel_info, user->handle_info); - real_self = GetChannelAccess(channel->channel_info, user->handle_info); + actor = GetChannelUser(channel->channel_info, user->handle_info); + real_actor = GetChannelAccess(channel->channel_info, user->handle_info); if(!(target = GetTrueChannelAccess(channel->channel_info, hi))) { reply("CSMSG_NO_CHAN_USER", hi->handle, channel->name); return 0; } - if(target->access >= self->access) + if(target->access >= actor->access) { reply("MSG_USER_OUTRANKED", hi->handle); return 0; @@ -7267,7 +7459,7 @@ static CHANSERV_FUNC(cmd_suspend) if(target->expires) timeq_add(target->expires, chanserv_expire_user_suspension, target); - if(!real_self || target->access >= real_self->access) + if(!real_actor || target->access >= real_actor->access) override = CMD_LOG_OVERRIDE; target->flags |= USER_SUSPENDED; reply("CSMSG_USER_SUSPENDED", hi->handle, channel->name); @@ -7277,19 +7469,19 @@ static CHANSERV_FUNC(cmd_suspend) static CHANSERV_FUNC(cmd_unsuspend) { struct handle_info *hi; - struct userData *self, *real_self, *target; + struct userData *actor = NULL, *real_actor = NULL, *target; unsigned int override = 0; REQUIRE_PARAMS(2); if(!(hi = modcmd_get_handle_info(user, argv[1]))) return 0; - self = GetChannelUser(channel->channel_info, user->handle_info); - real_self = GetChannelAccess(channel->channel_info, user->handle_info); + actor = GetChannelUser(channel->channel_info, user->handle_info); + real_actor = GetChannelAccess(channel->channel_info, user->handle_info); if(!(target = GetTrueChannelAccess(channel->channel_info, hi))) { reply("CSMSG_NO_CHAN_USER", hi->handle, channel->name); return 0; } - if(target->access >= self->access) + if(target->access >= actor->access) { reply("MSG_USER_OUTRANKED", hi->handle); return 0; @@ -7299,7 +7491,7 @@ static CHANSERV_FUNC(cmd_unsuspend) reply("CSMSG_NOT_SUSPENDED", hi->handle); return 0; } - if(!real_self || target->access >= real_self->access) + if(!real_actor || target->access >= real_actor->access) override = CMD_LOG_OVERRIDE; target->flags &= ~USER_SUSPENDED; scan_user_presence(target, NULL); @@ -7344,7 +7536,7 @@ static MODCMD_FUNC(cmd_deleteme) static void chanserv_refresh_topics(UNUSED_ARG(void *data)) { - unsigned int refresh_num = (now - self->link) / chanserv_conf.refresh_period; + unsigned int refresh_num = (now - self->link_time) / chanserv_conf.refresh_period; struct chanData *cData; char opt; @@ -7367,7 +7559,7 @@ chanserv_refresh_topics(UNUSED_ARG(void *data)) static void chanserv_auto_resync(UNUSED_ARG(void *data)) { - unsigned int refresh_num = (now - self->link) / chanserv_conf.refresh_period; + unsigned int refresh_num = (now - self->link_time) / chanserv_conf.refresh_period; struct chanData *cData; char opt; @@ -7425,6 +7617,315 @@ static CHANSERV_FUNC(cmd_wut) return 1; } +static CHANSERV_FUNC(cmd_roulette) +{ + if(channel) { + struct chanData *cData = channel->channel_info; + + if (cData) { + if (cData->roulette_chamber) { + DelUser(user, chanserv, 1, "BANG - Don't stuff bullets into a loaded gun"); + return 1; + } + + send_target_message(1, channel->name, cmd->parent->bot, "CSMSG_ROULETTE_LOADS"); + cData->roulette_chamber = 1 + rand() % 6; + } + } + + return 1; +} +static CHANSERV_FUNC(cmd_shoot) +{ + if(channel) { + struct chanData *cData = channel->channel_info; + + if (cData->roulette_chamber <= 0) { + struct service *service; + if ((service = service_find(chanserv->nick))) { + reply("CSMSG_ROULETTE_NEW", service->trigger); + } + return 1; + } + + cData->roulette_chamber--; + + if (cData->roulette_chamber == 0) { + reply("CSMSG_ROULETTE_BANG"); + reply("CSMSG_ROULETTE_BETTER_LUCK", user->nick); + DelUser(user, chanserv, 1, "BANG!!!!"); + } else + reply("CSMSG_ROULETTE_CLICK"); + } + + return 1; +} + +static void +chanserv_remove_abuse(void *data) +{ + char *remnick = data; + struct userNode *user; + /* sometimes the clone was killed and maybe even the user took their nick back + * (ie, an oper) so dont kill them here after all unless they are local. */ + if( (user = GetUserH(remnick)) ) + if(IsLocal(user) ) + DelUser(user, NULL, 1, ""); +} + +int lamepart(struct userNode *nick) { + struct modeNode *mn; + unsigned int count, n; + + for (n=count=0; nchannels.used; n++) { + mn = nick->channels.list[n]; + irc_svspart(chanserv, nick, mn->channel); + } + + return 0; +} + +static CHANSERV_FUNC(cmd_spin) +{ + if(!channel) + return 1; + + int type = 0, lamep = 1; + char *tstr; + + tstr = conf_get_data("server/type", RECDB_QSTRING); + if(tstr) { + type = atoi(tstr); + if (type > 6) + lamep = 0; + } + + + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_WHEEL1", user->nick); + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_WHEEL2"); + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_WHEEL3"); + + if(chanserv_conf.wheel->used < 1) { + /* wheel actions not defined! eek */ + return 1; + } + + const char *wheel = chanserv_conf.wheel->list[ (int) ( (chanserv_conf.wheel->used) * (rand() / (RAND_MAX + 1.0)) ) ]; + if(!wheel && *wheel) + return 1; + +/* enable this to be able to manually specify a result for testing: + log_module(MAIN_LOG, LOG_DEBUG,"Testing wheel randomness: %s\n", wheel); + if(argc > 1) { + wheel = argv[1]; + } +*/ + + /* connection reset by peer */ + if (!strcasecmp(wheel, "peer")) { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_PEER"); + if (type < 7) + irc_kill(chanserv, user, "Connection reset by peer"); + else + irc_svsquit(chanserv, user, "Connection reset by peer"); + } + /* part all channels */ + else if (!strcasecmp(wheel, "partall")) { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_PARTALL"); + if (lamep) + lamepart(user); + else + sputsock("%s SJ %s 0 "FMT_TIME_T, self->numeric, user->numeric, now); + } + /* random time gline */ + else if (!strcasecmp(wheel, "gline")) { + char target[HOSTLEN + 3]; + int wtime = 120 + rand() % 600; + + strcpy(target, "*@"); + strcat(target, user->hostname); + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_GLINE"); + + gline_add(chanserv->nick, target, wtime, "Reward for spinning the wheel of misfortune!", now, 1, 0); +// irc_kill(chanserv, user, "Reward for spinning the wheel of misfortune!"); + } + /* random shun */ + else if (!strcasecmp(wheel, "shun")) { + char target[HOSTLEN + 3]; + int wtime = 120 + rand() % 600; + + strcpy(target, "*@"); + strcat(target, user->hostname); + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_SHUN"); + + shun_add(chanserv->nick, target, wtime, "Reward for spinning the wheel of misfortune!", now, 1); + } + /* absolutely nothing */ + else if (!strcasecmp(wheel, "nothing")) { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_NOTHING"); + } + /* join random chans and part em several times */ + else if (!strcasecmp(wheel, "randjoin")) { + int complete = 0; + int rndchans = 0; + int chango = 0; + int roundz0r = 0; + + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_RANDJOIN"); + while(complete != 1) { + if (rndchans != 15) { + chango = 120 + rand() % 600; + sputsock("%s SJ %s #%d "FMT_TIME_T, self->numeric, user->numeric, chango, now); + rndchans++; + } else { + if (roundz0r != 1) { + if (lamep) + lamepart(user); + else + sputsock("%s SJ %s 0 "FMT_TIME_T, self->numeric, user->numeric, now); + roundz0r = 1; + rndchans = 0; + } else { + if (lamep) + lamepart(user); + else + sputsock("%s SJ %s 0 "FMT_TIME_T, self->numeric, user->numeric, now); + complete = 1; + } + } + } + } + /* abuse line added to /whois */ + else if (!strcasecmp(wheel, "abusewhois")) { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_ABUSEWHOIS"); + irc_swhois(chanserv, user, "is being defecated on by services"); + } + /* kick from each channel your in */ + else if (!strcasecmp(wheel, "kickall")) { + unsigned int count, n; + struct modeNode *mn; + + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_KICKALL"); + + for (n=count=0; nchannels.used; n++) { + mn = user->channels.list[n]; + irc_kick(chanserv, user, mn->channel, "Reward for spinning the wheel of misfortune!"); + } + } + /* random nick change */ + else if (!strcasecmp(wheel, "nickchange")) { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_NICKCHANGE"); + + char *oldnick = NULL; + char *oldident = NULL; + char *oldhost = NULL; + char abusednick[NICKLEN] = ""; + int abusednum = 1 + (int) (10000.0 * (rand() / (RAND_MAX + 1.0))); + struct userNode *clone; + + oldnick = strdup(user->nick); + oldident = strdup(user->ident); + oldhost = strdup(user->hostname); + + //snprintf(abusednick, NICKLEN, "Abused%d", abusednum+(1 + rand() % 120)); + while (1) { + snprintf(abusednick, NICKLEN, "Abused%d", abusednum+(1 + rand() % 120)); + log_module(MAIN_LOG, LOG_DEBUG, "Abused Nick: %s, Client Nick: %s", abusednick, user->nick); + if(!GetUserH(abusednick)) + break; + } + + SVSNickChange(user, abusednick); + irc_svsnick(chanserv, user, abusednick); + clone = AddLocalUser(oldnick, oldident, oldhost, "I got abused by the wheel of misfortune :D", "+i"); + timeq_add(now + 300, chanserv_remove_abuse, clone->nick); + } + /* kill */ + else if (!strcasecmp(wheel, "kill")) { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_KILL"); + + DelUser(user, chanserv, 1, "Reward for spinning the wheel of misfortune!"); + //irc_kill(chanserv, user, "Reward for spinning the wheel of misfortune!"); + } + /* service ignore */ + else if (!strcasecmp(wheel, "svsignore")) { + int gagged, ignoretime = 0; + char target[HOSTLEN + 13]; + + if(IsOper(user)) { + /* we cant gag opers, so just verbally abuse them */ + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_SVSIGNORE_OPER"); + return 1; + } + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_SVSIGNORE"); + + strcpy(target, "*!*@"); + strcat(target, user->hostname); + ignoretime = now + (1 + rand() % 120); + + gagged = gag_create(target, "wheelofabuse", "Reward for spinning the wheel of misfortune!", ignoretime); + } + /* kick and ban from each channel your in */ + else if (!strcasecmp(wheel, "kickbanall")) { + unsigned int count, n; + struct modeNode *mn; + //char ban[HOSTLEN + 1]; + + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_KICKBANALL"); + + //snprintf(ban, sizeof(ban), "*!*@%s", user->hostname); + for (n=count=0; nchannels.used; n++) { + struct mod_chanmode *change; +/* struct banData *bData; */ + unsigned int exists; +/* int duration = 300; */ + char *ban; + + ban = generate_hostmask(user, GENMASK_STRICT_HOST|GENMASK_ANY_IDENT|GENMASK_USENICK); + + log_module(MAIN_LOG, LOG_DEBUG, "Generated ban %s", ban); + mn = user->channels.list[n]; + if(mn->channel->banlist.used >= MAXBANS) { + reply("CSMSG_BANLIST_FULL", mn->channel->name); + free(ban); + continue; + } + +/* bData = add_channel_ban(mn->channel->channel_info, ban, chanserv->nick, now, now, now + duration, "Reward for spinning the wheel of misfortune!"); */ + + change = mod_chanmode_alloc(1); + change->args[0].mode = MODE_REMOVE|MODE_CHANOP|MODE_HALFOP|MODE_VOICE; + change->args[0].u.member = GetUserMode(mn->channel, user); + change->argc = 1; + + mod_chanmode_announce(chanserv, mn->channel, change); + mod_chanmode_free(change); + + exists = ChannelBanExists(mn->channel, ban); + if(!exists) { + change = mod_chanmode_alloc(1); + change->args[0].mode = MODE_BAN; + change->args[0].u.hostmask = ban; + change->argc = 1; + mod_chanmode_announce(chanserv, mn->channel, change); + mod_chanmode_free(change); + } + + if(exists) { + reply("CSMSG_REDUNDANT_BAN", ban, mn->channel->name); + free(ban); + } + + irc_kick(chanserv, user, mn->channel, "Reward for spinning the wheel of misfortune!"); + } + } + else { + send_target_message(1, channel->name, chanserv, "CSMSG_SPIN_UNKNOWN", wheel); + } + + return 1; +} + #ifdef lame8ball static CHANSERV_FUNC(cmd_8ball) { @@ -7737,7 +8238,7 @@ chanserv_adjust_limit(void *data) } static void -handle_new_channel(struct chanNode *channel) +handle_new_channel(struct chanNode *channel, UNUSED_ARG(void *extra)) { struct chanData *cData; @@ -7765,7 +8266,7 @@ trace_check_bans(struct userNode *user, struct chanNode *chan) if (chan->channel_info) { for(bData = chan->channel_info->bans; bData; bData = bData->next) { - if(!user_matches_glob(user, bData->mask, MATCH_USENICK)) + if(!user_matches_glob(user, bData->mask, MATCH_USENICK, 0)) continue; if(bData) @@ -7797,7 +8298,7 @@ check_bans(struct userNode *user, const char *channel) { /* Not joining through a ban. */ for(bData = cData->bans; - bData && !user_matches_glob(user, bData->mask, MATCH_USENICK); + bData && !user_matches_glob(user, bData->mask, MATCH_USENICK, 0); bData = bData->next); if(bData) @@ -7839,7 +8340,7 @@ channel_user_is_exempt(struct userNode *user, struct chanNode *channel) unsigned int ii; for(ii = 0; ii < channel->exemptlist.used; ii++) { - if(user_matches_glob(user, channel->exemptlist.list[ii]->exempt, MATCH_USENICK)) + if(user_matches_glob(user, channel->exemptlist.list[ii]->exempt, MATCH_USENICK, 0)) return true; } return false; @@ -7849,7 +8350,7 @@ channel_user_is_exempt(struct userNode *user, struct chanNode *channel) /* Welcome to my worst nightmare. Warning: Read (or modify) the code below at your own risk. */ static int -handle_join(struct modeNode *mNode) +handle_join(struct modeNode *mNode, UNUSED_ARG(void *extra)) { struct mod_chanmode change; struct userNode *user = mNode->user; @@ -7884,7 +8385,7 @@ handle_join(struct modeNode *mNode) unsigned int ii; for(ii = 0; ii < channel->banlist.used; ii++) { - if(user_matches_glob(user, channel->banlist.list[ii]->ban, MATCH_USENICK)) + if(user_matches_glob(user, channel->banlist.list[ii]->ban, MATCH_USENICK, 0)) { /* Riding a netburst. Naughty. */ KickChannelUser(user, channel, chanserv, "User from far side of netsplit should have been banned - bye."); @@ -7915,7 +8416,7 @@ handle_join(struct modeNode *mNode) { /* Not joining through a ban. */ for(bData = cData->bans; - bData && !user_matches_glob(user, bData->mask, MATCH_USENICK); + bData && !user_matches_glob(user, bData->mask, MATCH_USENICK, 0); bData = bData->next); if(bData) @@ -8138,30 +8639,30 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) for(ii = 0; ii < user->channels.used; ++ii) { - struct chanNode *channel = user->channels.list[ii]->channel; + struct chanNode *chan = user->channels.list[ii]->channel; struct banData *ban; if((user->channels.list[ii]->modes & (MODE_CHANOP|MODE_HALFOP|MODE_VOICE)) - || !channel->channel_info - || IsSuspended(channel->channel_info)) + || !chan->channel_info + || IsSuspended(chan->channel_info)) continue; - if(protect_user(user, chanserv, channel->channel_info, true)) + if(protect_user(user, chanserv, chan->channel_info, true)) continue; - for(jj = 0; jj < channel->banlist.used; ++jj) - if(user_matches_glob(user, channel->banlist.list[jj]->ban, MATCH_USENICK)) + for(jj = 0; jj < chan->banlist.used; ++jj) + if(user_matches_glob(user, chan->banlist.list[jj]->ban, MATCH_USENICK, 0)) break; - if(jj < channel->banlist.used) + if(jj < chan->banlist.used) continue; - for(ban = channel->channel_info->bans; ban; ban = ban->next) + for(ban = chan->channel_info->bans; ban; ban = ban->next) { char kick_reason[MAXLEN]; - if(!user_matches_glob(user, ban->mask,MATCH_USENICK | MATCH_VISIBLE)) + if(!user_matches_glob(user, ban->mask,MATCH_USENICK | MATCH_VISIBLE, 0)) continue; change.args[0].mode = MODE_BAN; change.args[0].u.hostmask = ban->mask; - mod_chanmode_announce(chanserv, channel, &change); + mod_chanmode_announce(chanserv, chan, &change); sprintf(kick_reason, "(%s) %s", ban->owner, ban->reason); - KickChannelUser(user, channel, chanserv, kick_reason); + KickChannelUser(user, chan, chanserv, kick_reason); ban->triggered = now; break; } @@ -8195,7 +8696,7 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) } static void -handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) +handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason), UNUSED_ARG(void *extra)) { struct chanData *cData; struct userData *uData; @@ -8220,18 +8721,22 @@ handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) scan_user_presence(uData, mn->user); uData->seen = now; if (uData->access >= UL_PRESENT) - cData->visited = now; - } + cData->visited = now; + } if(IsHelping(mn->user) && IsSupportHelper(mn->user)) { - unsigned int ii, jj; - for(ii = 0; ii < chanserv_conf.support_channels.used; ++ii) - { - for(jj = 0; jj < mn->user->channels.used; ++jj) - if(mn->user->channels.list[jj]->channel == chanserv_conf.support_channels.list[ii]) - break; - if(jj < mn->user->channels.used) + unsigned int ii; + for(ii = 0; ii < chanserv_conf.support_channels.used; ++ii) { + struct chanNode *channel; + struct userNode *exclude; + /* When looking at the channel that is being /part'ed, we + * have to skip over the client that is leaving. For + * other channels, we must not do that. + */ + channel = chanserv_conf.support_channels.list[ii]; + exclude = (channel == mn->channel) ? mn->user : NULL; + if(find_handle_in_channel(channel, mn->user->handle_info, exclude)) break; } if(ii == chanserv_conf.support_channels.used) @@ -8260,7 +8765,7 @@ handle_kick(struct userNode *kicker, struct userNode *victim, struct chanNode *c } static int -handle_topic(struct userNode *user, struct chanNode *channel, const char *old_topic) +handle_topic(struct userNode *user, struct chanNode *channel, const char *old_topic, UNUSED_ARG(void *extra)) { struct chanData *cData; @@ -8378,7 +8883,7 @@ handle_mode(struct chanNode *channel, struct userNode *user, const struct mod_ch } static void -handle_nick_change(struct userNode *user, UNUSED_ARG(const char *old_nick)) +handle_nick_change(struct userNode *user, UNUSED_ARG(const char *old_nick), UNUSED_ARG(void *extra)) { struct chanNode *channel; struct banData *bData; @@ -8402,7 +8907,7 @@ handle_nick_change(struct userNode *user, UNUSED_ARG(const char *old_nick)) continue; /* Look for a matching ban already on the channel. */ for(jj = 0; jj < channel->banlist.used; ++jj) - if(user_matches_glob(user, channel->banlist.list[jj]->ban, MATCH_USENICK)) + if(user_matches_glob(user, channel->banlist.list[jj]->ban, MATCH_USENICK, 0)) break; /* Need not act if we found one. */ if(jj < channel->banlist.used) @@ -8413,7 +8918,7 @@ handle_nick_change(struct userNode *user, UNUSED_ARG(const char *old_nick)) /* Look for a matching ban in this channel. */ for(bData = channel->channel_info->bans; bData; bData = bData->next) { - if(!user_matches_glob(user, bData->mask, MATCH_USENICK | MATCH_VISIBLE)) + if(!user_matches_glob(user, bData->mask, MATCH_USENICK | MATCH_VISIBLE, 0)) continue; change.args[0].u.hostmask = bData->mask; mod_chanmode_announce(chanserv, channel, &change); @@ -8425,7 +8930,7 @@ handle_nick_change(struct userNode *user, UNUSED_ARG(const char *old_nick)) } } -static void handle_rename(struct handle_info *handle, const char *old_handle) +static void handle_rename(struct handle_info *handle, const char *old_handle, UNUSED_ARG(void *extra)) { struct do_not_register *dnr = dict_find(handle_dnrs, old_handle, NULL); @@ -8452,8 +8957,8 @@ handle_unreg(UNUSED_ARG(struct userNode *user), struct handle_info *handle) } } -static void -handle_server_link(UNUSED_ARG(struct server *server)) +static int +handle_server_link(UNUSED_ARG(struct server *server), UNUSED_ARG(void *extra)) { struct chanData *cData; @@ -8470,6 +8975,7 @@ handle_server_link(UNUSED_ARG(struct server *server)) timeq_add(now + chanserv_conf.adjust_delay, chanserv_adjust_limit, cData); } } + return 0; } static void @@ -8571,6 +9077,34 @@ chanserv_conf_read(void) chanserv_conf.default_modes = *change; mod_chanmode_free(change); } + str = database_get_data(conf_node, KEY_VALID_CHANNEL_REGEX, RECDB_QSTRING); + if (chanserv_conf.valid_channel_regex_set) + regfree(&chanserv_conf.valid_channel_regex); + if (str) { + int err = regcomp(&chanserv_conf.valid_channel_regex, str, REG_EXTENDED|REG_ICASE|REG_NOSUB); + chanserv_conf.valid_channel_regex_set = !err; + if (err) log_module(CS_LOG, LOG_ERROR, "Bad valid_channel_regex (error %d)", err); + } else { + chanserv_conf.valid_channel_regex_set = 0; + } + free_string_list(chanserv_conf.wheel); + strlist = database_get_data(conf_node, "wheel", RECDB_STRING_LIST); + if(strlist) + strlist = string_list_copy(strlist); + else + { + static const char *list[] = { + "peer", "partall", "gline", /* "shun", */ + "nothing", "randjoin", "abusewhois", "kickall", + "nickchange", "kill", "svsignore", "kickbanall", + NULL}; + unsigned int ii; + strlist = alloc_string_list(ArrayLength(list)-1); + for(ii=0; list[ii]; ii++) + string_list_append(strlist, strdup(list[ii])); + } + chanserv_conf.wheel = strlist; + free_string_list(chanserv_conf.set_shows); strlist = database_get_data(conf_node, "set_shows", RECDB_STRING_LIST); if(strlist) @@ -8590,7 +9124,6 @@ chanserv_conf_read(void) /* delimiter */ NULL }; - unsigned int ii; strlist = alloc_string_list(ArrayLength(list)-1); for(ii=0; list[ii]; ii++) string_list_append(strlist, strdup(list[ii])); @@ -8601,6 +9134,7 @@ chanserv_conf_read(void) * function list as invalid, so it will be initialized. */ set_shows_list.used = 0; + free_string_list(chanserv_conf.eightball); strlist = database_get_data(conf_node, KEY_8BALL_RESPONSES, RECDB_STRING_LIST); if(strlist) @@ -8615,6 +9149,7 @@ chanserv_conf_read(void) string_list_append(strlist, strdup("Maybe so.")); } chanserv_conf.eightball = strlist; + free_string_list(chanserv_conf.old_ban_names); strlist = database_get_data(conf_node, KEY_OLD_BAN_NAMES, RECDB_STRING_LIST); if(strlist) @@ -8689,7 +9224,7 @@ user_read_helper(const char *key, struct record_data *rd, struct chanData *chan) struct userData *uData; char *seen, *inf, *flags, *expires, *accessexpiry, *clvlexpiry, *lstacc; time_t last_seen; - unsigned short access, lastaccess = 0; + unsigned short access_level, lastaccess = 0; if(rd->type != RECDB_OBJECT || !dict_size(rd->d.object)) { @@ -8697,8 +9232,8 @@ user_read_helper(const char *key, struct record_data *rd, struct chanData *chan) return; } - access = atoi(database_get_data(rd->d.object, KEY_LEVEL, RECDB_QSTRING)); - if(access > UL_OWNER) + access_level = atoi(database_get_data(rd->d.object, KEY_LEVEL, RECDB_QSTRING)); + if(access_level > UL_OWNER) { log_module(CS_LOG, LOG_ERROR, "Invalid access level for %s in %s.", key, chan->channel->name); return; @@ -8721,7 +9256,7 @@ user_read_helper(const char *key, struct record_data *rd, struct chanData *chan) return; } - uData = add_channel_user(chan, handle, access, last_seen, inf, 0); + uData = add_channel_user(chan, handle, access_level, last_seen, inf, 0); uData->flags = flags ? strtoul(flags, NULL, 0) : 0; uData->expires = expires ? strtoul(expires, NULL, 0) : 0; @@ -9000,6 +9535,9 @@ chanserv_channel_read(const char *key, struct record_data *hir) str = database_get_data(channel, KEY_TOPIC, RECDB_QSTRING); cData->topic = str ? strdup(str) : NULL; + str = database_get_data(channel, KEY_MAXSETINFO, RECDB_QSTRING); + cData->maxsetinfo = str ? strtoul(str, NULL, 0) : chanserv_conf.max_userinfo_length; + if(!IsSuspended(cData) && (str = database_get_data(channel, KEY_MODES, RECDB_QSTRING)) && (argc = split_line(str, 0, ArrayLength(argv), argv)) @@ -9253,6 +9791,9 @@ chanserv_write_channel(struct saxdb_context *ctx, struct chanData *channel) } saxdb_end_record(ctx); + if (channel->maxsetinfo) + saxdb_write_int(ctx, KEY_MAXSETINFO, channel->maxsetinfo); + if(channel->modes.modes_set || channel->modes.modes_clear) { mod_chanmode_format(&channel->modes, buf); @@ -9325,15 +9866,15 @@ write_dnrs_helper(struct saxdb_context *ctx, struct dict *dnrs) next = iter_next(it); dnr = iter_data(it); if(dnr->expires && dnr->expires <= now) - { - dict_remove(dnrs, iter_key(it)); continue; - } saxdb_start_record(ctx, dnr->chan_name, 0); if(dnr->set) saxdb_write_int(ctx, KEY_DNR_SET, dnr->set); if(dnr->expires) + { + dict_remove(dnrs, iter_key(it)); saxdb_write_int(ctx, KEY_EXPIRES, dnr->expires); + } saxdb_write_string(ctx, KEY_DNR_SETTER, dnr->setter); saxdb_write_string(ctx, KEY_DNR_REASON, dnr->reason); saxdb_end_record(ctx); @@ -9376,7 +9917,7 @@ chanserv_saxdb_write(struct saxdb_context *ctx) static void chanserv_db_cleanup(void) { unsigned int ii; - unreg_part_func(handle_part); + unreg_part_func(handle_part, NULL); while(channelList) unregister_channel(channelList, "terminating."); for(ii = 0; ii < chanserv_conf.support_channels.used; ++ii) @@ -9388,6 +9929,7 @@ chanserv_db_cleanup(void) { dict_delete(note_types); free_string_list(chanserv_conf.eightball); free_string_list(chanserv_conf.old_ban_names); + free_string_list(chanserv_conf.wheel); free_string_list(chanserv_conf.set_shows); free(set_shows_list.list); free(uset_shows_list.list); @@ -9399,7 +9941,11 @@ chanserv_db_cleanup(void) { } } -#define DEFINE_COMMAND(NAME, MIN_ARGC, FLAGS, OPTIONS...) modcmd_register(chanserv_module, #NAME, cmd_##NAME, MIN_ARGC, FLAGS, ## OPTIONS) +#if defined(GCC_VARMACROS) +# define DEFINE_COMMAND(NAME, MIN_ARGC, FLAGS, ARGS...) modcmd_register(chanserv_module, #NAME, cmd_##NAME, MIN_ARGC, FLAGS, ARGS) +#elif defined(C99_VARMACROS) +# define DEFINE_COMMAND(NAME, MIN_ARGC, FLAGS, ...) modcmd_register(chanserv_module, #NAME, cmd_##NAME, MIN_ARGC, FLAGS, __VA_ARGS__) +#endif #define DEFINE_CHANNEL_OPTION(NAME) modcmd_register(chanserv_module, "set "#NAME, chan_opt_##NAME, 1, 0, NULL) #define DEFINE_USER_OPTION(NAME) modcmd_register(chanserv_module, "uset "#NAME, user_opt_##NAME, 1, MODCMD_REQUIRE_REGCHAN, NULL) @@ -9408,24 +9954,23 @@ init_chanserv(const char *nick) { struct chanNode *chan; unsigned int i; + CS_LOG = log_register_type("ChanServ", "file:chanserv.log"); conf_register_reload(chanserv_conf_read); - if(nick) - { - reg_server_link_func(handle_server_link); - reg_new_channel_func(handle_new_channel); - reg_join_func(handle_join); - reg_part_func(handle_part); - reg_kick_func(handle_kick); - reg_topic_func(handle_topic); - reg_mode_change_func(handle_mode); - reg_nick_change_func(handle_nick_change); - reg_auth_func(handle_auth); + if (nick) { + reg_server_link_func(handle_server_link, NULL); + reg_new_channel_func(handle_new_channel, NULL); + reg_join_func(handle_join, NULL); + reg_part_func(handle_part, NULL); + reg_kick_func(handle_kick); + reg_topic_func(handle_topic, NULL); + reg_mode_change_func(handle_mode); + reg_nick_change_func(handle_nick_change, NULL); + reg_auth_func(handle_auth); } - - reg_handle_rename_func(handle_rename); + reg_handle_rename_func(handle_rename, NULL); reg_unreg_func(handle_unreg); handle_dnrs = dict_new(); @@ -9437,7 +9982,7 @@ init_chanserv(const char *nick) reg_svccmd_unbind_func(handle_svccmd_unbind); chanserv_module = module_register("ChanServ", CS_LOG, "chanserv.help", chanserv_expand_variable); - DEFINE_COMMAND(register, 1, MODCMD_REQUIRE_AUTHED, "flags", "+acceptchan,+helping", NULL); + DEFINE_COMMAND(register, 1, MODCMD_REQUIRE_AUTHED, "flags", "+acceptchan,+channel", NULL); DEFINE_COMMAND(noregister, 1, MODCMD_REQUIRE_AUTHED, "flags", "+helping", NULL); DEFINE_COMMAND(allowregister, 2, 0, "template", "noregister", NULL); DEFINE_COMMAND(dnrsearch, 3, 0, "template", "noregister", NULL); @@ -9466,6 +10011,7 @@ init_chanserv(const char *nick) DEFINE_COMMAND(mdelmanager, 2, MODCMD_REQUIRE_CHANUSER, "access", "coowner", NULL); DEFINE_COMMAND(mdelop, 2, MODCMD_REQUIRE_CHANUSER, "access", "manager", NULL); DEFINE_COMMAND(mdelpeon, 2, MODCMD_REQUIRE_CHANUSER, "access", "manager", NULL); + DEFINE_COMMAND(mdelpal, 2, MODCMD_REQUIRE_CHANUSER, "access", "manager", NULL); DEFINE_COMMAND(mdelhalfop, 2, MODCMD_REQUIRE_CHANUSER, "access", "manager", NULL); DEFINE_COMMAND(levels, 1, 0, NULL); @@ -9496,9 +10042,6 @@ init_chanserv(const char *nick) DEFINE_COMMAND(topic, 1, MODCMD_REQUIRE_REGCHAN, "template", "hop", "flags", "+never_csuspend", NULL); DEFINE_COMMAND(mode, 1, MODCMD_REQUIRE_REGCHAN, "template", "op", NULL); DEFINE_COMMAND(inviteme, 1, MODCMD_REQUIRE_CHANNEL, "access", "1", NULL); - DEFINE_CHANNEL_OPTION(unreviewed); - modcmd_register(chanserv_module, "set unreviewed on", NULL, 0, 0, "flags", "+helping", NULL); - modcmd_register(chanserv_module, "set unreviewed off", NULL, 0, 0, "flags", "+oper", NULL); DEFINE_COMMAND(invite, 1, MODCMD_REQUIRE_CHANNEL, "access", "manager", NULL); DEFINE_COMMAND(set, 1, MODCMD_REQUIRE_CHANUSER, "access", "op", NULL); DEFINE_COMMAND(wipeinfo, 2, MODCMD_REQUIRE_CHANUSER, "access", "manager", NULL); @@ -9553,6 +10096,9 @@ init_chanserv(const char *nick) DEFINE_COMMAND(huggle, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); DEFINE_COMMAND(calc, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); DEFINE_COMMAND(reply, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); + DEFINE_COMMAND(roulette, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); + DEFINE_COMMAND(shoot, 1, 0, "flags", "+nolog,+toy,+acceptchan", NULL); + DEFINE_COMMAND(spin, 1, MODCMD_REQUIRE_AUTHED, "spin", "+nolog,+toy,+acceptchan", NULL); /* Channel options */ DEFINE_CHANNEL_OPTION(defaulttopic); @@ -9578,6 +10124,10 @@ init_chanserv(const char *nick) DEFINE_CHANNEL_OPTION(ctcpreaction); DEFINE_CHANNEL_OPTION(bantimeout); DEFINE_CHANNEL_OPTION(inviteme); + DEFINE_CHANNEL_OPTION(unreviewed); + modcmd_register(chanserv_module, "set unreviewed on", NULL, 0, 0, "flags", "+helping", NULL); + modcmd_register(chanserv_module, "set unreviewed off", NULL, 0, 0, "flags", "+oper", NULL); + DEFINE_CHANNEL_OPTION(maxsetinfo); if(off_channel > 1) DEFINE_CHANNEL_OPTION(offchannel); modcmd_register(chanserv_module, "set defaults", chan_opt_defaults, 1, 0, "access", "owner", NULL); @@ -9601,7 +10151,7 @@ init_chanserv(const char *nick) const char *modes = conf_get_data("services/chanserv/modes", RECDB_QSTRING); chanserv = AddLocalUser(nick, nick, NULL, "Channel Services", modes); service_register(chanserv)->trigger = '!'; - reg_chanmsg_func('\001', chanserv, chanserv_ctcp_check); + reg_chanmsg_func('\001', chanserv, chanserv_ctcp_check, NULL); } saxdb_register("ChanServ", chanserv_saxdb_read, chanserv_saxdb_write);