]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/chancmds/op.c
fix bug in G stats
[irc/quakenet/newserv.git] / chanserv / chancmds / op.c
index 9971a0719b725a6a51d82cb41424da5e4d9f867f..b4a9cc37e7f61c0d63f33c95bc7744947d6a4f7b 100644 (file)
@@ -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 [<channel> [<user1> [<user2> [...]]]]
+ * 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<n> - 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,11 +96,16 @@ 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, 1))
+    donotice=1;
+
   /* Set up the modes */
   localsetmodeinit(&changes, cip->channel, chanservnick);
 
@@ -109,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);