/* chanserv.c - Channel service bot
- * Copyright 2000-2004 srvx Development Team
+ * Copyright 2000-2006 srvx Development Team
*
* This file is part of srvx.
*
{ "CSMSG_MULTIPLE_OWNERS", "There is more than one owner in %s; please use $bCLVL$b, $bDELOWNER$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_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 */
{ "CSMSG_TOPIC_SET", "Topic is now '%s'." },
{ "CSMSG_NO_TOPIC", "$b%s$b does not have a default topic." },
{ "CSMSG_TOPICMASK_CONFLICT1", "I do not know how to make that topic work with the current topic mask in $b%s$b, which is: %s" },
- { "CSMSG_TOPICMASK_CONFLICT2", "Please make sure your topic at most %d characters and matches the topic mask pattern." },
+ { "CSMSG_TOPICMASK_CONFLICT2", "Please make sure your topic is at most %d characters and matches the topic mask pattern." },
{ "CSMSG_TOPIC_LOCKED", "The %s topic is locked." },
{ "CSMSG_MASK_BUT_NO_TOPIC", "Warning: $b%s$b does not have a default topic, but you just set the topic mask." },
{ "CSMSG_TOPIC_MISMATCH", "Warning: The default topic for $b%s$b does not match the topic mask; changing it anyway." },
{ "CSMSG_HELPER_HAS_ACCESS", "%s has access $b%d$b in %s and has $bsecurity override$b enabled." },
{ "CSMSG_LAZY_SMURF_TARGET", "%s is %s ($bIRCOp$b; not logged in)." },
{ "CSMSG_SMURF_TARGET", "%s is %s ($b%s$b)." },
+ { "CSMSG_OPERATOR_TITLE", "IRC operator" },
+ { "CSMSG_UC_H_TITLE", "network helper" },
+ { "CSMSG_LC_H_TITLE", "support helper" },
{ "CSMSG_LAME_SMURF_TARGET", "%s is an IRC operator." },
/* Seen information */
/* Channel configuration */
{ "CSMSG_INVALID_OPTION", "$b%s$b is not a valid %s option." },
+ { "CSMSG_INVALID_CFLAG", "$b%s$b is not a recognized channel flag." },
{ "CSMSG_CHANNEL_OPTIONS", "Channel Options:" },
{ "CSMSG_GREETING_TOO_LONG", "Your greeting ($b%d$b characters) must be shorter than $b%d$b characters." },
}
static void
-chanserv_ctcp_check(struct userNode *user, struct chanNode *channel, char *text, UNUSED_ARG(struct userNode *bot))
+chanserv_ctcp_check(struct userNode *user, struct chanNode *channel, const char *text, UNUSED_ARG(struct userNode *bot))
{
unsigned int eflags, argc;
char *argv[4];
return;
/* We need to enforce against them; do so. */
eflags = 0;
- argv[0] = text;
+ argv[0] = (char*)text;
argv[1] = user->nick;
argc = 2;
if(GetUserMode(channel, user))
static CHANSERV_FUNC(cmd_adduser)
{
struct userData *actee;
- struct userData *actor;
+ struct userData *actor, *real_actor;
struct handle_info *handle;
- unsigned short access;
+ unsigned short access, override = 0;
REQUIRE_PARAMS(3);
}
actor = GetChannelUser(channel->channel_info, user->handle_info);
+ real_actor = GetChannelAccess(channel->channel_info, user->handle_info);
+
if(actor->access <= access)
{
reply("CSMSG_NO_BUMP_ACCESS");
return 0;
}
+ /* Trying to add someone with equal/more access? */
+ if (!real_actor || real_actor->access <= access)
+ override = CMD_LOG_OVERRIDE;
+
if(!(handle = modcmd_get_handle_info(user, argv[1])))
return 0;
- if((actee = GetTrueChannelAccess(channel->channel_info, handle)))
+ if((actee = GetChannelAccess(channel->channel_info, handle)))
{
reply("CSMSG_USER_EXISTS", handle->handle, channel->name, actee->access);
return 0;
actee = add_channel_user(channel->channel_info, handle, access, 0, NULL);
scan_user_presence(actee, NULL);
reply("CSMSG_ADDED_USER", handle->handle, channel->name, access);
- return 1;
+ return 1 | override;
}
static CHANSERV_FUNC(cmd_clvl)
{
struct handle_info *handle;
struct userData *victim;
- struct userData *actor;
- unsigned short new_access;
+ struct userData *actor, *real_actor;
+ unsigned short new_access, override = 0;
int privileged = IsHelping(user) && ((user->handle_info->opserv_level >= chanserv_conf.nodelete_level) || !IsProtected(channel->channel_info));
REQUIRE_PARAMS(3);
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[1])))
return 0;
return 0;
}
+ /* 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? */
+ 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.
+ */
+
victim->access = new_access;
reply("CSMSG_CHANGED_ACCESS", handle->handle, new_access, channel->name);
- return 1;
+ return 1 | override;
}
static CHANSERV_FUNC(cmd_deluser)
{
struct handle_info *handle;
struct userData *victim;
- struct userData *actor;
- unsigned short access;
+ struct userData *actor, *real_actor;
+ unsigned short access, 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;
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(!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);
free(chan_name);
- return 1;
+ return 1 | override;
}
static int
cmd_mdel_user(struct userNode *user, struct chanNode *channel, unsigned short min_access, unsigned short max_access, char *mask, struct svccmd *cmd)
{
- struct userData *actor, *uData, *next;
+ struct userData *actor, *real_actor, *uData, *next;
+ unsigned int override = 0;
actor = GetChannelUser(channel->channel_info, user->handle_info);
+ real_actor = GetChannelAccess(channel->channel_info, user->handle_info);
if(min_access > max_access)
{
return 0;
}
+ if(!real_actor || real_actor->access <= max_access)
+ override = CMD_LOG_OVERRIDE;
+
for(uData = channel->channel_info->users; uData; uData = next)
{
next = uData->next;
}
reply("CSMSG_DELETED_USERS", mask, min_access, max_access, channel->name);
- return 1;
+ return 1 | override;
}
static CHANSERV_FUNC(cmd_mdelowner)
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)
{
send_message(user, chanserv, "CSMSG_BAD_RANGE", min_access, max_access);
return 0;
}
- if((actor->access <= max_access) && !IsHelping(user))
+ if(!actor || actor->access <= max_access)
{
send_message(user, chanserv, "CSMSG_NO_ACCESS");
return 0;
if(IsOper(target))
{
epithet = chanserv_conf.irc_operator_epithet;
- type = "IRCOp";
+ type = user_find_message(user, "CSMSG_OPERATOR_TITLE");
}
else if(IsNetworkHelper(target))
{
epithet = chanserv_conf.network_helper_epithet;
- type = "network helper";
+ type = user_find_message(user, "CSMSG_UC_H_TITLE");
}
else if(IsSupportHelper(target))
{
epithet = chanserv_conf.support_helper_epithet;
- type = "support helper";
+ type = user_find_message(user, "CSMSG_LC_H_TITLE");
}
if(epithet)
{
static CHANSERV_FUNC(cmd_bans)
{
+ struct userNode *search_u = NULL;
struct helpfile_table tbl;
- unsigned int matches = 0, timed = 0, ii;
+ unsigned int matches = 0, timed = 0, search_wilds = 0, ii;
char t_buffer[INTERVALLEN], e_buffer[INTERVALLEN], *search;
const char *msg_never, *triggered, *expires;
struct banData *ban, **bans;
- if(argc > 1)
- search = argv[1];
- else
+ if(argc < 2)
search = NULL;
+ else if(strchr(search = argv[1], '!'))
+ {
+ search = argv[1];
+ search_wilds = search[strcspn(search, "?*")];
+ }
+ else if(!(search_u = GetUserH(search)))
+ reply("MSG_NICK_UNKNOWN", search);
bans = alloca(channel->channel_info->banCount * sizeof(struct banData *));
for(ban = channel->channel_info->bans; ban; ban = ban->next)
{
- if(search && !match_ircglobs(search, ban->mask))
- continue;
+ if(search_u)
+ {
+ if(!user_matches_glob(search_u, ban->mask, MATCH_USENICK | MATCH_VISIBLE))
+ continue;
+ }
+ else if(search)
+ {
+ if(search_wilds ? !match_ircglobs(search, ban->mask) : !match_ircglob(search, ban->mask))
+ continue;
+ }
bans[matches++] = ban;
if(ban->expires)
timed = 1;
static MODCMD_FUNC(cmd_wipeinfo)
{
struct handle_info *victim;
- struct userData *ud, *actor;
+ struct userData *ud, *actor, *real_actor;
+ unsigned int override = 0;
REQUIRE_PARAMS(2);
actor = GetChannelUser(channel->channel_info, user->handle_info);
+ real_actor = GetChannelAccess(channel->channel_info, user->handle_info);
if(!(victim = modcmd_get_handle_info(user, argv[1])))
return 0;
if(!(ud = GetTrueChannelAccess(channel->channel_info, victim)))
reply("MSG_USER_OUTRANKED", victim->handle);
return 0;
}
+ if((ud->access >= real_actor->access) && (ud != real_actor))
+ override = CMD_LOG_OVERRIDE;
if(ud->info)
free(ud->info);
ud->info = NULL;
reply("CSMSG_WIPED_INFO_LINE", argv[1], channel->name);
- return 1;
+ return 1 | override;
}
static CHANSERV_FUNC(cmd_resync)
static CHANSERV_FUNC(cmd_giveownership)
{
struct handle_info *new_owner_hi;
- struct userData *new_owner, *curr_user;
+ struct userData *new_owner;
+ struct userData *curr_user;
+ struct userData *invoker;
struct chanData *cData = channel->channel_info;
struct do_not_register *dnr;
+ const char *confirm;
unsigned int force;
unsigned short co_access;
char reason[MAXLEN];
}
curr_user = owner;
}
- else if (!force && (now < (time_t)(cData->ownerTransfer + chanserv_conf.giveownership_period)))
+ else if(!force && (now < (time_t)(cData->ownerTransfer + chanserv_conf.giveownership_period)))
{
char delay[INTERVALLEN];
intervalString(delay, cData->ownerTransfer + chanserv_conf.giveownership_period - now, user->handle_info);
chanserv_show_dnrs(user, cmd, NULL, new_owner_hi->handle);
return 0;
}
+ invoker = GetChannelUser(cData, user->handle_info);
+ if(invoker->access <= UL_OWNER)
+ {
+ confirm = make_confirmation_string(curr_user);
+ if((argc < 3) || strcmp(argv[2], confirm))
+ {
+ reply("CSMSG_CONFIRM_GIVEOWNERSHIP", new_owner_hi->handle, confirm);
+ return 0;
+ }
+ }
if(new_owner->access >= UL_COOWNER)
co_access = new_owner->access;
else
static CHANSERV_FUNC(cmd_suspend)
{
struct handle_info *hi;
- struct userData *self, *target;
+ struct userData *self, *real_self, *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);
if(!(target = GetTrueChannelAccess(channel->channel_info, hi)))
{
reply("CSMSG_NO_CHAN_USER", hi->handle, channel->name);
target->present = 0;
target->seen = now;
}
+ if(!real_self || target->access >= real_self->access)
+ override = CMD_LOG_OVERRIDE;
target->flags |= USER_SUSPENDED;
reply("CSMSG_USER_SUSPENDED", hi->handle, channel->name);
- return 1;
+ return 1 | override;
}
static CHANSERV_FUNC(cmd_unsuspend)
{
struct handle_info *hi;
- struct userData *self, *target;
+ struct userData *self, *real_self, *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);
if(!(target = GetTrueChannelAccess(channel->channel_info, hi)))
{
reply("CSMSG_NO_CHAN_USER", hi->handle, channel->name);
reply("CSMSG_NOT_SUSPENDED", hi->handle);
return 0;
}
+ if(!real_self || target->access >= real_self->access)
+ override = CMD_LOG_OVERRIDE;
target->flags &= ~USER_SUSPENDED;
scan_user_presence(target, NULL);
reply("CSMSG_USER_UNSUSPENDED", hi->handle, channel->name);
- return 1;
+ return 1 | override;
}
static MODCMD_FUNC(cmd_deleteme)
{
scan_user_presence(uData, mn->user);
uData->seen = now;
+ if (uData->access >= UL_PRESENT)
+ cData->visited = now;
}
if(IsHelping(mn->user) && IsSupportHelper(mn->user))
CS_LOG = log_register_type("ChanServ", "file:chanserv.log");
conf_register_reload(chanserv_conf_read);
- 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);
+ 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);
+ }
- reg_auth_func(handle_auth);
reg_handle_rename_func(handle_rename);
reg_unreg_func(handle_unreg);
if(nick)
{
const char *modes = conf_get_data("services/chanserv/modes", RECDB_QSTRING);
- chanserv = AddService(nick, modes ? modes : NULL, "Channel Services", NULL);
+ chanserv = AddLocalUser(nick, nick, NULL, "Channel Services", modes);
service_register(chanserv)->trigger = '!';
reg_chanmsg_func('\001', chanserv, chanserv_ctcp_check);
}