grim/purple-spasm

Move the parsing to regex and make real_send add the trailing \r\n
/*
* Spasm - A Twitch Protocol Plugin
* Copyright (C) 2017-2020 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 <glib.h>
#include <glib/gi18n-lib.h>
#include <purple.h>
#include "spasm-account.h"
#include "spasm-const.h"
/******************************************************************************
* Simple Protocol Functions
*****************************************************************************/
static GList *
spasm_status_types(PurpleAccount *account) {
PurpleStatusType *type = NULL;
GList *types = NULL;
type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE);
types = g_list_append(types, type);
type = purple_status_type_new(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE);
types = g_list_append(types, type);
return types;
}
static const gchar *
spasm_list_icon(PurpleAccount *account, PurpleBuddy *buddy) {
return "spasm";
}
static void
spasm_close(PurpleConnection *connection) {
}
/******************************************************************************
* Purple2 Plugin Interface
*****************************************************************************/
static gboolean
spasm_plugin_load(PurplePlugin *plugin) {
return TRUE;
}
static gboolean
spasm_plugin_unload(PurplePlugin *plugin) {
return TRUE;
}
static void
spasm_plugin_init(PurplePlugin *plugin) {
}
static PurplePluginProtocolInfo spasm_protocol_info = {
.options = OPT_PROTO_NO_PASSWORD,
.login = spasm_account_login,
.close = spasm_close,
.list_icon = spasm_list_icon,
.status_types = spasm_status_types,
// chat stuff
.chat_info = spasm_chat_service_info,
.chat_info_defaults = spasm_chat_service_info_default,
.join_chat = spasm_chat_service_join,
.get_chat_name = spasm_chat_service_name,
.chat_leave = spasm_chat_service_leave,
.chat_send = spasm_chat_service_send,
.set_chat_topic = spasm_chat_service_set_topic,
};
static PurplePluginInfo info = {
.magic = PURPLE_PLUGIN_MAGIC,
.major_version = PURPLE_MAJOR_VERSION,
.minor_version = PURPLE_MINOR_VERSION,
.type = PURPLE_PLUGIN_PROTOCOL,
.id = SPASM_PLUGIN_ID,
.name = N_("Twitch.tv"),
.version = SPASM_VERSION,
.author = "Gary Kramlich <grim@reaperworld.com>",
.homepage = "https://keep.imfreedom.org/grim/purple-spasm",
.load = spasm_plugin_load,
.unload = spasm_plugin_unload,
.extra_info = &spasm_protocol_info,
};
PURPLE_INIT_PLUGIN(spasm, spasm_plugin_init, info);