- if (!IsOper(sptr) && !IsLocalChannel(parv[1]))
- return send_error_to_client(sptr, ERR_NOPRIVILEGES);
+ 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;
+ }
+
+ if (!HasPriv(sptr,
+ IsLocalChannel(chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+
+ if (('#' != *chname && '&' != *chname) || !(chptr = FindChannel(chname)))
+ return send_reply(sptr, ERR_NOSUCHCHANNEL, chname);