Send the user's mode after registration
This commit is contained in:
parent
531b1c71bf
commit
b1780e3efb
32
src/kike.c
32
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
|
||||
|
Loading…
Reference in New Issue
Block a user