1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 12:26:40 +02:00

Added "modifier" in plugins API, improved /plugin command

This commit is contained in:
Sebastien Helleu
2006-10-24 11:23:31 +00:00
parent 1e81591803
commit dfa9ed31d4
68 changed files with 11080 additions and 5962 deletions
+158 -37
View File
@@ -141,6 +141,23 @@ weechat_lua_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_lua_modifier: general modifier for Lua
*/
char *
weechat_lua_modifier (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
/*if (argc >= 2)
return weechat_lua_exec (plugin, (t_plugin_script *)modifier_pointer,
modifier_args, argv[0], argv[1], NULL);
else
return NULL;*/
return NULL;
}
/*
* weechat_lua_register: startup function for all WeeChat Lua scripts
*/
@@ -875,6 +892,108 @@ weechat_lua_remove_keyboard_handler (lua_State *L)
return 1;
}
/*
* weechat_lua_add_modifier: add a modifier
*/
static int
weechat_lua_add_modifier (lua_State *L)
{
const char *type, *command, *function;
int n;
/* make gcc happy */
(void) L;
if (!lua_current_script)
{
lua_plugin->print_server (lua_plugin,
"Lua error: unable to add modifier, "
"script not initialized");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
type = NULL;
command = NULL;
function = NULL;
n = lua_gettop (lua_current_interpreter);
if (n != 3)
{
lua_plugin->print_server (lua_plugin,
"Lua error: wrong parameters for "
"\"add_modifier\" function");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
type = lua_tostring (lua_current_interpreter, -3);
command = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
if (!lua_plugin->modifier_add (lua_plugin, (char *)type, (char *)command,
weechat_lua_modifier,
(char *)function,
(void *)lua_current_script))
{
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
lua_pushnumber (lua_current_interpreter, 1);
return 1;
}
/*
* weechat_lua_remove_modifier: remove a modifier
*/
static int
weechat_lua_remove_modifier (lua_State *L)
{
const char *type, *command, *function;
int n;
/* make gcc happy */
(void) L;
if (!lua_current_script)
{
lua_plugin->print_server (lua_plugin,
"Lua error: unable to remove modifier, "
"script not initialized");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
command = NULL;
function = NULL;
n = lua_gettop (lua_current_interpreter);
if (n != 2)
{
lua_plugin->print_server (lua_plugin,
"Lua error: wrong parameters for "
"\"remove_modifier\" function");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
type = lua_tostring (lua_current_interpreter, -3);
command = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
weechat_script_remove_modifier (lua_plugin, lua_current_script,
(char *)type, (char *)command,
(char *)function);
lua_pushnumber (lua_current_interpreter, 1);
return 1;
}
/*
* weechat_lua_get_info: get various infos
*/
@@ -1882,40 +2001,42 @@ weechat_lua_constant_plugin_rc_ok_ignore_all (lua_State *L)
static
const struct luaL_reg weechat_lua_funcs[] = {
{ "register", weechat_lua_register},
{ "print", weechat_lua_print},
{ "print_server", weechat_lua_print_server},
{ "print_infobar", weechat_lua_print_infobar},
{ "remove_infobar", weechat_lua_remove_infobar},
{ "log", weechat_lua_log},
{ "command", weechat_lua_command},
{ "add_message_handler", weechat_lua_add_message_handler},
{ "add_command_handler", weechat_lua_add_command_handler},
{ "add_timer_handler", weechat_lua_add_timer_handler},
{ "add_keyboard_handler", weechat_lua_add_keyboard_handler},
{ "remove_handler", weechat_lua_remove_handler},
{ "remove_timer_handler", weechat_lua_remove_timer_handler},
{ "remove_keyboard_handler", weechat_lua_remove_keyboard_handler},
{ "get_info", weechat_lua_get_info},
{ "get_dcc_info", weechat_lua_get_dcc_info},
{ "get_config", weechat_lua_get_config},
{ "set_config", weechat_lua_set_config},
{ "get_plugin_config", weechat_lua_get_plugin_config},
{ "set_plugin_config", weechat_lua_set_plugin_config},
{ "get_server_info", weechat_lua_get_server_info},
{ "get_channel_info", weechat_lua_get_channel_info},
{ "get_nick_info", weechat_lua_get_nick_info},
{ "get_irc_color", weechat_lua_get_irc_color},
{ "get_window_info", weechat_lua_get_window_info},
{ "get_buffer_info", weechat_lua_get_buffer_info},
{ "get_buffer_data", weechat_lua_get_buffer_data},
{ "register", weechat_lua_register },
{ "print", weechat_lua_print },
{ "print_server", weechat_lua_print_server },
{ "print_infobar", weechat_lua_print_infobar },
{ "remove_infobar", weechat_lua_remove_infobar },
{ "log", weechat_lua_log },
{ "command", weechat_lua_command },
{ "add_message_handler", weechat_lua_add_message_handler },
{ "add_command_handler", weechat_lua_add_command_handler },
{ "add_timer_handler", weechat_lua_add_timer_handler },
{ "add_keyboard_handler", weechat_lua_add_keyboard_handler },
{ "remove_handler", weechat_lua_remove_handler },
{ "remove_timer_handler", weechat_lua_remove_timer_handler },
{ "remove_keyboard_handler", weechat_lua_remove_keyboard_handler },
{ "add_modifier", weechat_lua_add_modifier },
{ "remove_modifier", weechat_lua_remove_modifier },
{ "get_info", weechat_lua_get_info },
{ "get_dcc_info", weechat_lua_get_dcc_info },
{ "get_config", weechat_lua_get_config },
{ "set_config", weechat_lua_set_config },
{ "get_plugin_config", weechat_lua_get_plugin_config },
{ "set_plugin_config", weechat_lua_set_plugin_config },
{ "get_server_info", weechat_lua_get_server_info },
{ "get_channel_info", weechat_lua_get_channel_info },
{ "get_nick_info", weechat_lua_get_nick_info },
{ "get_irc_color", weechat_lua_get_irc_color },
{ "get_window_info", weechat_lua_get_window_info },
{ "get_buffer_info", weechat_lua_get_buffer_info },
{ "get_buffer_data", weechat_lua_get_buffer_data },
/* define constants as function which returns values */
{ "PLUGIN_RC_OK", weechat_lua_constant_plugin_rc_ok},
{ "PLUGIN_RC_KO", weechat_lua_constant_plugin_rc_ko},
{ "PLUGIN_RC_OK_IGNORE_WEECHAT", weechat_lua_constant_plugin_rc_ok_ignore_weechat},
{ "PLUGIN_RC_OK_IGNORE_PLUGINS", weechat_lua_constant_plugin_rc_ok_ignore_plugins},
{ "PLUGIN_RC_OK_IGNORE_ALL", weechat_lua_constant_plugin_rc_ok_ignore_all},
{ NULL, NULL}
{ "PLUGIN_RC_OK", weechat_lua_constant_plugin_rc_ok },
{ "PLUGIN_RC_KO", weechat_lua_constant_plugin_rc_ko },
{ "PLUGIN_RC_OK_IGNORE_WEECHAT", weechat_lua_constant_plugin_rc_ok_ignore_weechat },
{ "PLUGIN_RC_OK_IGNORE_PLUGINS", weechat_lua_constant_plugin_rc_ok_ignore_plugins },
{ "PLUGIN_RC_OK_IGNORE_ALL", weechat_lua_constant_plugin_rc_ok_ignore_all },
{ NULL, NULL }
};
int
@@ -2142,7 +2263,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_MESSAGE)
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2161,7 +2282,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2180,7 +2301,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_TIMER)
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2199,7 +2320,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_KEYBOARD)
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& (ptr_handler->handler_args))
{
handler_found = 1;
+101 -4
View File
@@ -246,6 +246,23 @@ weechat_perl_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_perl_modifier: general modifier for Perl
*/
char *
weechat_perl_modifier (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
/*if (argc >= 2)
return weechat_perl_exec (plugin, (t_plugin_script *)modifier_pointer,
modifier_args, argv[0], argv[1], NULL);
else
return NULL;*/
return NULL;
}
/*
* weechat::register: startup function for all WeeChat Perl scripts
*/
@@ -818,6 +835,84 @@ static XS (XS_weechat_remove_keyboard_handler)
XSRETURN_YES;
}
/*
* weechat::add_modifier: add a modifier
*/
static XS (XS_weechat_add_modifier)
{
char *type, *command, *function;
dXSARGS;
/* make gcc happy */
(void) cv;
if (!perl_current_script)
{
perl_plugin->print_server (perl_plugin,
"Perl error: unable to add modifier, "
"script not initialized");
XSRETURN_NO;
}
if (items < 3)
{
perl_plugin->print_server (perl_plugin,
"Perl error: wrong parameters for "
"\"add_modifier\" function");
XSRETURN_NO;
}
type = SvPV (ST (0), PL_na);
command = SvPV (ST (1), PL_na);
function = SvPV (ST (2), PL_na);
if (perl_plugin->modifier_add (perl_plugin, type, command,
weechat_perl_modifier, function,
(void *)perl_current_script))
XSRETURN_YES;
XSRETURN_NO;
}
/*
* weechat::remove_modifier: remove a modifier
*/
static XS (XS_weechat_remove_modifier)
{
char *type, *command, *function;
dXSARGS;
/* make gcc happy */
(void) cv;
if (!perl_current_script)
{
perl_plugin->print_server (perl_plugin,
"Perl error: unable to remove modifier, "
"script not initialized");
XSRETURN_NO;
}
if (items < 2)
{
perl_plugin->print_server (perl_plugin,
"Perl error: wrong parameters for "
"\"remove_modifier\" function");
XSRETURN_NO;
}
type = SvPV (ST (0), PL_na);
command = SvPV (ST (1), PL_na);
function = SvPV (ST (2), PL_na);
weechat_script_remove_modifier (perl_plugin, perl_current_script,
type, command, function);
XSRETURN_YES;
}
/*
* weechat::get_info: get various infos
*/
@@ -1599,6 +1694,8 @@ weechat_perl_xs_init (pTHX)
newXS ("weechat::remove_handler", XS_weechat_remove_handler, "weechat");
newXS ("weechat::remove_timer_handler", XS_weechat_remove_timer_handler, "weechat");
newXS ("weechat::remove_keyboard_handler", XS_weechat_remove_keyboard_handler, "weechat");
newXS ("weechat::add_modifier", XS_weechat_add_modifier, "weechat");
newXS ("weechat::remove_modifier", XS_weechat_remove_modifier, "weechat");
newXS ("weechat::get_info", XS_weechat_get_info, "weechat");
newXS ("weechat::get_dcc_info", XS_weechat_get_dcc_info, "weechat");
newXS ("weechat::get_config", XS_weechat_get_config, "weechat");
@@ -1869,7 +1966,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_MESSAGE)
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -1888,7 +1985,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -1907,7 +2004,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_TIMER)
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -1926,7 +2023,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_KEYBOARD)
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& (ptr_handler->handler_args))
{
handler_found = 1;
+102 -4
View File
@@ -172,6 +172,23 @@ weechat_python_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_python_modifier: general modifier for Python
*/
char *
weechat_python_modifier (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
/*if (argc >= 2)
return weechat_python_exec (plugin, (t_plugin_script *)modifier_pointer,
modifier_args, argv[0], argv[1], NULL);
else
return NULL;*/
return NULL;
}
/*
* weechat_python_register: startup function for all WeeChat Python scripts
*/
@@ -735,6 +752,85 @@ weechat_python_remove_keyboard_handler (PyObject *self, PyObject *args)
return Py_BuildValue ("i", 1);
}
/*
* weechat_python_add_modifier: add a modifier
*/
static PyObject *
weechat_python_add_modifier (PyObject *self, PyObject *args)
{
char *type, *command, *function;
/* make gcc happy */
(void) self;
if (!python_current_script)
{
python_plugin->print_server (python_plugin,
"Python error: unable to add modifier, "
"script not initialized");
return Py_BuildValue ("i", 0);
}
type = NULL;
command = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "sss", &type, &command, &function))
{
python_plugin->print_server (python_plugin,
"Python error: wrong parameters for "
"\"add_modifier\" function");
return Py_BuildValue ("i", 0);
}
if (python_plugin->modifier_add (python_plugin, type, command,
weechat_python_modifier,
function,
(void *)python_current_script))
return Py_BuildValue ("i", 1);
return Py_BuildValue ("i", 0);
}
/*
* weechat_python_remove_modifier: remove a modifier
*/
static PyObject *
weechat_python_remove_modifier (PyObject *self, PyObject *args)
{
char *type, *command, *function;
/* make gcc happy */
(void) self;
if (!python_current_script)
{
python_plugin->print_server (python_plugin,
"Python error: unable to remove modifier, "
"script not initialized");
return Py_BuildValue ("i", 0);
}
type = NULL;
command = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "sss", &type, &command, &function))
{
python_plugin->print_server (python_plugin,
"Python error: wrong parameters for "
"\"remove_modifier\" function");
return Py_BuildValue ("i", 0);
}
weechat_script_remove_modifier (python_plugin, python_current_script,
type, command, function);
return Py_BuildValue ("i", 1);
}
/*
* weechat_python_get_info: get various infos
*/
@@ -1520,6 +1616,8 @@ PyMethodDef weechat_python_funcs[] = {
{ "remove_handler", weechat_python_remove_handler, METH_VARARGS, "" },
{ "remove_timer_handler", weechat_python_remove_timer_handler, METH_VARARGS, "" },
{ "remove_keyboard_handler", weechat_python_remove_keyboard_handler, METH_VARARGS, "" },
{ "add_modifier", weechat_python_add_modifier, METH_VARARGS, "" },
{ "remove_modifier", weechat_python_remove_modifier, METH_VARARGS, "" },
{ "get_info", weechat_python_get_info, METH_VARARGS, "" },
{ "get_dcc_info", weechat_python_get_dcc_info, METH_VARARGS, "" },
{ "get_config", weechat_python_get_config, METH_VARARGS, "" },
@@ -1815,7 +1913,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_MESSAGE)
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -1834,7 +1932,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -1853,7 +1951,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_TIMER)
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -1872,7 +1970,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_KEYBOARD)
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& (ptr_handler->handler_args))
{
handler_found = 1;
+119 -5
View File
@@ -79,7 +79,7 @@ protect_funcall0(VALUE arg)
*/
VALUE
rb_protect_funcall(VALUE recv, ID mid, int *state, int argc, ...)
rb_protect_funcall (VALUE recv, ID mid, int *state, int argc, ...)
{
va_list ap;
VALUE *argv;
@@ -218,6 +218,23 @@ weechat_ruby_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_ruby_modifier: general modifier for Ruby
*/
char *
weechat_ruby_modifier (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
/*if (argc >= 2)
return weechat_ruby_exec (plugin, (t_plugin_script *)modifier_pointer,
modifier_args, argv[0], argv[1], NULL);
else
return NULL;*/
return NULL;
}
/*
* weechat_ruby_register: startup function for all WeeChat Ruby scripts
*/
@@ -930,6 +947,101 @@ weechat_ruby_remove_keyboard_handler (VALUE class, VALUE function)
return INT2FIX (1);
}
/*
* weechat_ruby_add_modifier: add a modifier
*/
static VALUE
weechat_ruby_add_modifier (VALUE class, VALUE type, VALUE message, VALUE function)
{
char *c_type, *c_message, *c_function;
/* make gcc happy */
(void) class;
if (!ruby_current_script)
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: unable to add modifier, "
"script not initialized");
return INT2FIX (0);
}
c_type = NULL;
c_message = NULL;
c_function = NULL;
if (NIL_P (type) || NIL_P (message) || NIL_P (function))
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: wrong parameters for "
"\"add_modifier\" function");
return INT2FIX (0);
}
Check_Type (type, T_STRING);
Check_Type (message, T_STRING);
Check_Type (function, T_STRING);
c_type = STR2CSTR (type);
c_message = STR2CSTR (message);
c_function = STR2CSTR (function);
if (ruby_plugin->modifier_add (ruby_plugin, c_type, c_message,
weechat_ruby_modifier,
c_function,
(void *)ruby_current_script))
return INT2FIX (1);
return INT2FIX (0);
}
/*
* weechat_ruby_remove_modifier: remove a modifier
*/
static VALUE
weechat_ruby_remove_modifier (VALUE class, VALUE type, VALUE command, VALUE function)
{
char *c_type, *c_command, *c_function;
/* make gcc happy */
(void) class;
if (!ruby_current_script)
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: unable to remove modifier, "
"script not initialized");
return INT2FIX (0);
}
c_type = NULL;
c_command = NULL;
c_function = NULL;
if (NIL_P (type) || NIL_P (command) || NIL_P (function))
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: wrong parameters for "
"\"remove_modifier\" function");
return INT2FIX (0);
}
Check_Type (type, T_STRING);
Check_Type (command, T_STRING);
Check_Type (function, T_STRING);
c_type = STR2CSTR (type);
c_command = STR2CSTR (command);
c_function = STR2CSTR (function);
weechat_script_remove_modifier (ruby_plugin, ruby_current_script,
c_type, c_command, c_function);
return INT2FIX (1);
}
/*
* weechat_ruby_get_info: get various infos
*/
@@ -2022,7 +2134,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_MESSAGE)
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2041,7 +2153,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2060,7 +2172,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_TIMER)
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2079,7 +2191,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
for (ptr_handler = plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_KEYBOARD)
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& (ptr_handler->handler_args))
{
handler_found = 1;
@@ -2212,6 +2324,8 @@ weechat_plugin_init (t_weechat_plugin *plugin)
rb_define_module_function (ruby_mWeechat, "remove_handler", weechat_ruby_remove_handler, 2);
rb_define_module_function (ruby_mWeechat, "remove_timer_handler", weechat_ruby_remove_timer_handler, 1);
rb_define_module_function (ruby_mWeechat, "remove_keyboard_handler", weechat_ruby_remove_keyboard_handler, 1);
rb_define_module_function (ruby_mWeechat, "add_modifier", weechat_ruby_add_modifier, 3);
rb_define_module_function (ruby_mWeechat, "remove_modifier", weechat_ruby_remove_modifier, 3);
rb_define_module_function (ruby_mWeechat, "get_info", weechat_ruby_get_info, -1);
rb_define_module_function (ruby_mWeechat, "get_dcc_info", weechat_ruby_get_dcc_info, 0);
rb_define_module_function (ruby_mWeechat, "get_config", weechat_ruby_get_config, 1);
+49 -4
View File
@@ -293,9 +293,9 @@ weechat_script_remove_handler (t_weechat_plugin *plugin,
while (ptr_handler)
{
ptr_arg1 = NULL;
if (ptr_handler->type == HANDLER_MESSAGE)
if (ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
ptr_arg1 = ptr_handler->irc_command;
else if (ptr_handler->type == HANDLER_COMMAND)
else if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
ptr_arg1 = ptr_handler->command;
if ((ptr_arg1)
@@ -327,7 +327,7 @@ weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
ptr_handler = plugin->handlers;
while (ptr_handler)
{
if ((ptr_handler->type == HANDLER_TIMER)
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
{
@@ -355,7 +355,7 @@ weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
ptr_handler = plugin->handlers;
while (ptr_handler)
{
if ((ptr_handler->type == HANDLER_KEYBOARD)
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
{
@@ -368,6 +368,51 @@ weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
}
}
/*
* weechat_script_remove_modifier: remove a modifier
* arg1=type, arg2=command, arg3=function
*/
void
weechat_script_remove_modifier (t_weechat_plugin *plugin,
t_plugin_script *script,
char *arg1, char *arg2, char *arg3)
{
t_plugin_modifier *ptr_modifier, *next_modifier;
t_plugin_modifier_type type;
char *ptr_arg2;
if (strcasecmp (arg1, PLUGIN_MODIFIER_IRC_IN_STR) == 0)
type = PLUGIN_MODIFIER_IRC_IN;
else if (strcasecmp (arg1, PLUGIN_MODIFIER_IRC_USER_STR) == 0)
type = PLUGIN_MODIFIER_IRC_USER;
else if (strcasecmp (arg1, PLUGIN_MODIFIER_IRC_OUT_STR) == 0)
type = PLUGIN_MODIFIER_IRC_OUT;
else
return;
/* search and remove modifiers */
ptr_modifier = plugin->modifiers;
while (ptr_modifier)
{
ptr_arg2 = NULL;
if (ptr_modifier->type == type)
ptr_arg2 = ptr_modifier->command;
if ((ptr_arg2)
&& ((t_plugin_script *)ptr_modifier->modifier_pointer == script)
&& (plugin->ascii_strcasecmp (plugin, ptr_arg2, arg2) == 0)
&& (plugin->ascii_strcasecmp (plugin, ptr_modifier->modifier_args, arg3) == 0))
{
next_modifier = ptr_modifier->next_modifier;
plugin->modifier_remove (plugin, ptr_modifier);
ptr_modifier = next_modifier;
}
else
ptr_modifier = ptr_modifier->next_modifier;
}
}
/*
* weechat_script_get_plugin_config: get a value of a script option
* format in file is: plugin.script.option=value
+3
View File
@@ -59,6 +59,9 @@ extern void weechat_script_remove_timer_handler (t_weechat_plugin *,
extern void weechat_script_remove_keyboard_handler (t_weechat_plugin *,
t_plugin_script *,
char *);
extern void weechat_script_remove_modifier (t_weechat_plugin *,
t_plugin_script *,
char *, char *, char *);
extern char *weechat_script_get_plugin_config (t_weechat_plugin *,
t_plugin_script *,
char *);