solanum-vs-hackint-and-char.../extensions/chm_quietunreg_compat.c
Ed Kellett 04952c32ad Rework channel mode handling
Incoming MODE processing is split into a parsing step and an execution
step, instead of a mode's effector function being involved in its own
parsing. Modes can no longer use custom logic to control their parsing,
and instead supply a combination of CHM_* flags to the parser. As a
result, we know before we try to effect any mode changes what all of
them will be.

The reauthorize hack for override is no longer necessary. A side effect
of its introduction was that `MODE #foo b x!y@z` no longer worked; in
removing it we restore that behaviour.

We gain the ability to reject various invalid inputs that:
- mutate or query unknown modes
- supply excess mode arguments
- query modes that can't be queried

In each case, whether we *should* reject it is an open question; for now
I'm rejecting the first one.
2020-11-08 00:26:27 +00:00

46 lines
1.1 KiB
C

/*
* Treat cmode +-R as +-q $~a.
* -- jilles
*/
#include "stdinc.h"
#include "modules.h"
#include "client.h"
#include "hook.h"
#include "ircd.h"
#include "chmode.h"
static const char chm_quietunreg_compat_desc[] =
"Adds an emulated channel mode +R which is converted into mode +q $~a";
static int _modinit(void);
static void _moddeinit(void);
static void chm_quietunreg(struct Client *source_p, struct Channel *chptr,
int alevel, const char *arg, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV2(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, chm_quietunreg_compat_desc);
static int
_modinit(void)
{
chmode_table['R'] = (struct ChannelMode){ chm_quietunreg, 0, 0 };
return 0;
}
static void
_moddeinit(void)
{
chmode_table['R'] = (struct ChannelMode){ chm_nosuch, 0, 0 };
}
static void
chm_quietunreg(struct Client *source_p, struct Channel *chptr,
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
{
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, "$~a",
errors, dir, 'q', CHFL_QUIET);
else
chm_nosuch(source_p, chptr, alevel, NULL,
errors, dir, c, mode_type);
}