X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/82f37c088726a44e666a119cdf872e21ffdd207f..0f3e9cfc4b5d0f13085c975e10c0e6c4c8e5fbc3:/src/chanserv.c diff --git a/src/chanserv.c b/src/chanserv.c index a21aec5..1410843 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -354,8 +354,14 @@ static const struct message_entry msgtab[] = { { "CSMSG_BANS_REMOVED", "Removed all channel bans from $b%s$b." }, /* Channel userlist */ - { "CSMSG_ACCESS_ALL_HEADER", "$b%s Users From Level %s To %s$b" }, - { "CSMSG_ACCESS_SEARCH_HEADER", "$b%s Users From Level %s To %s Matching %s$b" }, + { "CSMSG_ACCESS_ALL_HEADER_NORMAL", "$b%s Users From Level %s To %s$b" }, + { "CSMSG_ACCESS_SEARCH_HEADER_NORMAL", "$b%s Users From Level %s To %s Matching %s$b" }, + /* uncomment if needed to adujust styles (and change code below) + { "CSMSG_ACCESS_ALL_HEADER_CLEAN", "$b%s Users From Level %s To %s$b" }, + { "CSMSG_ACCESS_SEARCH_HEADER_CLEAN", "$b%s Users From Level %s To %s Matching %s$b" }, + { "CSMSG_ACCESS_ALL_HEADER_ADVANCED", "$b%s Users From Level %s To %s$b" }, + { "CSMSG_ACCESS_SEARCH_HEADER_ADVANCED", "$b%s Users From Level %s To %s Matching %s$b" }, + */ { "CSMSG_INVALID_ACCESS", "$b%s$b is an invalid access level." }, { "CSMSG_CHANGED_ACCESS", "%s now has access $b%s$b (%u) in %s." }, { "CSMSG_LAMERS_HEADER", "$bLamers in %s$b" }, @@ -437,6 +443,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_CHANNEL_OWNERSHIP_STAFF_REASON", "from %s to %s (%d access) by %s on %s reason: %s" }, { "CSMSG_CHANNEL_OWNERSHIP_STAFF", "from %s to %s (%d access) by %s on %s" }, { "CSMSG_CHANNEL_END", "---------------End of Info--------------"}, + { "CSMSG_CHANNEL_END_CLEAN", "End of Info"}, { "CSMSG_PEEK_INFO", "$bStatus of %s$b" }, { "CSMSG_PEEK_TOPIC", "$bTopic: $b%s" }, @@ -1807,7 +1814,8 @@ static CHANSERV_FUNC(cmd_noregister) dict_iterator_t it; reply("CSMSG_DNR_SEARCH_RESULTS"); - reply("CSMSG_BAR"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); matches = 0; for(it = dict_first(handle_dnrs); it; it = iter_next(it)) { @@ -1866,7 +1874,8 @@ static CHANSERV_FUNC(cmd_noregister) } reply("CSMSG_DNR_SEARCH_RESULTS"); - reply("CSMSG_BAR"); + 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 @@ -3862,13 +3871,31 @@ zoot_list(struct listData *list) */ static void -def_list(struct listData *list) +normal_list(struct listData *list) +{ + const char *msg; + if(list->search) + send_message(list->user, list->bot, "CSMSG_ACCESS_SEARCH_HEADER_NORMAL", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest), list->search); + else + send_message(list->user, list->bot, "CSMSG_ACCESS_ALL_HEADER_NORMAL", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest)); + if(list->table.length == 1) + { + msg = user_find_message(list->user, "MSG_NONE"); + send_message_type(4, list->user, list->bot, " %s", msg); + } + else + table_send(list->bot, list->user->nick, 0, NULL, list->table); +} + +/* if these need changed, uncomment and customize +static void +clean_list(struct listData *list) { const char *msg; if(list->search) - send_message(list->user, list->bot, "CSMSG_ACCESS_SEARCH_HEADER", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest), list->search); + send_message(list->user, list->bot, "CSMSG_ACCESS_SEARCH_HEADER_CLEAN", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest), list->search); else - send_message(list->user, list->bot, "CSMSG_ACCESS_ALL_HEADER", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest)); + send_message(list->user, list->bot, "CSMSG_ACCESS_ALL_HEADER_CLEAN", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest)); if(list->table.length == 1) { msg = user_find_message(list->user, "MSG_NONE"); @@ -3878,6 +3905,25 @@ def_list(struct listData *list) table_send(list->bot, list->user->nick, 0, NULL, list->table); } +static void +advanced_list(struct listData *list) +{ + const char *msg; + if(list->search) + send_message(list->user, list->bot, "CSMSG_ACCESS_SEARCH_HEADER_ADVANCED", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest), list->search); + else + send_message(list->user, list->bot, "CSMSG_ACCESS_ALL_HEADER_ADVANCED", list->channel->name, user_level_name_from_level(list->lowest), user_level_name_from_level(list->highest)); + if(list->table.length == 1) + { + msg = user_find_message(list->user, "MSG_NONE"); + send_message_type(4, list->user, list->bot, " %s", msg); + } + else + table_send(list->bot, list->user->nick, 0, NULL, list->table); +} + +*/ + static int userData_access_comp(const void *arg_a, const void *arg_b) { @@ -3899,6 +3945,8 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg struct listData lData; unsigned int matches; const char **ary; + int i = 0; + int seen_index; lData.user = user; lData.bot = cmd->parent->bot; @@ -3906,20 +3954,29 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg lData.lowest = lowest; lData.highest = highest; lData.search = (argc > 1) ? argv[1] : NULL; - send_list = def_list; + send_list = normal_list; /* What does the following line do exactly?? */ /*(void)zoot_list; ** since it doesn't show user levels */ - /* this does nothing!! -rubin + /* if(user->handle_info) { - switch(user->handle_info->userlist_style) - { - case HI_STYLE_DEF: send_list = def_list; break; - case HI_STYLE_ZOOT: send_list = def_list; break; - } + switch(user->handle_info->userlist_style) + { + case HI_STYLE_CLEAN: + send_list = clean_list; + break; + case HI_STYLE_ADVANCED: + send_list = advanced_list; + break; + case HI_STYLE_NORMAL: + default: + send_list = normal_list; + break; + } } */ + send_list = normal_list; lData.users = alloca(channel->channel_info->userCount * sizeof(struct userData *)); matches = 0; @@ -3934,45 +3991,54 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg qsort(lData.users, matches, sizeof(lData.users[0]), userData_access_comp); lData.table.length = matches+1; - lData.table.width = 5; lData.table.flags = TABLE_NO_FREE; lData.table.contents = malloc(lData.table.length*sizeof(*lData.table.contents)); + + if(user->handle_info && user->handle_info->userlist_style == HI_STYLE_ADVANCED) + lData.table.width = 5; /* with level = 5 */ + else + lData.table.width = 4; /* without = 4 */ ary = malloc(lData.table.width*sizeof(**lData.table.contents)); lData.table.contents[0] = ary; - ary[0] = "Access"; - ary[1] = "Level"; - ary[2] = "Account"; - ary[3] = "Last Seen"; - ary[4] = "Status"; + ary[i++] = "Access"; + if(user->handle_info && user->handle_info->userlist_style == HI_STYLE_ADVANCED) + ary[i++] = "Level"; /* Only on advanced view */ + ary[i++] = "Account"; + ary[i] = "Last Seen"; + seen_index = i++; + ary[i++] = "Status"; for(matches = 1; matches < lData.table.length; ++matches) { struct userData *uData = lData.users[matches-1]; char seen[INTERVALLEN]; + i = 0; ary = malloc(lData.table.width*sizeof(**lData.table.contents)); lData.table.contents[matches] = ary; - /* ary[0] = strtab(uData->access);*/ - ary[0] = user_level_name_from_level(uData->access); - ary[1] = strtab(uData->access); - ary[2] = uData->handle->handle; + ary[i++] = user_level_name_from_level(uData->access); + if(user->handle_info && user->handle_info->userlist_style == HI_STYLE_ADVANCED) + ary[i++] = strtab(uData->access); + ary[i++] = uData->handle->handle; if(uData->present) - ary[3] = "Here"; + ary[i] = "Here"; else if(!uData->seen) - ary[3] = "Never"; + ary[i] = "Never"; else - ary[3] = intervalString(seen, now - uData->seen, user->handle_info); - ary[3] = strdup(ary[3]); + ary[i] = intervalString(seen, now - uData->seen, user->handle_info); + ary[i] = strdup(ary[i]); + i++; if(IsUserSuspended(uData)) - ary[4] = "Suspended"; + ary[i++] = "Suspended"; else if(HANDLE_FLAGGED(uData->handle, FROZEN)) - ary[4] = "Vacation"; + ary[i++] = "Vacation"; else - ary[4] = "Normal"; + ary[i++] = "Normal"; } send_list(&lData); for(matches = 1; matches < lData.table.length; ++matches) { - free((char*)lData.table.contents[matches][3]); + /* Free strdup above */ + free((char*)lData.table.contents[matches][seen_index]); free(lData.table.contents[matches]); } free(lData.table.contents[0]); @@ -3986,7 +4052,8 @@ static CHANSERV_FUNC(cmd_pending) { struct adduserPending *ap; reply("CSMSG_ADDUSER_PENDING_HEADER"); - reply("CSMSG_BAR"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); for(ap = adduser_pendings;ap;ap = ap->next) reply("CSMSG_ADDUSER_PENDING_LIST", ap->channel->name, ap->user->nick); reply("CSMSG_ADDUSER_PENDING_FOOTER"); @@ -4191,13 +4258,18 @@ static CHANSERV_FUNC(cmd_topic) { struct chanData *cData; char *topic; + int p10 = 0; + +#ifdef WITH_PROTOCOL_P10 + p10 = 1; +#endif cData = channel->channel_info; if(argc < 2) { if(cData->topic) { - SetChannelTopic(channel, chanserv, cData->topic, 1); + SetChannelTopic(channel, chanserv, p10 ? user : chanserv, cData->topic, 1); reply("CSMSG_TOPIC_SET", cData->topic); return 1; } @@ -4233,10 +4305,10 @@ static CHANSERV_FUNC(cmd_topic) reply("CSMSG_TOPICMASK_CONFLICT2", TOPICLEN); return 0; } - SetChannelTopic(channel, chanserv, new_topic, 1); + SetChannelTopic(channel, chanserv, p10 ? user : chanserv, new_topic, 1); } else /* No mask set, just set the topic */ - SetChannelTopic(channel, chanserv, topic, 1); + SetChannelTopic(channel, chanserv, p10 ? user : chanserv, topic, 1); } if(check_user_level(channel, user, lvlTopicSnarf, 1, 0)) @@ -4436,7 +4508,8 @@ static CHANSERV_FUNC(cmd_info) cData = channel->channel_info; reply("CSMSG_CHANNEL_INFO", channel->name); - reply("CSMSG_BAR"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); uData = GetChannelUser(cData, user->handle_info); if(uData && (uData->access >= UL_OP /*cData->lvlOpts[lvlGiveOps]*/)) @@ -4494,7 +4567,10 @@ static CHANSERV_FUNC(cmd_info) for(giveownership = cData->giveownership; giveownership; giveownership = giveownership->previous) show_giveownership_info(cmd, user, giveownership); } - reply("CSMSG_CHANNEL_END"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_CHANNEL_END"); + else + reply("CSMSG_CHANNEL_END_CLEAN"); return 1; } @@ -4581,7 +4657,8 @@ static CHANSERV_FUNC(cmd_peek) irc_make_chanmode(channel, modes); reply("CSMSG_PEEK_INFO", channel->name); - reply("CSMSG_BAR"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); reply("CSMSG_PEEK_TOPIC", channel->topic); reply("CSMSG_PEEK_MODES", modes); reply("CSMSG_PEEK_USERS", channel->members.used); @@ -4871,16 +4948,16 @@ note_type_settable_by_user(struct chanNode *channel, struct note_type *ntype, st switch(ntype->set_access_type) { - case NOTE_SET_CHANNEL_ACCESS: - if(!user->handle_info) - return 0; - if(!(uData = GetChannelUser(channel->channel_info, user->handle_info))) - return 0; - return uData->access >= ntype->set_access.min_ulevel; - case NOTE_SET_CHANNEL_SETTER: - return check_user_level(channel, user, lvlSetters, 1, 0); - case NOTE_SET_PRIVILEGED: default: - return IsHelping(user) && (user->handle_info->opserv_level >= ntype->set_access.min_opserv); + case NOTE_SET_CHANNEL_ACCESS: + if(!user->handle_info) + return 0; + if(!(uData = GetChannelUser(channel->channel_info, user->handle_info))) + return 0; + return uData->access >= ntype->set_access.min_ulevel; + case NOTE_SET_CHANNEL_SETTER: + return check_user_level(channel, user, lvlSetters, 1, 0); + case NOTE_SET_PRIVILEGED: default: + return IsHelping(user) && (user->handle_info->opserv_level >= ntype->set_access.min_opserv); } } @@ -5026,7 +5103,8 @@ static CHANSERV_FUNC(cmd_events) report.reporter = chanserv; report.user = user; reply("CSMSG_EVENT_SEARCH_RESULTS", channel->name); - reply("CSMSG_BAR"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); matches = log_entry_search(&discrim, log_report_entry, &report); if(matches) reply("MSG_MATCH_COUNT", matches); @@ -5362,8 +5440,9 @@ static CHANSERV_FUNC(cmd_search) if(action == search_print) { - reply("CSMSG_CHANNEL_SEARCH_RESULTS"); - reply("CSMSG_BAR"); + reply("CSMSG_CHANNEL_SEARCH_RESULTS"); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); } matches = chanserv_channel_search(search, action, user); @@ -5433,7 +5512,7 @@ static MODCMD_FUNC(chan_opt_defaulttopic) && !match_ircglob(channel->channel_info->topic, channel->channel_info->topic_mask)) reply("CSMSG_TOPIC_MISMATCH", channel->name); } - SetChannelTopic(channel, chanserv, topic ? topic : "", 1); + SetChannelTopic(channel, chanserv, chanserv, topic ? topic : "", 1); } if(channel->channel_info->topic) @@ -5914,8 +5993,9 @@ static CHANSERV_FUNC(cmd_set) if(argc < 2) { - reply("CSMSG_CHANNEL_OPTIONS", channel->name); - reply("CSMSG_BAR"); + reply("CSMSG_CHANNEL_OPTIONS", channel->name); + if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN) + reply("CSMSG_BAR"); for(ii = 0; ii < set_shows_list.used; ii++) { subcmd = set_shows_list.list[ii]; @@ -6352,7 +6432,7 @@ chanserv_refresh_topics(UNUSED_ARG(void *data)) if((refresh_num - cData->last_refresh) < (unsigned int)(1 << (opt - '1'))) continue; if(cData->topic) - SetChannelTopic(cData->channel, chanserv, cData->topic, 1); + SetChannelTopic(cData->channel, chanserv, chanserv, cData->topic, 1); cData->last_refresh = refresh_num; } timeq_add(now + chanserv_conf.refresh_period, chanserv_refresh_topics, NULL); @@ -6487,13 +6567,13 @@ void eightball(char *outcome, int method, unsigned int seed) case 4: strcpy(tmp, "A gross kind of mucky %s."); break; case 5: strcpy(tmp, "Brilliant whiteish %s."); - break; - case 6: case 7: case 8: case 9: strcpy(tmp, "%s."); - break; - case 10: strcpy(tmp, "Solid %s."); - break; - case 11: strcpy(tmp, "Transparent %s."); - break; + break; + case 6: case 7: case 8: case 9: strcpy(tmp, "%s."); + break; + case 10: strcpy(tmp, "Solid %s."); + break; + case 11: strcpy(tmp, "Transparent %s."); + break; default: strcpy(outcome, "An invalid random number was generated."); return; } @@ -6710,7 +6790,7 @@ handle_new_channel(struct chanNode *channel) mod_chanmode_announce(chanserv, cData->channel, &cData->modes); if(self->uplink && !self->uplink->burst && channel->channel_info->topic) - SetChannelTopic(channel, chanserv, channel->channel_info->topic, 1); + SetChannelTopic(channel, chanserv, chanserv, channel->channel_info->topic, 1); } /* Welcome to my worst nightmare. Warning: Read (or modify) @@ -7040,7 +7120,7 @@ handle_topic(struct userNode *user, struct chanNode *channel, const char *old_to if(bad_topic(channel, user, channel->topic)) { /* User doesnt have privs to set topics. Undo it */ send_message(user, chanserv, "CSMSG_TOPIC_LOCKED", channel->name); - SetChannelTopic(channel, chanserv, old_topic, 1); + SetChannelTopic(channel, chanserv, chanserv, old_topic, 1); return 1; } /* If there is a topic mask set, and the new topic doesnt match, @@ -7051,12 +7131,12 @@ handle_topic(struct userNode *user, struct chanNode *channel, const char *old_to conform_topic(cData->topic_mask, channel->topic, new_topic); if(*new_topic) { - SetChannelTopic(channel, chanserv, new_topic, 1); + SetChannelTopic(channel, chanserv, chanserv, new_topic, 1); /* and fall through to topicsnarf code below.. */ } else /* Topic couldnt fit into mask, was too long */ { - SetChannelTopic(channel, chanserv, old_topic, 1); + SetChannelTopic(channel, chanserv, chanserv, old_topic, 1); send_message(user, chanserv, "CSMSG_TOPICMASK_CONFLICT1", channel->name, cData->topic_mask); send_message(user, chanserv, "CSMSG_TOPICMASK_CONFLICT2", TOPICLEN); return 1; @@ -8030,21 +8110,22 @@ chanserv_write_note_type(struct saxdb_context *ctx, struct note_type *ntype) saxdb_start_record(ctx, ntype->name, 0); switch(ntype->set_access_type) { - case NOTE_SET_CHANNEL_ACCESS: - saxdb_write_int(ctx, KEY_NOTE_CHANNEL_ACCESS, ntype->set_access.min_ulevel); - break; - case NOTE_SET_CHANNEL_SETTER: - saxdb_write_int(ctx, KEY_NOTE_SETTER_ACCESS, 1); - break; - case NOTE_SET_PRIVILEGED: default: - saxdb_write_int(ctx, KEY_NOTE_OPSERV_ACCESS, ntype->set_access.min_opserv); - break; + case NOTE_SET_CHANNEL_ACCESS: + saxdb_write_int(ctx, KEY_NOTE_CHANNEL_ACCESS, ntype->set_access.min_ulevel); + break; + case NOTE_SET_CHANNEL_SETTER: + saxdb_write_int(ctx, KEY_NOTE_SETTER_ACCESS, 1); + break; + case NOTE_SET_PRIVILEGED: default: + saxdb_write_int(ctx, KEY_NOTE_OPSERV_ACCESS, ntype->set_access.min_opserv); + break; } switch(ntype->visible_type) { - case NOTE_VIS_ALL: str = KEY_NOTE_VIS_ALL; break; - case NOTE_VIS_CHANNEL_USERS: str = KEY_NOTE_VIS_CHANNEL_USERS; break; - case NOTE_VIS_PRIVILEGED: default: str = KEY_NOTE_VIS_PRIVILEGED; break; + case NOTE_VIS_ALL: str = KEY_NOTE_VIS_ALL; break; + case NOTE_VIS_CHANNEL_USERS: str = KEY_NOTE_VIS_CHANNEL_USERS; break; + case NOTE_VIS_PRIVILEGED: + default: str = KEY_NOTE_VIS_PRIVILEGED; break; } saxdb_write_string(ctx, KEY_NOTE_VISIBILITY, str); saxdb_write_int(ctx, KEY_NOTE_MAX_LENGTH, ntype->max_length);