mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
Reintroduce option "irc.network.send_unknown_commands", save extra data for buffers with /upgrade (title, input data, text search)
This commit is contained in:
@@ -105,6 +105,9 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
|
||||
weechat_hook_signal_send ("logger_backlog",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||
|
||||
if (weechat_config_boolean (irc_config_network_send_unknown_commands))
|
||||
weechat_buffer_set (new_buffer, "input_get_unknown_commands", "1");
|
||||
}
|
||||
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
|
||||
@@ -238,6 +238,63 @@ irc_config_change_network_away_check (void *data,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_network_send_unknown_commands: called when "send_unknown_commands"
|
||||
* is changed
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_network_send_unknown_commands (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
char value[2];
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
strcpy (value,
|
||||
(weechat_config_boolean (irc_config_network_send_unknown_commands)) ?
|
||||
"1" : "0");
|
||||
|
||||
if (weechat_config_boolean (irc_config_look_one_server_buffer))
|
||||
{
|
||||
if (irc_buffer_servers)
|
||||
{
|
||||
weechat_buffer_set (irc_buffer_servers,
|
||||
"input_get_unknown_commands", value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->buffer)
|
||||
{
|
||||
weechat_buffer_set (ptr_server->buffer,
|
||||
"input_get_unknown_commands", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->buffer)
|
||||
{
|
||||
weechat_buffer_set (ptr_channel->buffer,
|
||||
"input_get_unknown_commands", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_server_default_change_cb: callback called when a default server
|
||||
* option is modified
|
||||
@@ -1129,7 +1186,8 @@ irc_config_init ()
|
||||
irc_config_file, ptr_section,
|
||||
"send_unknown_commands", "boolean",
|
||||
N_("send unknown commands to IRC server"),
|
||||
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, 0, 0, "off", NULL, NULL, NULL,
|
||||
&irc_config_change_network_send_unknown_commands, NULL, NULL, NULL);
|
||||
|
||||
/* filters */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ignore",
|
||||
|
||||
@@ -143,6 +143,7 @@ int
|
||||
irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
const char *input_data)
|
||||
{
|
||||
const char *ptr_data;
|
||||
char *data_with_colors, *msg;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -150,12 +151,24 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
IRC_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
/* if send unknown commands is enabled and that input data is a command,
|
||||
then send this command to IRC server */
|
||||
if (weechat_config_boolean (irc_config_network_send_unknown_commands)
|
||||
&& (input_data[0] == '/') && (input_data[1] != '/'))
|
||||
{
|
||||
if (ptr_server)
|
||||
irc_server_sendf (ptr_server, input_data + 1);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
data_with_colors = irc_color_encode (input_data,
|
||||
ptr_data = ((input_data[0] == '/') && (input_data[1] == '/')) ?
|
||||
input_data + 1 : 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 : input_data);
|
||||
msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
|
||||
if (msg)
|
||||
{
|
||||
irc_input_send_user_message (buffer, msg);
|
||||
|
||||
Reference in New Issue
Block a user