# HG changeset patch
# Node ID 324d04bcf6b5fc279b66bca826017782c279579d
# Parent  1f63e7d9d6897d353959d7ff2a8adfc3c801ce73
diff --git a/protocols/ircv3/purpleircv3commands.c b/protocols/ircv3/purpleircv3commands.c
--- a/protocols/ircv3/purpleircv3commands.c
+++ b/protocols/ircv3/purpleircv3commands.c
@@ -33,45 +33,77 @@
                               GStrv params,
                               G_GNUC_UNUSED gpointer data)
 {
-    PurpleIRCv3Connection *v3_connection = NULL;
-    PurpleAccount *account = NULL;
-    PurpleConnection *connection = NULL;
-    PurpleConversation *new_conversation = NULL;
-    guint n_params = 0;
+	PurpleIRCv3Connection *v3_connection = NULL;
+	PurpleAccount *account = NULL;
+	PurpleConnection *connection = NULL;
+	PurpleConversation *new_conversation = NULL;
+	guint n_params = 0;
+
+	n_params = g_strv_length(params);
+	if(n_params < 1) {
+		return FALSE;
+	}
+
+	account = purple_conversation_get_account(conversation);
+	connection = purple_account_get_connection(account);
+	v3_connection = PURPLE_IRCV3_CONNECTION(connection);
+
+	new_conversation = purple_ircv3_connection_find_or_create_conversation(v3_connection,
+	                                                                       params[0]);
 
-    n_params = g_strv_length(params);
-    if(n_params < 1) {
-        return FALSE;
-    }
+	if(n_params > 1) {
+		PurpleMessage *message = NULL;
+		PurpleContactInfo *info = NULL;
+		PurpleConversationMember *member = NULL;
+		PurpleConversationMembers *members = NULL;
+		char *contents = NULL;
 
-    account = purple_conversation_get_account(conversation);
-    connection = purple_account_get_connection(account);
-    v3_connection = PURPLE_IRCV3_CONNECTION(connection);
+		info = purple_account_get_contact_info(account);
+		members = purple_conversation_get_members(conversation);
+		member = purple_conversation_members_find_member(members, info);
+
+		contents = g_strjoinv(" ", params + 1);
 
-    new_conversation = purple_ircv3_connection_find_or_create_conversation(v3_connection,
-                                                                           params[0]);
+		message = purple_message_new(member, contents);
+		g_free(contents);
+
+		purple_conversation_send_message_async(new_conversation, message, NULL,
+		                                       NULL, NULL);
 
-    if(n_params > 1) {
-        PurpleMessage *message = NULL;
-        PurpleContactInfo *info = NULL;
-        PurpleConversationMember *member = NULL;
-        PurpleConversationMembers *members = NULL;
-        char *contents = NULL;
+		g_clear_object(&message);
+	}
+
+	return TRUE;
+}
 
-        info = purple_account_get_contact_info(account);
-        members = purple_conversation_get_members(conversation);
-        member = purple_conversation_members_find_member(members, info);
+gboolean
+purple_ircv3_command_quote_cb(G_GNUC_UNUSED PurpleCommand *command,
+                              PurpleConversation *conversation,
+                              GStrv params,
+                              G_GNUC_UNUSED gpointer data)
+{
+	IbisMessage *message = NULL;
+	char *raw = NULL;
+
+	raw = g_strjoinv(" ", params);
+	message = ibis_message_parse(raw, NULL);
+	g_free(raw);
 
-        contents = g_strjoinv(" ", params + 1);
-
-        message = purple_message_new(member, contents);
-        g_free(contents);
+	if(IBIS_IS_MESSAGE(message)) {
+		PurpleIRCv3Connection *v3_connection = NULL;
+		PurpleAccount *account = NULL;
+		PurpleConnection *connection = NULL;
+		IbisClient *client = NULL;
 
-        purple_conversation_send_message_async(new_conversation, message, NULL,
-                                               NULL, NULL);
+		account = purple_conversation_get_account(conversation);
+		connection = purple_account_get_connection(account);
+		v3_connection = PURPLE_IRCV3_CONNECTION(connection);
+		client = purple_ircv3_connection_get_client(v3_connection);
 
-        g_clear_object(&message);
-    }
+		ibis_client_write(client, message);
 
-    return TRUE;
+		return TRUE;
+	}
+
+	return FALSE;
 }
diff --git a/protocols/ircv3/purpleircv3commands.h b/protocols/ircv3/purpleircv3commands.h
--- a/protocols/ircv3/purpleircv3commands.h
+++ b/protocols/ircv3/purpleircv3commands.h
@@ -35,6 +35,7 @@
 G_BEGIN_DECLS
 
 G_GNUC_INTERNAL gboolean purple_ircv3_command_query_cb(PurpleCommand *command, PurpleConversation *conversation, GStrv params, gpointer data);
+G_GNUC_INTERNAL gboolean purple_ircv3_command_quote_cb(PurpleCommand *command, PurpleConversation *conversation, GStrv params, gpointer data);
 
 G_END_DECLS
 
diff --git a/protocols/ircv3/purpleircv3protocol.c b/protocols/ircv3/purpleircv3protocol.c
--- a/protocols/ircv3/purpleircv3protocol.c
+++ b/protocols/ircv3/purpleircv3protocol.c
@@ -243,6 +243,15 @@
 	                        G_CALLBACK(purple_ircv3_command_query_cb),
 	                        protocol, G_CONNECT_DEFAULT);
 	purple_command_manager_add(manager, command);
+
+	command = purple_command_new("quote", "IRCv3", 1000);
+	purple_command_set_summary(command,
+	                           _("Sends the command directly to the server"));
+	tags = purple_command_get_tags(command);
+	g_signal_connect_object(command, "executed",
+	                        G_CALLBACK(purple_ircv3_command_quote_cb),
+	                        protocol, G_CONNECT_DEFAULT);
+	purple_command_manager_add(manager, command);
 }
 
 static void
