X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodcmd.c;h=bb3199fea23bba07c84938665c1f9db032406d7c;hb=6385ddd8822a295c5b9b875ea52289b28f2df6d6;hp=290d75c75c79ee09c3539f683c53d888f2bb8cef;hpb=e4427641a86ef4b3d8336133db350ca359650ef2;p=srvx.git diff --git a/src/modcmd.c b/src/modcmd.c index 290d75c..bb3199f 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -39,6 +39,7 @@ static const struct message_entry msgtab[] = { { "MCMSG_BARE_FLAG", "Flag %.*s must be preceded by a + or -." }, { "MCMSG_UNKNOWN_FLAG", "Unknown module flag %.*s." }, { "MCMSG_BAD_OPSERV_LEVEL", "Invalid $O access level %s." }, + { "MCMSG_BAD_STAFF_LEVEL", "Invalid staff level %s." }, { "MCMSG_BAD_CHANSERV_LEVEL", "Invalid $C access level %s." }, { "MCMSG_LEVEL_TOO_LOW", "You cannot set the access requirements for %s (your level is too low.)" }, { "MCMSG_LEVEL_TOO_HIGH", "You cannot set the access requirements to %s (that is too high)." }, @@ -77,6 +78,7 @@ static const struct message_entry msgtab[] = { { "MCMSG_HELPFILE_READ", "Read %s help database in %lu.%03lu seconds." }, { "MCMSG_COMMAND_TIME", "Command $b%s$b finished in %lu.%06lu seconds." }, { "MCMSG_NEED_OPSERV_LEVEL", "You must have $O access of at least $b%u$b." }, + { "MCMSG_NEED_STAFF_LEVEL", "You must have staff access of at least $b%u$b." }, { "MCMSG_NEED_CHANSERV_LEVEL", "You must have $C access of at least $b%u$b in the channel." }, { "MCMSG_NEED_ACCOUNT_FLAGS", "You must have account flags $b%s$b." }, { "MCMSG_NEED_NOTHING", "Anyone may use the $b%s$b command." }, @@ -126,7 +128,7 @@ static const struct message_entry msgtab[] = { { "MCMSG_MESSAGE_DUMP_FAILED", "Message dump failed: %s." }, { "MCMSG_COMMAND_FLAGS", "Command flags are %s (inferred: %s)." }, { "MCMSG_COMMAND_ACCOUNT_FLAGS", "Requires account flags +%s, prohibits account flags +%s." }, - { "MCMSG_COMMAND_ACCESS_LEVEL", "Requires channel access %d and $O access %d." }, + { "MCMSG_COMMAND_ACCESS_LEVEL", "Requires channel access %d and $O access %d and staff access %d." }, { "MCMSG_COMMAND_USES", "%s has been used %d times." }, { NULL, NULL } }; @@ -302,6 +304,8 @@ svccmd_copy_rules(struct svccmd *dest, struct svccmd *src) { dest->deny_account_flags |= src->deny_account_flags; if (src->min_opserv_level > dest->min_opserv_level) dest->min_opserv_level = src->min_opserv_level; + if (src->min_staff_level > dest->min_staff_level) + dest->min_staff_level = src->min_staff_level; if (src->min_channel_access > dest->min_channel_access) dest->min_channel_access = src->min_channel_access; modcmd_set_effective_flags(dest); @@ -379,6 +383,18 @@ svccmd_configure(struct svccmd *cmd, struct userNode *user, struct userNode *bot } cmd->min_opserv_level = newval; return 1; + } else if (!irccasecmp(param, "staff_level") || !irccasecmp(param, "staff_access")) { + unsigned int newval = atoi(value); + if (newval > 1000) { + if (user) { + send_message(user, bot, "MCMSG_BAD_STAFF_LEVEL", value); + } else { + log_module(MAIN_LOG, LOG_ERROR, "Invalid staff level %s (for command %s).", value, cmd->name); + } + return 0; + } + cmd->min_staff_level = newval; + return 1; } else if (!irccasecmp(param, "account_flags")) { return nickserv_modify_handle_flags(user, bot, value, &cmd->req_account_flags, &cmd->deny_account_flags); } else { @@ -487,6 +503,7 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm send_message(user, bot, "MCMSG_CHAN_SUSPENDED", channel->name, channel->channel_info->suspended->reason); return 0; } + if (cmd->min_staff_level > 0 && !staff_has_access(user, bot, cmd->min_staff_level, !(options & SVCCMD_NOISY))) return 0; rflags |= ACTION_STAFF; } } @@ -538,6 +555,7 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm || ((flags & MODCMD_REQUIRE_NETWORK_HELPER) && IsNetworkHelper(user)) || ((flags & MODCMD_REQUIRE_SUPPORT_HELPER) && IsSupportHelper(user))) { /* allow it */ + if (cmd->min_staff_level > 0 && !staff_has_access(user, bot, cmd->min_staff_level, !(options & SVCCMD_NOISY))) return 0; rflags |= ACTION_STAFF; } else { if (options & SVCCMD_NOISY) @@ -551,11 +569,12 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm send_message(user, bot, "MCMSG_MUST_BE_HELPING"); return 0; } + if (cmd->min_staff_level > 0 && !staff_has_access(user, bot, cmd->min_staff_level, !(options & SVCCMD_NOISY))) return 0; rflags |= ACTION_STAFF; } if (cmd->min_opserv_level > 0) { - if (!oper_has_access(user, bot, cmd->min_opserv_level, !(options & SVCCMD_NOISY))) - return 0; + if (!oper_has_access(user, bot, cmd->min_opserv_level, !(options & SVCCMD_NOISY))) return 0; + if (cmd->min_staff_level > 0 && !staff_has_access(user, bot, cmd->min_staff_level, !(options & SVCCMD_NOISY))) return 0; rflags |= ACTION_STAFF; } if (cmd->req_account_flags || cmd->deny_account_flags) { @@ -580,6 +599,7 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm && (!(uData = _GetChannelUser(channel->channel_info, user->handle_info, 0, 0)) || uData->access < cmd->min_channel_access) && !(flags & (MODCMD_REQUIRE_STAFF|MODCMD_REQUIRE_HELPING))) { + if (cmd->min_staff_level > 0 && !staff_has_access(user, bot, cmd->min_staff_level, !(options & SVCCMD_NOISY))) return 0; rflags |= ACTION_OVERRIDE; } return rflags | ACTION_ALLOW; @@ -894,7 +914,7 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, const char *text, in * users, except to add copyright information pertaining * to changes you make to srvx. */ - snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, git_version); + snprintf(response, sizeof(response), "\x01VERSION %s (%s) GIT Revision: %s\x01", PACKAGE_STRING, CODENAME, git_version); irc_notice_user(bot, user, response); } return; @@ -1302,6 +1322,10 @@ static MODCMD_FUNC(cmd_command) { reply("MCMSG_NEED_OPSERV_LEVEL", svccmd->min_opserv_level); shown_flags |= MODCMD_REQUIRE_OPER | MODCMD_REQUIRE_AUTHED; } + if (svccmd->min_staff_level > 0) { // && (IsNetworkHelper(user) || IsSupportHelper(user) || IsOper(user)) + reply("MCMSG_NEED_STAFF_LEVEL", svccmd->min_staff_level); + shown_flags |= MODCMD_REQUIRE_STAFF | MODCMD_REQUIRE_AUTHED; + } if (svccmd->min_channel_access > 0) { reply("MCMSG_NEED_CHANSERV_LEVEL", svccmd->min_channel_access); shown_flags |= MODCMD_REQUIRE_CHANUSER | MODCMD_REQUIRE_REGCHAN | MODCMD_REQUIRE_CHANNEL | MODCMD_REQUIRE_AUTHED; @@ -1424,7 +1448,7 @@ modcmd_describe_command(struct userNode *user, struct svccmd *cmd, struct svccmd } buf1[buf1_used] = buf2[buf2_used] = '\0'; reply("MCMSG_COMMAND_ACCOUNT_FLAGS", buf1, buf2); - reply("MCMSG_COMMAND_ACCESS_LEVEL", target->min_channel_access, target->min_opserv_level); + reply("MCMSG_COMMAND_ACCESS_LEVEL", target->min_channel_access, target->min_opserv_level, target->min_staff_level); reply("MCMSG_COMMAND_USES", target->name, target->uses); } @@ -1574,7 +1598,7 @@ static MODCMD_FUNC(cmd_stats_services) { if (argc < 2) { tbl.length = dict_size(services) + 1; - tbl.width = 4; + tbl.width = 5; tbl.flags = TABLE_PAD_LEFT; tbl.contents = calloc(tbl.length, sizeof(tbl.contents[0])); tbl.contents[0] = calloc(tbl.width, sizeof(tbl.contents[0][0])); @@ -1582,6 +1606,7 @@ static MODCMD_FUNC(cmd_stats_services) { tbl.contents[0][1] = "Commands"; tbl.contents[0][2] = "Priv'd?"; tbl.contents[0][3] = "Trigger"; + tbl.contents[0][4] = "Offchannel"; extra = calloc(2, tbl.length); for (ii=1, it=dict_first(services); it; it=iter_next(it), ii++) { service = iter_data(it); @@ -1591,6 +1616,7 @@ static MODCMD_FUNC(cmd_stats_services) { tbl.contents[ii][2] = service->privileged ? "yes" : "no"; extra[ii*2] = service->trigger; tbl.contents[ii][3] = extra+ii*2; + tbl.contents[ii][4] = offchannel_allowed[(unsigned char)service->trigger] ? "yes" : "no"; } table_send(cmd->parent->bot, user->nick, 0, 0, tbl); free(extra); @@ -1915,11 +1941,8 @@ static MODCMD_FUNC(cmd_version) { * command or its accessibility to normal IRC users, except to add * copyright information pertaining to changes you make to srvx. */ - send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__". Copyright 2000-2008 srvx Development Team."); - if (argc > 1) - send_message_type(4, user, cmd->parent->bot, "%s", git_version); - else - send_message_type(12, user, cmd->parent->bot, "The srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net."); + send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), GIT Revision: %s, Built: "__DATE__", "__TIME__". Copyright 2000-2008 srvx Development Team.", git_version); + send_message_type(12, user, cmd->parent->bot, "The srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net.\nThis version has been modified by pk910 - visit #srvx @ irc.nextirc.net.\nThis version has been modified by Stricted - visit #dev @ irc.easy-scripting.net."); return 1; } @@ -1967,6 +1990,8 @@ modcmd_saxdb_write_command(struct saxdb_context *ctx, struct svccmd *cmd) { saxdb_write_string_list(ctx, "aliased", &cmd->alias); if (cmd->min_opserv_level != template->min_opserv_level) saxdb_write_int(ctx, "oper_access", cmd->min_opserv_level); + if (cmd->min_staff_level != template->min_staff_level) + saxdb_write_int(ctx, "staff_access", cmd->min_staff_level); if (cmd->min_channel_access != template->min_channel_access) saxdb_write_int(ctx, "channel_access", cmd->min_channel_access); if (cmd->flags != template->flags) { @@ -2247,6 +2272,10 @@ modcmd_db_load_command(struct service *service, const char *cmdname, struct dict || (str = database_get_data(obj, "opserv_level", RECDB_QSTRING))) { svccmd_configure(svccmd, NULL, service->bot, "oper_access", str); } + if ((str = database_get_data(obj, "staff_access", RECDB_QSTRING)) + || (str = database_get_data(obj, "staff_level", RECDB_QSTRING))) { + svccmd_configure(svccmd, NULL, service->bot, "staff_access", str); + } if ((str = database_get_data(obj, "channel_access", RECDB_QSTRING)) || (str = database_get_data(obj, "chanserv_level", RECDB_QSTRING))) { svccmd_configure(svccmd, NULL, service->bot, "channel_access", str);