Changeset f7cc734 for irc_send.c


Ignore:
Timestamp:
2018-07-31T04:41:25Z (6 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
9767d03
Parents:
c82e4ca
git-author:
Philippe Daouadi <philippe@…> (15-03-17 17:06:52)
git-committer:
dequis <dx@…> (31-07-18 04:41:25)
Message:

irc: implement server-time capability

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_send.c

    rc82e4ca rf7cc734  
    136136
    137137        dst = irc_user_msgdest(iu);
    138         irc_send_msg(iu, cmd, dst, text, NULL);
     138        irc_send_msg(iu, cmd, dst, text, NULL, 0);
    139139}
    140140
     
    363363}
    364364
    365 void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix)
     365void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, time_t ts)
    366366{
    367367        char last = 0;
    368368        const char *s = msg, *line = msg;
     369        char *tags = NULL;
    369370        char raw_msg[strlen(msg) + 1024];
     371
     372        if (!(iu->irc->caps & CAP_SERVER_TIME)) {
     373                ts = 0;
     374        }
    370375
    371376        while (!last) {
     
    379384                }
    380385                if (*s == 0 || *s == '\n') {
     386                        if (ts)
     387                                tags = irc_format_servertime(iu->irc, ts);
    381388                        if (g_strncasecmp(line, "/me ", 4) == 0 && (!prefix || !*prefix) &&
    382389                            g_strcasecmp(type, "PRIVMSG") == 0) {
     
    384391                                strncat(raw_msg, line + 4, s - line - 4);
    385392                                strcat(raw_msg, "\001");
    386                                 irc_send_msg_raw(iu, type, dst, raw_msg);
     393                                irc_send_msg_raw(iu, type, dst, tags, raw_msg);
    387394                        } else {
    388395                                *raw_msg = '\0';
     
    391398                                }
    392399                                strncat(raw_msg, line, s - line);
    393                                 irc_send_msg_raw(iu, type, dst, raw_msg);
     400                                irc_send_msg_raw(iu, type, dst, tags, raw_msg);
    394401                        }
     402                        if (ts)
     403                                g_free(tags);
    395404                        line = s + 1;
    396405                }
     
    399408}
    400409
    401 void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg)
    402 {
    403         irc_write(iu->irc, ":%s!%s@%s %s %s :%s",
    404                   iu->nick, iu->user, iu->host, type, dst, msg && *msg ? msg : " ");
     410void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char* tags, const char *msg)
     411{
     412        irc_write(iu->irc, "%s%s:%s!%s@%s %s %s :%s",
     413                  tags ? tags : "", tags ? " " : "", iu->nick, iu->user, iu->host, type, dst, msg && *msg ? msg : " ");
    405414}
    406415
Note: See TracChangeset for help on using the changeset viewer.