aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-17 22:54:16 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-17 23:48:38 +0200
commitb1780e3efba9913f7f0011efa9e7dfc5bd65603a (patch)
tree38bf32906b1529f017fe8b2241ee1616936f5df3 /src
parent531b1c71bf5a81e04d31795ece37db6dd322dddb (diff)
downloadxK-b1780e3efba9913f7f0011efa9e7dfc5bd65603a.tar.gz
xK-b1780e3efba9913f7f0011efa9e7dfc5bd65603a.tar.xz
xK-b1780e3efba9913f7f0011efa9e7dfc5bd65603a.zip
Send the user's mode after registration
Diffstat (limited to 'src')
-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