1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 20:06:38 +02:00

scripts: add function hook_url in scripting API

This commit is contained in:
Sébastien Helleu
2023-09-08 17:07:03 +02:00
parent 24d2ba3338
commit fb00bc1f4b
16 changed files with 705 additions and 2 deletions
+44
View File
@@ -704,6 +704,50 @@ plugin_script_api_hook_process (struct t_weechat_plugin *weechat_plugin,
callback, function, data);
}
/*
* Hooks a URL.
*
* Returns pointer to new hook, NULL if error.
*/
struct t_hook *
plugin_script_api_hook_url (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *url,
struct t_hashtable *options,
int timeout,
int (*callback)(const void *pointer,
void *data,
const char *url,
struct t_hashtable *options,
struct t_hashtable *output),
const char *function,
const char *data)
{
char *function_and_data;
struct t_hook *new_hook;
if (!script)
return NULL;
function_and_data = plugin_script_build_function_and_data (function, data);
new_hook = weechat_hook_url (url, options, timeout,
callback, script, function_and_data);
if (new_hook)
{
weechat_hook_set (new_hook, "subplugin", script->name);
}
else
{
if (function_and_data)
free (function_and_data);
}
return new_hook;
}
/*
* Hooks a connection to a peer (using fork).
*