aboutsummaryrefslogtreecommitdiff
path: root/xD.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-02-04 22:45:04 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-02-04 22:48:54 +0100
commit60d52ad4795c00fa7da0a652ceb4ddc08d557f10 (patch)
tree8fde4dba53d8c4d73d3c2c4ee8daf2970cfb8456 /xD.c
parentb358f53ec357892a1432ac6a5c5335524175e1bc (diff)
downloadxK-60d52ad4795c00fa7da0a652ceb4ddc08d557f10.tar.gz
xK-60d52ad4795c00fa7da0a652ceb4ddc08d557f10.tar.xz
xK-60d52ad4795c00fa7da0a652ceb4ddc08d557f10.zip
xC, xD: add basic WALLOPS support
Diffstat (limited to 'xD.c')
-rw-r--r--xD.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/xD.c b/xD.c
index 8d24cef..4ec365a 100644
--- a/xD.c
+++ b/xD.c
@@ -2933,6 +2933,29 @@ irc_handle_links (const struct irc_message *msg, struct client *c)
}
static void
+irc_handle_wallops (const struct irc_message *msg, struct client *c)
+{
+ if (msg->params.len < 1)
+ RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
+ if (!(c->mode & IRC_USER_MODE_OPERATOR))
+ RETURN_WITH_REPLY (c, IRC_ERR_NOPRIVILEGES);
+
+ const char *message = msg->params.vector[0];
+
+ // Our interpretation: anonymize the sender,
+ // and target all users who want to receive these messages
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
+ struct client *target;
+ while ((target = str_map_iter_next (&iter)))
+ {
+ if (target != c && !(target->mode & IRC_USER_MODE_RX_WALLOPS))
+ continue;
+
+ client_send (target, ":%s WALLOPS :%s", c->ctx->server_name, message);
+ }
+}
+
+static void
irc_handle_kill (const struct irc_message *msg, struct client *c)
{
if (msg->params.len < 2)
@@ -2994,6 +3017,7 @@ irc_register_handlers (struct server_context *ctx)
{ "ADMIN", true, irc_handle_admin, 0, 0 },
{ "STATS", true, irc_handle_stats, 0, 0 },
{ "LINKS", true, irc_handle_links, 0, 0 },
+ { "WALLOPS", true, irc_handle_wallops, 0, 0 },
{ "MODE", true, irc_handle_mode, 0, 0 },
{ "PRIVMSG", true, irc_handle_privmsg, 0, 0 },