X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/6196b851afae60472f9f96c6dcb2ccd162fdc461..8c684fca9c7dbb4a2601628c744be9236ee68641:/chanserv/chancmds/op.c diff --git a/chanserv/chancmds/op.c b/chanserv/chancmds/op.c index 36afc98c..b4a9cc37 100644 --- a/chanserv/chancmds/op.c +++ b/chanserv/chancmds/op.c @@ -7,6 +7,19 @@ * CMDDESC: Ops you or other users on channel(s). * CMDFUNC: csc_doop * CMDPROTO: int csc_doop(void *source, int cargc, char **cargv); + * CMDHELP: Usage: OP [ [ [ [...]]]] + * CMDHELP: Ops you on one or more channels, or ops other named users on a given channel. + * CMDHELP: This command cannot be used to op users who are otherwise prevented from getting + * CMDHELP: ops, e.g. via the +d chanlev flag (see CHANLEV) or bitch mode (see CHANFLAGS). + * CMDHELP: Where: + * CMDHELP: channel - channel to use. If no channel is specified, you will be given ops on + * CMDHELP: every channel where you have appropriate access and are not already + * CMDHELP: opped. + * CMDHELP: user - user(s) to op instead of yourself. Each user must be specified as the + * CMDHELP: current nickname of a user on the named channel. + * CMDHELP: OP requires operator access (+o) on the named channel. If this command is used + * CMDHELP: to op other users, a notice will be sent to other channel operators on the + * CMDHELP: channel identifying you, unless you have master (+m) access. */ #include "../chanserv.h" @@ -23,6 +36,7 @@ int csc_doop(void *source, int cargc, char **cargv) { nick *sender=source, *np; reguser *rup=getreguserfromnick(sender); + reguser *srup=rup; chanindex *cip; regchan *rcp=NULL; regchanuser *rcup; @@ -30,6 +44,8 @@ int csc_doop(void *source, int cargc, char **cargv) { unsigned long *lp; int i; modechanges changes; + int donotice=0, bufpos=0; + char buf[512]; if (!rup) return CMD_ERROR; @@ -49,6 +65,7 @@ int csc_doop(void *source, int cargc, char **cargv) { localsetmodeinit(&changes, ca[i], chanservnick); localdosetmode_nick(&changes, sender, MC_OP); localsetmodeflush(&changes,1); + cs_logchanop(rcp, sender->nick, rup); } } } @@ -64,6 +81,12 @@ int csc_doop(void *source, int cargc, char **cargv) { return CMD_ERROR; rcp=cip->exts[chanservext]; + + /* If the channel doesn't currently exist, forget it. */ + if (!cip->channel) { + chanservstdmessage(sender, QM_EMPTYCHAN, cip->name->content); + return CMD_ERROR; + } if (cargc==1) { /* Only one arg: "op me" */ @@ -73,14 +96,15 @@ int csc_doop(void *source, int cargc, char **cargv) { localsetmodeinit(&changes, cip->channel, chanservnick); localdosetmode_nick(&changes, sender, MC_OP); localsetmodeflush(&changes,1); + cs_logchanop(rcp, sender->nick, srup); chanservstdmessage(sender, QM_DONE); return CMD_OK; } /* You've got to be a master to 'silently' op other people */ - if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, "op", 0, 0)) - return CMD_ERROR; + if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, "op", 0, 1)) + donotice=1; /* Set up the modes */ localsetmodeinit(&changes, cip->channel, chanservnick); @@ -113,9 +137,15 @@ int csc_doop(void *source, int cargc, char **cargv) { continue; } + bufpos += sprintf(buf+bufpos,"%s%s",bufpos?", ":"",np->nick); localdosetmode_nick(&changes, np, MC_OP); + cs_logchanop(rcp, np->nick, srup); } + if (donotice && bufpos) { + sendopnoticetochannel(chanservnick, cip->channel, "%s opped %s", sender->nick, buf); + } + localsetmodeflush(&changes, 1); chanservstdmessage(sender, QM_DONE);