X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/13ae2f4b6904ebf7b8160902f9ffeb80f7585ed2..133755685ef38d8f9ac79ac27c4505b9e96f81fd:/extensions/m_omode.c diff --git a/extensions/m_omode.c b/extensions/m_omode.c index f1407ff..c588c53 100644 --- a/extensions/m_omode.c +++ b/extensions/m_omode.c @@ -22,7 +22,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: m_omode.c 3121 2007-01-02 13:23:04Z jilles $ */ #include "stdinc.h" @@ -55,7 +54,6 @@ DECLARE_MODULE_AV1(omode, NULL, NULL, omode_clist, NULL, NULL, "$Revision: 3121 /* * mo_omode - MODE command handler - * parv[0] - sender * parv[1] - channel */ static int @@ -95,7 +93,7 @@ mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char msptr = find_channel_membership(chptr, source_p); wasonchannel = msptr != NULL; - if (is_chanop(msptr)) + if (is_any_op(msptr)) { sendto_one_notice(source_p, ":Use a normal MODE you idiot"); return 0; @@ -125,7 +123,24 @@ mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char set_channel_mode(client_p, source_p->servptr, chptr, msptr, parc - 2, parv + 2); #else - if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name)) + if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name)) + { + /* Admining themselves */ + if (!wasonchannel) + { + sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, + form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname); + return 0; + } + sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s", + me.name, parv[1], source_p->name); + sendto_server(NULL, chptr, CAP_TS6, NOCAPS, + ":%s TMODE %ld %s +a %s", + me.id, (long) chptr->channelts, parv[1], + source_p->id); + msptr->flags |= CHFL_ADMIN; + } + else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name)) { /* Opping themselves */ if (!wasonchannel) @@ -140,16 +155,30 @@ mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char ":%s TMODE %ld %s +o %s", me.id, (long) chptr->channelts, parv[1], source_p->id); - sendto_server(NULL, chptr, NOCAPS, CAP_TS6, - ":%s MODE %s +o %s", - me.name, parv[1], source_p->name); msptr->flags |= CHFL_CHANOP; } - else + else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name)) + { + /* Halfopping themselves */ + if (!wasonchannel) + { + sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, + form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname); + return 0; + } + sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s", + me.name, parv[1], source_p->name); + sendto_server(NULL, chptr, CAP_TS6, NOCAPS, + ":%s TMODE %ld %s +h %s", + me.id, (long) chptr->channelts, parv[1], + source_p->id); + msptr->flags |= CHFL_HALFOP; + } + else if (ConfigChannel.use_admin) { /* Hack it so set_channel_mode() will accept */ if (wasonchannel) - msptr->flags |= CHFL_CHANOP; + msptr->flags |= CHFL_ADMIN; else { add_user_to_channel(chptr, source_p, CHFL_CHANOP); @@ -160,6 +189,27 @@ mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char /* We know they were not opped before and they can't have opped * themselves as set_channel_mode() does not allow that * -- jilles */ + if (wasonchannel) + msptr->flags &= ~CHFL_ADMIN; + else + remove_user_from_channel(msptr); + } + else + { + /* CHFL_ADMIN is only useful if admin is enabled + * so hack it with op if it is not. */ + if (wasonchannel) + msptr->flags |= CHFL_CHANOP; + else + { + add_user_to_channel(chptr, source_p, CHFL_CHANOP); + msptr = find_channel_membership(chptr, source_p); + } + set_channel_mode(client_p, source_p, chptr, msptr, + parc - 2, parv + 2); + /* We know they were not opped before and they can't have opped + * themselves as set_channel_mode() does not allow that + * -- jilles */ if (wasonchannel) msptr->flags &= ~CHFL_CHANOP; else