1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 17:53:13 +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
+412 -8
View File
@@ -1917,7 +1917,9 @@ int msg_kick (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);
t_plugin_handler *msg_handler;
msg_handler = plugin->msg_handler_add (plugin, "KICK",
&msg_kick, NULL, NULL);
</screen>
</para>
</section>
@@ -2158,9 +2160,10 @@ int cmd_test (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->cmd_handler_add (plugin, "test", "Test command",
"[nick]", "nick: nick of channel",
"%n", &amp;cmd_test, NULL, NULL);
t_plugin_handler *cmd_handler;
cmd_handler = plugin->cmd_handler_add (plugin, "test", "Test command",
"[nick]", "nick: nick of channel",
"%n", &amp;cmd_test, NULL, NULL);
</screen>
</para>
</section>
@@ -2249,7 +2252,8 @@ int my_timer (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->timer_handler_add (plugin, 60, &amp;my_timer);
t_plugin_handler *timer_handler;
timer_handler = plugin->timer_handler_add (plugin, 60, &amp;my_timer);
</screen>
</para>
</section>
@@ -2345,8 +2349,8 @@ plugin->timer_handler_add (plugin, 60, &amp;my_timer);
<para>
Beispiel:
<screen>
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
int my_keyb (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
{
if (argc == 2)
{
@@ -2359,7 +2363,8 @@ int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->keyboard_handler_add (plugin, &amp;keyb_handler);
t_plugin_handler *keyb_handler;
keyb_handler = plugin->keyboard_handler_add (plugin, &amp;my_keyb);
</screen>
</para>
</section>
@@ -2432,6 +2437,214 @@ plugin->keyboard_handler_add (plugin, &amp;keyb_handler);
</para>
</section>
<section id="secAPI_modifier_add">
<title>modifier_add</title>
<para>
Prototype:
<command>
t_plugin_modifier *modifier_add (t_weechat_plugin *plugin,
char *type, char *message, t_plugin_modifier_func *function,
char *modifier_args, void *modifier_pointer)
</command>
</para>
<para>
Add a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>plugin</option>: pointer to plugin structure
</para>
</listitem>
<listitem>
<para>
<option>type</option>: modifier type:
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>irc_in</literal></entry>
<entry>called for incoming IRC messages</entry>
</row>
<row>
<entry><literal>irc_user</literal></entry>
<entry>
called for each user message (or command) (before
WeeChat parses message)
</entry>
</row>
<row>
<entry><literal>irc_out</literal></entry>
<entry>
called for outgoing messages, immediately before
sending it to IRC server (this includes messages
sent automatically by WeeChat to server)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
<listitem>
<para>
<option>message</option>: name of IRC message (used only for
types "irc_in" and "irc_out").
To know list of IRC messages, please consult
<acronym>RFC</acronym>s
<ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink> and
<ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
Moreover, special value "*" means all messages (no filter).
</para>
</listitem>
<listitem>
<para>
<option>function</option>: function called
</para>
<para>
It uses following prototype:
<command>
int my_function (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
</command>
</para>
<para>
Argument argc is set to 2, following values are set in
argv array:
<itemizedlist>
<listitem>
<para>argv[0] = server name</para>
</listitem>
<listitem>
<para>argv[1] = message</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
<option>modifier_args</option>: arguments given to function
when called
</para>
</listitem>
<listitem>
<para>
<option>modifier_pointer</option>: pointer given to function
when called
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: pointer to new message modifier.
</para>
<para>
Note: function has to return modified string, or NULL if no
changes are made to message.
If function returns empty string, then message is dropped and
will not be read at all by WeeChat (be careful when dropping
messages!).
Returned string must have been allocated by malloc() and will
be freed (with call to free()) automatically by WeeChat after use.
</para>
<para>
Example:
<screen>
char *adder (t_weechat_plugin *plugin, int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
char *string;
string = (char *)malloc (strlen (argv[1]) + 16);
strcpy (string, argv[1]);
strcat (string, "test");
return string;
}
...
t_plugin_modifier *modifier;
modifier = plugin->modifier_add (plugin, "irc_in", "privmsg",
&amp;adder, NULL, NULL);
</screen>
</para>
</section>
<section id="secAPI_modifier_remove">
<title>modifier_remove</title>
<para>
Prototype:
<command>
void modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
</command>
</para>
<para>
Remove a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>plugin</option>: pointer to plugin structure
</para>
</listitem>
<listitem>
<para>
<option>modifier</option>: modifier to remove
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: none.
</para>
<para>
Example:
<screen>plugin->modifier_remove (plugin, my_modifier);</screen>
</para>
</section>
<section id="secAPI_modifier_remove_all">
<title>modifier_remove_all</title>
<para>
Prototype:
<command>
void modifier_remove_all (t_weechat_plugin *plugin)
</command>
</para>
<para>
Remove all modifiers for a plugin.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>plugin</option>: pointer to plugin structure
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: none.
</para>
<para>
Example:
<screen>plugin->modifier_remove_all (plugin);</screen>
</para>
</section>
<section id="secAPI_exec_command">
<title>exec_command</title>
@@ -5431,6 +5644,197 @@ weechat.remove_keyboard_handler("my_keyboard")
</para>
</section>
<section id="secScript_add_modifier">
<title>add_modifier</title>
<para>
Perl prototype:
<command>
weechat::add_modifier(type, message, function);
</command>
</para>
<para>
Python prototype:
<command>
weechat.add_modifier(type, message, function)
</command>
</para>
<para>
Ruby prototype:
<command>
Weechat.add_modifier(type, message, function)
</command>
</para>
<para>
Lua prototype:
<command>
weechat.add_modifier(type, message, function)
</command>
</para>
<para>
Add a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>type</option>: modifier type:
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>irc_in</literal></entry>
<entry>called for incoming IRC messages</entry>
</row>
<row>
<entry><literal>irc_user</literal></entry>
<entry>
called for each user message (or command) (before
WeeChat parses message)
</entry>
</row>
<row>
<entry><literal>irc_out</literal></entry>
<entry>
called for outgoing messages, immediately before
sending it to IRC server (this includes messages
sent automatically by WeeChat to server)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
<listitem>
<para>
<option>message</option>: name of IRC message (used only for
types "irc_in" and "irc_out").
To know list of IRC messages, please consult
<acronym>RFC</acronym>s
<ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink> and
<ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
Moreover, special value "*" means all messages (no filter).
</para>
</listitem>
<listitem>
<para>
<option>function</option>: function called
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: 1 if success, 0 if an error occurred.
</para>
<para>
Examples:
<screen>
# perl
weechat::add_modifier("irc_in", "privmsg", "my_function");
sub my_function
{
# TODO
}
# python
weechat.add_modifier("irc_in", "privmsg", "my_function")
def my_function(serveur, args):
# TODO
# ruby
Weechat.add_modifier("irc_in", "privmsg", "my_function")
def my_function(server, args)
# TODO
end
-- lua
weechat.add_modifier("irc_in", "privmsg", "my_function")
function my_function(server, args)
-- TODO
end
</screen>
</para>
</section>
<section id="secScript_remove_modifier">
<title>remove_modifier</title>
<para>
Perl prototype:
<command>
weechat::remove_modifier(type, message, function);
</command>
</para>
<para>
Python prototype:
<command>
weechat.remove_modifier(type, message, function)
</command>
</para>
<para>
Ruby prototype:
<command>
Weechat.remove_modifier(type, message, function)
</command>
</para>
<para>
Lua prototype:
<command>
weechat.remove_modifier(type, message, function)
</command>
</para>
<para>
Remove a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>type</option>: modifier type
</para>
</listitem>
<listitem>
<para>
<option>message</option>: message managed by modifier
</para>
</listitem>
<listitem>
<para>
<option>function</option>: function
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: 1 if success, 0 if an error occurred.
</para>
<para>
Examples:
<screen>
# perl
weechat::remove_modifier("irc_in", "privmsg", "my_function");
# python
weechat.remove_modifier("irc_in", "privmsg", "my_function")
# ruby
Weechat.remove_modifier("irc_in", "privmsg", "my_function")
-- lua
weechat.remove_modifier("irc_in", "privmsg", "my_function")
</screen>
</para>
</section>
<section id="secScript_command">
<title>command</title>
+9 -3
View File
@@ -128,13 +128,19 @@ functions: list internal functions for key bindings
reset: restore bindings to the default values and delete ALL personal bindings (use carefully!)
</programlisting>
<command>plugin [load Dateiname] | [autoload] | [reload] | [unload]</command>
<command>plugin [list [mask]] | [listfull [mask]] | [load filename] | [autoload] | [reload [name]] | [unload [name]]</command>
<programlisting>
auflisten/laden/entladen von Plugins
Dateiname: zu ladendes Plugin
list: list loaded plugins
listfull: list loaded plugins with detailed info for each plugin
mask: part of name of a loaded plugin
load: load a plugin
autoload: autoload plugins in system or user directory
reload: reload one plugin (if no name given, unload all plugins, then autoload plugins)
unload: unload one or all plugins
Ohne Argumente werden alle geladenen Plugins aufgelistet.
Without argument, /plugin command lists loaded plugins.
</programlisting>
<command>server [Servername] | [Servername Hostname Port [-auto | -noauto] [-ipv6] [-ssl] [-pwd Passwort] [-nicks Nick1 Nick2 Nick3] [-username Benutzername] [-realname Name] [-command Befehl] [-autojoin Channel[,Channel]] ] | [del Servername]</command>
+413 -9
View File
@@ -1930,7 +1930,9 @@ int msg_kick (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->msg_handler_add (plugin, "KICK", &amp;msg_kick, NULL, NULL);
t_plugin_handler *msg_handler;
msg_handler = plugin->msg_handler_add (plugin, "KICK",
&amp;msg_kick, NULL, NULL);
</screen>
</para>
</section>
@@ -2180,9 +2182,10 @@ int cmd_test (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->cmd_handler_add (plugin, "test", "Test command",
"[nick]", "nick: nick of channel",
"%n", &amp;cmd_test, NULL, NULL);
t_plugin_handler *cmd_handler;
cmd_handler = plugin->cmd_handler_add (plugin, "test", "Test command",
"[nick]", "nick: nick of channel",
"%n", &amp;cmd_test, NULL, NULL);
</screen>
</para>
</section>
@@ -2274,7 +2277,8 @@ int my_timer (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->timer_handler_add (plugin, 60, &amp;my_timer);
t_plugin_handler *timer_handler;
timer_handler = plugin->timer_handler_add (plugin, 60, &amp;my_timer);
</screen>
</para>
</section>
@@ -2372,8 +2376,8 @@ plugin->timer_handler_add (plugin, 60, &amp;my_timer);
<para>
Example:
<screen>
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
int my_keyb (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
{
if (argc == 2)
{
@@ -2386,7 +2390,8 @@ int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->keyboard_handler_add (plugin, &amp;keyb_handler);
t_plugin_handler *keyb_handler;
keyb_handler = plugin->keyboard_handler_add (plugin, &amp;my_keyb);
</screen>
</para>
</section>
@@ -2459,6 +2464,214 @@ plugin->keyboard_handler_add (plugin, &amp;keyb_handler);
</para>
</section>
<section id="secAPI_modifier_add">
<title>modifier_add</title>
<para>
Prototype:
<command>
t_plugin_modifier *modifier_add (t_weechat_plugin *plugin,
char *type, char *message, t_plugin_modifier_func *function,
char *modifier_args, void *modifier_pointer)
</command>
</para>
<para>
Add a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>plugin</option>: pointer to plugin structure
</para>
</listitem>
<listitem>
<para>
<option>type</option>: modifier type:
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>irc_in</literal></entry>
<entry>called for incoming IRC messages</entry>
</row>
<row>
<entry><literal>irc_user</literal></entry>
<entry>
called for each user message (or command) (before
WeeChat parses message)
</entry>
</row>
<row>
<entry><literal>irc_out</literal></entry>
<entry>
called for outgoing messages, immediately before
sending it to IRC server (this includes messages
sent automatically by WeeChat to server)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
<listitem>
<para>
<option>message</option>: name of IRC message (used only for
types "irc_in" and "irc_out").
To know list of IRC messages, please consult
<acronym>RFC</acronym>s
<ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink> and
<ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
Moreover, special value "*" means all messages (no filter).
</para>
</listitem>
<listitem>
<para>
<option>function</option>: function called
</para>
<para>
It uses following prototype:
<command>
int my_function (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
</command>
</para>
<para>
Argument argc is set to 2, following values are set in
argv array:
<itemizedlist>
<listitem>
<para>argv[0] = server name</para>
</listitem>
<listitem>
<para>argv[1] = message</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
<option>modifier_args</option>: arguments given to function
when called
</para>
</listitem>
<listitem>
<para>
<option>modifier_pointer</option>: pointer given to function
when called
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: pointer to new message modifier.
</para>
<para>
Note: function has to return modified string, or NULL if no
changes are made to message.
If function returns empty string, then message is dropped and
will not be read at all by WeeChat (be careful when dropping
messages!).
Returned string must have been allocated by malloc() and will
be freed (with call to free()) automatically by WeeChat after use.
</para>
<para>
Example:
<screen>
char *adder (t_weechat_plugin *plugin, int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
char *string;
string = (char *)malloc (strlen (argv[1]) + 16);
strcpy (string, argv[1]);
strcat (string, "test");
return string;
}
...
t_plugin_modifier *modifier;
modifier = plugin->modifier_add (plugin, "irc_in", "privmsg",
&amp;adder, NULL, NULL);
</screen>
</para>
</section>
<section id="secAPI_modifier_remove">
<title>modifier_remove</title>
<para>
Prototype:
<command>
void modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
</command>
</para>
<para>
Remove a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>plugin</option>: pointer to plugin structure
</para>
</listitem>
<listitem>
<para>
<option>modifier</option>: modifier to remove
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: none.
</para>
<para>
Example:
<screen>plugin->modifier_remove (plugin, my_modifier);</screen>
</para>
</section>
<section id="secAPI_modifier_remove_all">
<title>modifier_remove_all</title>
<para>
Prototype:
<command>
void modifier_remove_all (t_weechat_plugin *plugin)
</command>
</para>
<para>
Remove all modifiers for a plugin.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>plugin</option>: pointer to plugin structure
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: none.
</para>
<para>
Example:
<screen>plugin->modifier_remove_all (plugin);</screen>
</para>
</section>
<section id="secAPI_exec_command">
<title>exec_command</title>
@@ -5281,7 +5494,7 @@ end
</para>
</section>
<section id="secScript_remode_handler">
<section id="secScript_remove_handler">
<title>remove_handler</title>
<para>
@@ -5469,6 +5682,197 @@ weechat.remove_keyboard_handler("my_keyboard")
</para>
</section>
<section id="secScript_add_modifier">
<title>add_modifier</title>
<para>
Perl prototype:
<command>
weechat::add_modifier(type, message, function);
</command>
</para>
<para>
Python prototype:
<command>
weechat.add_modifier(type, message, function)
</command>
</para>
<para>
Ruby prototype:
<command>
Weechat.add_modifier(type, message, function)
</command>
</para>
<para>
Lua prototype:
<command>
weechat.add_modifier(type, message, function)
</command>
</para>
<para>
Add a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>type</option>: modifier type:
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>irc_in</literal></entry>
<entry>called for incoming IRC messages</entry>
</row>
<row>
<entry><literal>irc_user</literal></entry>
<entry>
called for each user message (or command) (before
WeeChat parses message)
</entry>
</row>
<row>
<entry><literal>irc_out</literal></entry>
<entry>
called for outgoing messages, immediately before
sending it to IRC server (this includes messages
sent automatically by WeeChat to server)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
<listitem>
<para>
<option>message</option>: name of IRC message (used only for
types "irc_in" and "irc_out").
To know list of IRC messages, please consult
<acronym>RFC</acronym>s
<ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink> and
<ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
Moreover, special value "*" means all messages (no filter).
</para>
</listitem>
<listitem>
<para>
<option>function</option>: function called
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: 1 if success, 0 if an error occurred.
</para>
<para>
Examples:
<screen>
# perl
weechat::add_modifier("irc_in", "privmsg", "my_function");
sub my_function
{
# TODO
}
# python
weechat.add_modifier("irc_in", "privmsg", "my_function")
def my_function(serveur, args):
# TODO
# ruby
Weechat.add_modifier("irc_in", "privmsg", "my_function")
def my_function(server, args)
# TODO
end
-- lua
weechat.add_modifier("irc_in", "privmsg", "my_function")
function my_function(server, args)
-- TODO
end
</screen>
</para>
</section>
<section id="secScript_remove_modifier">
<title>remove_modifier</title>
<para>
Perl prototype:
<command>
weechat::remove_modifier(type, message, function);
</command>
</para>
<para>
Python prototype:
<command>
weechat.remove_modifier(type, message, function)
</command>
</para>
<para>
Ruby prototype:
<command>
Weechat.remove_modifier(type, message, function)
</command>
</para>
<para>
Lua prototype:
<command>
weechat.remove_modifier(type, message, function)
</command>
</para>
<para>
Remove a message modifier.
</para>
<para>
Arguments:
<itemizedlist>
<listitem>
<para>
<option>type</option>: modifier type
</para>
</listitem>
<listitem>
<para>
<option>message</option>: message managed by modifier
</para>
</listitem>
<listitem>
<para>
<option>function</option>: function
</para>
</listitem>
</itemizedlist>
</para>
<para>
Return value: 1 if success, 0 if an error occurred.
</para>
<para>
Examples:
<screen>
# perl
weechat::remove_modifier("irc_in", "privmsg", "my_function");
# python
weechat.remove_modifier("irc_in", "privmsg", "my_function")
# ruby
Weechat.remove_modifier("irc_in", "privmsg", "my_function")
-- lua
weechat.remove_modifier("irc_in", "privmsg", "my_function")
</screen>
</para>
</section>
<section id="secScript_command">
<title>command</title>
+9 -3
View File
@@ -127,13 +127,19 @@ functions: list internal functions for key bindings
reset: restore bindings to the default values and delete ALL personal bindings (use carefully!)
</programlisting>
<command>plugin [load filename] | [autoload] | [reload] | [unload]</command>
<command>plugin [list [mask]] | [listfull [mask]] | [load filename] | [autoload] | [reload [name]] | [unload [name]]</command>
<programlisting>
list/load/unload plugins
filename: WeeChat plugin (file) to load
list: list loaded plugins
listfull: list loaded plugins with detailed info for each plugin
mask: part of name of a loaded plugin
load: load a plugin
autoload: autoload plugins in system or user directory
reload: reload one plugin (if no name given, unload all plugins, then autoload plugins)
unload: unload one or all plugins
Without argument, /plugin command lists all loaded plugins.
Without argument, /plugin command lists loaded plugins.
</programlisting>
<command>server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername]</command>
+426 -12
View File
@@ -1969,7 +1969,9 @@ int msg_kick (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->msg_handler_add (plugin, "KICK", &amp;msg_kick, NULL, NULL);
t_plugin_handler *msg_handler;
msg_handler = plugin->msg_handler_add (plugin, "KICK",
&amp;msg_kick, NULL, NULL);
</screen>
</para>
</section>
@@ -2225,9 +2227,10 @@ int cmd_test (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->cmd_handler_add (plugin, "test", "Commande test",
"[pesudo]", "pseudo: un pseudo du canal",
"%n", &amp;cmd_test, NULL, NULL);
t_plugin_handler *cmd_handler;
cmd_handler = plugin->cmd_handler_add (plugin, "test", "Commande test",
"[pesudo]", "pseudo: un pseudo du canal",
"%n", &amp;cmd_test, NULL, NULL);
</screen>
</para>
</section>
@@ -2322,7 +2325,8 @@ int mon_timer (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->timer_handler_add (plugin, 60, &amp;mon_timer);
t_plugin_handler *timer_handler;
timer_handler = plugin->timer_handler_add (plugin, 60, &amp;mon_timer);
</screen>
</para>
</section>
@@ -2425,8 +2429,8 @@ plugin->timer_handler_add (plugin, 60, &amp;mon_timer);
<para>
Exemple :
<screen>
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
int mon_keyb (t_weechat_plugin *plugin, int argc, char **argv,
char *handler_args, void *handler_pointer)
{
if (argc == 2)
{
@@ -2439,7 +2443,8 @@ int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
return PLUGIN_RC_OK;
}
...
plugin->keyboard_handler_add (plugin, &amp;keyb_handler);
t_plugin_handler *keyb_handler;
keyb_handler = plugin->keyboard_handler_add (plugin, &amp;mon_keyb);
</screen>
</para>
</section>
@@ -2514,6 +2519,221 @@ plugin->keyboard_handler_add (plugin, &amp;keyb_handler);
</para>
</section>
<section id="secAPI_modifier_add">
<title>modifier_add</title>
<para>
Prototype :
<command>
t_plugin_modifier *modifier_add (t_weechat_plugin *plugin,
char *type, char *message, t_plugin_modifier_func *fonction,
char *modifier_args, void *modifier_pointer)
</command>
</para>
<para>
Ajoute un modifieur de message.
</para>
<para>
Paramètres :
<itemizedlist>
<listitem>
<para>
<option>plugin</option> : pointeur vers la structure
de l'extension
</para>
</listitem>
<listitem>
<para>
<option>type</option> : type de modifieur :
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>irc_in</literal></entry>
<entry>appelé pour chaque message IRC reçu</entry>
</row>
<row>
<entry><literal>irc_user</literal></entry>
<entry>
appelé pour chaque message (ou commande) envoyé par
l'utilisateur (avant traitement et affichage par
WeeChat)
</entry>
</row>
<row>
<entry><literal>irc_out</literal></entry>
<entry>
appelé pour chaque message sortant juste avant
envoi au serveur IRC (y compris pour les messages
envoyés automatiquement et de manière transparente
par WeeChat)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
<listitem>
<para>
<option>message</option> : nom du message IRC pour lequel la
fonction est appelée (utilisé uniquement pour les types
"irc_in" et "irc_out").
Pour connaître la liste des messages IRC disponibles, merci
de consulter les <acronym>RFC</acronym>s
<ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink> et
<ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
La valeur spéciale "*" signifie tous les messages (pas de filtre).
</para>
</listitem>
<listitem>
<para>
<option>fonction</option> : fonction appelée
</para>
<para>
Elle a le prototype suivant :
<command>
char *ma_fonction (t_weechat_plugin *plugin,
int argc, char **argv,
char *modifier_args, void *modifier_pointer)
</command>
</para>
<para>
Le paramètre argc vaut 2 et les arguments suivants sont
passés dans le tableau argv :
<itemizedlist>
<listitem>
<para>argv[0] = nom du serveur</para>
</listitem>
<listitem>
<para>argv[1] = message</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
<option>modifier_args</option> : paramètres passés à la
fonction appelée
</para>
</listitem>
<listitem>
<para>
<option>modifier_pointer</option> : pointeur passé à la
fonction appelée
</para>
</listitem>
</itemizedlist>
</para>
<para>
Valeur renvoyée : le pointeur vers le nouveau modifieur de message.
</para>
<para>
Note : la fonction doit retourner une chaîne modifiée, ou NULL si
elle ne souhaite pas modifier le message.
Si elle retourne une chaine vide, alors le message est supprimé et
ne sera pas traité du tout par WeeChat (soyez prudent en supprimant
des messages !).
La chaîne renvoyée doit avoir été allouée par malloc() et sera
libérée (par appel à free()) automatiquement par WeeChat après
utilisation.
</para>
<para>
Exemple :
<screen>
char *adder (t_weechat_plugin *plugin, int argc, char **argv,
char *modifier_args, void *modifier_pointer)
{
char *string;
string = (char *)malloc (strlen (argv[1]) + 16);
strcpy (string, argv[1]);
strcat (string, "test");
return string;
}
...
t_plugin_modifier *modifier;
modifier = plugin->modifier_add (plugin, "irc_in", "privmsg",
&amp;adder, NULL, NULL);
</screen>
</para>
</section>
<section id="secAPI_modifier_remove">
<title>modifier_remove</title>
<para>
Prototype :
<command>
void modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
</command>
</para>
<para>
Supprime un modifieur de message.
</para>
<para>
Paramètres :
<itemizedlist>
<listitem>
<para>
<option>plugin</option> : pointeur vers la structure
de l'extension
</para>
</listitem>
<listitem>
<para>
<option>modifier</option> : le modifieur à supprimer
</para>
</listitem>
</itemizedlist>
</para>
<para>
Valeur renvoyée : aucune.
</para>
<para>
Exemple :
<screen>plugin->modifier_remove (plugin, mon_modifier);</screen>
</para>
</section>
<section id="secAPI_modifier_remove_all">
<title>modifier_remove_all</title>
<para>
Prototype :
<command>
void modifier_remove_all (t_weechat_plugin *plugin)
</command>
</para>
<para>
Supprime tous les modifieurs d'une extension.
</para>
<para>
Paramètres :
<itemizedlist>
<listitem>
<para>
<option>plugin</option> : pointeur vers la structure
de l'extension
</para>
</listitem>
</itemizedlist>
</para>
<para>
Valeur renvoyée : aucune.
</para>
<para>
Exemple :
<screen>plugin->modifier_remove_all (plugin);</screen>
</para>
</section>
<section id="secAPI_exec_command">
<title>exec_command</title>
@@ -5012,7 +5232,7 @@ def ma_fonction(server, args)
end
-- lua
weechat.add_message_handler ("privmsg", "ma_fonction")
weechat.add_message_handler("privmsg", "ma_fonction")
function ma_fonction(server, args)
weechat.print("serveur=" .. server .. ", args=" .. args)
return weechat.PLUGIN_RC_OK()
@@ -5162,7 +5382,7 @@ def ma_commande(server, args)
end
-- lua
weechat.add_command_handler ("commande", "ma_commande")
weechat.add_command_handler("commande", "ma_commande")
def my_command(server, args)
weechat.print("serveur="..server..", args="..args)
return weechat.PLUGIN_RC_OK()
@@ -5356,7 +5576,7 @@ def mon_clavier(key, input_before, input_after):
return weechat.PLUGIN_RC_OK
# ruby
Weechat.add_clavier_handler("mon_clavier")
Weechat.add_keyboard_handler("mon_clavier")
def mon_clavier(server, input_before, input_after)
Weechat.print("gestionnaire clavier: touche = '#{key}', " \
"entrée avant = '#{input_before}' " \
@@ -5365,7 +5585,7 @@ def mon_clavier(server, input_before, input_after)
end
-- lua
weechat.add_clavier_handler("mon_clavier")
weechat.add_keyboard_handler("mon_clavier")
function mon_clavier(server, input_before, input_after)
weechat.print("gestionnaire clavier: touche = '"..key..
"', entrée avant = '"..input_before..
@@ -5580,6 +5800,200 @@ weechat.remove_keyboard_handler("mon_clavier")
</para>
</section>
<section id="secScript_add_modifier">
<title>add_modifier</title>
<para>
Prototype Perl :
<command>
weechat::add_modifier(type, message, fonction);
</command>
</para>
<para>
Prototype Python :
<command>
weechat.add_modifier(type, message, fonction)
</command>
</para>
<para>
Prototype Ruby :
<command>
Weechat.add_modifier(type, message, fonction)
</command>
</para>
<para>
Prototype Lua :
<command>
weechat.add_modifier(type, message, fonction)
</command>
</para>
<para>
Ajoute un modifieur de messages.
</para>
<para>
Paramètres :
<itemizedlist>
<listitem>
<para>
<option>type</option> : type de modifieur :
<informaltable colsep="0" frame="none">
<tgroup cols="2">
<thead>
<row>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>irc_in</literal></entry>
<entry>appelé pour chaque message IRC reçu</entry>
</row>
<row>
<entry><literal>irc_user</literal></entry>
<entry>
appelé pour chaque message (ou commande) envoyé par
l'utilisateur (avant traitement et affichage par
WeeChat)
</entry>
</row>
<row>
<entry><literal>irc_out</literal></entry>
<entry>
appelé pour chaque message sortant juste avant
envoi au serveur IRC (y compris pour les messages
envoyés automatiquement et de manière transparente
par WeeChat)
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</listitem>
<listitem>
<para>
<option>message</option> : nom du message IRC pour lequel la
fonction est appelée (utilisé uniquement pour les types
"irc_in" et "irc_out").
Pour connaître la liste des messages IRC disponibles, merci
de consulter les <acronym>RFC</acronym>s
<ulink url="http://www.ietf.org/rfc/rfc1459.txt">1459</ulink> et
<ulink url="http://www.ietf.org/rfc/rfc2812.txt">2812</ulink>.
La valeur spéciale "*" signifie tous les messages (pas de filtre).
</para>
</listitem>
<listitem>
<para>
<option>fonction</option> : fonction appelée
</para>
</listitem>
</itemizedlist>
</para>
<para>
Valeur renvoyée : 1 si succès, 0 si une erreur s'est produite.
</para>
<para>
Exemples :
<screen>
# perl
weechat::add_modifier("irc_in", "privmsg", "ma_fonction");
sub ma_fonction
{
# TODO
}
# python
weechat.add_modifier("irc_in", "privmsg", "ma_fonction")
def ma_fonction(serveur, args):
# TODO
# ruby
Weechat.add_modifier("irc_in", "privmsg", "ma_fonction")
def ma_fonction(server, args)
# TODO
end
-- lua
weechat.add_modifier("irc_in", "privmsg", "ma_fonction")
function ma_fonction(server, args)
-- TODO
end
</screen>
</para>
</section>
<section id="secScript_remove_modifier">
<title>remove_modifier</title>
<para>
Prototype Perl :
<command>
weechat::remove_modifier(type, message, fonction);
</command>
</para>
<para>
Prototype Python :
<command>
weechat.remove_handler(type, message, fonction)
</command>
</para>
<para>
Prototype Ruby :
<command>
Weechat.remove_handler(type, message, fonction)
</command>
</para>
<para>
Prototype Lua :
<command>
weechat.remove_handler(type, message, fonction)
</command>
</para>
<para>
Supprime un modifieur de messages.
</para>
<para>
Paramètres :
<itemizedlist>
<listitem>
<para>
<option>type</option> : type de modifieur
</para>
</listitem>
<listitem>
<para>
<option>message</option> : message traité par le modifieur
</para>
</listitem>
<listitem>
<para>
<option>fonction</option> : fonction associée
</para>
</listitem>
</itemizedlist>
</para>
<para>
Valeur renvoyée : 1 si succès, 0 si une erreur s'est produite.
</para>
<para>
Exemples :
<screen>
# perl
weechat::remove_modifier("irc_in", "privmsg", "ma_fonction");
# python
weechat.remove_modifier("irc_in", "privmsg", "ma_fonction")
# ruby
Weechat.remove_modifier("irc_in", "privmsg", "ma_fonction")
-- lua
weechat.remove_modifier("irc_in", "privmsg", "ma_fonction")
</screen>
</para>
</section>
<section id="secScript_command">
<title>command</title>
+9 -3
View File
@@ -127,13 +127,19 @@ functions: lister la liste des fonctions internes pour les associations de touch
reset: restaure les touches aux valeurs par défaut et supprime TOUTES les touches personnelles (utiliser avec précaution !)
</programlisting>
<command>plugin [load fichier] | [autoload] | [reload] | [unload]</command>
<command>plugin [list [masque]] | [listfull [masque]] | [load fichier] | [autoload] | [reload [nom]] | [unload [nom]]</command>
<programlisting>
liste/charge/décharge des extensions
fichier: extension WeeChat (fichier) à charger
list: lister les extensions chargées
listfull: lister les extensions chargées avec de l'info détaillée pour chaque extension
masque: morceau de nom d'une extension chargée
load: charger une extension
autoload: charger automatiquement les extensions dans un répertoire système ou utilisateur
reload: recharger une extension (si pas de nom donné, décharger toutes les extensions, puis puis recharger automatiquement les extensions)
unload: décharger une ou plusieurs exteneions
Sans paramètre, la commande /plugin liste toutes les extensions chargées.
Sans paramètre, la commande /plugin liste les extensions chargées.
</programlisting>
<command>server [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [del nom_serveur]</command>