657 |
user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) |
user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) |
658 |
{ |
{ |
659 |
t_irc_nick *ptr_nick; |
t_irc_nick *ptr_nick; |
660 |
|
int plugin_args_length; |
661 |
|
char *plugin_args; |
662 |
|
|
663 |
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n')) |
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n')) |
664 |
return; |
return; |
684 |
else |
else |
685 |
server_sendf (server, "PRIVMSG %s :%s\r\n", |
server_sendf (server, "PRIVMSG %s :%s\r\n", |
686 |
CHANNEL(buffer)->name, command); |
CHANNEL(buffer)->name, command); |
687 |
|
|
688 |
if (CHANNEL(buffer)->type == CHAT_PRIVATE) |
if (CHANNEL(buffer)->type == CHAT_PRIVATE) |
689 |
{ |
{ |
690 |
gui_printf_type_color (CHANNEL(buffer)->buffer, |
gui_printf_type_color (CHANNEL(buffer)->buffer, |
719 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
720 |
} |
} |
721 |
} |
} |
722 |
|
|
723 |
|
/* sending a copy of the message as PRIVMSG to plugins because irc server doesn't */ |
724 |
|
plugin_args_length = strlen ("localhost PRIVMSG :") + |
725 |
|
strlen (CHANNEL(buffer)->name) + strlen(command) + 16; |
726 |
|
plugin_args = (char *) malloc (plugin_args_length * sizeof (*plugin_args)); |
727 |
|
|
728 |
|
if (plugin_args) |
729 |
|
{ |
730 |
|
snprintf (plugin_args, plugin_args_length, |
731 |
|
"localhost PRIVMSG %s :%s", |
732 |
|
CHANNEL(buffer)->name, command); |
733 |
|
plugin_event_msg ("privmsg", server->name, plugin_args); |
734 |
|
free (plugin_args); |
735 |
|
} |
736 |
|
else |
737 |
|
{ |
738 |
|
irc_display_prefix (server->buffer, PREFIX_ERROR); |
739 |
|
gui_printf (server->buffer, |
740 |
|
_("%s unable to call handler for message (not enough memory)\n"), |
741 |
|
WEECHAT_ERROR); |
742 |
|
} |
743 |
} |
} |
744 |
else |
else |
745 |
{ |
{ |