/* received msg to all ops in channel */ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target) { char *nickmode, *optarget, *prefix; const char *cleantarget; /* only skip here so the difference can be stored in prefix */ cleantarget = fe_channel_skip_prefix(IRC_SERVER(server), target); prefix = g_strndup(target, cleantarget - target); /* and clean the rest here */ cleantarget = get_visible_target(IRC_SERVER(server), cleantarget); nickmode = channel_get_nickmode(channel_find(server, cleantarget), nick); optarget = g_strconcat(prefix, cleantarget, NULL); printformat_module("fe-common/core", server, cleantarget, MSGLEVEL_PUBLIC, TXT_PUBMSG_CHANNEL, nick, optarget, msg, nickmode); g_free(nickmode); g_free(optarget); g_free(prefix); }
static void sig_message_own_public(SERVER_REC *server, const char *msg, const char *target, const char *origtarget) { const char *oldtarget; char *nickmode; if (!IS_IRC_SERVER(server)) return; oldtarget = target; target = fe_channel_skip_prefix(IRC_SERVER(server), target); if (target != oldtarget) { /* Hybrid 6 / Bahamut feature, send msg to all ops / ops+voices in channel */ nickmode = channel_get_nickmode(channel_find(server, target), server->nick); printformat_module("fe-common/core", server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, server->nick, oldtarget, msg, nickmode); g_free(nickmode); signal_stop(); } }
static void print_own_channel_message(SERVER_REC *server, CHANNEL_REC *channel, const char *target, const char *msg) { WINDOW_REC *window; const char *nickmode; char *freemsg = NULL; int print_channel; nickmode = channel_get_nickmode(channel, server->nick); window = channel == NULL ? NULL : window_item_window((WI_ITEM_REC *) channel); print_channel = window == NULL || window->active != (WI_ITEM_REC *) channel; if (!print_channel && settings_get_bool("print_active_channel") && window != NULL && g_slist_length(window->items) > 1) print_channel = TRUE; if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg); if (!print_channel) { printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG, server->nick, msg, nickmode); } else { printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode); } g_free_not_null(freemsg); }
static void sig_history(SERVER_REC *server, const char *msg, const char *nick, const char *target, const char *stamp, gpointer gpointer_type) { void *item; char *text, *freemsg = NULL; int level, type; g_return_if_fail(server != NULL); g_return_if_fail(msg != NULL); g_return_if_fail(nick != NULL); g_return_if_fail(target != NULL); type = GPOINTER_TO_INT(gpointer_type); level = MSGLEVEL_NO_ACT | MSGLEVEL_NOHILIGHT | (type == SEND_TARGET_CHANNEL ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); item = type == SEND_TARGET_CHANNEL ? (void *)channel_find(server, target) : query_find(server, nick); if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis(item, msg); /* MUC */ if (type == SEND_TARGET_CHANNEL) { CHANNEL_REC *chanrec = item; int print_channel; char *nickmode; print_channel = chanrec == NULL || !window_item_is_active((WI_ITEM_REC *)chanrec); if (!print_channel && settings_get_bool("print_active_channel") && window_item_window((WI_ITEM_REC *)chanrec)->items->next != NULL) print_channel = TRUE; nickmode = channel_get_nickmode(chanrec, nick); text = !print_channel ? format_get_text(CORE_MODULE_NAME, NULL, server, target, TXT_PUBMSG, nick, msg, nickmode) : format_get_text(CORE_MODULE_NAME, NULL, server, target, TXT_PUBMSG_CHANNEL, nick, target, msg, nickmode); g_free(nickmode); /* General */ } else text = format_get_text(CORE_MODULE_NAME, NULL, server, target, item == NULL ? TXT_MSG_PRIVATE : TXT_MSG_PRIVATE_QUERY, nick, nick, msg); printformat_module(MODULE_NAME, server, target, level, XMPPTXT_MESSAGE_TIMESTAMP, stamp, text); g_free_not_null(freemsg); g_free(text); }
static void sig_message_own_wall(SERVER_REC *server, const char *msg, const char *target) { char *nickmode, *optarget; nickmode = channel_get_nickmode(channel_find(server, target), server->nick); optarget = g_strconcat("@", target, NULL); printformat_module("fe-common/core", server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, server->nick, optarget, msg, nickmode); g_free(optarget); }
/* received msg to all ops in channel */ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg, const char *nick, const char *address, const char *target) { char *nickmode, *optarget; nickmode = channel_get_nickmode(channel_find(server, target), server->nick); optarget = g_strconcat("@", target, NULL); printformat_module("fe-common/core", server, target, MSGLEVEL_PUBLIC, TXT_PUBMSG_CHANNEL, nick, optarget, msg, nickmode); g_free(optarget); }
static void sig_message_own_public(SERVER_REC *server, char *msg, char *target) { WINDOW_REC *window; CHANNEL_REC *channel; char *nick, *nickmode, *freemsg = NULL, *recoded; gboolean print_channel; g_return_if_fail(server != NULL); g_return_if_fail(msg != NULL); g_return_if_fail(target != NULL); if (!IS_XMPP_SERVER(server)) return; channel = channel_find(server, target); if (channel == NULL || channel->ownnick == NULL) return; nick = channel->ownnick->nick; nickmode = channel_get_nickmode(CHANNEL(channel), nick); window = (channel == NULL) ? NULL : window_item_window((WI_ITEM_REC *)channel); print_channel = (window == NULL || window->active != (WI_ITEM_REC *) channel); if (!print_channel && settings_get_bool("print_active_channel") && window != NULL && g_slist_length(window->items) > 1) print_channel = TRUE; if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis((WI_ITEM_REC *)channel, msg); /* ugly from irssi: recode the sent message back for printing */ recoded = recode_in(SERVER(server), msg, target); if (!print_channel) printformat_module(CORE_MODULE_NAME, server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG, nick, recoded, nickmode); else printformat_module(CORE_MODULE_NAME, server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, nick, target, recoded, nickmode); g_free(recoded); g_free(nickmode); g_free_not_null(freemsg); signal_stop(); /* emit signal for chat-completion */ }
static void sig_message_own_public(SERVER_REC *server, const char *msg, const char *target, const char *origtarget) { char *nickmode; if (IS_IRC_SERVER(server) && target != NULL && *target == '@' && ischannel(target[1])) { /* Hybrid 6 feature, send msg to all ops in channel */ nickmode = channel_get_nickmode(channel_find(server, target+1), server->nick); printformat_module("fe-common/core", server, target+1, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode); signal_stop(); } }
/* * Print a message using the public message format (to channel) * Can be from others or ourselves */ void print_message_public(SERVER_REC* server_rec, CHANNEL_REC* channel_rec, char* target, char* nick, char* address, char* msg) { // See fe-common/core/fe-messages.c, sig_message_public() // and fe-common/irc/fe-irc-messages.c, sig_message_irc_op_public() // for the below. char* nickmode = channel_get_nickmode(channel_rec, nick); // Check if hilight by someone referring to me int for_me = nick_match_msg(channel_rec, msg, server_rec->nick); // Also can hilight based on address? int hilight; if (address != NULL) { hilight = for_me || hilight_match_nick(server_rec, target, nick, address, MSGLEVEL_PUBLIC, msg); } else { hilight = for_me; } // If channel is active, we don't need to use the format which includes // channel name, such as <@nick:#channel> int should_print_channel = channel_rec == NULL || !window_item_is_active((WI_ITEM_REC*) channel_rec); // Check if it was us that said this int from_me = strcmp(nick, server_rec->nick) == 0; // Fix up the message level int msg_level = MSGLEVEL_PUBLIC; // We don't want to hilight ourselves if (!from_me && hilight) { msg_level |= MSGLEVEL_HILIGHT; } if (should_print_channel) { if (from_me) { printformat_module("fe-common/core", server_rec, target, msg_level, TXT_OWN_MSG_CHANNEL, nick, target, msg, nickmode); } else { printformat_module("fe-common/core", server_rec, target, msg_level, hilight ? TXT_PUBMSG_ME_CHANNEL : TXT_PUBMSG_CHANNEL, nick, target, msg, nickmode); } } else { if (from_me) { printformat_module("fe-common/core", server_rec, target, msg_level, TXT_OWN_MSG, nick, msg, nickmode); } else { printformat_module("fe-common/core", server_rec, target, msg_level, hilight ? TXT_PUBMSG_ME : TXT_PUBMSG, nick, msg, nickmode); } } g_free_not_null(nickmode); }