From 1007af9506dc94f3ab41ee52e4899182a48c8dec Mon Sep 17 00:00:00 2001 From: TingPing Date: Tue, 17 Sep 2013 18:19:02 -0400 Subject: [PATCH] Add message arguement to /query Closes #757 --- src/common/outbound.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/common/outbound.c b/src/common/outbound.c index a35ba429..42e2eeee 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -2980,17 +2980,43 @@ static int cmd_query (struct session *sess, char *tbuf, char *word[], char *word_eol[]) { char *nick = word[2]; + char *msg = word_eol[3]; + char *split_text = NULL; gboolean focus = TRUE; + int cmd_length = 13; /* " PRIVMSG ", " ", :, \r, \n */ + int offset = 0; if (strcmp (word[2], "-nofocus") == 0) { nick = word[3]; + msg = word_eol[4]; focus = FALSE; } if (*nick && !is_channel (sess->server, nick)) { open_query (sess->server, nick, focus); + + if (*msg) + { + if (!sess->server->connected) + { + notc_msg (sess); + return TRUE; + } + + while ((split_text = split_up_text (sess, msg + offset, cmd_length, split_text))) + { + sess->server->p_message (sess->server, nick, split_text); + + if (*split_text) + offset += strlen(split_text); + + g_free(split_text); + } + sess->server->p_message (sess->server, nick, msg + offset); + } + return TRUE; } return FALSE; @@ -3936,7 +3962,7 @@ const struct commands xc_cmds[] = { {"PING", cmd_ping, 1, 0, 1, N_("PING , CTCP pings nick or channel")}, {"QUERY", cmd_query, 0, 0, 1, - N_("QUERY [-nofocus] , opens up a new privmsg window to someone")}, + N_("QUERY [-nofocus] [message], opens up a new privmsg window to someone and optionally sends a message")}, {"QUIET", cmd_quiet, 1, 1, 1, N_("QUIET [], quiet everyone matching the mask in the current channel if supported by the server.")}, {"QUIT", cmd_quit, 0, 0, 1,