Changeset 80c2f3c


Ignore:
Timestamp:
2015-11-20T15:51:45Z (8 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
8fdeaa5
Parents:
0d8a9bb0
git-author:
dequis <dx@…> (20-11-15 15:33:34)
git-committer:
dequis <dx@…> (20-11-15 15:51:45)
Message:

IRCv3 away-notify capability

Neat lightweight notifications of the awayness of contacts.

In practice, this means weechat/hexchat users can see away people in
their nick list and change show_users to 'online,special,away' to avoid
the mode spam completely.

These are also sent on online/offline changes, since offline_user_quits
can be turned off, and you'd need something when they come back.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    r0d8a9bb0 r80c2f3c  
    7171        CAP_MULTI_PREFIX = (1 << 1),
    7272        CAP_EXTENDED_JOIN = (1 << 2),
     73        CAP_AWAY_NOTIFY = (1 << 3),
    7374} irc_cap_flag_t;
    7475
     
    342343void irc_send_invite(irc_user_t *iu, irc_channel_t *ic);
    343344void irc_send_cap(irc_t *irc, char *subcommand, char *body);
     345void irc_send_away_notify(irc_user_t *iu);
    344346
    345347/* irc_user.c */
  • irc_cap.c

    r0d8a9bb0 r80c2f3c  
    4141        {"multi-prefix", CAP_MULTI_PREFIX},
    4242        {"extended-join", CAP_EXTENDED_JOIN},
     43        {"away-notify", CAP_AWAY_NOTIFY},
    4344        {NULL},
    4445};
  • irc_im.c

    r0d8a9bb0 r80c2f3c  
    118118        if (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) {
    119119                iu->flags |= IRC_USER_AWAY;
     120        }
     121
     122        if ((irc->caps & CAP_AWAY_NOTIFY) &&
     123            ((bu->flags & BEE_USER_AWAY) != (old->flags & BEE_USER_AWAY) ||
     124             (bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE))) {
     125                irc_send_away_notify(iu);
    120126        }
    121127
  • irc_send.c

    r0d8a9bb0 r80c2f3c  
    470470        irc_write(irc, ":%s CAP %s %s :%s", irc->root->host, nick, subcommand, body);
    471471}
     472
     473void irc_send_away_notify(irc_user_t *iu)
     474{
     475        bee_user_t *bu = iu->bu;
     476
     477        if (!bu) {
     478                return;
     479        }
     480
     481        if (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) {
     482                char *msg1, *msg2;
     483
     484                get_status_message(bu, &msg1, &msg2);
     485
     486                if (msg2) {
     487                        irc_write(iu->irc, ":%s!%s@%s AWAY :%s (%s)", iu->nick, iu->user, iu->host, msg1, msg2);
     488                } else {
     489                        irc_write(iu->irc, ":%s!%s@%s AWAY :%s", iu->nick, iu->user, iu->host, msg1);
     490                }
     491        } else {
     492                irc_write(iu->irc, ":%s!%s@%s AWAY", iu->nick, iu->user, iu->host);
     493        }
     494}
     495
Note: See TracChangeset for help on using the changeset viewer.