summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/CMakeLists.txt1
-rw-r--r--src/plugins/irc/Makefile.am2
-rw-r--r--src/plugins/irc/irc-command.c178
-rw-r--r--src/plugins/irc/irc-config.c87
-rw-r--r--src/plugins/irc/irc-ignore.c286
-rw-r--r--src/plugins/irc/irc-ignore.h56
-rw-r--r--src/plugins/irc/irc-info.c38
-rw-r--r--src/plugins/irc/irc-protocol.c1865
-rw-r--r--src/plugins/irc/irc-protocol.h14
9 files changed, 1633 insertions, 894 deletions
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt
index 05eb00665..7ed63016c 100644
--- a/src/plugins/irc/CMakeLists.txt
+++ b/src/plugins/irc/CMakeLists.txt
@@ -24,6 +24,7 @@ irc-completion.c irc-completion.h
irc-config.c irc-config.h
irc-debug.c irc-debug.h
irc-display.c irc-display.h
+irc-ignore.c irc-ignore.h
irc-info.c irc-info.h
irc-input.c irc-input.h
irc-mode.c irc-mode.h
diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am
index 9adf6056b..f6ff77f85 100644
--- a/src/plugins/irc/Makefile.am
+++ b/src/plugins/irc/Makefile.am
@@ -38,6 +38,8 @@ irc_la_SOURCES = irc.c \
irc-debug.h \
irc-display.c \
irc-display.h \
+ irc-ignore.c \
+ irc-ignore.h \
irc-info.c \
irc-info.h \
irc-input.c \
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 3343ad18e..d89fb9d01 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -38,6 +38,7 @@
#include "irc-channel.h"
#include "irc-nick.h"
#include "irc-display.h"
+#include "irc-ignore.h"
/*
@@ -1286,6 +1287,159 @@ irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc,
}
/*
+ * irc_command_ignore: add or remove ignore
+ */
+
+int
+irc_command_ignore (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
+{
+ int i;
+ struct t_irc_ignore *ptr_ignore;
+ char *mask, *server, *channel, *error;
+ long number;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) buffer;
+ (void) argv_eol;
+
+ if ((argc == 1)
+ || ((argc == 2) && (weechat_strcasecmp (argv[1], "list") == 0)))
+ {
+ /* display all key bindings */
+ if (irc_ignore_list)
+ {
+ weechat_printf (NULL, "");
+ weechat_printf (NULL, _("%s: ignore list:"), "irc");
+ i = 0;
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ i++;
+ weechat_printf (NULL,
+ _(" %s[%s%d%s]%s mask: %s / server: %s / channel: %s"),
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ i,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ ptr_ignore->mask,
+ (ptr_ignore->server) ?
+ ptr_ignore->server : "*",
+ (ptr_ignore->channel) ?
+ ptr_ignore->channel : "*");
+ }
+ }
+ else
+ weechat_printf (NULL, _("%s: no ignore in list"), "irc");
+
+ return WEECHAT_RC_OK;
+ }
+
+ /* add ignore */
+ if (weechat_strcasecmp (argv[1], "add") == 0)
+ {
+ if (argc < 3)
+ {
+ weechat_printf (NULL,
+ _("%s%s: missing arguments for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc",
+ "ignore add");
+ return WEECHAT_RC_ERROR;
+ }
+
+ mask = argv[2];
+ server = (argc > 3) ? argv[3] : NULL;
+ channel = (argc > 4) ? argv[4] : NULL;
+
+ if (irc_ignore_search (mask, server, channel))
+ {
+ weechat_printf (NULL,
+ _("%s%s: ignore already exists"),
+ weechat_prefix ("error"), "irc");
+ return WEECHAT_RC_ERROR;
+ }
+
+ if (irc_ignore_new (mask, server, channel))
+ {
+ weechat_printf (NULL, _("%s: ignore added"), "irc");
+ }
+ else
+ {
+ weechat_printf (NULL, _("%s%s: error adding ignore"),
+ weechat_prefix ("error"), "irc");
+ }
+
+ return WEECHAT_RC_OK;
+ }
+
+ /* delete ignore */
+ if (weechat_strcasecmp (argv[1], "del") == 0)
+ {
+ if (argc < 3)
+ {
+ weechat_printf (NULL,
+ _("%s%s: missing arguments for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc",
+ "ignore del");
+ return WEECHAT_RC_ERROR;
+ }
+
+ if (weechat_strcasecmp (argv[2], "-all") == 0)
+ {
+ if (irc_ignore_list)
+ {
+ irc_ignore_free_all ();
+ weechat_printf (NULL, _("%s: all ignore deleted"), "irc");
+ }
+ else
+ {
+ weechat_printf (NULL, _("%s: no ignore in list"), "irc");
+ }
+ }
+ else
+ {
+ error = NULL;
+ number = strtol (argv[2], &error, 10);
+ if (error && !error[0])
+ {
+ ptr_ignore = irc_ignore_search_by_number (number);
+ if (ptr_ignore)
+ {
+ irc_ignore_free (ptr_ignore);
+ weechat_printf (NULL, _("%s: ignore deleted"), "irc");
+ }
+ else
+ {
+ weechat_printf (NULL,
+ _("%s%s: ignore not found"),
+ weechat_prefix ("error"), "irc");
+ return WEECHAT_RC_ERROR;
+ }
+ }
+ else
+ {
+ weechat_printf (NULL,
+ _("%s%s: wrong ignore number"),
+ weechat_prefix ("error"), "irc");
+ return WEECHAT_RC_ERROR;
+ }
+ }
+
+ return WEECHAT_RC_OK;
+ }
+
+ weechat_printf (NULL,
+ _("%s%s: unknown option for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc", "ignore");
+ return WEECHAT_RC_ERROR;
+}
+
+/*
* irc_command_info: get information describing the server
*/
@@ -3602,6 +3756,30 @@ irc_command_init ()
N_("[nickname [nickname]]"),
"",
NULL, &irc_command_halfop, NULL);
+ weechat_hook_command ("ignore",
+ N_("ignore nicks/hosts from servers or channels"),
+ N_("[list] | [add nick/host [server [channel]]] | "
+ "[del number|-all]"),
+ N_(" list: list all ignore\n"
+ " add: add a ignore\n"
+ " del: del a ignore\n"
+ " number: number of ignore to delete (look at "
+ "list to find it)\n"
+ " -all: delete all ignore\n"
+ "nick/host: nick or host to ignore (regular "
+ "expression allowed)\n"
+ " server: internal server name where ignore "
+ "is working\n"
+ " channel: channel name where ignore is "
+ "working\n\n"
+ "Examples:\n"
+ " ignore nick \"toto\" everywhere:\n"
+ " /ignore add toto\n"
+ " ignore host \"toto@domain.com\" on freenode server:\n"
+ " /ignore add toto@domain.com freenode\n"
+ " ignore host \"toto*@*.domain.com\" on freenode/#weechat:\n"
+ " /ignore add toto*@*.domain.com freenode #weechat"),
+ NULL, &irc_command_ignore, NULL);
weechat_hook_command ("info",
N_("get information describing the server"),
N_("[target]"),
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 24d05f9af..c627377b5 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -29,6 +29,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-config.h"
+#include "irc-ignore.h"
#include "irc-server.h"
@@ -444,6 +445,8 @@ irc_config_reload (void *data, struct t_config_file *config_file)
ptr_server->reloaded_from_config = 0;
}
+ irc_ignore_free_all ();
+
rc = weechat_config_reload (config_file);
if (rc == WEECHAT_CONFIG_READ_OK)
@@ -479,6 +482,72 @@ irc_config_reload (void *data, struct t_config_file *config_file)
}
/*
+ * irc_config_ignore_read: read ignore option from config file
+ * return 1 if ok, 0 if error
+ */
+
+int
+irc_config_ignore_read (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ const char *option_name, const char *value)
+{
+ char **argv, **argv_eol;
+ int argc;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) config_file;
+ (void) section;
+
+ if (option_name)
+ {
+ if (value && value[0])
+ {
+ argv = weechat_string_explode (value, ";", 0, 0, &argc);
+ argv_eol = weechat_string_explode (value, ";", 1, 0, NULL);
+ if (argv && argv_eol && (argc >= 3))
+ {
+ irc_ignore_new (argv_eol[2], argv[0], argv[1]);
+ }
+ if (argv)
+ weechat_string_free_exploded (argv);
+ if (argv_eol)
+ weechat_string_free_exploded (argv_eol);
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * irc_config_ignore_write: write ignore section in configuration file
+ */
+
+void
+irc_config_ignore_write (void *data, struct t_config_file *config_file,
+ const char *section_name)
+{
+ struct t_irc_ignore *ptr_ignore;
+
+ /* make C compiler happy */
+ (void) data;
+
+ weechat_config_write_line (config_file, section_name, NULL);
+
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ weechat_config_write_line (config_file,
+ "ignore",
+ "%s;%s;%s",
+ (ptr_ignore->server) ? ptr_ignore->server : "*",
+ (ptr_ignore->channel) ? ptr_ignore->channel : "*",
+ ptr_ignore->mask);
+ }
+}
+
+/*
* irc_config_server_write_default: write default server section in configuration file
*/
@@ -847,6 +916,7 @@ irc_config_init ()
if (!irc_config_file)
return 0;
+ /* look */
ptr_section = weechat_config_new_section (irc_config_file, "look",
0, 0,
NULL, NULL, NULL, NULL,
@@ -905,6 +975,7 @@ irc_config_init ()
N_("display notices as private messages"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
+ /* network */
ptr_section = weechat_config_new_section (irc_config_file, "network",
0, 0,
NULL, NULL, NULL, NULL,
@@ -980,6 +1051,7 @@ irc_config_init ()
N_("send unknown commands to IRC server"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
+ /* log */
ptr_section = weechat_config_new_section (irc_config_file, "log",
0, 0,
NULL, NULL, NULL, NULL,
@@ -1010,7 +1082,21 @@ irc_config_init ()
"hide_nickserv_pwd", "boolean",
N_("hide password displayed by nickserv"),
NULL, 0, 0, "on", NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
+
+ /* filters */
+ ptr_section = weechat_config_new_section (irc_config_file, "ignore",
+ 0, 0,
+ &irc_config_ignore_read, NULL,
+ &irc_config_ignore_write, NULL,
+ &irc_config_ignore_write, NULL,
+ NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (irc_config_file);
+ return 0;
+ }
+ /* server_default */
ptr_section = weechat_config_new_section (irc_config_file, "server_default",
0, 0,
NULL, NULL, NULL, NULL,
@@ -1025,6 +1111,7 @@ irc_config_init ()
irc_config_server_create_default_options (ptr_section);
+ /* server */
ptr_section = weechat_config_new_section (irc_config_file, "server",
1, 1,
NULL, NULL,
diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c
new file mode 100644
index 000000000..22d827436
--- /dev/null
+++ b/src/plugins/irc/irc-ignore.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* irc-ignore.c: manages ignore list (nicks/hosts) on IRC servers/channels */
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "../weechat-plugin.h"
+#include "irc.h"
+#include "irc-ignore.h"
+#include "irc-channel.h"
+#include "irc-server.h"
+
+
+struct t_irc_ignore *irc_ignore_list = NULL; /* list of ignore */
+struct t_irc_ignore *last_irc_ignore = NULL; /* last ignore in list */
+
+
+/*
+ * irc_ignore_valid: check if a ignore pointer exists
+ * return 1 if ignore exists
+ * 0 if ignore is not found
+ */
+
+int
+irc_ignore_valid (struct t_irc_ignore *ignore)
+{
+ struct t_irc_ignore *ptr_ignore;
+
+ if (!ignore)
+ return 0;
+
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ if (ptr_ignore == ignore)
+ return 1;
+ }
+
+ /* ignore not found */
+ return 0;
+}
+
+/*
+ * irc_ignore_search: search a ignore
+ */
+
+struct t_irc_ignore *
+irc_ignore_search (const char *mask, const char *server, const char *channel)
+{
+ struct t_irc_ignore *ptr_ignore;
+ char any[2] = "*";
+
+ if (!server)
+ server = any;
+ if (!channel)
+ channel = any;
+
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ if ((strcmp (ptr_ignore->mask, mask) == 0)
+ && (weechat_strcasecmp (ptr_ignore->server, server) == 0)
+ && (weechat_strcasecmp (ptr_ignore->channel, channel) == 0))
+ {
+ return ptr_ignore;
+ }
+ }
+
+ /* ignore not found */
+ return NULL;
+}
+
+/*
+ * irc_ignore_search_by_number: search a ignore by number (first is #1)
+ */
+
+struct t_irc_ignore *
+irc_ignore_search_by_number (int number)
+{
+ struct t_irc_ignore *ptr_ignore;
+ int i;
+
+ i = 1;
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ if (i == number)
+ return ptr_ignore;
+ i++;
+ }
+
+ /* ignore not found */
+ return NULL;
+}
+
+/*
+ * irc_ignore_new: add new ignore
+ */
+
+struct t_irc_ignore *
+irc_ignore_new (const char *mask, const char *server, const char *channel)
+{
+ struct t_irc_ignore *new_ignore;
+ regex_t *regex;
+
+ if (!mask)
+ return NULL;
+
+ regex = malloc (sizeof (*regex));
+ if (!regex)
+ return NULL;
+
+ if (regcomp (regex, mask, REG_NOSUB | REG_ICASE) != 0)
+ {
+ free (regex);
+ return NULL;
+ }
+
+ new_ignore = malloc (sizeof (*new_ignore));
+ if (new_ignore)
+ {
+ new_ignore->mask = strdup (mask);
+ new_ignore->regex_mask = regex;
+ new_ignore->server = (server) ? strdup (server) : strdup ("*");
+ new_ignore->channel = (channel) ? strdup (channel) : strdup ("*");
+
+ /* add ignore to ignore list */
+ new_ignore->prev_ignore = last_irc_ignore;
+ if (irc_ignore_list)
+ last_irc_ignore->next_ignore = new_ignore;
+ else
+ irc_ignore_list = new_ignore;
+ last_irc_ignore = new_ignore;
+ new_ignore->next_ignore = NULL;
+ }
+
+ return new_ignore;
+}
+
+/*
+ * irc_ignore_check: check if a message (from an IRC server) should be ignored
+ * or not
+ * return: 1 if message will be ignored
+ * 0 if message will be displayed (NOT ignored)
+ */
+
+int
+irc_ignore_check (struct t_irc_server *server, struct t_irc_channel *channel,
+ char *nick, char *host)
+{
+ struct t_irc_ignore *ptr_ignore;
+ int server_match, channel_match, regex_match;
+
+ if (!server)
+ return 0;
+
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ server_match = 0;
+ channel_match = 0;
+ regex_match = 0;
+
+ if (!server || (strcmp (ptr_ignore->server, "*") == 0))
+ server_match = 1;
+ else
+ server_match = (weechat_strcasecmp (ptr_ignore->server,
+ server->name) == 0);
+
+ if (!channel || (strcmp (ptr_ignore->channel, "*") == 0))
+ channel_match = 1;
+ else
+ {
+ channel_match = (weechat_strcasecmp (ptr_ignore->channel,
+ channel->name) == 0);
+ }
+
+ if (server_match && channel_match)
+ {
+ if (nick && (strcmp (ptr_ignore->mask, nick) == 0))
+ return 1;
+ if (host && regexec (ptr_ignore->regex_mask, host, 0, NULL, 0) == 0)
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * irc_ignore_free: remove a ignore
+ */
+
+void
+irc_ignore_free (struct t_irc_ignore *ignore)
+{
+ weechat_hook_signal_send ("irc_ignore_removing",
+ WEECHAT_HOOK_SIGNAL_POINTER, ignore);
+
+ /* free data */
+ if (ignore->mask)
+ free (ignore->mask);
+ if (ignore->regex_mask)
+ {
+ regfree (ignore->regex_mask);
+ free (ignore->regex_mask);
+ }
+ if (ignore->server)
+ free (ignore->server);
+ if (ignore->channel)
+ free (ignore->channel);
+
+ /* remove filter from filters list */
+ if (ignore->prev_ignore)
+ ignore->prev_ignore->next_ignore = ignore->next_ignore;
+ if (ignore->next_ignore)
+ ignore->next_ignore->prev_ignore = ignore->prev_ignore;
+ if (irc_ignore_list == ignore)
+ irc_ignore_list = ignore->next_ignore;
+ if (last_irc_ignore == ignore)
+ last_irc_ignore = ignore->prev_ignore;
+
+ free (ignore);
+
+ weechat_hook_signal_send ("irc_ignore_removed",
+ WEECHAT_HOOK_SIGNAL_STRING, NULL);
+}
+
+/*
+ * irc_ignore_free_all: remove all ignore
+ */
+
+void
+irc_ignore_free_all ()
+{
+ while (irc_ignore_list)
+ {
+ irc_ignore_free (irc_ignore_list);
+ }
+}
+
+/*
+ * irc_ignore_add_to_infolist: add a ignore in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+irc_ignore_add_to_infolist (struct t_infolist *infolist,
+ struct t_irc_ignore *ignore)
+{
+ struct t_infolist_item *ptr_item;
+
+ if (!infolist || !ignore)
+ return 0;
+
+ ptr_item = weechat_infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!weechat_infolist_new_var_string (ptr_item, "mask", ignore->mask))
+ return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "server", ignore->server))
+ return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "channel", ignore->channel))
+ return 0;
+
+ return 1;
+}
diff --git a/src/plugins/irc/irc-ignore.h b/src/plugins/irc/irc-ignore.h
new file mode 100644
index 000000000..ba9ac7c55
--- /dev/null
+++ b/src/plugins/irc/irc-ignore.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_IRC_IGNORE_H
+#define __WEECHAT_IRC_IGNORE_H 1
+
+#include <regex.h>
+
+struct t_irc_server;
+struct t_irc_channel;
+
+struct t_irc_ignore
+{
+ char *mask; /* nick / host mask */
+ regex_t *regex_mask; /* regex for mask */
+ char *server; /* server name */
+ char *channel; /* channel name */
+ struct t_irc_ignore *prev_ignore; /* link to previous ignore */
+ struct t_irc_ignore *next_ignore; /* link to next ignore */
+};
+
+extern struct t_irc_ignore *irc_ignore_list;
+
+extern int irc_ignore_valid (struct t_irc_ignore *ignore);
+extern struct t_irc_ignore *irc_ignore_search (const char *mask,
+ const char *server,
+ const char *channel);
+extern struct t_irc_ignore *irc_ignore_search_by_number (int number);
+extern struct t_irc_ignore *irc_ignore_new (const char *mask,
+ const char *server,
+ const char *channel);
+extern int irc_ignore_check (struct t_irc_server *server,
+ struct t_irc_channel *channel,
+ char *nick, char *host);
+extern void irc_ignore_free (struct t_irc_ignore *ignore);
+extern void irc_ignore_free_all ();
+extern int irc_ignore_add_to_infolist (struct t_infolist *infolist,
+ struct t_irc_ignore *ignore);
+
+#endif /* irc-ignore.h */
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index ec654a549..594d74e9e 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -26,6 +26,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-channel.h"
+#include "irc-ignore.h"
#include "irc-nick.h"
#include "irc-protocol.h"
#include "irc-server.h"
@@ -172,6 +173,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
+ struct t_irc_ignore *ptr_ignore;
char *pos_comma, *server_name;
/* make C compiler happy */
@@ -314,6 +316,40 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
}
}
}
+ else if (weechat_strcasecmp (infolist_name, "irc_ignore") == 0)
+ {
+ if (pointer && !irc_ignore_valid (pointer))
+ return NULL;
+
+ ptr_infolist = weechat_infolist_new ();
+ if (ptr_infolist)
+ {
+ if (pointer)
+ {
+ /* build list with only one ignore */
+ if (!irc_ignore_add_to_infolist (ptr_infolist, pointer))
+ {
+ weechat_infolist_free (ptr_infolist);
+ return NULL;
+ }
+ return ptr_infolist;
+ }
+ else
+ {
+ /* build list with all ignore */
+ for (ptr_ignore = irc_ignore_list; ptr_ignore;
+ ptr_ignore = ptr_ignore->next_ignore)
+ {
+ if (!irc_ignore_add_to_infolist (ptr_infolist, ptr_ignore))
+ {
+ weechat_infolist_free (ptr_infolist);
+ return NULL;
+ }
+ }
+ return ptr_infolist;
+ }
+ }
+ }
return NULL;
}
@@ -340,4 +376,6 @@ irc_info_init ()
&irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_nick", N_("list of nicks for an IRC channel"),
&irc_info_get_infolist_cb, NULL);
+ weechat_hook_infolist ("irc_ignore", N_("list of IRC ignore"),
+ &irc_info_get_infolist_cb, NULL);
}
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 4e9a6bfd2..8ab2494b4 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -41,6 +41,7 @@
#include "irc-channel.h"
#include "irc-nick.h"
#include "irc-mode.h"
+#include "irc-ignore.h"
/*
@@ -226,23 +227,26 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command,
:nick!user@host INVITE mynick :#channel
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_CHECK_HOST;
/* make C compiler happy */
(void) argv_eol;
- weechat_printf_tags (server->buffer,
- "irc_invite,notify_highlight",
- _("%sYou have been invited to %s%s%s by "
- "%s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- (argv[3][0] == ':') ? argv[3] + 1 : argv[3],
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]));
-
+ if (!irc_ignore_check (server, NULL, nick, host))
+ {
+ weechat_printf_tags (server->buffer,
+ "irc_invite,notify_highlight",
+ _("%sYou have been invited to %s%s%s by "
+ "%s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ (argv[3][0] == ':') ? argv[3] + 1 : argv[3],
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ }
return WEECHAT_RC_OK;
}
@@ -262,7 +266,8 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command,
/* JOIN message looks like:
:nick!user@host JOIN :#channel
*/
-
+
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
IRC_PROTOCOL_CHECK_HOST;
@@ -285,19 +290,22 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command,
}
}
- weechat_printf_tags (ptr_channel->buffer,
- "irc_join",
- _("%s%s%s %s(%s%s%s)%s has joined %s%s"),
- weechat_prefix ("join"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_HOST,
- irc_protocol_get_address_from_host (argv[0]),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- pos_channel);
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_join",
+ _("%s%s%s %s(%s%s%s)%s has joined %s%s"),
+ weechat_prefix ("join"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ address,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ pos_channel);
+ }
/* remove topic and display channel creation date if joining new channel */
if (!ptr_channel->nicks)
@@ -309,11 +317,9 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command,
}
/* add nick in channel */
- ptr_nick = irc_nick_new (server, ptr_channel,
- irc_protocol_get_nick_from_host (argv[0]),
- 0, 0, 0, 0, 0, 0, 0);
+ ptr_nick = irc_nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0, 0, 0);
if (ptr_nick)
- ptr_nick->host = strdup (irc_protocol_get_address_from_host (argv[0]));
+ ptr_nick->host = strdup (address);
return WEECHAT_RC_OK;
}
@@ -329,11 +335,12 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command,
char *pos_comment;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
-
+
/* KICK message looks like:
:nick1!user@host KICK #channel nick2 :kick reason
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_CHECK_HOST;
@@ -351,40 +358,43 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command,
return WEECHAT_RC_ERROR;
}
- if (pos_comment)
- {
- weechat_printf_tags (ptr_channel->buffer,
- "irc_kick",
- _("%s%s%s%s has kicked %s%s%s from %s%s "
- "%s(%s%s%s)"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- argv[3],
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- argv[2],
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- pos_comment,
- IRC_COLOR_CHAT_DELIMITERS);
- }
- else
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- weechat_printf_tags (ptr_channel->buffer,
- "irc_kick",
- _("%s%s%s%s has kicked %s%s%s from %s%s"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- argv[3],
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- argv[2]);
+ if (pos_comment)
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_kick",
+ _("%s%s%s%s has kicked %s%s%s from %s%s "
+ "%s(%s%s%s)"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ argv[3],
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ argv[2],
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ pos_comment,
+ IRC_COLOR_CHAT_DELIMITERS);
+ }
+ else
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_kick",
+ _("%s%s%s%s has kicked %s%s%s from %s%s"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ argv[3],
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ argv[2]);
+ }
}
if (strcmp (argv[3], server->nick) == 0)
@@ -423,6 +433,7 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command,
:nick1!user@host KILL mynick :kill reason
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
IRC_PROTOCOL_CHECK_HOST;
@@ -432,27 +443,30 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command,
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- if (pos_comment)
- {
- weechat_printf_tags (ptr_channel->buffer,
- "irc_kill",
- _("%sYou were killed by %s%s %s(%s%s%s)"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- pos_comment,
- IRC_COLOR_CHAT_DELIMITERS);
- }
- else
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- weechat_printf_tags (ptr_channel->buffer,
- "irc_kill",
- _("%sYou were killed by %s%s"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]));
+ if (pos_comment)
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_kill",
+ _("%sYou were killed by %s%s %s(%s%s%s)"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ pos_comment,
+ IRC_COLOR_CHAT_DELIMITERS);
+ }
+ else
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_kill",
+ _("%sYou were killed by %s%s"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ }
}
if (strcmp (argv[2], server->nick) == 0)
@@ -489,6 +503,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
:nick!user@host MODE #test +o nick
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_CHECK_HOST;
@@ -502,34 +517,40 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
irc_mode_channel_set (server, ptr_channel, pos_modes);
irc_server_sendf (server, "MODE %s", ptr_channel->name);
}
- weechat_printf_tags ((ptr_channel) ?
- ptr_channel->buffer : server->buffer,
- "irc_mode",
- _("%sMode %s%s %s[%s%s%s]%s by %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- ptr_channel->name,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- pos_modes,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]));
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ weechat_printf_tags ((ptr_channel) ?
+ ptr_channel->buffer : server->buffer,
+ "irc_mode",
+ _("%sMode %s%s %s[%s%s%s]%s by %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ (ptr_channel) ? ptr_channel->name : argv[2],
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ pos_modes,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ }
}
else
{
- weechat_printf_tags (server->buffer,
- "irc_mode",
- _("%sUser mode %s[%s%s%s]%s by %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- pos_modes,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]));
+ if (!irc_ignore_check (server, NULL, nick, host))
+ {
+ weechat_printf_tags (server->buffer,
+ "irc_mode",
+ _("%sUser mode %s[%s%s%s]%s by %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ pos_modes,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ }
}
irc_mode_user_set (server, pos_modes);
@@ -546,23 +567,23 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command,
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
- char *old_nick, *new_nick;
+ char *new_nick;
int nick_is_me;
/* NICK message looks like:
:oldnick!user@host NICK :newnick
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
IRC_PROTOCOL_CHECK_HOST;
/* make C compiler happy */
(void) argv_eol;
- old_nick = irc_protocol_get_nick_from_host (argv[0]);
new_nick = (argv[2][0] == ':') ? argv[2] + 1 : argv[2];
- nick_is_me = (strcmp (old_nick, server->nick) == 0) ? 1 : 0;
+ nick_is_me = (strcmp (nick, server->nick) == 0) ? 1 : 0;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
@@ -571,7 +592,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command,
{
case IRC_CHANNEL_TYPE_PRIVATE:
/* rename private window if this is with "old nick" */
- if (weechat_strcasecmp (ptr_channel->name, old_nick) == 0)
+ if (weechat_strcasecmp (ptr_channel->name, nick) == 0)
{
free (ptr_channel->name);
ptr_channel->name = strdup (new_nick);
@@ -580,7 +601,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command,
break;
case IRC_CHANNEL_TYPE_CHANNEL:
/* rename nick in nicklist if found */
- ptr_nick = irc_nick_search (ptr_channel, old_nick);
+ ptr_nick = irc_nick_search (ptr_channel, nick);
if (ptr_nick)
{
/* temporary disable hotlist */
@@ -600,16 +621,19 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command,
}
else
{
- weechat_printf_tags (ptr_channel->buffer,
- "irc_nick",
- _("%s%s%s%s is now known as "
- "%s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_NICK,
- old_nick,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- new_nick);
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_nick",
+ _("%s%s%s%s is now known as "
+ "%s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ new_nick);
+ }
}
/* enable hotlist */
@@ -633,7 +657,7 @@ int
irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
- char *nick, *host, *pos_args, *pos_end, *pos_usec, tags[128];
+ char *pos_args, *pos_end, *pos_usec, tags[128];
struct timeval tv;
long sec1, usec1, sec2, usec2, difftime;
struct t_irc_channel *ptr_channel;
@@ -643,20 +667,16 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
:nick!user@host NOTICE mynick :notice text
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
-
+
if (argv[0][0] == ':')
- {
- nick = irc_protocol_get_nick_from_host (argv[0]);
- host = irc_protocol_get_address_from_host (argv[0]);
pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3];
- }
else
- {
- nick = NULL;
- host = NULL;
pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];
- }
+
+ if (nick && irc_ignore_check (server, NULL, nick, host))
+ return WEECHAT_RC_OK;
if (nick && strncmp (pos_args, "\01VERSION", 8) == 0)
{
@@ -758,7 +778,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
}
}
if (!ptr_channel->topic)
- irc_channel_set_topic (ptr_channel, host);
+ irc_channel_set_topic (ptr_channel, address);
weechat_printf_tags (ptr_channel->buffer,
tags,
@@ -769,7 +789,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
}
else
{
- if (host && host[0])
+ if (address && address[0])
{
weechat_printf_tags (server->buffer,
tags,
@@ -779,7 +799,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
nick,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- host,
+ address,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
pos_args);
@@ -821,7 +841,7 @@ int
irc_protocol_cmd_part (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
- char *nick, *host, *pos_comment, *join_string;
+ char *pos_comment, *join_string;
int join_length;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
@@ -830,12 +850,10 @@ irc_protocol_cmd_part (struct t_irc_server *server, const char *command,
:nick!user@host PART #channel :part message
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
IRC_PROTOCOL_CHECK_HOST;
- nick = irc_protocol_get_nick_from_host (argv[0]);
- host = irc_protocol_get_address_from_host (argv[0]);
-
pos_comment = (argc > 3) ?
((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;
@@ -846,43 +864,46 @@ irc_protocol_cmd_part (struct t_irc_server *server, const char *command,
if (ptr_nick)
{
/* display part message */
- if (pos_comment)
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- weechat_printf_tags (ptr_channel->buffer,
- "irc_part",
- _("%s%s%s %s(%s%s%s)%s has left %s%s "
- "%s(%s%s%s)"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_HOST,
- host,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- ptr_channel->name,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- pos_comment,
- IRC_COLOR_CHAT_DELIMITERS);
- }
- else
- {
- weechat_printf_tags (ptr_channel->buffer,
- "irc_part",
- _("%s%s%s %s(%s%s%s)%s has left "
- "%s%s"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_HOST,
- host,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- ptr_channel->name);
+ if (pos_comment)
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_part",
+ _("%s%s%s %s(%s%s%s)%s has left %s%s "
+ "%s(%s%s%s)"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ address,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ ptr_channel->name,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ pos_comment,
+ IRC_COLOR_CHAT_DELIMITERS);
+ }
+ else
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_part",
+ _("%s%s%s %s(%s%s%s)%s has left "
+ "%s%s"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ address,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ ptr_channel->name);
+ }
}
/* part request was issued by local client ? */
@@ -1052,7 +1073,7 @@ int
irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
- char *nick, *host, *pos_args, *pos_end_01, *pos, *pos_message;
+ char *pos_args, *pos_end_01, *pos, *pos_message;
char *dcc_args, *pos_file, *pos_addr, *pos_port, *pos_size, *pos_start_resume; /* for DCC */
struct t_infolist *infolist;
struct t_infolist_item *item;
@@ -1068,12 +1089,10 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
:nick!user@host PRIVMSG mynick :\01DCC SEND file.txt 1488915698 50612 128\01
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_CHECK_HOST;
- nick = irc_protocol_get_nick_from_host (argv[0]);
- host = irc_protocol_get_address_from_host (argv[0]);
-
pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3];
/* receiver is a channel ? */
@@ -1084,85 +1103,97 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
if (strncmp (pos_args, "\01ACTION ", 8) == 0)
{
- pos_args += 8;
- pos_end_01 = strchr (pos_args, '\01');
- if (pos_end_01)
- pos_end_01[0] = '\0';
-
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_action,notify_message",
- "%s%s%s %s%s",
- weechat_prefix ("action"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT,
- pos_args);
-
- irc_channel_add_nick_speaking (ptr_channel, nick);
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ pos_args += 8;
+ pos_end_01 = strchr (pos_args, '\01');
+ if (pos_end_01)
+ pos_end_01[0] = '\0';
- if (pos_end_01)
- pos_end_01[0] = '\01';
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,irc_action,notify_message",
+ "%s%s%s %s%s",
+ weechat_prefix ("action"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ pos_args);
+
+ irc_channel_add_nick_speaking (ptr_channel, nick);
+
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
+ }
return WEECHAT_RC_OK;
}
if (strncmp (pos_args, "\01SOUND ", 7) == 0)
{
- pos_args += 7;
- pos_end_01 = strchr (pos_args, '\01');
- if (pos_end_01)
- pos_end_01[0] = '\0';
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ pos_args += 7;
+ pos_end_01 = strchr (pos_args, '\01');
+ if (pos_end_01)
+ pos_end_01[0] = '\0';
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sReceived a CTCP %sSOUND%s \"%s\" "
- "from %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- IRC_COLOR_CHAT,
- pos_args,
- IRC_COLOR_CHAT_NICK,
- nick);
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sReceived a CTCP %sSOUND%s \"%s\" "
+ "from %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ IRC_COLOR_CHAT,
+ pos_args,
+ IRC_COLOR_CHAT_NICK,
+ nick);
- if (pos_end_01)
- pos_end_01[0] = '\01';
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
+ }
return WEECHAT_RC_OK;
}
if (strncmp (pos_args, "\01PING", 5) == 0)
{
- pos_args += 5;
- while (pos_args[0] == ' ')
- pos_args++;
- pos_end_01 = strchr (pos_args, '\01');
- if (pos_end_01)
- pos_end_01[0] = '\0';
- else
- pos_args = NULL;
- if (pos_args && !pos_args[0])
- pos_args = NULL;
- if (pos_args)
- irc_server_sendf (server, "NOTICE %s :\01PING %s\01",
- nick, pos_args);
- else
- irc_server_sendf (server, "NOTICE %s :\01PING\01",
- nick);
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sCTCP %sPING%s received from %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick);
- if (pos_end_01)
- pos_end_01[0] = '\01';
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ pos_args += 5;
+ while (pos_args[0] == ' ')
+ pos_args++;
+ pos_end_01 = strchr (pos_args, '\01');
+ if (pos_end_01)
+ pos_end_01[0] = '\0';
+ else
+ pos_args = NULL;
+ if (pos_args && !pos_args[0])
+ pos_args = NULL;
+ if (pos_args)
+ irc_server_sendf (server, "NOTICE %s :\01PING %s\01",
+ nick, pos_args);
+ else
+ irc_server_sendf (server, "NOTICE %s :\01PING\01",
+ nick);
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sCTCP %sPING%s received from %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
+ }
return WEECHAT_RC_OK;
}
if (strncmp (pos_args, "\01VERSION", 8) == 0)
{
- irc_protocol_reply_version (server, ptr_channel, nick,
- argv_eol[0], pos_args);
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ irc_protocol_reply_version (server, ptr_channel, nick,
+ argv_eol[0], pos_args);
+ }
return WEECHAT_RC_OK;
}
@@ -1172,75 +1203,81 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if ((pos_args[0] == '\01')
&& pos_end_01 && (pos_end_01[1] == '\0'))
{
- pos_args++;
- pos_end_01[0] = '\0';
- pos = strchr (pos_args, ' ');
- if (pos)
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- pos[0] = '\0';
- pos_message = pos + 1;
- while (pos_message[0] == ' ')
+ pos_args++;
+ pos_end_01[0] = '\0';
+ pos = strchr (pos_args, ' ');
+ if (pos)
{
- pos_message++;
+ pos[0] = '\0';
+ pos_message = pos + 1;
+ while (pos_message[0] == ' ')
+ {
+ pos_message++;
+ }
+ if (!pos_message[0])
+ pos_message = NULL;
}
- if (!pos_message[0])
+ else
pos_message = NULL;
- }
- else
- pos_message = NULL;
- if (pos_message)
- {
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sUnknown CTCP %s%s%s "
- "received from %s%s%s: %s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- pos_args,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT,
- pos_message);
- }
- else
- {
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sUnknown CTCP %s%s%s "
- "received from %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- pos_args,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick);
- }
- if (pos_end_01)
- pos_end_01[0] = '\01';
- if (pos)
- pos[0] = ' ';
+ if (pos_message)
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sUnknown CTCP %s%s%s "
+ "received from %s%s%s: %s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ pos_args,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ pos_message);
+ }
+ else
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sUnknown CTCP %s%s%s "
+ "received from %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ pos_args,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ }
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
+ if (pos)
+ pos[0] = ' ';
- weechat_hook_signal_send ("irc_ctcp",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
+ weechat_hook_signal_send ("irc_ctcp",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+ }
return WEECHAT_RC_OK;
}
-
+
/* other message */
ptr_nick = irc_nick_search (ptr_channel, nick);
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,notify_message",
- "%s%s",
- irc_nick_as_prefix (ptr_nick,
- (ptr_nick) ? NULL : nick,
- NULL),
- pos_args);
-
- irc_channel_add_nick_speaking (ptr_channel, nick);
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,notify_message",
+ "%s%s",
+ irc_nick_as_prefix (ptr_nick,
+ (ptr_nick) ? NULL : nick,
+ NULL),
+ pos_args);
+
+ irc_channel_add_nick_speaking (ptr_channel, nick);
+ }
}
else
{
@@ -1257,8 +1294,11 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
/* version asked by another user => answer with WeeChat version */
if (strncmp (pos_args, "\01VERSION", 8) == 0)
{
- irc_protocol_reply_version (server, NULL, nick, argv_eol[0],
- pos_args);
+ if (!irc_ignore_check (server, NULL, nick, host))
+ {
+ irc_protocol_reply_version (server, NULL, nick, argv_eol[0],
+ pos_args);
+ }
return WEECHAT_RC_OK;
}
@@ -1266,37 +1306,40 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
/* ping request from another user => answer */
if (strncmp (pos_args, "\01PING", 5) == 0)
{
- pos_args += 5;
- while (pos_args[0] == ' ')
+ if (!irc_ignore_check (server, NULL, nick, host))
{
- pos_args++;
+ pos_args += 5;
+ while (pos_args[0] == ' ')
+ {
+ pos_args++;
+ }
+ pos_end_01 = strchr (pos, '\01');
+ if (pos_end_01)
+ pos_end_01[0] = '\0';
+ else
+ pos_args = NULL;
+ if (pos_args && !pos_args[0])
+ pos_args = NULL;
+ if (pos_args)
+ irc_server_sendf (server, "NOTICE %s :\01PING %s\01",
+ nick, pos_args);
+ else
+ irc_server_sendf (server, "NOTICE %s :\01PING\01",
+ nick);
+ weechat_printf_tags (server->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sCTCP %sPING%s received from %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ weechat_hook_signal_send ("irc_ctcp",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
}
- pos_end_01 = strchr (pos, '\01');
- if (pos_end_01)
- pos_end_01[0] = '\0';
- else
- pos_args = NULL;
- if (pos_args && !pos_args[0])
- pos_args = NULL;
- if (pos_args)
- irc_server_sendf (server, "NOTICE %s :\01PING %s\01",
- nick, pos_args);
- else
- irc_server_sendf (server, "NOTICE %s :\01PING\01",
- nick);
- weechat_printf_tags (server->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sCTCP %sPING%s received from %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick);
- weechat_hook_signal_send ("irc_ctcp",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
- if (pos_end_01)
- pos_end_01[0] = '\01';
return WEECHAT_RC_OK;
}
@@ -1304,124 +1347,128 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
/* incoming DCC file */
if (strncmp (pos_args, "\01DCC SEND", 9) == 0)
{
- /* check if DCC SEND is ok, i.e. with 0x01 at end */
- pos_end_01 = strchr (pos_args + 1, '\01');
- if (!pos_end_01)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
-
- dcc_args = weechat_strndup (pos_args + 9, pos_end_01 - pos_args - 9);
-
- if (!dcc_args)
+ if (!irc_ignore_check (server, NULL, nick, host))
{
- weechat_printf (server->buffer,
- _("%s%s: not enough memory for \"%s\" "
- "command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
+ /* check if DCC SEND is ok, i.e. with 0x01 at end */
+ pos_end_01 = strchr (pos_args + 1, '\01');
+ if (!pos_end_01)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- /* DCC filename */
- pos_file = dcc_args;
- while (pos_file[0] == ' ')
- {
- pos_file++;
- }
+ dcc_args = weechat_strndup (pos_args + 9,
+ pos_end_01 - pos_args - 9);
- /* look for file size */
- pos_size = strrchr (pos_file, ' ');
- if (!pos_size)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_size;
- pos_size++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
+ if (!dcc_args)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: not enough memory for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- /* look for DCC port */
- pos_port = strrchr (pos_file, ' ');
- if (!pos_port)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_port;
- pos_port++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
+ /* DCC filename */
+ pos_file = dcc_args;
+ while (pos_file[0] == ' ')
+ {
+ pos_file++;
+ }
- /* look for DCC IP address */
- pos_addr = strrchr (pos_file, ' ');
- if (!pos_addr)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_addr;
- pos_addr++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
-
- /* add DCC file via xfer plugin */
- infolist = weechat_infolist_new ();
- if (infolist)
- {
- item = weechat_infolist_new_item (infolist);
- if (item)
+ /* look for file size */
+ pos_size = strrchr (pos_file, ' ');
+ if (!pos_size)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_size;
+ pos_size++;
+ while (pos[0] == ' ')
{
- weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
- snprintf (plugin_id, sizeof (plugin_id),
- "%x", (unsigned int)server);
- weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
- weechat_infolist_new_var_string (item, "type", "file_recv");
- weechat_infolist_new_var_string (item, "protocol", "dcc");
- weechat_infolist_new_var_string (item, "remote_nick", nick);
- weechat_infolist_new_var_string (item, "local_nick", server->nick);
- weechat_infolist_new_var_string (item, "filename", pos_file);
- weechat_infolist_new_var_string (item, "size", pos_size);
- weechat_infolist_new_var_string (item, "address", pos_addr);
- weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
- weechat_hook_signal_send ("xfer_add",
- WEECHAT_HOOK_SIGNAL_POINTER,
- infolist);
+ pos--;
}
- weechat_infolist_free (infolist);
- }
-
- weechat_hook_signal_send ("irc_dcc",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
+ pos[1] = '\0';
- free (dcc_args);
+ /* look for DCC port */
+ pos_port = strrchr (pos_file, ' ');
+ if (!pos_port)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_port;
+ pos_port++;
+ while (pos[0] == ' ')
+ {
+ pos--;
+ }
+ pos[1] = '\0';
+
+ /* look for DCC IP address */
+ pos_addr = strrchr (pos_file, ' ');
+ if (!pos_addr)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_addr;
+ pos_addr++;
+ while (pos[0] == ' ')
+ {
+ pos--;
+ }
+ pos[1] = '\0';
+
+ /* add DCC file via xfer plugin */
+ infolist = weechat_infolist_new ();
+ if (infolist)
+ {
+ item = weechat_infolist_new_item (infolist);
+ if (item)
+ {
+ weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
+ snprintf (plugin_id, sizeof (plugin_id),
+ "%x", (unsigned int)server);
+ weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
+ weechat_infolist_new_var_string (item, "type", "file_recv");
+ weechat_infolist_new_var_string (item, "protocol", "dcc");
+ weechat_infolist_new_var_string (item, "remote_nick", nick);
+ weechat_infolist_new_var_string (item, "local_nick", server->nick);
+ weechat_infolist_new_var_string (item, "filename", pos_file);
+ weechat_infolist_new_var_string (item, "size", pos_size);
+ weechat_infolist_new_var_string (item, "address", pos_addr);
+ weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
+ weechat_hook_signal_send ("xfer_add",
+ WEECHAT_HOOK_SIGNAL_POINTER,
+ infolist);
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ weechat_hook_signal_send ("irc_dcc",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+
+ free (dcc_args);
+ }
return WEECHAT_RC_OK;
}
@@ -1429,101 +1476,105 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
/* incoming DCC RESUME (asked by receiver) */
if (strncmp (pos_args, "\01DCC RESUME", 11) == 0)
{
- /* check if DCC RESUME is ok, i.e. with 0x01 at end */
- pos_end_01 = strchr (pos_args + 1, '\01');
- if (!pos_end_01)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
-
- dcc_args = weechat_strndup (pos_args + 11, pos_end_01 - pos_args - 11);
-
- if (!dcc_args)
+ if (!irc_ignore_check (server, NULL, nick, host))
{
- weechat_printf (server->buffer,
- _("%s%s: not enough memory for \"%s\" "
- "command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
+ /* check if DCC RESUME is ok, i.e. with 0x01 at end */
+ pos_end_01 = strchr (pos_args + 1, '\01');
+ if (!pos_end_01)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- /* DCC filename */
- pos_file = dcc_args;
- while (pos_file[0] == ' ')
- {
- pos_file++;
- }
+ dcc_args = weechat_strndup (pos_args + 11,
+ pos_end_01 - pos_args - 11);
- /* look for resume start position */
- pos_start_resume = strrchr (pos_file, ' ');
- if (!pos_start_resume)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_start_resume;
- pos_start_resume++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
+ if (!dcc_args)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: not enough memory for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- /* look for DCC port */
- pos_port = strrchr (pos_file, ' ');
- if (!pos_port)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_port;
- pos_port++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
-
- /* accept resume via xfer plugin */
- infolist = weechat_infolist_new ();
- if (infolist)
- {
- item = weechat_infolist_new_item (infolist);
- if (item)
+ /* DCC filename */
+ pos_file = dcc_args;
+ while (pos_file[0] == ' ')
{
- weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
- snprintf (plugin_id, sizeof (plugin_id),
- "%x", (unsigned int)server);
- weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
- weechat_infolist_new_var_string (item, "type", "file_recv");
- weechat_infolist_new_var_string (item, "filename", pos_file);
- weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
- weechat_infolist_new_var_string (item, "start_resume", pos_start_resume);
- weechat_hook_signal_send ("xfer_accept_resume",
- WEECHAT_HOOK_SIGNAL_POINTER,
- infolist);
+ pos_file++;
}
- weechat_infolist_free (infolist);
- }
-
- weechat_hook_signal_send ("irc_dcc",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
- free (dcc_args);
+ /* look for resume start position */
+ pos_start_resume = strrchr (pos_file, ' ');
+ if (!pos_start_resume)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_start_resume;
+ pos_start_resume++;
+ while (pos[0] == ' ')
+ {
+ pos--;
+ }
+ pos[1] = '\0';
+
+ /* look for DCC port */
+ pos_port = strrchr (pos_file, ' ');
+ if (!pos_port)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_port;
+ pos_port++;
+ while (pos[0] == ' ')
+ {
+ pos--;
+ }
+ pos[1] = '\0';
+
+ /* accept resume via xfer plugin */
+ infolist = weechat_infolist_new ();
+ if (infolist)
+ {
+ item = weechat_infolist_new_item (infolist);
+ if (item)
+ {
+ weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
+ snprintf (plugin_id, sizeof (plugin_id),
+ "%x", (unsigned int)server);
+ weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
+ weechat_infolist_new_var_string (item, "type", "file_recv");
+ weechat_infolist_new_var_string (item, "filename", pos_file);
+ weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
+ weechat_infolist_new_var_string (item, "start_resume", pos_start_resume);
+ weechat_hook_signal_send ("xfer_accept_resume",
+ WEECHAT_HOOK_SIGNAL_POINTER,
+ infolist);
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ weechat_hook_signal_send ("irc_dcc",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+
+ free (dcc_args);
+ }
return WEECHAT_RC_OK;
}
@@ -1531,101 +1582,105 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
/* incoming DCC ACCEPT (resume accepted by sender) */
if (strncmp (pos_args, "\01DCC ACCEPT", 11) == 0)
{
- /* check if DCC ACCEPT is ok, i.e. with 0x01 at end */
- pos_end_01 = strchr (pos_args + 1, '\01');
- if (!pos_end_01)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
-
- dcc_args = weechat_strndup (pos_args + 11, pos_end_01 - pos_args - 11);
-
- if (!dcc_args)
+ if (!irc_ignore_check (server, NULL, nick, host))
{
- weechat_printf (server->buffer,
- _("%s%s: not enough memory for \"%s\" "
- "command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
+ /* check if DCC ACCEPT is ok, i.e. with 0x01 at end */
+ pos_end_01 = strchr (pos_args + 1, '\01');
+ if (!pos_end_01)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- /* DCC filename */
- pos_file = dcc_args;
- while (pos_file[0] == ' ')
- {
- pos_file++;
- }
+ dcc_args = weechat_strndup (pos_args + 11,
+ pos_end_01 - pos_args - 11);
- /* look for resume start position */
- pos_start_resume = strrchr (pos_file, ' ');
- if (!pos_start_resume)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_start_resume;
- pos_start_resume++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
+ if (!dcc_args)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: not enough memory for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- /* look for DCC port */
- pos_port = strrchr (pos_file, ' ');
- if (!pos_port)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos = pos_port;
- pos_port++;
- while (pos[0] == ' ')
- {
- pos--;
- }
- pos[1] = '\0';
-
- /* resume file via xfer plugin */
- infolist = weechat_infolist_new ();
- if (infolist)
- {
- item = weechat_infolist_new_item (infolist);
- if (item)
+ /* DCC filename */
+ pos_file = dcc_args;
+ while (pos_file[0] == ' ')
{
- weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
- snprintf (plugin_id, sizeof (plugin_id),
- "%x", (unsigned int)server);
- weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
- weechat_infolist_new_var_string (item, "type", "file_recv");
- weechat_infolist_new_var_string (item, "filename", pos_file);
- weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
- weechat_infolist_new_var_string (item, "start_resume", pos_start_resume);
- weechat_hook_signal_send ("xfer_start_resume",
- WEECHAT_HOOK_SIGNAL_POINTER,
- infolist);
+ pos_file++;
}
- weechat_infolist_free (infolist);
- }
-
- weechat_hook_signal_send ("irc_dcc",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
- free (dcc_args);
+ /* look for resume start position */
+ pos_start_resume = strrchr (pos_file, ' ');
+ if (!pos_start_resume)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_start_resume;
+ pos_start_resume++;
+ while (pos[0] == ' ')
+ {
+ pos--;
+ }
+ pos[1] = '\0';
+
+ /* look for DCC port */
+ pos_port = strrchr (pos_file, ' ');
+ if (!pos_port)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos = pos_port;
+ pos_port++;
+ while (pos[0] == ' ')
+ {
+ pos--;
+ }
+ pos[1] = '\0';
+
+ /* resume file via xfer plugin */
+ infolist = weechat_infolist_new ();
+ if (infolist)
+ {
+ item = weechat_infolist_new_item (infolist);
+ if (item)
+ {
+ weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
+ snprintf (plugin_id, sizeof (plugin_id),
+ "%x", (unsigned int)server);
+ weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
+ weechat_infolist_new_var_string (item, "type", "file_recv");
+ weechat_infolist_new_var_string (item, "filename", pos_file);
+ weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
+ weechat_infolist_new_var_string (item, "start_resume", pos_start_resume);
+ weechat_hook_signal_send ("xfer_start_resume",
+ WEECHAT_HOOK_SIGNAL_POINTER,
+ infolist);
+ }
+ weechat_infolist_free (infolist);
+ }
+
+ weechat_hook_signal_send ("irc_dcc",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+
+ free (dcc_args);
+ }
return WEECHAT_RC_OK;
}
@@ -1633,114 +1688,118 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
/* incoming DCC CHAT */
if (strncmp (pos_args, "\01DCC CHAT", 9) == 0)
{
- /* check if DCC CHAT is ok, i.e. with 0x01 at end */
- pos_end_01 = strchr (pos_args + 1, '\01');
- if (!pos_end_01)
+ if (!irc_ignore_check (server, NULL, nick, host))
{
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
+ /* check if DCC CHAT is ok, i.e. with 0x01 at end */
+ pos_end_01 = strchr (pos_args + 1, '\01');
+ if (!pos_end_01)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
- dcc_args = weechat_strndup (pos_args + 9, pos_end_01 - pos_args - 9);
-
- if (!dcc_args)
- {
- weechat_printf (server->buffer,
- _("%s%s: not enough memory for \"%s\" "
- "command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- return WEECHAT_RC_ERROR;
- }
+ dcc_args = weechat_strndup (pos_args + 9,
+ pos_end_01 - pos_args - 9);
- /* CHAT type */
- pos_file = dcc_args;
- while (pos_file[0] == ' ')
- {
- pos_file++;
- }
-
- /* DCC IP address */
- pos_addr = strchr (pos_file, ' ');
- if (!pos_addr)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos_addr[0] = '\0';
- pos_addr++;
- while (pos_addr[0] == ' ')
- {
+ if (!dcc_args)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: not enough memory for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* CHAT type */
+ pos_file = dcc_args;
+ while (pos_file[0] == ' ')
+ {
+ pos_file++;
+ }
+
+ /* DCC IP address */
+ pos_addr = strchr (pos_file, ' ');
+ if (!pos_addr)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos_addr[0] = '\0';
pos_addr++;
- }
+ while (pos_addr[0] == ' ')
+ {
+ pos_addr++;
+ }
- /* look for DCC port */
- pos_port = strchr (pos_addr, ' ');
- if (!pos_port)
- {
- weechat_printf (server->buffer,
- _("%s%s: cannot parse \"%s\" command"),
- weechat_prefix ("error"), "irc",
- "privmsg");
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
- pos_port[0] = '\0';
- pos_port++;
- while (pos_port[0] == ' ')
- {
+ /* look for DCC port */
+ pos_port = strchr (pos_addr, ' ');
+ if (!pos_port)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot parse \"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ "privmsg");
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
+ pos_port[0] = '\0';
pos_port++;
- }
+ while (pos_port[0] == ' ')
+ {
+ pos_port++;
+ }
- if (weechat_strcasecmp (pos_file, "chat") != 0)
- {
- weechat_printf (server->buffer,
- _("%s%s: unknown DCC CHAT type "
- "received from %s%s%s: \"%s\""),
- weechat_prefix ("error"), "irc",
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT,
- pos_file);
- free (dcc_args);
- return WEECHAT_RC_ERROR;
- }
+ if (weechat_strcasecmp (pos_file, "chat") != 0)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: unknown DCC CHAT type "
+ "received from %s%s%s: \"%s\""),
+ weechat_prefix ("error"), "irc",
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ pos_file);
+ free (dcc_args);
+ return WEECHAT_RC_ERROR;
+ }
- /* add DCC chat via xfer plugin */
- infolist = weechat_infolist_new ();
- if (infolist)
- {
- item = weechat_infolist_new_item (infolist);
- if (item)
+ /* add DCC chat via xfer plugin */
+ infolist = weechat_infolist_new ();
+ if (infolist)
{
- weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
- snprintf (plugin_id, sizeof (plugin_id),
- "%x", (unsigned int)server);
- weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
- weechat_infolist_new_var_string (item, "type", "chat_recv");
- weechat_infolist_new_var_string (item, "remote_nick", nick);
- weechat_infolist_new_var_string (item, "local_nick", server->nick);
- weechat_infolist_new_var_string (item, "address", pos_addr);
- weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
- weechat_hook_signal_send ("xfer_add",
- WEECHAT_HOOK_SIGNAL_POINTER,
- infolist);
+ item = weechat_infolist_new_item (infolist);
+ if (item)
+ {
+ weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
+ snprintf (plugin_id, sizeof (plugin_id),
+ "%x", (unsigned int)server);
+ weechat_infolist_new_var_string (item, "plugin_id", plugin_id);
+ weechat_infolist_new_var_string (item, "type", "chat_recv");
+ weechat_infolist_new_var_string (item, "remote_nick", nick);
+ weechat_infolist_new_var_string (item, "local_nick", server->nick);
+ weechat_infolist_new_var_string (item, "address", pos_addr);
+ weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
+ weechat_hook_signal_send ("xfer_add",
+ WEECHAT_HOOK_SIGNAL_POINTER,
+ infolist);
+ }
+ weechat_infolist_free (infolist);
}
- weechat_infolist_free (infolist);
- }
-
- weechat_hook_signal_send ("irc_dcc",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
- free (dcc_args);
+ weechat_hook_signal_send ("irc_dcc",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+
+ free (dcc_args);
+ }
return WEECHAT_RC_OK;
}
@@ -1750,43 +1809,46 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if (strncmp (pos_args, "\01ACTION ", 8) == 0)
{
- if (!ptr_channel)
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- ptr_channel = irc_channel_new (server,
- IRC_CHANNEL_TYPE_PRIVATE,
- nick, 0);
if (!ptr_channel)
{
- weechat_printf (server->buffer,
- _("%s%s: cannot create new "
- "private buffer \"%s\""),
- weechat_prefix ("error"), "irc",
- nick);
- return WEECHAT_RC_ERROR;
+ ptr_channel = irc_channel_new (server,
+ IRC_CHANNEL_TYPE_PRIVATE,
+ nick, 0);
+ if (!ptr_channel)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot create new "
+ "private buffer \"%s\""),
+ weechat_prefix ("error"), "irc",
+ nick);
+ return WEECHAT_RC_ERROR;
+ }
}
+ if (!ptr_channel->topic)
+ irc_channel_set_topic (ptr_channel, address);
+
+ pos_args += 8;
+ pos_end_01 = strchr (pos, '\01');
+ if (pos_end_01)
+ pos_end_01[0] = '\0';
+
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,irc_action,notify_private",
+ "%s%s%s %s%s",
+ weechat_prefix ("action"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ pos_args);
+ weechat_hook_signal_send ("irc_pv",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
}
- if (!ptr_channel->topic)
- irc_channel_set_topic (ptr_channel, host);
-
- pos_args += 8;
- pos_end_01 = strchr (pos, '\01');
- if (pos_end_01)
- pos_end_01[0] = '\0';
-
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_action,notify_private",
- "%s%s%s %s%s",
- weechat_prefix ("action"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT,
- pos_args);
- weechat_hook_signal_send ("irc_pv",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
-
- if (pos_end_01)
- pos_end_01[0] = '\01';
}
else
{
@@ -1795,93 +1857,97 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if ((pos_args[0] == '\01')
&& pos_end_01 && (pos_end_01[1] == '\0'))
{
- pos_args++;
- pos_end_01[0] = '\0';
- pos = strchr (pos_args, ' ');
- if (pos)
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- pos[0] = '\0';
- pos_message = pos + 1;
- while (pos_message[0] == ' ')
+ pos_args++;
+ pos_end_01[0] = '\0';
+ pos = strchr (pos_args, ' ');
+ if (pos)
{
- pos_message++;
+ pos[0] = '\0';
+ pos_message = pos + 1;
+ while (pos_message[0] == ' ')
+ {
+ pos_message++;
+ }
+ if (!pos_message[0])
+ pos_message = NULL;
}
- if (!pos_message[0])
+ else
pos_message = NULL;
- }
- else
- pos_message = NULL;
- if (pos_message)
- {
- weechat_printf_tags (server->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sUnknown CTCP %s%s%s "
- "received from %s%s%s: %s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- pos_args,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT,
- pos_message);
- }
- else
- {
- weechat_printf_tags (server->buffer,
- "irc_privmsg,irc_ctcp",
- _("%sUnknown CTCP %s%s%s "
- "received from %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_CHANNEL,
- pos_args,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick);
- }
- if (pos_end_01)
- pos_end_01[0] = '\01';
- if (pos)
- pos[0] = ' ';
+ if (pos_message)
+ {
+ weechat_printf_tags (server->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sUnknown CTCP %s%s%s "
+ "received from %s%s%s: %s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ pos_args,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ pos_message);
+ }
+ else
+ {
+ weechat_printf_tags (server->buffer,
+ "irc_privmsg,irc_ctcp",
+ _("%sUnknown CTCP %s%s%s "
+ "received from %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_CHANNEL,
+ pos_args,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ nick);
+ }
+ if (pos_end_01)
+ pos_end_01[0] = '\01';
+ if (pos)
+ pos[0] = ' ';
- weechat_hook_signal_send ("irc_ctcp",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
-
- return WEECHAT_RC_OK;
+ weechat_hook_signal_send ("irc_ctcp",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
+ }
}
else
{
/* private message */
- if (!ptr_channel)
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- ptr_channel = irc_channel_new (server,
- IRC_CHANNEL_TYPE_PRIVATE,
- nick, 0);
if (!ptr_channel)
{
- weechat_printf (server->buffer,
- _("%s%s: cannot create new "
- "private buffer \"%s\""),
- weechat_prefix ("error"),
- "irc", nick);
- return WEECHAT_RC_ERROR;
+ ptr_channel = irc_channel_new (server,
+ IRC_CHANNEL_TYPE_PRIVATE,
+ nick, 0);
+ if (!ptr_channel)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: cannot create new "
+ "private buffer \"%s\""),
+ weechat_prefix ("error"),
+ "irc", nick);
+ return WEECHAT_RC_ERROR;
+ }
}
+ irc_channel_set_topic (ptr_channel, address);
+
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_privmsg,notify_private",
+ "%s%s",
+ irc_nick_as_prefix (NULL,
+ nick,
+ IRC_COLOR_CHAT_NICK_OTHER),
+ pos_args);
+
+ weechat_hook_signal_send ("irc_pv",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ argv_eol[0]);
}
- irc_channel_set_topic (ptr_channel, host);
-
- weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,notify_private",
- "%s%s",
- irc_nick_as_prefix (NULL,
- nick,
- IRC_COLOR_CHAT_NICK_OTHER),
- pos_args);
-
- weechat_hook_signal_send ("irc_pv",
- WEECHAT_HOOK_SIGNAL_STRING,
- argv_eol[0]);
}
}
}
@@ -1897,7 +1963,7 @@ int
irc_protocol_cmd_quit (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
- char *nick, *host, *pos_comment;
+ char *pos_comment;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
@@ -1905,12 +1971,10 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command,
:nick!user@host QUIT :quit message
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(2);
IRC_PROTOCOL_CHECK_HOST;
- nick = irc_protocol_get_nick_from_host (argv[0]);
- host = irc_protocol_get_address_from_host (argv[0]);
-
pos_comment = (argc > 2) ?
((argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]) : NULL;
@@ -1926,38 +1990,43 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command,
{
if (ptr_nick)
irc_nick_free (ptr_channel, ptr_nick);
- if (pos_comment && pos_comment[0])
- {
- weechat_printf_tags (ptr_channel->buffer,
- "irc_quit",
- _("%s%s%s %s(%s%s%s)%s has quit "
- "%s(%s%s%s)"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_HOST,
- host,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- pos_comment,
- IRC_COLOR_CHAT_DELIMITERS);
- }
- else
+
+ /* display quit message */
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- weechat_printf_tags (ptr_channel->buffer,
- "irc_quit",
- _("%s%s%s %s(%s%s%s)%s has quit"),
- weechat_prefix ("quit"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_HOST,
- host,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT);
+ if (pos_comment && pos_comment[0])
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_quit",
+ _("%s%s%s %s(%s%s%s)%s has quit "
+ "%s(%s%s%s)"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ address,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ pos_comment,
+ IRC_COLOR_CHAT_DELIMITERS);
+ }
+ else
+ {
+ weechat_printf_tags (ptr_channel->buffer,
+ "irc_quit",
+ _("%s%s%s %s(%s%s%s)%s has quit"),
+ weechat_prefix ("quit"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ address,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT);
+ }
}
}
}
@@ -2050,6 +2119,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
:nick!user@host TOPIC #channel :new topic for channel
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
if (!irc_channel_is_channel (argv[2]))
@@ -2065,38 +2135,41 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
ptr_channel = irc_channel_search (server, argv[2]);
buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
-
- if (pos_topic && pos_topic[0])
- {
- topic_color = irc_color_decode (pos_topic,
- weechat_config_boolean (irc_config_network_colors_receive));
- weechat_printf_tags (buffer,
- "irc_topic",
- _("%s%s%s%s has changed topic for %s%s%s to: "
- "\"%s%s\""),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- argv[2],
- IRC_COLOR_CHAT,
- (topic_color) ? topic_color : pos_topic,
- IRC_COLOR_CHAT);
- if (topic_color)
- free (topic_color);
- }
- else
+
+ if (!irc_ignore_check (server, ptr_channel, nick, host))
{
- weechat_printf_tags (buffer,
- "irc_topic",
- _("%s%s%s%s has unset topic for %s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- argv[2]);
+ if (pos_topic && pos_topic[0])
+ {
+ topic_color = irc_color_decode (pos_topic,
+ weechat_config_boolean (irc_config_network_colors_receive));
+ weechat_printf_tags (buffer,
+ "irc_topic",
+ _("%s%s%s%s has changed topic for %s%s%s to: "
+ "\"%s%s\""),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ argv[2],
+ IRC_COLOR_CHAT,
+ (topic_color) ? topic_color : pos_topic,
+ IRC_COLOR_CHAT);
+ if (topic_color)
+ free (topic_color);
+ }
+ else
+ {
+ weechat_printf_tags (buffer,
+ "irc_topic",
+ _("%s%s%s%s has unset topic for %s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ argv[2]);
+ }
}
if (ptr_channel)
@@ -2117,20 +2190,24 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, const char *command,
:nick!user@host WALLOPS :message from admin
*/
+ IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
- weechat_printf_tags (server->buffer,
- "irc_wallops",
- _("%sWallops from %s%s %s(%s%s%s)%s: %s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_NICK,
- irc_protocol_get_nick_from_host (argv[0]),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_HOST,
- irc_protocol_get_address_from_host (argv[0]),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]);
+ if (!irc_ignore_check (server, NULL, nick, host))
+ {
+ weechat_printf_tags (server->buffer,
+ "irc_wallops",
+ _("%sWallops from %s%s %s(%s%s%s)%s: %s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_HOST,
+ address,
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]);
+ }
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 49e68196e..c19773164 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -20,6 +20,20 @@
#ifndef __WEECHAT_IRC_PROTOCOL_H
#define __WEECHAT_IRC_PROTOCOL_H 1
+#define IRC_PROTOCOL_GET_HOST \
+ char *nick, *address, *host; \
+ if (argv[0][0] == ':') \
+ { \
+ nick = irc_protocol_get_nick_from_host (argv[0]); \
+ address = irc_protocol_get_address_from_host (argv[0]); \
+ host = argv[0] + 1; \
+ } \
+ else \
+ { \
+ nick = NULL; \
+ address = NULL; \
+ host = NULL; \
+ }
#define IRC_PROTOCOL_MIN_ARGS(__min_args) \
if (argc < __min_args) \
{ \