Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_opmode.c
index 01db05a54e496cd0017867a930e60a6d325ad433..0c4bbe19651bbe0e77c09799b0260494d012e8b3 100644 (file)
@@ -123,7 +123,8 @@ int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
             (MODE_PARSE_SET    | /* Set the modes on the channel */
              MODE_PARSE_STRICT | /* Be strict about it */
-             MODE_PARSE_FORCE)); /* And force them to be accepted */
+             MODE_PARSE_FORCE),  /* And force them to be accepted */
+             NULL);
 
   modebuf_flush(&mbuf); /* flush the modes */
 
@@ -137,6 +138,8 @@ int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   struct Channel *chptr = 0;
   struct ModeBuf mbuf;
+  char *chname, *qreason;
+  int force = 0;
   struct Membership *member;
 
   if (!feature_bool(FEAT_CONFIG_OPERCMDS))
@@ -145,17 +148,25 @@ int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (parc < 3)
     return need_more_params(sptr, "OPMODE");
 
-  clean_channelname(parv[1]);
+  chname = parv[1];
+  if (*chname == '!')
+  {
+    chname++;
+    if (!HasPriv(sptr, IsLocalChannel(chname) ? PRIV_FORCE_LOCAL_OPMODE : PRIV_FORCE_OPMODE))
+      return send_reply(sptr, ERR_NOPRIVILEGES);
+    force = 1;
+  }
+  clean_channelname(chname);
 
   if (!HasPriv(sptr,
-              IsLocalChannel(parv[1]) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
+              IsLocalChannel(chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
     return send_reply(sptr, ERR_NOPRIVILEGES);
 
-  if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
-    return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+  if (!IsChannelName(chname) || !(chptr = FindChannel(chname)))
+    return send_reply(sptr, ERR_NOSUCHCHANNEL, chname);
 
-  if (!(member = find_member_link(chptr, sptr)))
-    return send_reply(sptr, ERR_NOTONCHANNEL, chptr->chname);
+  if (!force && (qreason = find_quarantine(chptr->chname)))
+    return send_reply(sptr, ERR_QUARANTINED, chptr->chname, qreason);
 
   modebuf_init(&mbuf, sptr, cptr, chptr,
               (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
@@ -166,7 +177,8 @@ int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
             (MODE_PARSE_SET |    /* set the modes on the channel */
-             MODE_PARSE_FORCE)); /* And force them to be accepted */
+             MODE_PARSE_FORCE),  /* And force them to be accepted */
+             NULL);
 
   modebuf_flush(&mbuf); /* flush the modes */