From: pk910 Date: Wed, 12 Oct 2011 19:09:35 +0000 (+0200) Subject: added cmd_opme command to chanserv (based on new devnull privilege: OpMe) X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=03eb826ca8a7b85b90f768587e98afe312883e44 added cmd_opme command to chanserv (based on new devnull privilege: OpMe) --- diff --git a/src/chanserv.c b/src/chanserv.c index 28db426..9b54681 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -22,7 +22,7 @@ #include "conf.h" #include "global.h" #include "modcmd.h" -#include "opserv.h" /* for opserv_bad_channel() */ +#include "opserv.h" /* for opserv_bad_channel() and devnull management */ #include "nickserv.h" /* for oper_outranks() */ #include "saxdb.h" #include "spamserv.h" @@ -3236,6 +3236,45 @@ static CHANSERV_FUNC(cmd_devoice) return modify_users(CSFUNC_ARGS, NULL, MODE_REMOVE|MODE_VOICE, "CSMSG_DEVOICED_USERS"); } +static CHANSERV_FUNC(cmd_opme) +{ + struct mod_chanmode change; + struct userData *uData; + const char *errmsg; + + mod_chanmode_init(&change); + change.argc = 1; + change.args[0].u.member = GetUserMode(channel, user); + if(!change.args[0].u.member) + { + if(argc) + reply("MSG_CHANNEL_ABSENT", channel->name); + return 0; + } + + struct devnull_class *devnull; + if(user->handle_info->devnull && (devnull = devnull_get(user->handle_info->devnull)) && (devnull->modes & DEVNULL_MODE_OPME)) + { + change.args[0].mode = MODE_CHANOP; + errmsg = "CSMSG_ALREADY_OPPED"; + } + else + { + if(argc) + reply("CSMSG_NO_ACCESS"); + return 0; + } + change.args[0].mode &= ~change.args[0].u.member->modes; + if(!change.args[0].mode) + { + if(argc) + reply(errmsg, channel->name); + return 0; + } + modcmd_chanmode_announce(&change); + return 1; +} + static int bad_channel_ban(struct chanNode *channel, struct userNode *user, const char *ban, unsigned int *victimCount, struct modeNode **victims) { @@ -8663,6 +8702,8 @@ init_chanserv(const char *nick) DEFINE_COMMAND(endvote, 1, MODCMD_REQUIRE_AUTHED, NULL); DEFINE_COMMAND(voteresults, 1, MODCMD_REQUIRE_AUTHED, NULL); + DEFINE_COMMAND(opme, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_CHANNEL, NULL); + /* Channel options */ DEFINE_CHANNEL_OPTION(defaulttopic); DEFINE_CHANNEL_OPTION(topicmask); diff --git a/src/opserv.c b/src/opserv.c index 2776e5a..e81b784 100644 --- a/src/opserv.c +++ b/src/opserv.c @@ -297,6 +297,7 @@ static const struct message_entry msgtab[] = { { "OSMSG_DEVNULL_SET_M", "OverrideNoAmsg: %s" }, { "OSMSG_DEVNULL_SET_N", "MaxSendQ: %s" }, { "OSMSG_DEVNULL_SET_N_i", "MaxSendQ: %i" }, + { "OSMSG_DEVNULL_SET_OPME", "OpMe: %s" }, { "OSMSG_DEVNULL_SET_DONE", "Done." }, { "OSMSG_DEVNULL_RENAMED", "Devnull class %s renamed to %s" }, { "OSMSG_DEVNULL_SET_INVALID", "Invalid Option for setting %s" }, @@ -4271,7 +4272,7 @@ static MODCMD_FUNC(cmd_listdevnull) count++; } tbl.length = count+1; - tbl.width = 14; + tbl.width = 15; tbl.flags = 0; tbl.flags = TABLE_NO_FREE; tbl.contents = malloc(tbl.length * sizeof(tbl.contents[0])); @@ -4290,6 +4291,7 @@ static MODCMD_FUNC(cmd_listdevnull) tbl.contents[0][11] = "+S"; tbl.contents[0][12] = "+X"; tbl.contents[0][13] = "MaxQ"; + tbl.contents[0][14] = "OpMe"; if(!count) { table_send(cmd->parent->bot, user->nick, 0, NULL, tbl); @@ -4369,6 +4371,11 @@ static MODCMD_FUNC(cmd_listdevnull) } else { tbl.contents[ii][13] = off; } + if(DEVNULL_FLAGGED(th, MODE_OPME)) { + tbl.contents[ii][14] = on; + } else { + tbl.contents[ii][14] = off; + } } table_send(cmd->parent->bot, user->nick, 0, NULL, tbl); for(ii = 1; ii < tbl.length; ++ii) @@ -4405,6 +4412,7 @@ static MODCMD_FUNC(cmd_listdevnull) send_message_type(4, user, opserv,"+k = ChanServ Mode (mode +k)"); send_message_type(4, user, opserv,"+S = NetServ Mode (mode +S)"); send_message_type(4, user, opserv,"+X = XtraOp Mode (mode +X)"); + send_message_type(4, user, opserv,"OpMe = ChanServ opme command"); return 1; } @@ -4612,6 +4620,17 @@ static MODCMD_FUNC(cmd_setdevnull) th->maxsendq = strtoul(argv[offset+3], NULL, 0); reply("OSMSG_DEVNULL_SET_DONE"); } + } + else if(!strcmp("OPME",argv[offset+2])) { + if (!strcmp("OFF",argv[offset+3]) || !strcmp("0",argv[offset+3])) { + DEVNULL_CLEAR_FLAG(th, MODE_OPME); + reply("OSMSG_DEVNULL_SET_DONE"); + } else if (!strcmp("ON",argv[offset+3]) || !strcmp("1",argv[offset+3])) { + DEVNULL_SET_FLAG(th, MODE_OPME); + reply("OSMSG_DEVNULL_SET_DONE"); + } else { + reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+3]); + } } else { reply("OSMSG_DEVNULL_SET_INVALID", argv[offset+2]); } @@ -4685,6 +4704,11 @@ static MODCMD_FUNC(cmd_setdevnull) } else { reply("OSMSG_DEVNULL_SET_N", "off"); } + if(DEVNULL_FLAGGED(th, MODE_OPME)) { + reply("OSMSG_DEVNULL_SET_OPME", "on"); + } else { + reply("OSMSG_DEVNULL_SET_OPME", "off"); + } } } else { reply("OSMSG_DEVNULL_NOTFOUND", argv[offset+1]); diff --git a/src/opserv.h b/src/opserv.h index fcb9c8d..92b35ec 100644 --- a/src/opserv.h +++ b/src/opserv.h @@ -36,8 +36,9 @@ #define DEVNULL_MODE_L 0x00000800 #define DEVNULL_MODE_M 0x00001000 #define DEVNULL_MODE_N 0x00002000 +#define DEVNULL_MODE_OPME 0x00004000 -#define DEVNULL_MODES "abcdefghijklmn" +#define DEVNULL_MODES "abcdefghijklmno" #define DEVNULL_FLAGGED(hi, tok) ((hi)->modes & DEVNULL_##tok) #define DEVNULL_SET_FLAG(hi, tok) ((hi)->modes |= DEVNULL_##tok)