Changes in / [921ea8b:3b0c1c3]
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r921ea8b r3b0c1c3 76 76 CAP_AWAY_NOTIFY = (1 << 3), 77 77 CAP_USERHOST_IN_NAMES = (1 << 4), 78 CAP_SERVER_TIME = (1 << 5), 78 79 } irc_cap_flag_t; 79 80 … … 352 353 void irc_send_away_notify(irc_user_t *iu); 353 354 355 G_GNUC_INTERNAL void irc_send_msg_ts(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, time_t ts); 356 G_GNUC_INTERNAL void irc_send_msg_raw_tags(irc_user_t *iu, const char *type, const char *dst, const char* tags, const char *msg); 357 354 358 /* irc_user.c */ 355 359 irc_user_t *irc_user_new(irc_t *irc, const char *nick); … … 364 368 char *set_eval_timezone(struct set *set, char *value); 365 369 char *irc_format_timestamp(irc_t *irc, time_t msg_ts); 370 G_GNUC_INTERNAL char *irc_format_servertime(irc_t *irc, time_t msg_ts); 366 371 char *set_eval_self_messages(struct set *set, char *value); 367 372 -
irc_cap.c
r921ea8b r3b0c1c3 43 43 {"away-notify", CAP_AWAY_NOTIFY}, 44 44 {"userhost-in-names", CAP_USERHOST_IN_NAMES}, 45 {"server-time", CAP_SERVER_TIME}, 45 46 {NULL}, 46 47 }; -
irc_im.c
r921ea8b r3b0c1c3 232 232 GSList *l; 233 233 234 if (sent_at > 0 && set_getbool(&irc->b->set, "display_timestamps")) { 234 if (sent_at > 0 && 235 !(irc->caps & CAP_SERVER_TIME) && 236 set_getbool(&irc->b->set, "display_timestamps")) { 235 237 ts = irc_format_timestamp(irc, sent_at); 236 238 } … … 305 307 306 308 wrapped = word_wrap(msg, IRC_WORD_WRAP); 307 irc_send_msg (src_iu, message_type, dst, wrapped, prefix);309 irc_send_msg_ts(src_iu, message_type, dst, wrapped, prefix, sent_at); 308 310 g_free(wrapped); 309 311 … … 702 704 } 703 705 704 if (sent_at > 0 && set_getbool(&bee->set, "display_timestamps")) { 706 if (sent_at > 0 && 707 !(irc->caps & CAP_SERVER_TIME) && 708 set_getbool(&bee->set, "display_timestamps")) { 705 709 ts = irc_format_timestamp(irc, sent_at); 706 710 } 707 711 708 712 wrapped = word_wrap(msg, IRC_WORD_WRAP); 709 irc_send_msg (iu, "PRIVMSG", ic->name, wrapped, ts);713 irc_send_msg_ts(iu, "PRIVMSG", ic->name, wrapped, ts, sent_at); 710 714 g_free(ts); 711 715 g_free(wrapped); -
irc_send.c
r921ea8b r3b0c1c3 365 365 void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix) 366 366 { 367 irc_send_msg_ts(iu, type, dst, msg, prefix, 0); 368 } 369 370 void irc_send_msg_ts(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, time_t ts) 371 { 367 372 char last = 0; 368 373 const char *s = msg, *line = msg; 374 char *tags = NULL; 369 375 char raw_msg[strlen(msg) + 1024]; 376 377 if (!(iu->irc->caps & CAP_SERVER_TIME)) { 378 ts = 0; 379 } 370 380 371 381 while (!last) { … … 379 389 } 380 390 if (*s == 0 || *s == '\n') { 391 if (ts) { 392 tags = irc_format_servertime(iu->irc, ts); 393 } 381 394 if (g_strncasecmp(line, "/me ", 4) == 0 && (!prefix || !*prefix) && 382 395 g_strcasecmp(type, "PRIVMSG") == 0) { … … 384 397 strncat(raw_msg, line + 4, s - line - 4); 385 398 strcat(raw_msg, "\001"); 386 irc_send_msg_raw (iu, type, dst, raw_msg);399 irc_send_msg_raw_tags(iu, type, dst, tags, raw_msg); 387 400 } else { 388 401 *raw_msg = '\0'; … … 391 404 } 392 405 strncat(raw_msg, line, s - line); 393 irc_send_msg_raw(iu, type, dst, raw_msg); 406 irc_send_msg_raw_tags(iu, type, dst, tags, raw_msg); 407 } 408 if (ts) { 409 g_free(tags); 394 410 } 395 411 line = s + 1; … … 401 417 void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg) 402 418 { 403 irc_write(iu->irc, ":%s!%s@%s %s %s :%s", 404 iu->nick, iu->user, iu->host, type, dst, msg && *msg ? msg : " "); 419 irc_send_msg_raw_tags(iu, type, dst, NULL, msg); 420 } 421 422 void irc_send_msg_raw_tags(irc_user_t *iu, const char *type, const char *dst, const char* tags, const char *msg) 423 { 424 irc_write(iu->irc, "%s%s:%s!%s@%s %s %s :%s", 425 tags ? tags : "", tags ? " " : "", iu->nick, iu->user, iu->host, type, dst, msg && *msg ? msg : " "); 405 426 } 406 427 -
irc_util.c
r921ea8b r3b0c1c3 120 120 } 121 121 122 char *irc_format_servertime(irc_t *irc, time_t msg_ts) 123 { 124 struct tm msg; 125 126 if (msg_ts <= 0) { 127 return NULL; 128 } 129 130 gmtime_r(&msg_ts, &msg); 131 132 return g_strdup_printf("@time=%04d-%02d-%02dT" 133 "%02d:%02d:%02d.000Z", 134 msg.tm_year + 1900, msg.tm_mon + 1, msg.tm_mday, 135 msg.tm_hour, msg.tm_min, msg.tm_sec); 136 } 122 137 123 138 char *set_eval_self_messages(set_t *set, char *value)
Note: See TracChangeset
for help on using the changeset viewer.