grim/purple-spasm

First stab at emote support. It kind of works...
draft emotes
2020-06-18, Gary Kramlich
1eb66b376722
First stab at emote support. It kind of works...
/*
* 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 <purple.h>
#include "spasm-account.h"
#include "spasm-chat.h"
#include "spasm-commands.h"
/******************************************************************************
* Command Implementations
*****************************************************************************/
static PurpleCmdRet
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;
if(sa == 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),
quoted);
g_free(quoted);
spasm_chat_service_send_raw(chat, msg);
g_free(msg);
return PURPLE_CMD_RET_OK;
}
/******************************************************************************
* Public API
*****************************************************************************/
void
spasm_commands_register() {
PurpleCmdFlag f;
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.",
NULL);
}