diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-05-08 12:19:47 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-05-08 12:19:47 +0000 |
commit | bff5f95056b22cbfd195a8da3c6efd960a829c6e (patch) | |
tree | 963f55e7bed6987925e4f5f5cb7fe184c13f7359 /src | |
parent | 2b178c73fa26e695069228bbc733f807ed07708a (diff) | |
download | weechat-bff5f95056b22cbfd195a8da3c6efd960a829c6e.zip |
Plugin message handler is now called for own messages (as "privmsg" IRC command, with "localhost" as host to differenciate from other messages)
Diffstat (limited to 'src')
-rw-r--r-- | src/common/command.c | 25 | ||||
-rw-r--r-- | src/plugins/plugins.c | 12 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/common/command.c b/src/common/command.c index 61d65db7e..f0682f73b 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -657,6 +657,8 @@ void user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) { t_irc_nick *ptr_nick; + int plugin_args_length; + char *plugin_args; if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n')) return; @@ -682,7 +684,7 @@ user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) else server_sendf (server, "PRIVMSG %s :%s\r\n", CHANNEL(buffer)->name, command); - + if (CHANNEL(buffer)->type == CHAT_PRIVATE) { gui_printf_type_color (CHANNEL(buffer)->buffer, @@ -717,6 +719,27 @@ user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) WEECHAT_ERROR); } } + + /* sending a copy of the message as PRIVMSG to plugins because irc server doesn't */ + plugin_args_length = strlen ("localhost PRIVMSG :") + + strlen (CHANNEL(buffer)->name) + strlen(command) + 16; + plugin_args = (char *) malloc (plugin_args_length * sizeof (*plugin_args)); + + if (plugin_args) + { + snprintf (plugin_args, plugin_args_length, + "localhost PRIVMSG %s :%s", + CHANNEL(buffer)->name, command); + plugin_event_msg ("privmsg", server->name, plugin_args); + free (plugin_args); + } + else + { + irc_display_prefix (server->buffer, PREFIX_ERROR); + gui_printf (server->buffer, + _("%s unable to call handler for message (not enough memory)\n"), + WEECHAT_ERROR); + } } else { diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index bd5e4af9f..aa35bbc36 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -290,7 +290,7 @@ plugin_handler_free_all_type (t_plugin_handler **plugin_handlers, */ void -plugin_event_msg (char *irc_command, char *arguments, char *server) +plugin_event_msg (char *irc_command, char *server, char *arguments) { #ifdef PLUGINS t_plugin_handler *ptr_plugin_handler; @@ -306,7 +306,7 @@ plugin_event_msg (char *irc_command, char *arguments, char *server) if (ptr_plugin_handler->running == 0) { ptr_plugin_handler->running = 1; - wee_perl_exec (ptr_plugin_handler->function_name, arguments, server); + wee_perl_exec (ptr_plugin_handler->function_name, server, arguments); ptr_plugin_handler->running = 0; } } @@ -317,7 +317,7 @@ plugin_event_msg (char *irc_command, char *arguments, char *server) if (ptr_plugin_handler->running == 0) { ptr_plugin_handler->running = 1; - wee_python_exec (ptr_plugin_handler->function_name, arguments, server); + wee_python_exec (ptr_plugin_handler->function_name, server, arguments); ptr_plugin_handler->running = 0; } } @@ -337,7 +337,7 @@ plugin_event_msg (char *irc_command, char *arguments, char *server) */ int -plugin_exec_command (char *user_command, char *arguments, char *server) +plugin_exec_command (char *user_command, char *server, char *arguments) { #ifdef PLUGINS t_plugin_handler *ptr_plugin_handler; @@ -353,7 +353,7 @@ plugin_exec_command (char *user_command, char *arguments, char *server) if (ptr_plugin_handler->running == 0) { ptr_plugin_handler->running = 1; - wee_perl_exec (ptr_plugin_handler->function_name, arguments, server); + wee_perl_exec (ptr_plugin_handler->function_name, server, arguments); ptr_plugin_handler->running = 0; } } @@ -364,7 +364,7 @@ plugin_exec_command (char *user_command, char *arguments, char *server) if (ptr_plugin_handler->running == 0) { ptr_plugin_handler->running = 1; - wee_python_exec (ptr_plugin_handler->function_name, arguments, server); + wee_python_exec (ptr_plugin_handler->function_name, server, arguments); ptr_plugin_handler->running = 0; } } |