mirror of
https://github.com/weechat/weechat.git
synced 2026-06-22 10:56:38 +02:00
Update of translations for scripts, fix bugs and code factorized in script plugins
This commit is contained in:
@@ -153,7 +153,7 @@ weechat_python_exec (struct t_plugin_script *script,
|
||||
if (ret_value == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: not enough memory for "
|
||||
weechat_gettext ("%s%s: not enough memory in "
|
||||
"function \"%s\""),
|
||||
weechat_prefix ("error"), "python", function);
|
||||
/* PyEval_ReleaseThread (python_current_script->interpreter); */
|
||||
@@ -211,7 +211,7 @@ weechat_python_output (PyObject *self, PyObject *args)
|
||||
if (strlen(m) + strlen(python_buffer_output) > sizeof(python_buffer_output))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: stdout/stderr : %s%s"),
|
||||
weechat_gettext ("%s: stdout/stderr: %s%s"),
|
||||
"python", python_buffer_output, m);
|
||||
python_buffer_output[0] = '\0';
|
||||
}
|
||||
@@ -490,11 +490,7 @@ int
|
||||
weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
//int handler_found, modifier_found;
|
||||
char *path_script;
|
||||
struct t_plugin_script *ptr_script;
|
||||
//struct t_plugin_handler *ptr_handler;
|
||||
//struct t_plugin_modifier *ptr_modifier;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -502,164 +498,29 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
/* list registered Python scripts */
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("Registered %s scripts:"),
|
||||
"python");
|
||||
if (python_scripts)
|
||||
{
|
||||
for (ptr_script = python_scripts; ptr_script;
|
||||
ptr_script = ptr_script->next_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext (" %s v%s (%s), by %s, "
|
||||
"license %s"),
|
||||
ptr_script->name,
|
||||
ptr_script->version,
|
||||
ptr_script->description,
|
||||
ptr_script->author,
|
||||
ptr_script->license);
|
||||
}
|
||||
}
|
||||
else
|
||||
weechat_printf (NULL, weechat_gettext (" (none)"));
|
||||
|
||||
/*
|
||||
// list Python message handlers
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python message handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " IRC(%s) => Python(%s)",
|
||||
ptr_handler->irc_command,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
// list Python command handlers
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python command handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " /%s => Python(%s)",
|
||||
ptr_handler->command,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
// list Python timer handlers
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python timer handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == PLUGIN_HANDLER_TIMER)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " %d seconds => Python(%s)",
|
||||
ptr_handler->interval,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
// list Python keyboard handlers
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Python(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
// list Python event handlers
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python event handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == PLUGIN_HANDLER_EVENT)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " %s => Python(%s)",
|
||||
ptr_handler->event,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
// list Python modifiers
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python modifiers:");
|
||||
modifier_found = 0;
|
||||
for (ptr_modifier = plugin->modifiers;
|
||||
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
|
||||
{
|
||||
modifier_found = 1;
|
||||
if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_IN)
|
||||
plugin->print_server (plugin, " IRC(%s, %s) => Python(%s)",
|
||||
ptr_modifier->command,
|
||||
PLUGIN_MODIFIER_IRC_IN_STR,
|
||||
ptr_modifier->modifier_args);
|
||||
else if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_USER)
|
||||
plugin->print_server (plugin, " IRC(%s, %s) => Python(%s)",
|
||||
ptr_modifier->command,
|
||||
PLUGIN_MODIFIER_IRC_USER_STR,
|
||||
ptr_modifier->modifier_args);
|
||||
else if (ptr_modifier->type == PLUGIN_MODIFIER_IRC_OUT)
|
||||
plugin->print_server (plugin, " IRC(%s, %s) => Python(%s)",
|
||||
ptr_modifier->command,
|
||||
PLUGIN_MODIFIER_IRC_OUT_STR,
|
||||
ptr_modifier->modifier_args);
|
||||
}
|
||||
if (!modifier_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
*/
|
||||
script_display_list (weechat_python_plugin, python_scripts,
|
||||
NULL, 0);
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "autoload") == 0)
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
{
|
||||
script_auto_load (weechat_python_plugin,
|
||||
"python", &weechat_python_load_cb);
|
||||
script_display_list (weechat_python_plugin, python_scripts,
|
||||
NULL, 0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
script_display_list (weechat_python_plugin, python_scripts,
|
||||
NULL, 1);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "autoload") == 0)
|
||||
{
|
||||
script_auto_load (weechat_python_plugin, &weechat_python_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
{
|
||||
weechat_python_unload_all ();
|
||||
script_auto_load (weechat_python_plugin,
|
||||
"python", &weechat_python_load_cb);
|
||||
script_auto_load (weechat_python_plugin, &weechat_python_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "unload") == 0)
|
||||
{
|
||||
@@ -668,11 +529,21 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "load") == 0)
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
{
|
||||
script_display_list (weechat_python_plugin, python_scripts,
|
||||
argv_eol[2], 0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
script_display_list (weechat_python_plugin, python_scripts,
|
||||
argv_eol[2], 1);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "load") == 0)
|
||||
{
|
||||
/* load Python script */
|
||||
path_script = script_search_full_name (weechat_python_plugin,
|
||||
"python", argv_eol[2]);
|
||||
argv_eol[2]);
|
||||
weechat_python_load ((path_script) ? path_script : argv_eol[2]);
|
||||
if (path_script)
|
||||
free (path_script);
|
||||
@@ -749,25 +620,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
weechat_hook_command ("python",
|
||||
weechat_gettext ("list/load/unload Python scripts"),
|
||||
weechat_gettext ("[load filename] | [autoload] | "
|
||||
"[reload] | [unload [script]]"),
|
||||
weechat_gettext ("filename: Python script (file) to "
|
||||
"load\n"
|
||||
"script: script name to unload\n\n"
|
||||
"Without argument, /python command "
|
||||
"lists all loaded Python scripts."),
|
||||
"load|autoload|reload|unload %f",
|
||||
&weechat_python_command_cb, NULL);
|
||||
|
||||
weechat_mkdir_home ("python", 0644);
|
||||
weechat_mkdir_home ("python/autoload", 0644);
|
||||
|
||||
weechat_hook_signal ("dump_data", &weechat_python_dump_data_cb, NULL);
|
||||
|
||||
script_init (weechat_python_plugin);
|
||||
script_auto_load (weechat_python_plugin, "python", &weechat_python_load_cb);
|
||||
script_init (weechat_python_plugin,
|
||||
&weechat_python_command_cb, &weechat_python_dump_data_cb,
|
||||
&weechat_python_load_cb);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
Reference in New Issue
Block a user