mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
Added new return codes for plugin handlers, to discard messages for WeeChat, plugins, or both.
This commit is contained in:
@@ -77,7 +77,7 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
SPAGAIN;
|
||||
|
||||
sv = GvSV (gv_fetchpv ("@", TRUE, SVt_PV));
|
||||
return_code = 1;
|
||||
return_code = PLUGIN_RC_KO;
|
||||
if (SvTRUE (sv))
|
||||
{
|
||||
plugin->printf_server (plugin, "Perl error: %s", SvPV (sv, count));
|
||||
@@ -114,9 +114,8 @@ weechat_perl_handler (t_weechat_plugin *plugin,
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
|
||||
weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
return 1;
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -211,6 +210,8 @@ static XS (XS_weechat_print)
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
message = SvPV (ST (0), integer);
|
||||
|
||||
channel_name = NULL;
|
||||
server_name = NULL;
|
||||
|
||||
@@ -221,7 +222,6 @@ static XS (XS_weechat_print)
|
||||
server_name = SvPV (ST (2), integer);
|
||||
}
|
||||
|
||||
message = SvPV (ST (0), integer);
|
||||
perl_plugin->printf (perl_plugin,
|
||||
server_name, channel_name,
|
||||
"%s", message);
|
||||
@@ -1072,7 +1072,7 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
weechat_script_auto_load (plugin, "perl", weechat_perl_load);
|
||||
|
||||
/* init ok */
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -52,31 +52,41 @@ weechat_python_exec (t_weechat_plugin *plugin,
|
||||
PyObject *evMain;
|
||||
PyObject *evDict;
|
||||
PyObject *evFunc;
|
||||
|
||||
PyObject *rc;
|
||||
int ret;
|
||||
|
||||
PyThreadState_Swap (NULL);
|
||||
|
||||
|
||||
PyEval_AcquireLock ();
|
||||
|
||||
|
||||
PyThreadState_Swap (script->interpreter);
|
||||
|
||||
|
||||
evMain = PyImport_AddModule ((char *) "__main__");
|
||||
evDict = PyModule_GetDict (evMain);
|
||||
evFunc = PyDict_GetItemString (evDict, function);
|
||||
|
||||
|
||||
if ( !(evFunc && PyCallable_Check (evFunc)) )
|
||||
{
|
||||
plugin->printf_server (plugin,
|
||||
"Python error: unable to run function \"%s\"",
|
||||
function);
|
||||
PyEval_ReleaseLock();
|
||||
return 1;
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
ret = -1;
|
||||
rc = PyObject_CallFunction(evFunc, "ss", server == NULL ? "" : server, arguments == NULL ? "" : arguments);
|
||||
if (rc)
|
||||
{
|
||||
ret = (int) PyInt_AsLong(rc);
|
||||
Py_XDECREF(rc);
|
||||
}
|
||||
|
||||
PyObject_CallFunction(evFunc, "ss", server == NULL ? "" : server, arguments == NULL ? "" : arguments);
|
||||
|
||||
PyEval_ReleaseLock();
|
||||
|
||||
return 0;
|
||||
|
||||
if (ret < 0)
|
||||
return PLUGIN_RC_OK;
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -91,9 +101,8 @@ weechat_python_handler (t_weechat_plugin *plugin,
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
|
||||
weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
return 1;
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1104,7 +1113,7 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
{
|
||||
plugin->printf_server (plugin,
|
||||
"Python error: unable to launch global interpreter");
|
||||
return 0;
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
PySys_SetArgv(1, argv);
|
||||
@@ -1117,7 +1126,7 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
{
|
||||
plugin->printf_server (plugin,
|
||||
"Python error: unable to get current interpreter state");
|
||||
return 0;
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
PyEval_ReleaseLock ();
|
||||
@@ -1134,7 +1143,8 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
|
||||
weechat_script_auto_load (plugin, "python", weechat_python_load);
|
||||
|
||||
return 1;
|
||||
/* init ok */
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -57,7 +57,7 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
(void) arguments;
|
||||
|
||||
/* TODO: exec Ruby script */
|
||||
return 0;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -72,9 +72,8 @@ weechat_ruby_handler (t_weechat_plugin *plugin,
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
|
||||
weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
return 1;
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -962,7 +961,8 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
|
||||
weechat_script_auto_load (plugin, "ruby", weechat_ruby_load);
|
||||
|
||||
return 1;
|
||||
/* init ok */
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user