static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, guint32 flags, time_t sent_at) { irc_t *irc = bee->ui_data; irc_user_t *iu = (irc_user_t *) bu->ui_data; irc_user_t *src_iu = iu; irc_user_t *dst_iu = irc->user; const char *dst; char *prefix = NULL; char *wrapped, *ts = NULL; char *msg = g_strdup(msg_); char *message_type = "PRIVMSG"; GSList *l; if (sent_at > 0 && set_getbool(&irc->b->set, "display_timestamps")) { ts = irc_format_timestamp(irc, sent_at); } dst = irc_user_msgdest(iu); if (flags & OPT_SELFMESSAGE) { char *setting = set_getstr(&irc->b->set, "self_messages"); if (is_bool(setting)) { if (bool2int(setting)) { /* set to true, send it with src/dst flipped */ dst_iu = iu; src_iu = irc->user; if (dst == irc->user->nick) { dst = dst_iu->nick; } } else { /* set to false, skip the message completely */ goto cleanup; } } else if (g_strncasecmp(setting, "prefix", 6) == 0) { /* third state, prefix, loosely imitates the znc privmsg_prefix module */ g_free(msg); if (g_strncasecmp(msg_, "/me ", 4) == 0) { msg = g_strdup_printf("/me -> %s", msg_ + 4); } else { msg = g_strdup_printf("-> %s", msg_); } if (g_strcasecmp(setting, "prefix_notice") == 0) { message_type = "NOTICE"; } } } if (dst != dst_iu->nick) { /* if not messaging directly (control channel), call user by name */ prefix = g_strdup_printf("%s%s%s", dst_iu->nick, set_getstr(&bee->set, "to_char"), ts ? : ""); } else {
/* cmd = "PRIVMSG" or "NOTICE" */ static void irc_usermsg_(const char *cmd, irc_user_t *iu, const char *format, va_list params) { char text[2048]; const char *dst; g_vsnprintf(text, sizeof(text), format, params); dst = irc_user_msgdest(iu); irc_send_msg(iu, cmd, dst, text, NULL); }
static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at ) { irc_t *irc = bee->ui_data; irc_user_t *iu = (irc_user_t *) bu->ui_data; const char *dst; char *prefix = NULL; char *wrapped, *ts = NULL; char *msg = g_strdup( msg_ ); GSList *l; if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) ) ts = irc_format_timestamp( irc, sent_at ); dst = irc_user_msgdest( iu ); if( dst != irc->user->nick ) { /* if not messaging directly, call user by name */ prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" ); }