diff options
-rw-r--r-- | irc.h | 2 | ||||
-rw-r--r-- | irc_cap.c | 1 | ||||
-rw-r--r-- | irc_im.c | 6 | ||||
-rw-r--r-- | irc_send.c | 24 |
4 files changed, 33 insertions, 0 deletions
@@ -70,6 +70,7 @@ typedef enum { CAP_SASL = (1 << 0), CAP_MULTI_PREFIX = (1 << 1), CAP_EXTENDED_JOIN = (1 << 2), + CAP_AWAY_NOTIFY = (1 << 3), } irc_cap_flag_t; struct irc_user; @@ -341,6 +342,7 @@ void irc_send_channel_user_mode_diff(irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t old_flags, irc_channel_user_flags_t new_flags); void irc_send_invite(irc_user_t *iu, irc_channel_t *ic); void irc_send_cap(irc_t *irc, char *subcommand, char *body); +void irc_send_away_notify(irc_user_t *iu); /* irc_user.c */ irc_user_t *irc_user_new(irc_t *irc, const char *nick); @@ -40,6 +40,7 @@ static const cap_info_t supported_caps[] = { {"sasl", CAP_SASL}, {"multi-prefix", CAP_MULTI_PREFIX}, {"extended-join", CAP_EXTENDED_JOIN}, + {"away-notify", CAP_AWAY_NOTIFY}, {NULL}, }; @@ -119,6 +119,12 @@ static gboolean bee_irc_user_status(bee_t *bee, bee_user_t *bu, bee_user_t *old) iu->flags |= IRC_USER_AWAY; } + if ((irc->caps & CAP_AWAY_NOTIFY) && + ((bu->flags & BEE_USER_AWAY) != (old->flags & BEE_USER_AWAY) || + (bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE))) { + irc_send_away_notify(iu); + } + if ((bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE)) { if (bu->flags & BEE_USER_ONLINE) { if (g_hash_table_lookup(irc->watches, iu->key)) { @@ -469,3 +469,27 @@ void irc_send_cap(irc_t *irc, char *subcommand, char *body) irc_write(irc, ":%s CAP %s %s :%s", irc->root->host, nick, subcommand, body); } + +void irc_send_away_notify(irc_user_t *iu) +{ + bee_user_t *bu = iu->bu; + + if (!bu) { + return; + } + + if (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) { + char *msg1, *msg2; + + get_status_message(bu, &msg1, &msg2); + + if (msg2) { + irc_write(iu->irc, ":%s!%s@%s AWAY :%s (%s)", iu->nick, iu->user, iu->host, msg1, msg2); + } else { + irc_write(iu->irc, ":%s!%s@%s AWAY :%s", iu->nick, iu->user, iu->host, msg1); + } + } else { + irc_write(iu->irc, ":%s!%s@%s AWAY", iu->nick, iu->user, iu->host); + } +} + |