Full example of plugin, which adds a /double command, which displays two times arguments on current channel (ok that's not very useful, but that's just an example!):
#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, int argc, char **argv,
char *handler_args, void *handler_pointer)
{
if (argv[2] && (argv[2][0] != '/'))
{
plugin->exec_command (plugin, NULL, NULL, argv[2]);
plugin->exec_command (plugin, NULL, NULL, argv[2]);
}
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 */
}