aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.h2
-rw-r--r--irc_cap.c1
-rw-r--r--irc_im.c6
-rw-r--r--irc_send.c24
4 files changed, 33 insertions, 0 deletions
diff --git a/irc.h b/irc.h
index b39c306c..9374473c 100644
--- a/irc.h
+++ b/irc.h
@@ -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);
diff --git a/irc_cap.c b/irc_cap.c
index 4d1c2caa..76935d26 100644
--- a/irc_cap.c
+++ b/irc_cap.c
@@ -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},
};
diff --git a/irc_im.c b/irc_im.c
index a66b72a2..587821c5 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -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)) {
diff --git a/irc_send.c b/irc_send.c
index 86975605..af432d4d 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -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);
+ }
+}
+