aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kike.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/kike.c b/src/kike.c
index 0f23b97..1b218c9 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -270,6 +270,28 @@ client_free (struct client *self)
free (self->away_message);
}
+static char *
+client_get_mode (struct client *self)
+{
+ struct str mode;
+ str_init (&mode);
+
+ if (self->away_message) str_append_c (&mode, 'a');
+
+ unsigned m = self->mode;
+ if (m & IRC_USER_MODE_INVISIBLE) str_append_c (&mode, 'i');
+ if (m & IRC_USER_MODE_RX_WALLOPS) str_append_c (&mode, 'w');
+ if (m & IRC_USER_MODE_RESTRICTED) str_append_c (&mode, 'r');
+ if (m & IRC_USER_MODE_OPERATOR) str_append_c (&mode, 'o');
+ if (m & IRC_USER_MODE_RX_SERVER_NOTICES) str_append_c (&mode, 's');
+
+ if (mode.len)
+ return str_steal (&mode);
+
+ str_free (&mode);
+ return NULL;
+}
+
#define IRC_SUPPORTED_CHAN_MODES "ov" "imnqpst" "kl"
enum
@@ -561,20 +583,26 @@ irc_send_motd (struct client *c)
static void
irc_try_finish_registration (struct client *c)
{
+ struct server_context *ctx = c->ctx;
if (!c->nickname || !c->username || !c->realname)
return;
c->registered = true;
irc_send_reply (c, IRC_RPL_WELCOME, c->nickname, c->username, c->hostname);
- irc_send_reply (c, IRC_RPL_YOURHOST, c->ctx->server_name, PROGRAM_VERSION);
+ irc_send_reply (c, IRC_RPL_YOURHOST, ctx->server_name, PROGRAM_VERSION);
// The purpose of this message eludes me
irc_send_reply (c, IRC_RPL_CREATED, __DATE__);
- irc_send_reply (c, IRC_RPL_MYINFO, c->ctx->server_name, PROGRAM_VERSION,
+ irc_send_reply (c, IRC_RPL_MYINFO, ctx->server_name, PROGRAM_VERSION,
IRC_SUPPORTED_USER_MODES, IRC_SUPPORTED_CHAN_MODES);
// Although not strictly required, bots often need this to work
irc_send_motd (c);
+
+ char *mode = client_get_mode (c);
+ if (mode)
+ irc_send (c, ":%s MODE %s :+%s", c->nickname, c->nickname, mode);
+ free (mode);
}
static void