Plugin Beispiel

Vollständiges Beispiel eines Plugins, welches das Kommando /double implementiert, dass seine Argumente im gegenwärtigen Channel doppelt ausgibt (ok, das ist weniger nützlich, aber auch nur ein Beispiel!):

#include <stdlib.h>

#include "weechat-plugin.h"

char plugin_name[]        = "Double";
char plugin_version[]     = "0.1";
char plugin_description[] = "Test plugin for WeeChat";

/* "/double" command manager */

int double_cmd (t_weechat_plugin *plugin, char *server,
                char *command, char *arguments,
                char *handler_args, void *handler_pointer)
{
    if (arguments && arguments[0] && (arguments[0] != '/'))
    {
        plugin->exec_command (plugin, NULL, NULL, arguments);
        plugin->exec_command (plugin, NULL, NULL, arguments);
    }
    return PLUGIN_RC_OK;
}

int weechat_plugin_init (t_weechat_plugin *plugin)
{
    plugin->cmd_handler_add (plugin, "double",
                             "Display two times a message",
                             "msg",
                             "msg: message to display two times",
                             NULL,
                             &double_cmd,
                             NULL, NULL);
    return PLUGIN_RC_OK;
}

void weechat_plugin_end (t_weechat_plugin *plugin)
{
    /* nothing done here */
}