Pidgin

来自百合仙子's Wiki
跳转到导航 跳转到搜索

快捷键

在聊天窗口输入框,使用C-↑/↓来获取聊天历史内容。

快捷键配置文件位于 ~/.purple/accels

插件

colorize
将发出的文本以彩色渐变显示(作为 HTML 消息)
位于 purple-plugin-pack 软件包中
XMPP Receipt
XMPP 消息回执(XEP 0184
https://www.assembla.com/code/pidgin-xmpp-receipts/git/nodes
hotkeys
配置全局快捷键。但是(提取消息时)不能切换桌面

插件编写

pidgin的插件可以使用C或者Perl编写。

C插件示例

#define PURPLE_PLUGINS

#include <string.h>
#include <conversation.h>
#include <debug.h>
#include <plugin.h>
#include <signals.h>
#include <util.h>
#include <version.h>
#include <glib/gprintf.h>

static gboolean receiving_im_msg_cb(PurpleAccount *account, char **sender, 
    char **message, PurpleConversation *conv, PurpleMessageFlags *flags){

  if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM){
    if(g_str_has_prefix(*sender, "vim-cn@appspot.com") &&
	g_str_has_prefix(*message, "[")){
      gchar **parts = g_strsplit_set(*message, "[]", 3);
      gchar *tmp = g_strconcat("<b>", parts[1], "</b>", parts[2], parts[3], NULL);
      g_free(*message);
      g_strfreev(parts);
      *message = tmp;
    }else if(g_str_has_prefix(*sender, "rain-cloud@appspot.com") &&
	g_str_has_prefix(*message, "<b>")){
      gchar **parts = g_strsplit(*message, " :", 2);
      gchar *tmp = g_strconcat(parts[0], parts[1], NULL);
      g_free(*message);
      g_strfreev(parts);
      *message = tmp;
    }
  }
  /* forward the message */
  return FALSE;
}

static gboolean plugin_load(PurplePlugin *plugin) {
	void *conversation = purple_conversations_get_handle();

	purple_signal_connect(conversation, "receiving-im-msg",
	    plugin, PURPLE_CALLBACK(receiving_im_msg_cb), NULL);

	return TRUE;
}

static PurplePluginUiInfo prefs_info = {
	NULL,
	0,    /* page_num (Reserved) */
	NULL, /* frame (Reserved)    */
	/* Padding */
	NULL,
	NULL,
	NULL,
	NULL
};

static PurplePluginInfo info =
{
        PURPLE_PLUGIN_MAGIC,             /* magic              */
        PURPLE_MAJOR_VERSION,            /* major version      */
        PURPLE_MINOR_VERSION,            /* minor version      */
        PURPLE_PLUGIN_STANDARD,          /* type               */
        NULL,                            /* ui_requirement     */
        0,                               /* flags              */
        NULL,                            /* dependencies       */
        PURPLE_PRIORITY_DEFAULT,         /* priority           */

        "chatgroup",                     /* id                 */
        "更好地显示群聊消息",                /* name               */
        "0.1",                           /* version            */
        "更好地显示群聊消息",               /* summary            */
        "更好地显示群聊消息",               /* description        */
        "Email here",                    /* author             */
        "Website here",                  /* homepage           */

        plugin_load,                     /* load               */
        NULL,                            /* unload             */
        NULL,                            /* destroy            */

        NULL,                            /* ui_info            */
        NULL,                            /* extra_info         */
        &prefs_info,                     /* prefs_info         */
        NULL,                            /* actions            */

	/* padding */
	NULL,
	NULL,
	NULL,
	NULL
};

static void init_plugin(PurplePlugin *plugin) {
}

PURPLE_INIT_PLUGIN(groupchat, init_plugin, info)

Perl插件示例

use utf8;
use Purple;

%PLUGIN_INFO = (
    perl_api_version => 2,
    name => "xqbot message cleaner",
    version => "0.1",
    summary => "xqbot message cleaner",
    description => "xqbot message cleaner",
    author => "lilydjwg <lilydjwg\@gmail.com>",
    url => "http://blog.lilydjwg.me/",
    load => "plugin_load",
    unload => "plugin_unload"
);
sub plugin_init {
    return %PLUGIN_INFO;
}
sub plugin_load {
    my $plugin = shift;
    $convs_handle = Purple::Conversations::get_handle();
    Purple::Signal::connect($convs_handle, "receiving-im-msg", $plugin,
                            \&receiving_im_msg_cb, "yyy");
    Purple::Debug::info("xqbotEnhanced", "xqbotEnhanced Plugin Loaded.\n");
}
sub plugin_unload {
    my $plugin = shift;
    Purple::Debug::info("xqbotEnhanced", "xqbotEnhanced Plugin Unloaded.\n");
}
sub receiving_im_msg_cb {
    my ($account, $who, $msg, $conv, $flags) = @_;
    my $badmsg = '^你使用了|^\*来自\[';
    if ($who =~ /^z\@lisux\.tk/ && $msg =~ $badmsg) {
      Purple::Debug::info("xqbotEnhanced", "$msg ignored.\n");
      return 1;
    } else {
      return 0;
    }
}

外部链接

插件

插件列表

参见