mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
Merge pull request #15 from ailin-nemui/server-outgoing
Add a "server outgoing modify" signal to intercept outgoing messages
This commit is contained in:
commit
69358fbe7c
@ -151,6 +151,7 @@ irc.c:
|
|||||||
"whois default event", SERVER_REC, char *args, char *sender_nick, char *sender_address
|
"whois default event", SERVER_REC, char *args, char *sender_nick, char *sender_address
|
||||||
|
|
||||||
"server incoming", SERVER_REC, char *data
|
"server incoming", SERVER_REC, char *data
|
||||||
|
"server outgoing modify", SERVER_REC, GString *data
|
||||||
|
|
||||||
(for perl parser..)
|
(for perl parser..)
|
||||||
"redir "<cmd>, SERVER_REC, char *args, char *sender_nick, char *sender_address
|
"redir "<cmd>, SERVER_REC, char *args, char *sender_nick, char *sender_address
|
||||||
|
@ -734,9 +734,9 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now)
|
|||||||
{
|
{
|
||||||
REDIRECT_REC *redirect;
|
REDIRECT_REC *redirect;
|
||||||
GSList *link;
|
GSList *link;
|
||||||
|
GString *str;
|
||||||
long usecs;
|
long usecs;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!IS_IRC_SERVER(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return 0;
|
return 0;
|
||||||
@ -759,16 +759,20 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now)
|
|||||||
redirect = server->cmdqueue->next->data;
|
redirect = server->cmdqueue->next->data;
|
||||||
|
|
||||||
/* send command */
|
/* send command */
|
||||||
len = strlen(cmd);
|
str = g_string_new(cmd);
|
||||||
irc_server_send_data(server, cmd, len);
|
signal_emit("server outgoing modify", 2, server, str);
|
||||||
|
if (str->len) {
|
||||||
|
irc_server_send_data(server, str->str, str->len);
|
||||||
|
|
||||||
/* add to rawlog without [CR+]LF */
|
/* add to rawlog without [CR+]LF */
|
||||||
if (len > 2 && cmd[len-2] == '\r')
|
if (str->len > 2 && str->str[str->len - 2] == '\r')
|
||||||
cmd[len-2] = '\0';
|
str->str[str->len - 2] = '\0';
|
||||||
else if (cmd[len-1] == '\n')
|
else if (str->str[str->len - 1] == '\n')
|
||||||
cmd[len-1] = '\0';
|
str->str[str->len - 1] = '\0';
|
||||||
rawlog_output(server->rawlog, cmd);
|
rawlog_output(server->rawlog, str->str);
|
||||||
server_redirect_command(server, cmd, redirect);
|
server_redirect_command(server, str->str, redirect);
|
||||||
|
}
|
||||||
|
g_string_free(str, TRUE);
|
||||||
|
|
||||||
/* remove from queue */
|
/* remove from queue */
|
||||||
server->cmdqueue = g_slist_remove(server->cmdqueue, cmd);
|
server->cmdqueue = g_slist_remove(server->cmdqueue, cmd);
|
||||||
|
@ -113,20 +113,25 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, int irc_send_whe
|
|||||||
g_string_append(str, cmd);
|
g_string_append(str, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irc_send_when == IRC_SEND_NOW) {
|
|
||||||
rawlog_output(server->rawlog, str->str);
|
|
||||||
server_redirect_command(server, str->str, server->redirect_next);
|
|
||||||
server->redirect_next = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
/* Add CR+LF to command */
|
/* Add CR+LF to command */
|
||||||
g_string_append_c(str, 13);
|
g_string_append_c(str, 13);
|
||||||
g_string_append_c(str, 10);
|
g_string_append_c(str, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irc_send_when == IRC_SEND_NOW) {
|
if (irc_send_when == IRC_SEND_NOW) {
|
||||||
irc_server_send_data(server, str->str, str->len);
|
signal_emit("server outgoing modify", 2, server, str);
|
||||||
|
if (str->len) {
|
||||||
|
irc_server_send_data(server, str->str, str->len);
|
||||||
|
|
||||||
|
/* add to rawlog without [CR+]LF */
|
||||||
|
if (str->len > 2 && str->str[str->len - 2] == '\r')
|
||||||
|
str->str[str->len - 2] = '\0';
|
||||||
|
else if (str->str[str->len - 1] == '\n')
|
||||||
|
str->str[str->len - 1] = '\0';
|
||||||
|
rawlog_output(server->rawlog, str->str);
|
||||||
|
server_redirect_command(server, str->str, server->redirect_next);
|
||||||
|
}
|
||||||
g_string_free(str, TRUE);
|
g_string_free(str, TRUE);
|
||||||
} else if (irc_send_when == IRC_SEND_NEXT) {
|
} else if (irc_send_when == IRC_SEND_NEXT) {
|
||||||
/* add to queue */
|
/* add to queue */
|
||||||
|
Loading…
Reference in New Issue
Block a user