void irc_input_user_message_display (struct t_gui_buffer *buffer, int action, const char *text) { struct t_irc_nick *ptr_nick; char *pos, *text2, *text_decoded, str_tags[256], *str_color; const char *ptr_text; /* if message is an action, force "action" to 1 and extract message */ if (strncmp (text, "\01ACTION ", 8) == 0) { action = 1; pos = strrchr (text + 8, '\01'); if (pos) text2 = dogechat_strndup (text + 8, pos - text - 8); else text2 = strdup (text + 8); } else text2 = strdup (text); text_decoded = irc_color_decode ( (text2) ? text2 : text, dogechat_config_boolean (irc_config_network_colors_send)); IRC_BUFFER_GET_SERVER_CHANNEL(buffer); if (ptr_channel) { ptr_nick = NULL; if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) { ptr_nick = irc_nick_search (ptr_server, ptr_channel, ptr_server->nick); } if (action) { snprintf (str_tags, sizeof (str_tags), "irc_action,notify_none,no_highlight"); } else { str_color = irc_color_for_tags ( dogechat_config_color ( dogechat_config_get ("dogechat.color.chat_nick_self"))); snprintf (str_tags, sizeof (str_tags), "notify_none,no_highlight,prefix_nick_%s", (str_color) ? str_color : "default"); if (str_color) free (str_color); } ptr_text = (text_decoded) ? text_decoded : ((text2) ? text2 : text); if (action) { dogechat_printf_tags ( buffer, irc_protocol_tags ( "privmsg", str_tags, (ptr_nick) ? ptr_nick->name : ptr_server->nick, NULL), "%s%s%s%s%s %s", dogechat_prefix ("action"), irc_nick_mode_for_display (ptr_server, ptr_nick, 0), IRC_COLOR_CHAT_NICK_SELF, ptr_server->nick, IRC_COLOR_RESET, ptr_text); } else { dogechat_printf_tags ( buffer, irc_protocol_tags ( "privmsg", str_tags, (ptr_nick) ? ptr_nick->name : ptr_server->nick, NULL), "%s%s", irc_nick_as_prefix ( ptr_server, (ptr_nick) ? ptr_nick : NULL, (ptr_nick) ? NULL : ptr_server->nick, IRC_COLOR_CHAT_NICK_SELF), ptr_text); } } if (text2) free (text2); if (text_decoded) free (text_decoded); }
int irc_completion_channel_nicks_cb (const void *pointer, void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { struct t_irc_nick *ptr_nick; IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ (void) pointer; (void) data; (void) completion_item; if (ptr_channel) { switch (ptr_channel->type) { case IRC_CHANNEL_TYPE_CHANNEL: for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { weechat_hook_completion_list_add (completion, ptr_nick->name, 1, WEECHAT_LIST_POS_SORT); } /* add recent speakers on channel */ if (weechat_config_integer (irc_config_look_nick_completion_smart) == IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS) { irc_completion_channel_nicks_add_speakers (completion, ptr_server, ptr_channel, 0); } /* add nicks whose make highlights on me recently on this channel */ if (weechat_config_integer (irc_config_look_nick_completion_smart) == IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS_HIGHLIGHTS) { irc_completion_channel_nicks_add_speakers (completion, ptr_server, ptr_channel, 1); } /* add self nick at the end */ weechat_hook_completion_list_add (completion, ptr_server->nick, 1, WEECHAT_LIST_POS_END); break; case IRC_CHANNEL_TYPE_PRIVATE: /* remote nick */ weechat_hook_completion_list_add (completion, ptr_channel->name, 1, WEECHAT_LIST_POS_SORT); /* add self nick at the end */ weechat_hook_completion_list_add (completion, ptr_server->nick, 1, WEECHAT_LIST_POS_END); break; } ptr_channel->nick_completion_reset = 0; } return WEECHAT_RC_OK; }
int irc_completion_channels_cb (const void *pointer, void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { struct t_irc_server *ptr_server2; struct t_irc_channel *ptr_channel2; struct t_weelist *channels_current_server; int i; IRC_BUFFER_GET_SERVER_CHANNEL(buffer); /* make C compiler happy */ (void) pointer; (void) data; (void) completion_item; channels_current_server = weechat_list_new (); for (ptr_server2 = irc_servers; ptr_server2; ptr_server2 = ptr_server2->next_server) { for (ptr_channel2 = ptr_server2->channels; ptr_channel2; ptr_channel2 = ptr_channel2->next_channel) { if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL) { if (ptr_server2 == ptr_server) { /* will be added later to completions */ weechat_list_add (channels_current_server, ptr_channel2->name, WEECHAT_LIST_POS_SORT, NULL); } else { weechat_hook_completion_list_add (completion, ptr_channel2->name, 0, WEECHAT_LIST_POS_SORT); } } } } /* add channels of current server first in list */ for (i = weechat_list_size (channels_current_server) - 1; i >= 0; i--) { weechat_hook_completion_list_add ( completion, weechat_list_string ( weechat_list_get (channels_current_server, i)), 0, WEECHAT_LIST_POS_BEGINNING); } weechat_list_free (channels_current_server); /* add current channel first in list */ if (ptr_channel) { weechat_hook_completion_list_add (completion, ptr_channel->name, 0, WEECHAT_LIST_POS_BEGINNING); } return WEECHAT_RC_OK; }
int irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags, int force_user_message) { const char *ptr_data; char *data_with_colors, *msg; IRC_BUFFER_GET_SERVER_CHANNEL(buffer); if (buffer == irc_raw_buffer) { if (weechat_strcasecmp (input_data, "q") == 0) weechat_buffer_close (buffer); } else { /* * if send unknown commands is enabled and that input data is a * command, then send this command to IRC server */ if (!force_user_message && weechat_config_boolean (irc_config_network_send_unknown_commands) && !weechat_string_input_for_buffer (input_data)) { if (ptr_server) { irc_server_sendf (ptr_server, flags, NULL, "%s", weechat_utf8_next_char (input_data)); } return WEECHAT_RC_OK; } if (ptr_channel) { ptr_data = input_data; if (!force_user_message) { ptr_data = weechat_string_input_for_buffer (input_data); if (!ptr_data) ptr_data = input_data; } data_with_colors = irc_color_encode ( ptr_data, weechat_config_boolean (irc_config_network_colors_send)); msg = strdup ((data_with_colors) ? data_with_colors : ptr_data); if (msg) { irc_input_send_user_message (buffer, flags, NULL, msg); free (msg); } if (data_with_colors) free (data_with_colors); } else { weechat_printf (buffer, _("%s%s: this buffer is not a channel!"), weechat_prefix ("error"), IRC_PLUGIN_NAME); } } return WEECHAT_RC_OK; }