Add a /quote command to run twitch specific commands
--- a/src/meson.build Mon Feb 28 21:53:34 2022 -0600
+++ b/src/meson.build Mon Feb 28 22:41:06 2022 -0600
@@ -3,6 +3,8 @@
--- a/src/spasm-account.c Mon Feb 28 21:53:34 2022 -0600
+++ b/src/spasm-account.c Mon Feb 28 22:41:06 2022 -0600
@@ -383,3 +383,16 @@
+spasm_account_from_conversation(PurpleConversation *conv) { + PurpleConnection *connection = NULL; + g_return_val_if_fail(conv != NULL, NULL); + connection = purple_conversation_get_gc(conv); + if(connection == NULL) { + return purple_connection_get_protocol_data(connection); --- a/src/spasm-account.h Mon Feb 28 21:53:34 2022 -0600
+++ b/src/spasm-account.h Mon Feb 28 22:41:06 2022 -0600
@@ -61,6 +61,8 @@
SpasmChatService *spasm_account_get_chat_service(SpasmAccount *sa);
+SpasmAccount *spasm_account_from_conversation(PurpleConversation *conv); #endif /* SPASM_ACCOUNT_H */
--- a/src/spasm-chat.c Mon Feb 28 21:53:34 2022 -0600
+++ b/src/spasm-chat.c Mon Feb 28 22:41:06 2022 -0600
@@ -549,7 +549,7 @@
chat->output_stream = g_io_stream_get_output_stream(G_IO_STREAM(chat->socket_connection));
/* first check that we have the right capabilities */
- spasm_chat_service_real_send(chat, "CAP REQ :twitch.tv/membership twitch.tv/tags");
+ spasm_chat_service_real_send(chat, "CAP REQ :twitch.tv/commands twitch.tv/membership twitch.tv/tags"); spasm_chat_service_real_send(
@@ -734,3 +734,10 @@
+spasm_chat_service_send_raw(SpasmChatService *chat, const gchar *raw) { + g_return_if_fail(chat != NULL); + spasm_chat_service_real_send(chat, "%s", raw); --- a/src/spasm-chat.h Mon Feb 28 21:53:34 2022 -0600
+++ b/src/spasm-chat.h Mon Feb 28 22:41:06 2022 -0600
@@ -41,6 +41,8 @@
gint spasm_chat_service_send(PurpleConnection *connection, gint id, const gchar *message, PurpleMessageFlags flags);
void spasm_chat_service_set_topic(PurpleConnection *connection, gint id, const gchar *topic);
+void spasm_chat_service_send_raw(SpasmChatService *chat, const gchar *raw); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/spasm-commands.c Mon Feb 28 22:41:06 2022 -0600
@@ -0,0 +1,69 @@
+ * Spasm - A Twitch Protocol Plugin + * Copyright (C) 2017-2022 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#include "spasm-account.h" +#include "spasm-commands.h" +/****************************************************************************** + * Command Implementations + *****************************************************************************/ +spasm_command_quote(PurpleConversation *conv, const gchar *cmd, gchar **args, + gchar **error, gpointer data) + SpasmAccount *sa = spasm_account_from_conversation(conv); + SpasmChatService *chat = NULL; + gchar *msg = NULL, *quoted = NULL; + return PURPLE_CMD_RET_FAILED; + chat = spasm_account_get_chat_service(sa); + quoted = g_strjoinv(" ", args); + msg = g_strdup_printf("PRIVMSG #%s :%s", + purple_conversation_get_name(conv), + spasm_chat_service_send_raw(chat, msg); + return PURPLE_CMD_RET_OK; +/****************************************************************************** + *****************************************************************************/ +spasm_commands_register() { + f = PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY | + PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS; + purple_cmd_register("quote", "s", PURPLE_CMD_P_PRPL, f, + "prpl-grim-spasm", spasm_command_quote, + "quote [...]: Send a raw command to the server.", --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/spasm-commands.h Mon Feb 28 22:41:06 2022 -0600
@@ -0,0 +1,31 @@
+ * Spasm - A Twitch Protocol Plugin + * Copyright (C) 2017-2022 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifndef SPASM_COMMANDS_H +#define SPASM_COMMANDS_H +void spasm_commands_register(); +#endif /* SPASM_COMMANDS_H */ --- a/src/spasm-plugin.c Mon Feb 28 21:53:34 2022 -0600
+++ b/src/spasm-plugin.c Mon Feb 28 22:41:06 2022 -0600
@@ -66,6 +66,7 @@
spasm_plugin_init(PurplePlugin *plugin) {
+ spasm_commands_register(); static PurplePluginProtocolInfo spasm_protocol_info = {