diff options
| author | Nakidai <nakidai@disroot.org> | 2026-01-10 16:32:54 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-01-10 16:32:54 +0300 |
| commit | 76e2c978829bc6ff7bfe6c49bfa3739e19370990 (patch) | |
| tree | 07851d4ee5ca107ce4ec18889b20c006f56f53d3 /reply.c | |
| parent | 346abf24c900a19a77a8ce66566a7ffd86a819bb (diff) | |
| download | libreircd-76e2c978829bc6ff7bfe6c49bfa3739e19370990.tar.gz libreircd-76e2c978829bc6ff7bfe6c49bfa3739e19370990.zip | |
Add basic user mode handling
So, now there're all modes listed in RFC 2812. The only what they do now, though, is a +r restricting user from changing their nick
Diffstat (limited to 'reply.c')
| -rw-r--r-- | reply.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/reply.c b/reply.c index eaa56f4..2aa0e9b 100644 --- a/reply.c +++ b/reply.c @@ -29,8 +29,11 @@ #define M5(x, ...) ARG(x); M4(__VA_ARGS__) #define M6(x, ...) ARG(x); M5(__VA_ARGS__) #define M7(x, ...) ARG(x); M6(__VA_ARGS__) -#define GET_M(_0,_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME -#define ARGS(_0, ...) GET_M(_0,__VA_ARGS__,M7,M6,M5,M4,M3,M2,M1,M0,)(__VA_ARGS__,) +#define M8(x, ...) ARG(x); M7(__VA_ARGS__) +#define M10(x, ...) ARG(x); M9(__VA_ARGS__) +#define M11(x, ...) ARG(x); M10(__VA_ARGS__) +#define GET_M(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,NAME,...) NAME +#define ARGS(_0, ...) GET_M(_0,__VA_ARGS__,M11,M10,M9,M8,M7,M6,M5,M4,M3,M2,M1,M0,)(__VA_ARGS__,) /* * REPLY macro allows to write less boilerplate for each IRC reply @@ -71,6 +74,18 @@ vreply(const struct Peer *peer, int number, va_list ap) peer->user, peer->host ), _); + REPLY(221, WRITE( + ":%s 221 %s +%s%s%s%s%s%s%s", + hostname, + getnick(peer), + peer->modes & AWAY ? "a" : "", + peer->modes & INVISIBLE ? "i" : "", + peer->modes & WALLOPS ? "w" : "", + peer->modes & RESTRICTED ? "r" : "", + peer->modes & OPER ? "o" : "", + peer->modes & LOCALOPER ? "O" : "", + peer->modes & SNOTICE ? "s" : "" + ), _); REPLY(401, WRITE( ":%s 401 %s %s :No such nick/channel", hostname, @@ -138,7 +153,18 @@ vreply(const struct Peer *peer, int number, va_list ap) getnick(peer), channel ), channel, _); - default: warn("unknown reply: %d", number); WRITE( + REPLY(484, WRITE( + ":%s 484 %s :Your connection is restricted!", + hostname, + getnick(peer) + ), _); + REPLY(501, WRITE( + ":%s 501 %s :Unknown MODE flag (+%c)", + hostname, + getnick(peer), + *m + ), m, _); + default: warn("unknown reply: %d", number); return WRITE( ":%s 421 %s err :Reply %d is not implemented yet", hostname, getnick(peer), |