1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-24 20:06:38 +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>
+405 -364
View File
File diff suppressed because it is too large Load Diff
+405 -364
View File
File diff suppressed because it is too large Load Diff
+407 -364
View File
File diff suppressed because it is too large Load Diff
+417 -365
View File
File diff suppressed because it is too large Load Diff
+405 -364
View File
File diff suppressed because it is too large Load Diff
+406 -365
View File
File diff suppressed because it is too large Load Diff
+395 -364
View File
File diff suppressed because it is too large Load Diff
+184 -111
View File
@@ -143,10 +143,16 @@ t_weechat_command weechat_commands[] =
"list|add|close|move global|local top|bottom|left|right",
0, MAX_ARGS, 0, weechat_cmd_panel, NULL },*/
{ "plugin", N_("list/load/unload plugins"),
N_("[load filename] | [autoload] | [reload] | [unload]"),
N_("filename: WeeChat plugin (file) to load\n\n"
"Without argument, /plugin command lists all loaded plugins."),
"load|autoload|reload|unload", 0, 2, 0, weechat_cmd_plugin, NULL },
N_("[list [mask]] | [listfull [mask]] | [load filename] | [autoload] | [reload [name]] | [unload [name]]"),
N_(" list: list loaded plugins\n"
"listfull: list loaded plugins with detailed info for each plugin\n"
" mask: part of name of a loaded plugin\n"
" load: load a plugin\n"
"autoload: autoload plugins in system or user directory\n"
" reload: reload one plugin (if no name given, unload all plugins, then autoload plugins)\n"
" unload: unload one or all plugins\n\n"
"Without argument, /plugin command lists loaded plugins."),
"list|listfull|load|autoload|reload|unload %P", 0, 2, 0, weechat_cmd_plugin, NULL },
{ "server", N_("list, add or remove servers"),
N_("[servername] | "
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 "
@@ -717,7 +723,7 @@ user_message (t_irc_server *server, t_gui_buffer *buffer, char *text)
next = pos;
}
server_sendf (server, "PRIVMSG %s :%s\r\n", CHANNEL(buffer)->name, text);
server_sendf (server, "PRIVMSG %s :%s", CHANNEL(buffer)->name, text);
user_message_display (server, buffer, text);
if (next)
@@ -736,98 +742,103 @@ void
user_command (t_irc_server *server, t_irc_channel *channel, char *command, int only_builtin)
{
t_gui_buffer *buffer;
int plugin_args_length;
char *new_cmd, *ptr_cmd, *pos;
char *command_with_colors, *command_encoded;
char *plugin_args;
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n'))
return;
irc_find_context (server, channel, NULL, &buffer);
#ifdef PLUGINS
new_cmd = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_USER,
(server) ? server->name : "",
command);
#else
new_cmd = NULL;
#endif
if ((command[0] == '/') && (command[1] != '/'))
/* no changes in new command */
if (new_cmd && (strcmp (command, new_cmd) == 0))
{
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (server, channel, command, only_builtin);
free (new_cmd);
new_cmd = NULL;
}
else
/* message not dropped? */
if (!new_cmd || new_cmd[0])
{
if ((command[0] == '/') && (command[1] == '/'))
command++;
/* use new command (returned by plugin) */
ptr_cmd = (new_cmd) ? new_cmd : command;
if (server && (!BUFFER_IS_SERVER(buffer)))
while (ptr_cmd && ptr_cmd[0])
{
command_with_colors = (cfg_irc_colors_send) ?
(char *)gui_color_encode ((unsigned char *)command) : NULL;
pos = strchr (ptr_cmd, '\n');
if (pos)
pos[0] = '\0';
command_encoded = channel_iconv_encode (server, channel,
(command_with_colors) ? command_with_colors : command);
irc_find_context (server, channel, NULL, &buffer);
if (CHANNEL(buffer)->dcc_chat)
if ((ptr_cmd[0] == '/') && (ptr_cmd[1] != '/'))
{
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (server, channel, ptr_cmd, only_builtin);
}
else
{
if ((ptr_cmd[0] == '/') && (ptr_cmd[1] == '/'))
ptr_cmd++;
if (server && (!BUFFER_IS_SERVER(buffer)))
{
irc_display_prefix (server, buffer, PREFIX_ERROR);
gui_printf_nolog (buffer, "%s DCC CHAT is closed\n",
WEECHAT_ERROR);
command_with_colors = (cfg_irc_colors_send) ?
(char *)gui_color_encode ((unsigned char *)ptr_cmd) : NULL;
command_encoded = channel_iconv_encode (server, channel,
(command_with_colors) ? command_with_colors : ptr_cmd);
if (CHANNEL(buffer)->dcc_chat)
{
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
{
irc_display_prefix (server, buffer, PREFIX_ERROR);
gui_printf_nolog (buffer, "%s DCC CHAT is closed\n",
WEECHAT_ERROR);
}
else
{
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
"%s\r\n",
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : ptr_cmd));
user_message_display (server, buffer,
(command_with_colors) ?
command_with_colors : ptr_cmd);
}
}
else
user_message (server, buffer,
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : ptr_cmd));
if (command_with_colors)
free (command_with_colors);
if (command_encoded)
free (command_encoded);
}
else
{
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
"%s\r\n",
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : command));
user_message_display (server, buffer,
(command_with_colors) ?
command_with_colors : command);
irc_display_prefix (NULL, (server) ? server->buffer : NULL, PREFIX_ERROR);
gui_printf_nolog ((server) ? server->buffer : NULL,
_("This window is not a channel!\n"));
}
}
else
user_message (server, buffer,
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : command));
if (command_with_colors)
free (command_with_colors);
if (command_encoded)
free (command_encoded);
/* sending a copy of the message as PRIVMSG to plugins because irc server doesn't */
/* code commented by FlashCode, 2005-11-06: problem when a handler
is called after a weechat::command("somethin") in perl, reetrance,
and crash at perl script unload */
/* make gcc happy */
(void) plugin_args_length;
(void) plugin_args;
/*plugin_args_length = strlen ("localhost PRIVMSG :") +
strlen (CHANNEL(buffer)->name) + strlen(command) + 16;
plugin_args = (char *) malloc (plugin_args_length * sizeof (*plugin_args));
if (plugin_args)
if (pos)
{
snprintf (plugin_args, plugin_args_length,
"localhost PRIVMSG %s :%s",
CHANNEL(buffer)->name, command);
#ifdef PLUGINS
plugin_msg_handler_exec (server->name, "privmsg", plugin_args);
#endif
free (plugin_args);
pos[0] = '\n';
ptr_cmd = pos + 1;
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to call handler for message (not enough memory)\n"),
WEECHAT_ERROR);
}*/
}
else
{
irc_display_prefix (NULL, (server) ? server->buffer : NULL, PREFIX_ERROR);
gui_printf_nolog ((server) ? server->buffer : NULL,
_("This window is not a channel!\n"));
ptr_cmd = NULL;
}
}
}
@@ -1966,7 +1977,7 @@ weechat_cmd_help (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
{
gui_printf (NULL, " %s%s",
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
@@ -2045,7 +2056,7 @@ weechat_cmd_help (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command, argv[0]) == 0))
{
gui_printf (NULL, "\n");
@@ -2464,42 +2475,48 @@ weechat_cmd_panel (t_irc_server *server, t_irc_channel *channel,
}
/*
* weechat_cmd_plugin: list/load/unload WeeChat plugins
* weechat_cmd_plugin_list: list loaded plugins
*/
int
weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
int argc, char **argv)
void
weechat_cmd_plugin_list (char *name, int full)
{
#ifdef PLUGINS
t_weechat_plugin *ptr_plugin;
int plugins_found;
t_plugin_handler *ptr_handler;
int handler_found;
t_plugin_modifier *ptr_modifier;
int modifier_found;
/* make gcc happy */
(void) server;
(void) channel;
switch (argc)
gui_printf (NULL, "\n");
if (!name)
{
case 0:
/* list plugins */
gui_printf (NULL, "\n");
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _("Plugins loaded:\n"));
}
plugins_found = 0;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
if (!name || (ascii_strcasestr (ptr_plugin->name, name)))
{
plugins_found++;
/* plugin info */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _("Plugins loaded:\n"));
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
gui_printf (NULL, " %s%s%s v%s - %s (%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_plugin->name,
GUI_COLOR(COLOR_WIN_CHAT),
ptr_plugin->version,
ptr_plugin->description,
ptr_plugin->filename);
if (full)
{
/* plugin info */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, " %s%s%s v%s - %s (%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_plugin->name,
GUI_COLOR(COLOR_WIN_CHAT),
ptr_plugin->version,
ptr_plugin->description,
ptr_plugin->filename);
/* message handlers */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _(" message handlers:\n"));
@@ -2507,7 +2524,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_MESSAGE)
if (ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
{
handler_found = 1;
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2528,7 +2545,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
{
handler_found = 1;
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2554,7 +2571,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_TIMER)
if (ptr_handler->type == PLUGIN_HANDLER_TIMER)
{
handler_found = 1;
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2575,7 +2592,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_KEYBOARD)
if (ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
handler_found++;
}
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2584,15 +2601,65 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
else
gui_printf (NULL, _(" %d defined\n"),
handler_found);
}
if (!weechat_plugins)
{
/* IRC modifiers */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _(" (no plugin)\n"));
gui_printf (NULL, _(" IRC modifiers:\n"));
modifier_found = 0;
for (ptr_modifier = ptr_plugin->modifiers;
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
{
if (ptr_modifier->type == PLUGIN_HANDLER_KEYBOARD)
modifier_found++;
}
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
if (!modifier_found)
gui_printf (NULL, _(" (no IRC modifier)\n"));
else
gui_printf (NULL, _(" %d defined\n"),
modifier_found);
}
}
}
if (plugins_found == 0)
{
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
if (name)
gui_printf (NULL, _("No plugin found.\n"));
else
gui_printf (NULL, _(" (no plugin)\n"));
}
#else
/* make gcc happy */
(void) name;
(void) full;
#endif
}
/*
* weechat_cmd_plugin: list/load/unload WeeChat plugins
*/
int
weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
int argc, char **argv)
{
#ifdef PLUGINS
/* make gcc happy */
(void) server;
(void) channel;
switch (argc)
{
case 0:
weechat_cmd_plugin_list (NULL, 0);
break;
case 1:
if (ascii_strcasecmp (argv[0], "autoload") == 0)
if (ascii_strcasecmp (argv[0], "list") == 0)
weechat_cmd_plugin_list (NULL, 0);
else if (ascii_strcasecmp (argv[0], "listfull") == 0)
weechat_cmd_plugin_list (NULL, 1);
else if (ascii_strcasecmp (argv[0], "autoload") == 0)
plugin_auto_load ();
else if (ascii_strcasecmp (argv[0], "reload") == 0)
{
@@ -2603,8 +2670,14 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
plugin_unload_all ();
break;
case 2:
if (ascii_strcasecmp (argv[0], "load") == 0)
if (ascii_strcasecmp (argv[0], "list") == 0)
weechat_cmd_plugin_list (argv[1], 0);
else if (ascii_strcasecmp (argv[0], "listfull") == 0)
weechat_cmd_plugin_list (argv[1], 1);
else if (ascii_strcasecmp (argv[0], "load") == 0)
plugin_load (argv[1]);
else if (ascii_strcasecmp (argv[0], "reload") == 0)
plugin_reload_name (argv[1]);
else if (ascii_strcasecmp (argv[0], "unload") == 0)
plugin_unload_name (argv[1]);
else
+2 -2
View File
@@ -154,7 +154,7 @@ completion_get_command_infos (t_completion *completion,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command,
ptr_command2) == 0))
{
@@ -304,7 +304,7 @@ completion_list_add_plugin_cmd (t_completion *completion)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
completion_list_add (completion, ptr_handler->command);
}
}
+1 -1
View File
@@ -217,7 +217,7 @@ gui_main_loop ()
if ((ptr_server->lag_check_time.tv_sec == 0)
&& (new_time >= ptr_server->lag_next_check))
{
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
server_sendf (ptr_server, "PING %s", ptr_server->address);
gettimeofday (&(ptr_server->lag_check_time), NULL);
}
+4 -2
View File
@@ -360,10 +360,11 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
/*
* gui_printf_raw_data: display raw IRC data (only if raw IRC data buffer exists)
* type: 0 = recv, 1 = send, -1 = recv, modified by a modifier (plugin)
*/
void
gui_printf_raw_data (void *server, int send, char *message)
gui_printf_raw_data (void *server, int send, int modified, char *message)
{
char *pos;
@@ -381,7 +382,8 @@ gui_printf_raw_data (void *server, int send, char *message)
((t_irc_server *)server)->name,
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR((send) ? COLOR_WIN_CHAT_PART : COLOR_WIN_CHAT_JOIN),
(send) ? PREFIX_PART : PREFIX_JOIN,
(send) ? ((modified) ? PREFIX_SEND_MOD : PREFIX_PART) :
((modified) ? PREFIX_RECV_MOD : PREFIX_JOIN),
GUI_COLOR(COLOR_WIN_CHAT),
message);
if (pos)
+1 -1
View File
@@ -184,7 +184,7 @@ extern void gui_infobar_remove_all ();
extern int gui_word_strlen (t_gui_window *, char *);
extern int gui_word_real_pos (t_gui_window *, char *, int);
extern void gui_printf_internal (t_gui_buffer *, int, int, char *, char *, ...);
extern void gui_printf_raw_data (void *, int, char *);
extern void gui_printf_raw_data (void *, int, int, char *);
extern void gui_input_optimize_size (t_gui_buffer *);
extern void gui_input_init_color_mask (t_gui_buffer *);
extern void gui_input_move (t_gui_buffer *, char *, char *, int );
+1 -1
View File
@@ -427,7 +427,7 @@ channel_check_away (t_irc_server *server, t_irc_channel *channel, int force)
(channel->nicks_count <= cfg_irc_away_check_max_nicks))
{
channel->checking_away++;
server_sendf (server, "WHO %s\r\n", channel->name);
server_sendf (server, "WHO %s", channel->name);
}
else
channel_remove_away (channel);
+7 -7
View File
@@ -632,8 +632,8 @@ dcc_accept (t_irc_dcc *ptr_dcc)
ptr_dcc->status = DCC_CONNECTING;
server_sendf (ptr_dcc->server,
(strchr (ptr_dcc->filename, ' ')) ?
"PRIVMSG %s :\01DCC RESUME \"%s\" %d %u\01\r\n" :
"PRIVMSG %s :\01DCC RESUME %s %d %u\01\r\n",
"PRIVMSG %s :\01DCC RESUME \"%s\" %d %u\01\n" :
"PRIVMSG %s :\01DCC RESUME %s %d %u\01",
ptr_dcc->nick, ptr_dcc->filename,
ptr_dcc->port, ptr_dcc->start_resume);
dcc_redraw (HOTLIST_MSG);
@@ -661,8 +661,8 @@ dcc_accept_resume (t_irc_server *server, char *filename, int port,
ptr_dcc->last_check_pos = pos_start;
server_sendf (ptr_dcc->server,
(strchr (ptr_dcc->filename, ' ')) ?
"PRIVMSG %s :\01DCC ACCEPT \"%s\" %d %u\01\r\n" :
"PRIVMSG %s :\01DCC ACCEPT %s %d %u\01\r\n",
"PRIVMSG %s :\01DCC ACCEPT \"%s\" %d %u\01\n" :
"PRIVMSG %s :\01DCC ACCEPT %s %d %u\01",
ptr_dcc->nick, ptr_dcc->filename,
ptr_dcc->port, ptr_dcc->start_resume);
@@ -1158,13 +1158,13 @@ dcc_send_request (t_irc_server *server, int type, char *nick, char *filename)
/* send DCC request to nick */
if (type == DCC_CHAT_SEND)
server_sendf (server,
"PRIVMSG %s :\01DCC CHAT chat %lu %d\01\r\n",
"PRIVMSG %s :\01DCC CHAT chat %lu %d\01",
nick, local_addr, port);
else
server_sendf (server,
(spaces) ?
"PRIVMSG %s :\01DCC SEND \"%s\" %lu %d %u\01\r\n" :
"PRIVMSG %s :\01DCC SEND %s %lu %d %u\01\r\n",
"PRIVMSG %s :\01DCC SEND \"%s\" %lu %d %u\01\n" :
"PRIVMSG %s :\01DCC SEND %s %lu %d %u\01",
nick, short_filename, local_addr, port,
(unsigned long) st.st_size);
+11 -11
View File
@@ -725,7 +725,7 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments
nick);
}
irc_mode_channel_set (ptr_channel, pos_modes);
server_sendf (server, "MODE %s\r\n", ptr_channel->name);
server_sendf (server, "MODE %s", ptr_channel->name);
}
else
{
@@ -1180,7 +1180,7 @@ irc_cmd_recv_ping (t_irc_server *server, char *host, char *nick, char *arguments
pos = strrchr (arguments, ' ');
if (pos)
pos[0] = '\0';
server_sendf (server, "PONG :%s\r\n", arguments);
server_sendf (server, "PONG :%s", arguments);
return 0;
}
@@ -1253,7 +1253,7 @@ irc_cmd_reply_version (t_irc_server *server, t_irc_channel *channel,
"%s %s / %s%s",
nick, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__,
&buf->sysname,
&buf->release, &buf->machine, "\01\r\n");
&buf->release, &buf->machine, "\01");
free (buf);
}
else
@@ -1261,7 +1261,7 @@ irc_cmd_reply_version (t_irc_server *server, t_irc_channel *channel,
"NOTICE %s :%sVERSION %s v%s"
" compiled on %s%s",
nick, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__,
"\01\r\n");
"\01");
irc_display_prefix (server, ptr_buffer, PREFIX_SERVER);
gui_printf (ptr_buffer,
_("CTCP %sVERSION%s received from %s%s"),
@@ -1408,10 +1408,10 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if (pos && !pos[0])
pos = NULL;
if (pos)
server_sendf (server, "NOTICE %s :\01PING %s\01\r\n",
server_sendf (server, "NOTICE %s :\01PING %s\01",
nick, pos);
else
server_sendf (server, "NOTICE %s :\01PING\01\r\n",
server_sendf (server, "NOTICE %s :\01PING\01",
nick);
irc_display_prefix (server, ptr_channel->buffer, PREFIX_SERVER);
gui_printf (ptr_channel->buffer,
@@ -1549,10 +1549,10 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if (pos && !pos[0])
pos = NULL;
if (pos)
server_sendf (server, "NOTICE %s :\01PING %s\01\r\n",
server_sendf (server, "NOTICE %s :\01PING %s\01",
nick, pos);
else
server_sendf (server, "NOTICE %s :\01PING\01\r\n",
server_sendf (server, "NOTICE %s :\01PING\01",
nick);
irc_display_prefix (server, server->buffer, PREFIX_SERVER);
gui_printf (server->buffer,
@@ -2414,10 +2414,10 @@ irc_cmd_recv_001 (t_irc_server *server, char *host, char *nick, char *arguments)
if (ptr_channel->type == CHANNEL_TYPE_CHANNEL)
{
if (ptr_channel->key)
server_sendf (server, "JOIN %s %s\r\n",
server_sendf (server, "JOIN %s %s",
ptr_channel->name, ptr_channel->key);
else
server_sendf (server, "JOIN %s\r\n",
server_sendf (server, "JOIN %s",
ptr_channel->name);
}
}
@@ -4811,7 +4811,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *nick, char *arguments)
if (!hostname[0])
strcpy (hostname, _("unknown"));
server_sendf (server,
"NICK %s\r\n",
"NICK %s",
server->nick);
}
else
+94 -94
View File
@@ -54,7 +54,7 @@ irc_login (t_irc_server *server)
char hostname[NI_MAXHOST];
if ((server->password) && (server->password[0]))
server_sendf (server, "PASS %s\r\n", server->password);
server_sendf (server, "PASS %s", server->password);
gethostname (hostname, sizeof (hostname) - 1);
hostname[sizeof (hostname) - 1] = '\0';
@@ -68,8 +68,8 @@ irc_login (t_irc_server *server)
if (!server->nick)
server->nick = strdup (server->nick1);
server_sendf (server,
"NICK %s\r\n"
"USER %s %s %s :%s\r\n",
"NICK %s\n"
"USER %s %s %s :%s",
server->nick, server->username, hostname, "servername",
server->realname);
gui_input_draw (gui_current_window->buffer, 1);
@@ -87,9 +87,9 @@ irc_cmd_send_admin (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "ADMIN %s\r\n", arguments);
server_sendf (server, "ADMIN %s", arguments);
else
server_sendf (server, "ADMIN\r\n");
server_sendf (server, "ADMIN");
return 0;
}
@@ -103,7 +103,7 @@ irc_send_me (t_irc_server *server, t_irc_channel *channel,
{
char *string;
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01",
channel->name,
(arguments && arguments[0]) ? arguments : "");
irc_display_prefix (NULL, channel->buffer, PREFIX_ACTION_ME);
@@ -200,7 +200,7 @@ irc_cmd_send_amsg (t_irc_server *server, t_irc_channel *channel,
{
if (ptr_channel->type == CHANNEL_TYPE_CHANNEL)
{
server_sendf (ptr_server, "PRIVMSG %s :%s\r\n",
server_sendf (ptr_server, "PRIVMSG %s :%s",
ptr_channel->name, arguments);
ptr_nick = nick_search (ptr_channel, ptr_server->nick);
if (ptr_nick)
@@ -250,7 +250,7 @@ irc_send_away (t_irc_server *server, char *arguments)
if (server->away_message)
strcpy (server->away_message, arguments);
server->away_time = time (NULL);
server_sendf (server, "AWAY :%s\r\n", arguments);
server_sendf (server, "AWAY :%s", arguments);
if (cfg_irc_display_away != CFG_IRC_DISPLAY_AWAY_OFF)
{
string = (char *)gui_color_decode ((unsigned char *)arguments, 1);
@@ -275,7 +275,7 @@ irc_send_away (t_irc_server *server, char *arguments)
}
else
{
server_sendf (server, "AWAY\r\n");
server_sendf (server, "AWAY");
server->is_away = 0;
if (server->away_message)
{
@@ -428,7 +428,7 @@ irc_cmd_send_ban (t_irc_server *server, t_irc_channel *channel,
while (pos2[0] == ' ')
pos2++;
}
server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos);
server_sendf (server, "MODE %s +b %s", pos_channel, pos);
pos = pos2;
}
}
@@ -442,7 +442,7 @@ irc_cmd_send_ban (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, "ban");
return -1;
}
server_sendf (server, "MODE %s +b\r\n", CHANNEL(buffer)->name);
server_sendf (server, "MODE %s +b", CHANNEL(buffer)->name);
}
return 0;
@@ -500,7 +500,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
if ((ascii_strcasecmp (pos_type, "ping") == 0) && (!pos_args))
{
gettimeofday (&tv, NULL);
server_sendf (server, "PRIVMSG %s :\01PING %d %d\01\r\n",
server_sendf (server, "PRIVMSG %s :\01PING %d %d\01",
arguments, tv.tv_sec, tv.tv_usec);
gui_printf (server->buffer, " %s%d %d\n",
GUI_COLOR(COLOR_WIN_CHAT),
@@ -510,7 +510,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
{
if (pos_args)
{
server_sendf (server, "PRIVMSG %s :\01%s %s\01\r\n",
server_sendf (server, "PRIVMSG %s :\01%s %s\01",
arguments, pos_type, pos_args);
gui_printf (server->buffer, " %s%s\n",
GUI_COLOR(COLOR_WIN_CHAT),
@@ -518,7 +518,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
}
else
{
server_sendf (server, "PRIVMSG %s :\01%s\01\r\n",
server_sendf (server, "PRIVMSG %s :\01%s\01",
arguments, pos_type);
gui_printf (server->buffer, "\n");
}
@@ -617,13 +617,13 @@ irc_cmd_send_cycle (t_irc_server *server, t_irc_channel *channel,
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
server_sendf (server, "PART %s :%s", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
server_sendf (server, "PART %s", channel_name);
return 0;
}
@@ -643,7 +643,7 @@ irc_cmd_send_dehalfop (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s -h %s\r\n",
server_sendf (server, "MODE %s -h %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -675,7 +675,7 @@ irc_cmd_send_deop (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s -o %s\r\n",
server_sendf (server, "MODE %s -o %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -707,7 +707,7 @@ irc_cmd_send_devoice (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s -v %s\r\n",
server_sendf (server, "MODE %s -v %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -737,7 +737,7 @@ irc_cmd_send_die (t_irc_server *server, t_irc_channel *channel,
(void) channel;
(void) arguments;
server_sendf (server, "DIE\r\n");
server_sendf (server, "DIE");
return 0;
}
@@ -756,7 +756,7 @@ irc_cmd_send_halfop (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s +h %s\r\n",
server_sendf (server, "MODE %s +h %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -786,9 +786,9 @@ irc_cmd_send_info (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "INFO %s\r\n", arguments);
server_sendf (server, "INFO %s", arguments);
else
server_sendf (server, "INFO\r\n");
server_sendf (server, "INFO");
return 0;
}
@@ -805,7 +805,7 @@ irc_cmd_send_invite (t_irc_server *server, t_irc_channel *channel,
irc_find_context (server, channel, NULL, &buffer);
if (argc == 2)
server_sendf (server, "INVITE %s %s\r\n", argv[0], argv[1]);
server_sendf (server, "INVITE %s %s", argv[0], argv[1]);
else
{
if (!BUFFER_IS_CHANNEL(buffer))
@@ -816,7 +816,7 @@ irc_cmd_send_invite (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, "invite");
return -1;
}
server_sendf (server, "INVITE %s %s\r\n",
server_sendf (server, "INVITE %s %s",
argv[0], CHANNEL(buffer)->name);
}
return 0;
@@ -833,7 +833,7 @@ irc_cmd_send_ison (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "ISON %s\r\n", arguments);
server_sendf (server, "ISON %s", arguments);
return 0;
}
@@ -849,9 +849,9 @@ irc_cmd_send_join (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (string_is_channel (arguments))
server_sendf (server, "JOIN %s\r\n", arguments);
server_sendf (server, "JOIN %s", arguments);
else
server_sendf (server, "JOIN #%s\r\n", arguments);
server_sendf (server, "JOIN #%s", arguments);
return 0;
}
@@ -909,9 +909,9 @@ irc_cmd_send_kick (t_irc_server *server, t_irc_channel *channel,
}
if (pos_comment)
server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
server_sendf (server, "KICK %s %s :%s", pos_channel, pos_nick, pos_comment);
else
server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
server_sendf (server, "KICK %s %s", pos_channel, pos_nick);
return 0;
}
@@ -969,11 +969,11 @@ irc_cmd_send_kickban (t_irc_server *server, t_irc_channel *channel,
pos_comment++;
}
server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos_nick);
server_sendf (server, "MODE %s +b %s", pos_channel, pos_nick);
if (pos_comment)
server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
server_sendf (server, "KICK %s %s :%s", pos_channel, pos_nick, pos_comment);
else
server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
server_sendf (server, "KICK %s %s", pos_channel, pos_nick);
return 0;
}
@@ -998,10 +998,10 @@ irc_cmd_send_kill (t_irc_server *server, t_irc_channel *channel,
pos++;
while (pos[0] == ' ')
pos++;
server_sendf (server, "KILL %s :%s\r\n", arguments, pos);
server_sendf (server, "KILL %s :%s", arguments, pos);
}
else
server_sendf (server, "KILL %s\r\n", arguments);
server_sendf (server, "KILL %s", arguments);
return 0;
}
@@ -1018,9 +1018,9 @@ irc_cmd_send_links (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "LINKS %s\r\n", arguments);
server_sendf (server, "LINKS %s", arguments);
else
server_sendf (server, "LINKS\r\n");
server_sendf (server, "LINKS");
return 0;
}
@@ -1057,7 +1057,7 @@ irc_cmd_send_list (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, arguments, buffer);
}
else
server_sendf (server, "LIST\r\n");
server_sendf (server, "LIST");
}
else
{
@@ -1067,7 +1067,7 @@ irc_cmd_send_list (t_irc_server *server, t_irc_channel *channel,
}
}
else
server_sendf (server, "LIST\r\n");
server_sendf (server, "LIST");
return 0;
}
@@ -1084,9 +1084,9 @@ irc_cmd_send_lusers (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "LUSERS %s\r\n", arguments);
server_sendf (server, "LUSERS %s", arguments);
else
server_sendf (server, "LUSERS\r\n");
server_sendf (server, "LUSERS");
return 0;
}
@@ -1125,7 +1125,7 @@ irc_cmd_send_mode (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "MODE %s\r\n", arguments);
server_sendf (server, "MODE %s", arguments);
return 0;
}
@@ -1155,7 +1155,7 @@ irc_send_mode_nicks (t_irc_server *server, char *channel,
strcat (command, " ");
strcat (command, argv[i]);
}
server_sendf (server, "%s\r\n", command);
server_sendf (server, "%s", command);
free (command);
}
}
@@ -1172,9 +1172,9 @@ irc_cmd_send_motd (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "MOTD %s\r\n", arguments);
server_sendf (server, "MOTD %s", arguments);
else
server_sendf (server, "MOTD\r\n");
server_sendf (server, "MOTD");
return 0;
}
@@ -1237,7 +1237,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos);
server_sendf (server, "PRIVMSG %s :%s", ptr_channel->name, pos);
}
else
{
@@ -1265,7 +1265,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, server->nick, "msg");
}
}
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
}
else
{
@@ -1301,7 +1301,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
(string) ? string : "");
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
free (msg_pwd_hidden);
return 0;
}
@@ -1332,7 +1332,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
}
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
}
}
arguments = pos_comma;
@@ -1362,7 +1362,7 @@ irc_cmd_send_names (t_irc_server *server, t_irc_channel *channel,
irc_find_context (server, channel, NULL, &buffer);
if (arguments)
server_sendf (server, "NAMES %s\r\n", arguments);
server_sendf (server, "NAMES %s", arguments);
else
{
if (!BUFFER_IS_CHANNEL(buffer))
@@ -1374,7 +1374,7 @@ irc_cmd_send_names (t_irc_server *server, t_irc_channel *channel,
return -1;
}
else
server_sendf (server, "NAMES %s\r\n",
server_sendf (server, "NAMES %s",
CHANNEL(buffer)->name);
}
return 0;
@@ -1390,7 +1390,7 @@ irc_cmd_send_nick_server (t_irc_server *server, char *nickname)
t_irc_channel *ptr_channel;
if (server->is_connected)
server_sendf (server, "NICK %s\r\n", nickname);
server_sendf (server, "NICK %s", nickname);
else
{
if (server->nick)
@@ -1474,7 +1474,7 @@ irc_cmd_send_notice (t_irc_server *server, t_irc_channel *channel,
(string) ? string : "");
if (string)
free (string);
server_sendf (server, "NOTICE %s :%s\r\n", arguments, pos);
server_sendf (server, "NOTICE %s :%s", arguments, pos);
}
else
{
@@ -1502,7 +1502,7 @@ irc_cmd_send_op (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s +o %s\r\n",
server_sendf (server, "MODE %s +o %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -1531,7 +1531,7 @@ irc_cmd_send_oper (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "OPER %s\r\n", arguments);
server_sendf (server, "OPER %s", arguments);
return 0;
}
@@ -1607,13 +1607,13 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
server_sendf (server, "PART %s :%s", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
server_sendf (server, "PART %s", channel_name);
return 0;
}
@@ -1629,7 +1629,7 @@ irc_cmd_send_ping (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "PING %s\r\n", arguments);
server_sendf (server, "PING %s", arguments);
return 0;
}
@@ -1644,7 +1644,7 @@ irc_cmd_send_pong (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "PONG %s\r\n", arguments);
server_sendf (server, "PONG %s", arguments);
return 0;
}
@@ -1717,7 +1717,7 @@ irc_cmd_send_query (t_irc_server *server, t_irc_channel *channel,
(string) ? string : "");
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
}
return 0;
}
@@ -1740,13 +1740,13 @@ irc_send_quit_server (t_irc_server *server, char *arguments)
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "QUIT :%s\r\n",
server_sendf (server, "QUIT :%s",
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "QUIT\r\n");
server_sendf (server, "QUIT");
}
}
@@ -1784,7 +1784,7 @@ irc_cmd_send_quote (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "%s\r\n", arguments);
server_sendf (server, "%s", arguments);
return 0;
}
@@ -1800,7 +1800,7 @@ irc_cmd_send_rehash (t_irc_server *server, t_irc_channel *channel,
(void) channel;
(void) arguments;
server_sendf (server, "REHASH\r\n");
server_sendf (server, "REHASH");
return 0;
}
@@ -1816,7 +1816,7 @@ irc_cmd_send_restart (t_irc_server *server, t_irc_channel *channel,
(void) channel;
(void) arguments;
server_sendf (server, "RESTART\r\n");
server_sendf (server, "RESTART");
return 0;
}
@@ -1831,7 +1831,7 @@ irc_cmd_send_service (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "SERVICE %s\r\n", arguments);
server_sendf (server, "SERVICE %s", arguments);
return 0;
}
@@ -1847,9 +1847,9 @@ irc_cmd_send_servlist (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "SERVLIST %s\r\n", arguments);
server_sendf (server, "SERVLIST %s", arguments);
else
server_sendf (server, "SERVLIST\r\n");
server_sendf (server, "SERVLIST");
return 0;
}
@@ -1875,10 +1875,10 @@ irc_cmd_send_squery (t_irc_server *server, t_irc_channel *channel,
{
pos++;
}
server_sendf (server, "SQUERY %s :%s\r\n", arguments, pos);
server_sendf (server, "SQUERY %s :%s", arguments, pos);
}
else
server_sendf (server, "SQUERY %s\r\n", arguments);
server_sendf (server, "SQUERY %s", arguments);
return 0;
}
@@ -1894,7 +1894,7 @@ irc_cmd_send_squit (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "SQUIT %s\r\n", arguments);
server_sendf (server, "SQUIT %s", arguments);
return 0;
}
@@ -1910,9 +1910,9 @@ irc_cmd_send_stats (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "STATS %s\r\n", arguments);
server_sendf (server, "STATS %s", arguments);
else
server_sendf (server, "STATS\r\n");
server_sendf (server, "STATS");
return 0;
}
@@ -1928,7 +1928,7 @@ irc_cmd_send_summon (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "SUMMON %s\r\n", arguments);
server_sendf (server, "SUMMON %s", arguments);
return 0;
}
@@ -1944,9 +1944,9 @@ irc_cmd_send_time (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "TIME %s\r\n", arguments);
server_sendf (server, "TIME %s", arguments);
else
server_sendf (server, "TIME\r\n");
server_sendf (server, "TIME");
return 0;
}
@@ -2002,12 +2002,12 @@ irc_cmd_send_topic (t_irc_server *server, t_irc_channel *channel,
if (new_topic)
{
if (strcmp (new_topic, "-delete") == 0)
server_sendf (server, "TOPIC %s :\r\n", channel_name);
server_sendf (server, "TOPIC %s :", channel_name);
else
server_sendf (server, "TOPIC %s :%s\r\n", channel_name, new_topic);
server_sendf (server, "TOPIC %s :%s", channel_name, new_topic);
}
else
server_sendf (server, "TOPIC %s\r\n", channel_name);
server_sendf (server, "TOPIC %s", channel_name);
return 0;
}
@@ -2024,9 +2024,9 @@ irc_cmd_send_trace (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "TRACE %s\r\n", arguments);
server_sendf (server, "TRACE %s", arguments);
else
server_sendf (server, "TRACE\r\n");
server_sendf (server, "TRACE");
return 0;
}
@@ -2092,7 +2092,7 @@ irc_cmd_send_unban (t_irc_server *server, t_irc_channel *channel,
while (pos2[0] == ' ')
pos2++;
}
server_sendf (server, "MODE %s -b %s\r\n", pos_channel, pos);
server_sendf (server, "MODE %s -b %s", pos_channel, pos);
pos = pos2;
}
}
@@ -2118,7 +2118,7 @@ irc_cmd_send_userhost (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "USERHOST %s\r\n", arguments);
server_sendf (server, "USERHOST %s", arguments);
return 0;
}
@@ -2134,9 +2134,9 @@ irc_cmd_send_users (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "USERS %s\r\n", arguments);
server_sendf (server, "USERS %s", arguments);
else
server_sendf (server, "USERS\r\n");
server_sendf (server, "USERS");
return 0;
}
@@ -2156,10 +2156,10 @@ irc_cmd_send_version (t_irc_server *server, t_irc_channel *channel,
{
if (BUFFER_IS_CHANNEL(buffer) &&
nick_search (CHANNEL(buffer), arguments))
server_sendf (server, "PRIVMSG %s :\01VERSION\01\r\n",
server_sendf (server, "PRIVMSG %s :\01VERSION\01",
arguments);
else
server_sendf (server, "VERSION %s\r\n",
server_sendf (server, "VERSION %s",
arguments);
}
else
@@ -2168,7 +2168,7 @@ irc_cmd_send_version (t_irc_server *server, t_irc_channel *channel,
gui_printf (server->buffer, _("%s, compiled on %s %s\n"),
PACKAGE_STRING,
__DATE__, __TIME__);
server_sendf (server, "VERSION\r\n");
server_sendf (server, "VERSION");
}
return 0;
}
@@ -2188,7 +2188,7 @@ irc_cmd_send_voice (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s +v %s\r\n",
server_sendf (server, "MODE %s +v %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -2218,7 +2218,7 @@ irc_cmd_send_wallops (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "WALLOPS :%s\r\n", arguments);
server_sendf (server, "WALLOPS :%s", arguments);
return 0;
}
@@ -2234,9 +2234,9 @@ irc_cmd_send_who (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "WHO %s\r\n", arguments);
server_sendf (server, "WHO %s", arguments);
else
server_sendf (server, "WHO\r\n");
server_sendf (server, "WHO");
return 0;
}
@@ -2251,7 +2251,7 @@ irc_cmd_send_whois (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "WHOIS %s\r\n", arguments);
server_sendf (server, "WHOIS %s", arguments);
return 0;
}
@@ -2266,6 +2266,6 @@ irc_cmd_send_whowas (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "WHOWAS %s\r\n", arguments);
server_sendf (server, "WHOWAS %s", arguments);
return 0;
}
+215 -86
View File
@@ -49,6 +49,10 @@
#include "../common/weeconfig.h"
#include "../gui/gui.h"
#ifdef PLUGINS
#include "../plugins/plugins.h"
#endif
t_irc_server *irc_servers = NULL;
t_irc_server *last_irc_server = NULL;
@@ -553,8 +557,80 @@ server_send (t_irc_server *server, char *buffer, int size_buf)
return send (server->sock, buffer, size_buf, 0);
}
/*
* server_send_one_msg: send one message to IRC server
*/
int
server_send_one_msg (t_irc_server *server, char *message)
{
static char buffer[4096];
char *new_msg, *ptr_msg, *pos;
int rc;
rc = 1;
gui_printf_raw_data (server, 1, 0, message);
#ifdef DEBUG
gui_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n", message);
#endif
#ifdef PLUGINS
new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
server->name,
message);
#else
new_msg = NULL;
#endif
/* no changes in new message */
if (new_msg && (strcmp (buffer, new_msg) == 0))
{
free (new_msg);
new_msg = NULL;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
{
ptr_msg = (new_msg) ? new_msg : message;
while (rc && ptr_msg && ptr_msg[0])
{
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
if (new_msg)
gui_printf_raw_data (server, 1, 1, ptr_msg);
snprintf (buffer, sizeof (buffer) - 1, "%s\r\n", ptr_msg);
if (server_send (server, buffer, strlen (buffer)) <= 0)
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf (server->buffer, _("%s error sending data to IRC server\n"),
WEECHAT_ERROR);
rc = 0;
}
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
}
}
else
gui_printf_raw_data (server, 1, 1, _("(message dropped)"));
if (new_msg)
free (new_msg);
return rc;
}
/*
* server_sendf: send formatted data to IRC server
* many messages may be sent, separated by '\n'
*/
void
@@ -562,34 +638,81 @@ server_sendf (t_irc_server *server, char *fmt, ...)
{
va_list args;
static char buffer[4096];
int size_buf;
char *ptr_buf, *pos;
int rc;
if (!server)
return;
va_start (args, fmt);
size_buf = vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
va_end (args);
if ((size_buf == 0) || (strcmp (buffer, "\r\n") == 0))
return;
vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
va_end (args);
buffer[sizeof (buffer) - 1] = '\0';
if ((size_buf < 0) || (size_buf > (int) (sizeof (buffer) - 1)))
size_buf = strlen (buffer);
buffer[size_buf - 2] = '\0';
gui_printf_raw_data (server, 1, buffer);
#ifdef DEBUG
gui_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n", buffer);
#endif
buffer[size_buf - 2] = '\r';
if (server_send (server, buffer, strlen (buffer)) <= 0)
ptr_buf = buffer;
while (ptr_buf && ptr_buf[0])
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf (server->buffer, _("%s error sending data to IRC server\n"),
WEECHAT_ERROR);
pos = strchr (ptr_buf, '\n');
if (pos)
pos[0] = '\0';
rc = server_send_one_msg (server, ptr_buf);
if (pos)
{
pos[0] = '\n';
ptr_buf = pos + 1;
}
else
ptr_buf = NULL;
if (!rc)
ptr_buf = NULL;
}
}
/*
* server_parse_message: parse IRC message and return pointer to
* host, command and arguments (if any)
*/
void
server_parse_message (char *message, char **host, char **command, char **args)
{
char *pos, *pos2;
*host = NULL;
*command = NULL;
*args = NULL;
if (message[0] == ':')
{
pos = strchr (message, ' ');
if (pos)
{
*host = strndup (message + 1, pos - (message + 1));
pos++;
}
else
pos = message;
}
else
pos = message;
if (pos && pos[0])
{
while (pos[0] == ' ')
pos++;
pos2 = strchr (pos, ' ');
if (pos2)
{
*command = strndup (pos, pos2 - pos);
pos2++;
while (pos2[0] == ' ')
pos2++;
if (pos2[0] == ':')
pos2++;
*args = strdup (pos2);
}
}
}
@@ -735,7 +858,7 @@ void
server_msgq_flush ()
{
t_irc_message *next;
char *entire_line, *ptr_data, *pos, *pos2;
char *ptr_data, *new_msg, *ptr_msg, *pos;
char *host, *command, *args;
while (recv_msgq)
@@ -745,84 +868,90 @@ server_msgq_flush ()
#ifdef DEBUG
gui_printf (gui_current_window->buffer, "[DEBUG] %s\n", recv_msgq->data);
#endif
ptr_data = recv_msgq->data;
entire_line = strdup (ptr_data);
while (ptr_data[0] == ' ')
ptr_data++;
if (ptr_data && ptr_data[0])
if (ptr_data[0])
{
gui_printf_raw_data (recv_msgq->server, 0, ptr_data);
gui_printf_raw_data (recv_msgq->server, 0, 0, ptr_data);
#ifdef DEBUG
gui_printf (NULL, "[DEBUG] data received from server: %s\n", ptr_data);
#endif
host = NULL;
command = NULL;
args = ptr_data;
if (ptr_data[0] == ':')
#ifdef PLUGINS
new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN,
recv_msgq->server->name,
ptr_data);
#else
new_msg = NULL;
#endif
/* no changes in new message */
if (new_msg && (strcmp (ptr_data, new_msg) == 0))
{
pos = strchr (ptr_data, ' ');
if (pos)
free (new_msg);
new_msg = NULL;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
{
/* use new message (returned by plugin) */
ptr_msg = (new_msg) ? new_msg : ptr_data;
while (ptr_msg && ptr_msg[0])
{
pos[0] = '\0';
host = ptr_data + 1;
pos++;
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
if (new_msg)
gui_printf_raw_data (recv_msgq->server, 0, 1, ptr_msg);
server_parse_message (ptr_msg, &host, &command, &args);
switch (irc_recv_command (recv_msgq->server, ptr_msg, host, command, args))
{
case -1:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Command \"%s\" failed!\n"), WEECHAT_ERROR, command);
break;
case -2:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s No command to execute!\n"), WEECHAT_ERROR);
break;
case -3:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Unknown command: cmd=\"%s\", host=\"%s\", args=\"%s\"\n"),
WEECHAT_WARNING, command, host, args);
break;
}
if (host)
free (host);
if (command)
free (command);
if (args)
free (args);
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
}
else
pos = ptr_data;
}
else
pos = ptr_data;
if (pos && pos[0])
{
while (pos[0] == ' ')
pos++;
pos2 = strchr (pos, ' ');
if (pos2)
{
pos2[0] = '\0';
command = strdup (pos);
pos2++;
while (pos2[0] == ' ')
pos2++;
args = (pos2[0] == ':') ? pos2 + 1 : pos2;
}
}
switch (irc_recv_command (recv_msgq->server, entire_line, host,
command, args))
{
case -1:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Command \"%s\" failed!\n"), WEECHAT_ERROR, command);
break;
case -2:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s No command to execute!\n"), WEECHAT_ERROR);
break;
case -3:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Unknown command: cmd=\"%s\", host=\"%s\", args=\"%s\"\n"),
WEECHAT_WARNING, command, host, args);
break;
}
if (command)
free (command);
gui_printf_raw_data (recv_msgq->server, 0, 1, _("(message dropped)"));
if (new_msg)
free (new_msg);
}
free (entire_line);
free (recv_msgq->data);
}
+3
View File
@@ -50,6 +50,8 @@
#define PREFIX_QUIT "<--"
#define PREFIX_ERROR "=!="
#define PREFIX_PLUGIN "-P-"
#define PREFIX_RECV_MOD "==>"
#define PREFIX_SEND_MOD "<=="
#define DEFAULT_IRC_PORT 6667
@@ -345,6 +347,7 @@ extern char *server_get_charset_decode_utf (t_irc_server *);
extern char *server_get_charset_encode (t_irc_server *);
extern int server_send (t_irc_server *, char *, int);
extern void server_sendf (t_irc_server *, char *, ...);
extern void server_parse_message (char *, char **, char **, char **);
extern void server_recv (t_irc_server *);
extern void server_child_read (t_irc_server *);
extern int server_connect (t_irc_server *);
+40
View File
@@ -356,6 +356,46 @@ weechat_plugin_handler_remove_all (t_weechat_plugin *plugin)
plugin_handler_remove_all (plugin);
}
/*
* weechat_plugin_modifier_add: add a IRC message modifier
*/
t_plugin_modifier *
weechat_plugin_modifier_add (t_weechat_plugin *plugin,
char *type, char *message,
t_plugin_modifier_func *modifier_func,
char *modifier_args, void *modifier_pointer)
{
if (plugin && type && modifier_func)
return plugin_modifier_add (plugin, type, message, modifier_func,
modifier_args, modifier_pointer);
return NULL;
}
/*
* weechat_plugin_modifier_remove: remove a WeeChat modifier
*/
void
weechat_plugin_modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
{
if (plugin && modifier)
plugin_modifier_remove (plugin, modifier);
}
/*
* weechat_plugin_modifier_remove_all: remove all WeeChat modifiers
*/
void
weechat_plugin_modifier_remove_all (t_weechat_plugin *plugin)
{
if (plugin)
plugin_modifier_remove_all (plugin);
}
/*
* weechat_plugin_exec_command: execute a command (simulate user entry)
*/
+251 -14
View File
@@ -180,7 +180,7 @@ plugin_cmd_handler_search (char *command)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command, command) == 0))
return ptr_handler;
}
@@ -212,7 +212,7 @@ plugin_msg_handler_add (t_weechat_plugin *plugin, char *irc_command,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_MESSAGE;
new_handler->type = PLUGIN_HANDLER_MESSAGE;
new_handler->irc_command = strdup (irc_command);
new_handler->command = NULL;
new_handler->description = NULL;
@@ -295,7 +295,7 @@ plugin_cmd_handler_add (t_weechat_plugin *plugin, char *command,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_COMMAND;
new_handler->type = PLUGIN_HANDLER_COMMAND;
new_handler->irc_command = NULL;
new_handler->command = strdup (command);
new_handler->description = (description) ? strdup (description) : NULL;
@@ -355,7 +355,7 @@ plugin_timer_handler_add (t_weechat_plugin *plugin, int interval,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_TIMER;
new_handler->type = PLUGIN_HANDLER_TIMER;
new_handler->irc_command = NULL;
new_handler->command = NULL;
new_handler->description = NULL;
@@ -411,7 +411,7 @@ plugin_keyboard_handler_add (t_weechat_plugin *plugin,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_KEYBOARD;
new_handler->type = PLUGIN_HANDLER_KEYBOARD;
new_handler->irc_command = NULL;
new_handler->command = NULL;
new_handler->description = NULL;
@@ -471,7 +471,7 @@ plugin_msg_handler_exec (char *server, char *irc_command, char *irc_message)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_MESSAGE)
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ascii_strcasecmp (ptr_handler->irc_command, irc_command) == 0))
{
if (ptr_handler->running == 0)
@@ -523,7 +523,7 @@ plugin_cmd_handler_exec (char *server, char *command, char *arguments)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command, command) == 0))
{
if (ptr_handler->running == 0)
@@ -564,7 +564,7 @@ plugin_timer_handler_exec ()
for (ptr_handler = ptr_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->remaining--;
if (ptr_handler->remaining <= 0)
@@ -610,7 +610,7 @@ plugin_keyboard_handler_exec (char *key, char *input_before, char *input_after)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_KEYBOARD)
if (ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
{
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
3, argv,
@@ -650,7 +650,7 @@ plugin_handler_remove (t_weechat_plugin *plugin,
(handler->next_handler)->prev_handler = handler->prev_handler;
/* remove command from WeeChat command list, if command handler */
if (handler->type == HANDLER_COMMAND)
if (handler->type == PLUGIN_HANDLER_COMMAND)
weelist_remove (&index_commands, &last_index_command,
weelist_search (index_commands, handler->command));
@@ -682,6 +682,199 @@ plugin_handler_remove_all (t_weechat_plugin *plugin)
plugin_handler_remove (plugin, plugin->handlers);
}
/*
* plugin_modifier_add: add a IRC handler
* arguments:
* 1. the plugin pointer
* 2. type of modifier
* 3. message ("*" means all)
* 4. the modifier function
* 5. modifier args: a string given to
* modifier when called (used by scripts)
* 6. modifier pointer: a pointer given to
* modifier when called (used by scripts)
*/
t_plugin_modifier *
plugin_modifier_add (t_weechat_plugin *plugin, char *type, char *command,
t_plugin_modifier_func *modifier_func,
char *modifier_args, void *modifier_pointer)
{
t_plugin_modifier *new_modifier;
int type_int;
if (ascii_strcasecmp (type, PLUGIN_MODIFIER_IRC_IN_STR) == 0)
type_int = PLUGIN_MODIFIER_IRC_IN;
else if (ascii_strcasecmp (type, PLUGIN_MODIFIER_IRC_USER_STR) == 0)
type_int = PLUGIN_MODIFIER_IRC_USER;
else if (ascii_strcasecmp (type, PLUGIN_MODIFIER_IRC_OUT_STR) == 0)
type_int = PLUGIN_MODIFIER_IRC_OUT;
else
return NULL;
new_modifier = (t_plugin_modifier *)malloc (sizeof (t_plugin_modifier));
if (new_modifier)
{
new_modifier->type = type_int;
new_modifier->command = (command) ? strdup (command) : strdup ("*");
new_modifier->modifier = modifier_func;
new_modifier->modifier_args = (modifier_args) ? strdup (modifier_args) : NULL;
new_modifier->modifier_pointer = modifier_pointer;
new_modifier->running = 0;
/* add new modifier to list */
new_modifier->prev_modifier = plugin->last_modifier;
new_modifier->next_modifier = NULL;
if (plugin->modifiers)
(plugin->last_modifier)->next_modifier = new_modifier;
else
plugin->modifiers = new_modifier;
plugin->last_modifier = new_modifier;
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s plugin %s: unable to add modifier (not enough memory)\n"),
WEECHAT_ERROR, plugin->name);
return NULL;
}
return new_modifier;
}
/*
* plugin_modifier_exec: execute a modifier
* return: NULL if no modifier was applied on message
* "" (empty string) if message has been dropped by a modifier
* other string if message has been modified
*/
char *
plugin_modifier_exec (t_plugin_modifier_type type,
char *server, char *message)
{
t_weechat_plugin *ptr_plugin;
t_plugin_modifier *ptr_modifier;
char *argv[2] = { NULL, NULL };
char *new_msg, *pos, *command;
int length_command;
argv[0] = server;
argv[1] = message;
command = NULL;
length_command = 0;
if ((type == PLUGIN_MODIFIER_IRC_IN) || (type == PLUGIN_MODIFIER_IRC_OUT))
{
/* look for command in message */
if (message[0] == ':')
{
pos = strchr (message, ' ');
if (pos)
{
while (pos[0] == ' ')
pos++;
command = pos;
}
}
else
command = message;
if (command)
{
pos = strchr (command, ' ');
if (pos)
length_command = pos - command;
else
length_command = strlen (command);
}
}
new_msg = NULL;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
for (ptr_modifier = ptr_plugin->modifiers;
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
{
if (ptr_modifier->type == type)
{
if (ptr_modifier->running == 0)
{
if (((type != PLUGIN_MODIFIER_IRC_IN) && (type != PLUGIN_MODIFIER_IRC_OUT))
|| (ascii_strcasecmp (ptr_modifier->command, "*") == 0)
|| (command && (ascii_strncasecmp (ptr_modifier->command, command, length_command) == 0)))
{
ptr_modifier->running = 1;
new_msg = ((char *) (ptr_modifier->modifier) (ptr_plugin,
2, argv,
ptr_modifier->modifier_args,
ptr_modifier->modifier_pointer));
ptr_modifier->running = 0;
/* message dropped? */
if (new_msg && !new_msg[0])
return new_msg;
/* new message => keep it as base for next modifier */
if (new_msg)
{
/* free any new message allocated before by another modifier */
if (argv[1] != message)
free (argv[1]);
argv[1] = new_msg;
}
}
}
}
}
}
return new_msg;
}
/*
* plugin_modifier_remove: remove a modifier for a plugin
*/
void
plugin_modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
{
t_plugin_modifier *new_modifiers;
/* remove modifier from list */
if (plugin->last_modifier == modifier)
plugin->last_modifier = modifier->prev_modifier;
if (modifier->prev_modifier)
{
(modifier->prev_modifier)->next_modifier = modifier->next_modifier;
new_modifiers = plugin->modifiers;
}
else
new_modifiers = modifier->next_modifier;
if (modifier->next_modifier)
(modifier->next_modifier)->prev_modifier = modifier->prev_modifier;
/* free data */
if (modifier->command)
free (modifier->command);
plugin->modifiers = new_modifiers;
}
/*
* plugin_modifier_remove_all: remove all modifiers for a plugin
*/
void
plugin_modifier_remove_all (t_weechat_plugin *plugin)
{
while (plugin->modifiers)
plugin_modifier_remove (plugin, plugin->modifiers);
}
/*
* plugin_search_full_name: search the full name of a file with a part of name
* and look in WeeChat user's dir, then WeeChat global lib dir
@@ -857,6 +1050,9 @@ plugin_load (char *filename)
new_plugin->keyboard_handler_add = &weechat_plugin_keyboard_handler_add;
new_plugin->handler_remove = &weechat_plugin_handler_remove;
new_plugin->handler_remove_all = &weechat_plugin_handler_remove_all;
new_plugin->modifier_add = &weechat_plugin_modifier_add;
new_plugin->modifier_remove = &weechat_plugin_modifier_remove;
new_plugin->modifier_remove_all = &weechat_plugin_modifier_remove_all;
new_plugin->print = &weechat_plugin_print;
new_plugin->print_server = &weechat_plugin_print_server;
new_plugin->print_infobar = &weechat_plugin_print_infobar;
@@ -889,6 +1085,10 @@ plugin_load (char *filename)
new_plugin->handlers = NULL;
new_plugin->last_handler = NULL;
/* modifiers */
new_plugin->modifiers = NULL;
new_plugin->last_modifier = NULL;
/* add new plugin to list */
new_plugin->prev_plugin = last_weechat_plugin;
new_plugin->next_plugin = NULL;
@@ -936,11 +1136,12 @@ plugin_load (char *filename)
}
/*
* plugin_auto_load_file: load a file found by plugin_aut_load,
* plugin_auto_load_file: load a file found by plugin_auto_load,
* but only it this is really a dynamic library
*/
int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
int
plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
{
char *pos;
@@ -965,7 +1166,8 @@ int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
* plugin_auto_load: auto-load WeeChat plugins
*/
void plugin_auto_load ()
void
plugin_auto_load ()
{
char *ptr_home, *dir_name, *plugins_path, *plugins_path2;
char *list_plugins, *pos, *pos2;
@@ -1049,8 +1251,11 @@ plugin_remove (t_weechat_plugin *plugin)
if (plugin->next_plugin)
(plugin->next_plugin)->prev_plugin = plugin->prev_plugin;
/* free data */
/* remove all handlers and modifiers */
plugin_handler_remove_all (plugin);
plugin_modifier_remove_all (plugin);
/* free data */
if (plugin->filename)
free (plugin->filename);
dlclose (plugin->handle);
@@ -1116,6 +1321,38 @@ plugin_unload_all ()
plugin_unload (last_weechat_plugin);
}
/*
* plugin_reload_name: reload a WeeChat plugin by name
*/
void
plugin_reload_name (char *name)
{
t_weechat_plugin *ptr_plugin;
char *filename;
ptr_plugin = plugin_search (name);
if (ptr_plugin)
{
filename = strdup (ptr_plugin->filename);
if (filename)
{
plugin_unload (ptr_plugin);
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _("Plugin \"%s\" unloaded.\n"), name);
plugin_load (filename);
free (filename);
}
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s plugin \"%s\" not found\n"),
WEECHAT_ERROR, name);
}
}
/*
* plugin_init: init plugin support
*/
+9
View File
@@ -68,12 +68,21 @@ extern int plugin_keyboard_handler_exec (char *, char *, char *);
extern void plugin_handler_remove (t_weechat_plugin *,
t_plugin_handler *);
extern void plugin_handler_remove_all (t_weechat_plugin *);
extern t_plugin_modifier *plugin_modifier_add (t_weechat_plugin *,
char *, char *,
t_plugin_modifier_func *,
char *, void *);
extern char *plugin_modifier_exec (t_plugin_modifier_type, char *, char *);
extern void plugin_modifier_remove (t_weechat_plugin *,
t_plugin_modifier *);
extern void plugin_modifier_remove_all (t_weechat_plugin *);
extern t_weechat_plugin *plugin_load (char *);
extern void plugin_auto_load ();
extern void plugin_remove (t_weechat_plugin *);
extern void plugin_unload (t_weechat_plugin *);
extern void plugin_unload_name (char *);
extern void plugin_unload_all ();
extern void plugin_reload_name (char *);
extern void plugin_init (int);
extern void plugin_end ();
+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 *);
+67 -9
View File
@@ -183,25 +183,25 @@ struct t_plugin_buffer_line
typedef struct t_weechat_plugin t_weechat_plugin;
typedef int (t_plugin_handler_func) (t_weechat_plugin *, int, char **, char *, void *);
/* handlers */
typedef enum t_handler_type t_handler_type;
typedef int (t_plugin_handler_func) (t_weechat_plugin *, int, char **, char *, void *);
enum t_handler_type
typedef enum t_plugin_handler_type t_plugin_handler_type;
enum t_plugin_handler_type
{
HANDLER_MESSAGE = 0, /* IRC message handler */
HANDLER_COMMAND, /* command handler */
HANDLER_TIMER, /* timer handler */
HANDLER_KEYBOARD /* keyboard handler */
PLUGIN_HANDLER_MESSAGE = 0, /* IRC message handler */
PLUGIN_HANDLER_COMMAND, /* command handler */
PLUGIN_HANDLER_TIMER, /* timer handler */
PLUGIN_HANDLER_KEYBOARD /* keyboard handler */
};
typedef struct t_plugin_handler t_plugin_handler;
struct t_plugin_handler
{
t_handler_type type; /* handler type */
t_plugin_handler_type type; /* handler type */
/* data for message handler */
char *irc_command; /* name of IRC command (PRIVMSG, ..) */
@@ -229,6 +229,46 @@ struct t_plugin_handler
t_plugin_handler *next_handler; /* link to next handler */
};
/* modifiers */
typedef char * (t_plugin_modifier_func) (t_weechat_plugin *, int, char **, char *, void *);
typedef enum t_plugin_modifier_type t_plugin_modifier_type;
enum t_plugin_modifier_type
{
PLUGIN_MODIFIER_IRC_IN = 0, /* incoming IRC msg (server > user) */
PLUGIN_MODIFIER_IRC_USER, /* outgoing IRC msg (user > server) */
/* after user input (before 'out' mod.) */
PLUGIN_MODIFIER_IRC_OUT /* outgoing IRC msg (user > server) */
/* immediately before sending to server */
};
#define PLUGIN_MODIFIER_IRC_IN_STR "irc_in"
#define PLUGIN_MODIFIER_IRC_USER_STR "irc_user"
#define PLUGIN_MODIFIER_IRC_OUT_STR "irc_out"
typedef struct t_plugin_modifier t_plugin_modifier;
struct t_plugin_modifier
{
t_plugin_modifier_type type; /* modifier type */
/* data for IRC modifier */
char *command; /* IRC command */
/* data common to all modifiers */
t_plugin_modifier_func *modifier; /* pointer to modifier */
char *modifier_args; /* arguments sent to modifier */
void *modifier_pointer; /* pointer sent to modifier */
/* for internal use */
int running; /* 1 if currently running */
/* (used to prevent circular call) */
t_plugin_modifier *prev_modifier; /* link to previous modifier */
t_plugin_modifier *next_modifier; /* link to next modifier */
};
/* plugin, a WeeChat plugin, which is a dynamic library */
struct t_weechat_plugin
@@ -243,6 +283,10 @@ struct t_weechat_plugin
/* plugin handlers */
t_plugin_handler *handlers; /* pointer to first handler */
t_plugin_handler *last_handler; /* pointer to last handler */
/* plugin modifiers */
t_plugin_modifier *modifiers; /* pointer to first modifier */
t_plugin_modifier *last_modifier; /* pointer to last modifier */
/* links to previous/next plugins */
t_weechat_plugin *prev_plugin; /* link to previous plugin */
@@ -283,6 +327,12 @@ struct t_weechat_plugin
char *, void *);
void (*handler_remove) (t_weechat_plugin *, t_plugin_handler *);
void (*handler_remove_all) (t_weechat_plugin *);
t_plugin_modifier *(*modifier_add) (t_weechat_plugin *, char *, char *,
t_plugin_modifier_func *,
char *, void *);
void (*modifier_remove) (t_weechat_plugin *, t_plugin_modifier *);
void (*modifier_remove_all) (t_weechat_plugin *);
void (*exec_command) (t_weechat_plugin *, char *, char *, char *);
char *(*get_info) (t_weechat_plugin *, char *, char *);
@@ -351,6 +401,14 @@ extern t_plugin_handler *weechat_plugin_keyboard_handler_add (t_weechat_plugin *
extern void weechat_plugin_handler_remove (t_weechat_plugin *, t_plugin_handler *);
extern void weechat_plugin_handler_remove_all (t_weechat_plugin *);
/* modifier functions */
extern t_plugin_modifier *weechat_plugin_modifier_add (t_weechat_plugin *,
char *, char *,
t_plugin_modifier_func *,
char *, void *);
extern void weechat_plugin_modifier_remove (t_weechat_plugin *, t_plugin_modifier *);
extern void weechat_plugin_modifier_remove_all (t_weechat_plugin *);
/* other functions */
extern void weechat_plugin_exec_command (t_weechat_plugin *, char *, char *, char *);
extern char *weechat_plugin_get_info (t_weechat_plugin *, char *, char *);
+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", &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>
@@ -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>
+405 -364
View File
File diff suppressed because it is too large Load Diff
+405 -364
View File
File diff suppressed because it is too large Load Diff
+407 -364
View File
File diff suppressed because it is too large Load Diff
+417 -365
View File
File diff suppressed because it is too large Load Diff
+405 -364
View File
File diff suppressed because it is too large Load Diff
+406 -365
View File
File diff suppressed because it is too large Load Diff
+395 -364
View File
File diff suppressed because it is too large Load Diff
+184 -111
View File
@@ -143,10 +143,16 @@ t_weechat_command weechat_commands[] =
"list|add|close|move global|local top|bottom|left|right",
0, MAX_ARGS, 0, weechat_cmd_panel, NULL },*/
{ "plugin", N_("list/load/unload plugins"),
N_("[load filename] | [autoload] | [reload] | [unload]"),
N_("filename: WeeChat plugin (file) to load\n\n"
"Without argument, /plugin command lists all loaded plugins."),
"load|autoload|reload|unload", 0, 2, 0, weechat_cmd_plugin, NULL },
N_("[list [mask]] | [listfull [mask]] | [load filename] | [autoload] | [reload [name]] | [unload [name]]"),
N_(" list: list loaded plugins\n"
"listfull: list loaded plugins with detailed info for each plugin\n"
" mask: part of name of a loaded plugin\n"
" load: load a plugin\n"
"autoload: autoload plugins in system or user directory\n"
" reload: reload one plugin (if no name given, unload all plugins, then autoload plugins)\n"
" unload: unload one or all plugins\n\n"
"Without argument, /plugin command lists loaded plugins."),
"list|listfull|load|autoload|reload|unload %P", 0, 2, 0, weechat_cmd_plugin, NULL },
{ "server", N_("list, add or remove servers"),
N_("[servername] | "
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 "
@@ -717,7 +723,7 @@ user_message (t_irc_server *server, t_gui_buffer *buffer, char *text)
next = pos;
}
server_sendf (server, "PRIVMSG %s :%s\r\n", CHANNEL(buffer)->name, text);
server_sendf (server, "PRIVMSG %s :%s", CHANNEL(buffer)->name, text);
user_message_display (server, buffer, text);
if (next)
@@ -736,98 +742,103 @@ void
user_command (t_irc_server *server, t_irc_channel *channel, char *command, int only_builtin)
{
t_gui_buffer *buffer;
int plugin_args_length;
char *new_cmd, *ptr_cmd, *pos;
char *command_with_colors, *command_encoded;
char *plugin_args;
if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n'))
return;
irc_find_context (server, channel, NULL, &buffer);
#ifdef PLUGINS
new_cmd = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_USER,
(server) ? server->name : "",
command);
#else
new_cmd = NULL;
#endif
if ((command[0] == '/') && (command[1] != '/'))
/* no changes in new command */
if (new_cmd && (strcmp (command, new_cmd) == 0))
{
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (server, channel, command, only_builtin);
free (new_cmd);
new_cmd = NULL;
}
else
/* message not dropped? */
if (!new_cmd || new_cmd[0])
{
if ((command[0] == '/') && (command[1] == '/'))
command++;
/* use new command (returned by plugin) */
ptr_cmd = (new_cmd) ? new_cmd : command;
if (server && (!BUFFER_IS_SERVER(buffer)))
while (ptr_cmd && ptr_cmd[0])
{
command_with_colors = (cfg_irc_colors_send) ?
(char *)gui_color_encode ((unsigned char *)command) : NULL;
pos = strchr (ptr_cmd, '\n');
if (pos)
pos[0] = '\0';
command_encoded = channel_iconv_encode (server, channel,
(command_with_colors) ? command_with_colors : command);
irc_find_context (server, channel, NULL, &buffer);
if (CHANNEL(buffer)->dcc_chat)
if ((ptr_cmd[0] == '/') && (ptr_cmd[1] != '/'))
{
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
/* WeeChat internal command (or IRC command) */
(void) exec_weechat_command (server, channel, ptr_cmd, only_builtin);
}
else
{
if ((ptr_cmd[0] == '/') && (ptr_cmd[1] == '/'))
ptr_cmd++;
if (server && (!BUFFER_IS_SERVER(buffer)))
{
irc_display_prefix (server, buffer, PREFIX_ERROR);
gui_printf_nolog (buffer, "%s DCC CHAT is closed\n",
WEECHAT_ERROR);
command_with_colors = (cfg_irc_colors_send) ?
(char *)gui_color_encode ((unsigned char *)ptr_cmd) : NULL;
command_encoded = channel_iconv_encode (server, channel,
(command_with_colors) ? command_with_colors : ptr_cmd);
if (CHANNEL(buffer)->dcc_chat)
{
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
{
irc_display_prefix (server, buffer, PREFIX_ERROR);
gui_printf_nolog (buffer, "%s DCC CHAT is closed\n",
WEECHAT_ERROR);
}
else
{
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
"%s\r\n",
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : ptr_cmd));
user_message_display (server, buffer,
(command_with_colors) ?
command_with_colors : ptr_cmd);
}
}
else
user_message (server, buffer,
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : ptr_cmd));
if (command_with_colors)
free (command_with_colors);
if (command_encoded)
free (command_encoded);
}
else
{
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
"%s\r\n",
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : command));
user_message_display (server, buffer,
(command_with_colors) ?
command_with_colors : command);
irc_display_prefix (NULL, (server) ? server->buffer : NULL, PREFIX_ERROR);
gui_printf_nolog ((server) ? server->buffer : NULL,
_("This window is not a channel!\n"));
}
}
else
user_message (server, buffer,
(command_encoded) ? command_encoded :
((command_with_colors) ? command_with_colors : command));
if (command_with_colors)
free (command_with_colors);
if (command_encoded)
free (command_encoded);
/* sending a copy of the message as PRIVMSG to plugins because irc server doesn't */
/* code commented by FlashCode, 2005-11-06: problem when a handler
is called after a weechat::command("somethin") in perl, reetrance,
and crash at perl script unload */
/* make gcc happy */
(void) plugin_args_length;
(void) plugin_args;
/*plugin_args_length = strlen ("localhost PRIVMSG :") +
strlen (CHANNEL(buffer)->name) + strlen(command) + 16;
plugin_args = (char *) malloc (plugin_args_length * sizeof (*plugin_args));
if (plugin_args)
if (pos)
{
snprintf (plugin_args, plugin_args_length,
"localhost PRIVMSG %s :%s",
CHANNEL(buffer)->name, command);
#ifdef PLUGINS
plugin_msg_handler_exec (server->name, "privmsg", plugin_args);
#endif
free (plugin_args);
pos[0] = '\n';
ptr_cmd = pos + 1;
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to call handler for message (not enough memory)\n"),
WEECHAT_ERROR);
}*/
}
else
{
irc_display_prefix (NULL, (server) ? server->buffer : NULL, PREFIX_ERROR);
gui_printf_nolog ((server) ? server->buffer : NULL,
_("This window is not a channel!\n"));
ptr_cmd = NULL;
}
}
}
@@ -1966,7 +1977,7 @@ weechat_cmd_help (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
{
gui_printf (NULL, " %s%s",
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
@@ -2045,7 +2056,7 @@ weechat_cmd_help (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command, argv[0]) == 0))
{
gui_printf (NULL, "\n");
@@ -2464,42 +2475,48 @@ weechat_cmd_panel (t_irc_server *server, t_irc_channel *channel,
}
/*
* weechat_cmd_plugin: list/load/unload WeeChat plugins
* weechat_cmd_plugin_list: list loaded plugins
*/
int
weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
int argc, char **argv)
void
weechat_cmd_plugin_list (char *name, int full)
{
#ifdef PLUGINS
t_weechat_plugin *ptr_plugin;
int plugins_found;
t_plugin_handler *ptr_handler;
int handler_found;
t_plugin_modifier *ptr_modifier;
int modifier_found;
/* make gcc happy */
(void) server;
(void) channel;
switch (argc)
gui_printf (NULL, "\n");
if (!name)
{
case 0:
/* list plugins */
gui_printf (NULL, "\n");
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _("Plugins loaded:\n"));
}
plugins_found = 0;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
if (!name || (ascii_strcasestr (ptr_plugin->name, name)))
{
plugins_found++;
/* plugin info */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _("Plugins loaded:\n"));
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
gui_printf (NULL, " %s%s%s v%s - %s (%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_plugin->name,
GUI_COLOR(COLOR_WIN_CHAT),
ptr_plugin->version,
ptr_plugin->description,
ptr_plugin->filename);
if (full)
{
/* plugin info */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, " %s%s%s v%s - %s (%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_plugin->name,
GUI_COLOR(COLOR_WIN_CHAT),
ptr_plugin->version,
ptr_plugin->description,
ptr_plugin->filename);
/* message handlers */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _(" message handlers:\n"));
@@ -2507,7 +2524,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_MESSAGE)
if (ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
{
handler_found = 1;
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2528,7 +2545,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
{
handler_found = 1;
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2554,7 +2571,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_TIMER)
if (ptr_handler->type == PLUGIN_HANDLER_TIMER)
{
handler_found = 1;
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2575,7 +2592,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_KEYBOARD)
if (ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
handler_found++;
}
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
@@ -2584,15 +2601,65 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
else
gui_printf (NULL, _(" %d defined\n"),
handler_found);
}
if (!weechat_plugins)
{
/* IRC modifiers */
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _(" (no plugin)\n"));
gui_printf (NULL, _(" IRC modifiers:\n"));
modifier_found = 0;
for (ptr_modifier = ptr_plugin->modifiers;
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
{
if (ptr_modifier->type == PLUGIN_HANDLER_KEYBOARD)
modifier_found++;
}
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
if (!modifier_found)
gui_printf (NULL, _(" (no IRC modifier)\n"));
else
gui_printf (NULL, _(" %d defined\n"),
modifier_found);
}
}
}
if (plugins_found == 0)
{
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
if (name)
gui_printf (NULL, _("No plugin found.\n"));
else
gui_printf (NULL, _(" (no plugin)\n"));
}
#else
/* make gcc happy */
(void) name;
(void) full;
#endif
}
/*
* weechat_cmd_plugin: list/load/unload WeeChat plugins
*/
int
weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
int argc, char **argv)
{
#ifdef PLUGINS
/* make gcc happy */
(void) server;
(void) channel;
switch (argc)
{
case 0:
weechat_cmd_plugin_list (NULL, 0);
break;
case 1:
if (ascii_strcasecmp (argv[0], "autoload") == 0)
if (ascii_strcasecmp (argv[0], "list") == 0)
weechat_cmd_plugin_list (NULL, 0);
else if (ascii_strcasecmp (argv[0], "listfull") == 0)
weechat_cmd_plugin_list (NULL, 1);
else if (ascii_strcasecmp (argv[0], "autoload") == 0)
plugin_auto_load ();
else if (ascii_strcasecmp (argv[0], "reload") == 0)
{
@@ -2603,8 +2670,14 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
plugin_unload_all ();
break;
case 2:
if (ascii_strcasecmp (argv[0], "load") == 0)
if (ascii_strcasecmp (argv[0], "list") == 0)
weechat_cmd_plugin_list (argv[1], 0);
else if (ascii_strcasecmp (argv[0], "listfull") == 0)
weechat_cmd_plugin_list (argv[1], 1);
else if (ascii_strcasecmp (argv[0], "load") == 0)
plugin_load (argv[1]);
else if (ascii_strcasecmp (argv[0], "reload") == 0)
plugin_reload_name (argv[1]);
else if (ascii_strcasecmp (argv[0], "unload") == 0)
plugin_unload_name (argv[1]);
else
+2 -2
View File
@@ -154,7 +154,7 @@ completion_get_command_infos (t_completion *completion,
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command,
ptr_command2) == 0))
{
@@ -304,7 +304,7 @@ completion_list_add_plugin_cmd (t_completion *completion)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_COMMAND)
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
completion_list_add (completion, ptr_handler->command);
}
}
+1 -1
View File
@@ -217,7 +217,7 @@ gui_main_loop ()
if ((ptr_server->lag_check_time.tv_sec == 0)
&& (new_time >= ptr_server->lag_next_check))
{
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
server_sendf (ptr_server, "PING %s", ptr_server->address);
gettimeofday (&(ptr_server->lag_check_time), NULL);
}
+4 -2
View File
@@ -360,10 +360,11 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
/*
* gui_printf_raw_data: display raw IRC data (only if raw IRC data buffer exists)
* type: 0 = recv, 1 = send, -1 = recv, modified by a modifier (plugin)
*/
void
gui_printf_raw_data (void *server, int send, char *message)
gui_printf_raw_data (void *server, int send, int modified, char *message)
{
char *pos;
@@ -381,7 +382,8 @@ gui_printf_raw_data (void *server, int send, char *message)
((t_irc_server *)server)->name,
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR((send) ? COLOR_WIN_CHAT_PART : COLOR_WIN_CHAT_JOIN),
(send) ? PREFIX_PART : PREFIX_JOIN,
(send) ? ((modified) ? PREFIX_SEND_MOD : PREFIX_PART) :
((modified) ? PREFIX_RECV_MOD : PREFIX_JOIN),
GUI_COLOR(COLOR_WIN_CHAT),
message);
if (pos)
+1 -1
View File
@@ -184,7 +184,7 @@ extern void gui_infobar_remove_all ();
extern int gui_word_strlen (t_gui_window *, char *);
extern int gui_word_real_pos (t_gui_window *, char *, int);
extern void gui_printf_internal (t_gui_buffer *, int, int, char *, char *, ...);
extern void gui_printf_raw_data (void *, int, char *);
extern void gui_printf_raw_data (void *, int, int, char *);
extern void gui_input_optimize_size (t_gui_buffer *);
extern void gui_input_init_color_mask (t_gui_buffer *);
extern void gui_input_move (t_gui_buffer *, char *, char *, int );
+1 -1
View File
@@ -427,7 +427,7 @@ channel_check_away (t_irc_server *server, t_irc_channel *channel, int force)
(channel->nicks_count <= cfg_irc_away_check_max_nicks))
{
channel->checking_away++;
server_sendf (server, "WHO %s\r\n", channel->name);
server_sendf (server, "WHO %s", channel->name);
}
else
channel_remove_away (channel);
+7 -7
View File
@@ -632,8 +632,8 @@ dcc_accept (t_irc_dcc *ptr_dcc)
ptr_dcc->status = DCC_CONNECTING;
server_sendf (ptr_dcc->server,
(strchr (ptr_dcc->filename, ' ')) ?
"PRIVMSG %s :\01DCC RESUME \"%s\" %d %u\01\r\n" :
"PRIVMSG %s :\01DCC RESUME %s %d %u\01\r\n",
"PRIVMSG %s :\01DCC RESUME \"%s\" %d %u\01\n" :
"PRIVMSG %s :\01DCC RESUME %s %d %u\01",
ptr_dcc->nick, ptr_dcc->filename,
ptr_dcc->port, ptr_dcc->start_resume);
dcc_redraw (HOTLIST_MSG);
@@ -661,8 +661,8 @@ dcc_accept_resume (t_irc_server *server, char *filename, int port,
ptr_dcc->last_check_pos = pos_start;
server_sendf (ptr_dcc->server,
(strchr (ptr_dcc->filename, ' ')) ?
"PRIVMSG %s :\01DCC ACCEPT \"%s\" %d %u\01\r\n" :
"PRIVMSG %s :\01DCC ACCEPT %s %d %u\01\r\n",
"PRIVMSG %s :\01DCC ACCEPT \"%s\" %d %u\01\n" :
"PRIVMSG %s :\01DCC ACCEPT %s %d %u\01",
ptr_dcc->nick, ptr_dcc->filename,
ptr_dcc->port, ptr_dcc->start_resume);
@@ -1158,13 +1158,13 @@ dcc_send_request (t_irc_server *server, int type, char *nick, char *filename)
/* send DCC request to nick */
if (type == DCC_CHAT_SEND)
server_sendf (server,
"PRIVMSG %s :\01DCC CHAT chat %lu %d\01\r\n",
"PRIVMSG %s :\01DCC CHAT chat %lu %d\01",
nick, local_addr, port);
else
server_sendf (server,
(spaces) ?
"PRIVMSG %s :\01DCC SEND \"%s\" %lu %d %u\01\r\n" :
"PRIVMSG %s :\01DCC SEND %s %lu %d %u\01\r\n",
"PRIVMSG %s :\01DCC SEND \"%s\" %lu %d %u\01\n" :
"PRIVMSG %s :\01DCC SEND %s %lu %d %u\01",
nick, short_filename, local_addr, port,
(unsigned long) st.st_size);
+11 -11
View File
@@ -725,7 +725,7 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments
nick);
}
irc_mode_channel_set (ptr_channel, pos_modes);
server_sendf (server, "MODE %s\r\n", ptr_channel->name);
server_sendf (server, "MODE %s", ptr_channel->name);
}
else
{
@@ -1180,7 +1180,7 @@ irc_cmd_recv_ping (t_irc_server *server, char *host, char *nick, char *arguments
pos = strrchr (arguments, ' ');
if (pos)
pos[0] = '\0';
server_sendf (server, "PONG :%s\r\n", arguments);
server_sendf (server, "PONG :%s", arguments);
return 0;
}
@@ -1253,7 +1253,7 @@ irc_cmd_reply_version (t_irc_server *server, t_irc_channel *channel,
"%s %s / %s%s",
nick, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__,
&buf->sysname,
&buf->release, &buf->machine, "\01\r\n");
&buf->release, &buf->machine, "\01");
free (buf);
}
else
@@ -1261,7 +1261,7 @@ irc_cmd_reply_version (t_irc_server *server, t_irc_channel *channel,
"NOTICE %s :%sVERSION %s v%s"
" compiled on %s%s",
nick, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__,
"\01\r\n");
"\01");
irc_display_prefix (server, ptr_buffer, PREFIX_SERVER);
gui_printf (ptr_buffer,
_("CTCP %sVERSION%s received from %s%s"),
@@ -1408,10 +1408,10 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if (pos && !pos[0])
pos = NULL;
if (pos)
server_sendf (server, "NOTICE %s :\01PING %s\01\r\n",
server_sendf (server, "NOTICE %s :\01PING %s\01",
nick, pos);
else
server_sendf (server, "NOTICE %s :\01PING\01\r\n",
server_sendf (server, "NOTICE %s :\01PING\01",
nick);
irc_display_prefix (server, ptr_channel->buffer, PREFIX_SERVER);
gui_printf (ptr_channel->buffer,
@@ -1549,10 +1549,10 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
if (pos && !pos[0])
pos = NULL;
if (pos)
server_sendf (server, "NOTICE %s :\01PING %s\01\r\n",
server_sendf (server, "NOTICE %s :\01PING %s\01",
nick, pos);
else
server_sendf (server, "NOTICE %s :\01PING\01\r\n",
server_sendf (server, "NOTICE %s :\01PING\01",
nick);
irc_display_prefix (server, server->buffer, PREFIX_SERVER);
gui_printf (server->buffer,
@@ -2414,10 +2414,10 @@ irc_cmd_recv_001 (t_irc_server *server, char *host, char *nick, char *arguments)
if (ptr_channel->type == CHANNEL_TYPE_CHANNEL)
{
if (ptr_channel->key)
server_sendf (server, "JOIN %s %s\r\n",
server_sendf (server, "JOIN %s %s",
ptr_channel->name, ptr_channel->key);
else
server_sendf (server, "JOIN %s\r\n",
server_sendf (server, "JOIN %s",
ptr_channel->name);
}
}
@@ -4811,7 +4811,7 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *nick, char *arguments)
if (!hostname[0])
strcpy (hostname, _("unknown"));
server_sendf (server,
"NICK %s\r\n",
"NICK %s",
server->nick);
}
else
+94 -94
View File
@@ -54,7 +54,7 @@ irc_login (t_irc_server *server)
char hostname[NI_MAXHOST];
if ((server->password) && (server->password[0]))
server_sendf (server, "PASS %s\r\n", server->password);
server_sendf (server, "PASS %s", server->password);
gethostname (hostname, sizeof (hostname) - 1);
hostname[sizeof (hostname) - 1] = '\0';
@@ -68,8 +68,8 @@ irc_login (t_irc_server *server)
if (!server->nick)
server->nick = strdup (server->nick1);
server_sendf (server,
"NICK %s\r\n"
"USER %s %s %s :%s\r\n",
"NICK %s\n"
"USER %s %s %s :%s",
server->nick, server->username, hostname, "servername",
server->realname);
gui_input_draw (gui_current_window->buffer, 1);
@@ -87,9 +87,9 @@ irc_cmd_send_admin (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "ADMIN %s\r\n", arguments);
server_sendf (server, "ADMIN %s", arguments);
else
server_sendf (server, "ADMIN\r\n");
server_sendf (server, "ADMIN");
return 0;
}
@@ -103,7 +103,7 @@ irc_send_me (t_irc_server *server, t_irc_channel *channel,
{
char *string;
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01",
channel->name,
(arguments && arguments[0]) ? arguments : "");
irc_display_prefix (NULL, channel->buffer, PREFIX_ACTION_ME);
@@ -200,7 +200,7 @@ irc_cmd_send_amsg (t_irc_server *server, t_irc_channel *channel,
{
if (ptr_channel->type == CHANNEL_TYPE_CHANNEL)
{
server_sendf (ptr_server, "PRIVMSG %s :%s\r\n",
server_sendf (ptr_server, "PRIVMSG %s :%s",
ptr_channel->name, arguments);
ptr_nick = nick_search (ptr_channel, ptr_server->nick);
if (ptr_nick)
@@ -250,7 +250,7 @@ irc_send_away (t_irc_server *server, char *arguments)
if (server->away_message)
strcpy (server->away_message, arguments);
server->away_time = time (NULL);
server_sendf (server, "AWAY :%s\r\n", arguments);
server_sendf (server, "AWAY :%s", arguments);
if (cfg_irc_display_away != CFG_IRC_DISPLAY_AWAY_OFF)
{
string = (char *)gui_color_decode ((unsigned char *)arguments, 1);
@@ -275,7 +275,7 @@ irc_send_away (t_irc_server *server, char *arguments)
}
else
{
server_sendf (server, "AWAY\r\n");
server_sendf (server, "AWAY");
server->is_away = 0;
if (server->away_message)
{
@@ -428,7 +428,7 @@ irc_cmd_send_ban (t_irc_server *server, t_irc_channel *channel,
while (pos2[0] == ' ')
pos2++;
}
server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos);
server_sendf (server, "MODE %s +b %s", pos_channel, pos);
pos = pos2;
}
}
@@ -442,7 +442,7 @@ irc_cmd_send_ban (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, "ban");
return -1;
}
server_sendf (server, "MODE %s +b\r\n", CHANNEL(buffer)->name);
server_sendf (server, "MODE %s +b", CHANNEL(buffer)->name);
}
return 0;
@@ -500,7 +500,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
if ((ascii_strcasecmp (pos_type, "ping") == 0) && (!pos_args))
{
gettimeofday (&tv, NULL);
server_sendf (server, "PRIVMSG %s :\01PING %d %d\01\r\n",
server_sendf (server, "PRIVMSG %s :\01PING %d %d\01",
arguments, tv.tv_sec, tv.tv_usec);
gui_printf (server->buffer, " %s%d %d\n",
GUI_COLOR(COLOR_WIN_CHAT),
@@ -510,7 +510,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
{
if (pos_args)
{
server_sendf (server, "PRIVMSG %s :\01%s %s\01\r\n",
server_sendf (server, "PRIVMSG %s :\01%s %s\01",
arguments, pos_type, pos_args);
gui_printf (server->buffer, " %s%s\n",
GUI_COLOR(COLOR_WIN_CHAT),
@@ -518,7 +518,7 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
}
else
{
server_sendf (server, "PRIVMSG %s :\01%s\01\r\n",
server_sendf (server, "PRIVMSG %s :\01%s\01",
arguments, pos_type);
gui_printf (server->buffer, "\n");
}
@@ -617,13 +617,13 @@ irc_cmd_send_cycle (t_irc_server *server, t_irc_channel *channel,
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
server_sendf (server, "PART %s :%s", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
server_sendf (server, "PART %s", channel_name);
return 0;
}
@@ -643,7 +643,7 @@ irc_cmd_send_dehalfop (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s -h %s\r\n",
server_sendf (server, "MODE %s -h %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -675,7 +675,7 @@ irc_cmd_send_deop (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s -o %s\r\n",
server_sendf (server, "MODE %s -o %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -707,7 +707,7 @@ irc_cmd_send_devoice (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s -v %s\r\n",
server_sendf (server, "MODE %s -v %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -737,7 +737,7 @@ irc_cmd_send_die (t_irc_server *server, t_irc_channel *channel,
(void) channel;
(void) arguments;
server_sendf (server, "DIE\r\n");
server_sendf (server, "DIE");
return 0;
}
@@ -756,7 +756,7 @@ irc_cmd_send_halfop (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s +h %s\r\n",
server_sendf (server, "MODE %s +h %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -786,9 +786,9 @@ irc_cmd_send_info (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "INFO %s\r\n", arguments);
server_sendf (server, "INFO %s", arguments);
else
server_sendf (server, "INFO\r\n");
server_sendf (server, "INFO");
return 0;
}
@@ -805,7 +805,7 @@ irc_cmd_send_invite (t_irc_server *server, t_irc_channel *channel,
irc_find_context (server, channel, NULL, &buffer);
if (argc == 2)
server_sendf (server, "INVITE %s %s\r\n", argv[0], argv[1]);
server_sendf (server, "INVITE %s %s", argv[0], argv[1]);
else
{
if (!BUFFER_IS_CHANNEL(buffer))
@@ -816,7 +816,7 @@ irc_cmd_send_invite (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, "invite");
return -1;
}
server_sendf (server, "INVITE %s %s\r\n",
server_sendf (server, "INVITE %s %s",
argv[0], CHANNEL(buffer)->name);
}
return 0;
@@ -833,7 +833,7 @@ irc_cmd_send_ison (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "ISON %s\r\n", arguments);
server_sendf (server, "ISON %s", arguments);
return 0;
}
@@ -849,9 +849,9 @@ irc_cmd_send_join (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (string_is_channel (arguments))
server_sendf (server, "JOIN %s\r\n", arguments);
server_sendf (server, "JOIN %s", arguments);
else
server_sendf (server, "JOIN #%s\r\n", arguments);
server_sendf (server, "JOIN #%s", arguments);
return 0;
}
@@ -909,9 +909,9 @@ irc_cmd_send_kick (t_irc_server *server, t_irc_channel *channel,
}
if (pos_comment)
server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
server_sendf (server, "KICK %s %s :%s", pos_channel, pos_nick, pos_comment);
else
server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
server_sendf (server, "KICK %s %s", pos_channel, pos_nick);
return 0;
}
@@ -969,11 +969,11 @@ irc_cmd_send_kickban (t_irc_server *server, t_irc_channel *channel,
pos_comment++;
}
server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos_nick);
server_sendf (server, "MODE %s +b %s", pos_channel, pos_nick);
if (pos_comment)
server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
server_sendf (server, "KICK %s %s :%s", pos_channel, pos_nick, pos_comment);
else
server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
server_sendf (server, "KICK %s %s", pos_channel, pos_nick);
return 0;
}
@@ -998,10 +998,10 @@ irc_cmd_send_kill (t_irc_server *server, t_irc_channel *channel,
pos++;
while (pos[0] == ' ')
pos++;
server_sendf (server, "KILL %s :%s\r\n", arguments, pos);
server_sendf (server, "KILL %s :%s", arguments, pos);
}
else
server_sendf (server, "KILL %s\r\n", arguments);
server_sendf (server, "KILL %s", arguments);
return 0;
}
@@ -1018,9 +1018,9 @@ irc_cmd_send_links (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "LINKS %s\r\n", arguments);
server_sendf (server, "LINKS %s", arguments);
else
server_sendf (server, "LINKS\r\n");
server_sendf (server, "LINKS");
return 0;
}
@@ -1057,7 +1057,7 @@ irc_cmd_send_list (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, arguments, buffer);
}
else
server_sendf (server, "LIST\r\n");
server_sendf (server, "LIST");
}
else
{
@@ -1067,7 +1067,7 @@ irc_cmd_send_list (t_irc_server *server, t_irc_channel *channel,
}
}
else
server_sendf (server, "LIST\r\n");
server_sendf (server, "LIST");
return 0;
}
@@ -1084,9 +1084,9 @@ irc_cmd_send_lusers (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "LUSERS %s\r\n", arguments);
server_sendf (server, "LUSERS %s", arguments);
else
server_sendf (server, "LUSERS\r\n");
server_sendf (server, "LUSERS");
return 0;
}
@@ -1125,7 +1125,7 @@ irc_cmd_send_mode (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "MODE %s\r\n", arguments);
server_sendf (server, "MODE %s", arguments);
return 0;
}
@@ -1155,7 +1155,7 @@ irc_send_mode_nicks (t_irc_server *server, char *channel,
strcat (command, " ");
strcat (command, argv[i]);
}
server_sendf (server, "%s\r\n", command);
server_sendf (server, "%s", command);
free (command);
}
}
@@ -1172,9 +1172,9 @@ irc_cmd_send_motd (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "MOTD %s\r\n", arguments);
server_sendf (server, "MOTD %s", arguments);
else
server_sendf (server, "MOTD\r\n");
server_sendf (server, "MOTD");
return 0;
}
@@ -1237,7 +1237,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos);
server_sendf (server, "PRIVMSG %s :%s", ptr_channel->name, pos);
}
else
{
@@ -1265,7 +1265,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, server->nick, "msg");
}
}
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
}
else
{
@@ -1301,7 +1301,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
(string) ? string : "");
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
free (msg_pwd_hidden);
return 0;
}
@@ -1332,7 +1332,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
}
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
}
}
arguments = pos_comma;
@@ -1362,7 +1362,7 @@ irc_cmd_send_names (t_irc_server *server, t_irc_channel *channel,
irc_find_context (server, channel, NULL, &buffer);
if (arguments)
server_sendf (server, "NAMES %s\r\n", arguments);
server_sendf (server, "NAMES %s", arguments);
else
{
if (!BUFFER_IS_CHANNEL(buffer))
@@ -1374,7 +1374,7 @@ irc_cmd_send_names (t_irc_server *server, t_irc_channel *channel,
return -1;
}
else
server_sendf (server, "NAMES %s\r\n",
server_sendf (server, "NAMES %s",
CHANNEL(buffer)->name);
}
return 0;
@@ -1390,7 +1390,7 @@ irc_cmd_send_nick_server (t_irc_server *server, char *nickname)
t_irc_channel *ptr_channel;
if (server->is_connected)
server_sendf (server, "NICK %s\r\n", nickname);
server_sendf (server, "NICK %s", nickname);
else
{
if (server->nick)
@@ -1474,7 +1474,7 @@ irc_cmd_send_notice (t_irc_server *server, t_irc_channel *channel,
(string) ? string : "");
if (string)
free (string);
server_sendf (server, "NOTICE %s :%s\r\n", arguments, pos);
server_sendf (server, "NOTICE %s :%s", arguments, pos);
}
else
{
@@ -1502,7 +1502,7 @@ irc_cmd_send_op (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s +o %s\r\n",
server_sendf (server, "MODE %s +o %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -1531,7 +1531,7 @@ irc_cmd_send_oper (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "OPER %s\r\n", arguments);
server_sendf (server, "OPER %s", arguments);
return 0;
}
@@ -1607,13 +1607,13 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
server_sendf (server, "PART %s :%s", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
server_sendf (server, "PART %s", channel_name);
return 0;
}
@@ -1629,7 +1629,7 @@ irc_cmd_send_ping (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "PING %s\r\n", arguments);
server_sendf (server, "PING %s", arguments);
return 0;
}
@@ -1644,7 +1644,7 @@ irc_cmd_send_pong (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "PONG %s\r\n", arguments);
server_sendf (server, "PONG %s", arguments);
return 0;
}
@@ -1717,7 +1717,7 @@ irc_cmd_send_query (t_irc_server *server, t_irc_channel *channel,
(string) ? string : "");
if (string)
free (string);
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
server_sendf (server, "PRIVMSG %s :%s", arguments, pos);
}
return 0;
}
@@ -1740,13 +1740,13 @@ irc_send_quit_server (t_irc_server *server, char *arguments)
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "QUIT :%s\r\n",
server_sendf (server, "QUIT :%s",
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "QUIT\r\n");
server_sendf (server, "QUIT");
}
}
@@ -1784,7 +1784,7 @@ irc_cmd_send_quote (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "%s\r\n", arguments);
server_sendf (server, "%s", arguments);
return 0;
}
@@ -1800,7 +1800,7 @@ irc_cmd_send_rehash (t_irc_server *server, t_irc_channel *channel,
(void) channel;
(void) arguments;
server_sendf (server, "REHASH\r\n");
server_sendf (server, "REHASH");
return 0;
}
@@ -1816,7 +1816,7 @@ irc_cmd_send_restart (t_irc_server *server, t_irc_channel *channel,
(void) channel;
(void) arguments;
server_sendf (server, "RESTART\r\n");
server_sendf (server, "RESTART");
return 0;
}
@@ -1831,7 +1831,7 @@ irc_cmd_send_service (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "SERVICE %s\r\n", arguments);
server_sendf (server, "SERVICE %s", arguments);
return 0;
}
@@ -1847,9 +1847,9 @@ irc_cmd_send_servlist (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "SERVLIST %s\r\n", arguments);
server_sendf (server, "SERVLIST %s", arguments);
else
server_sendf (server, "SERVLIST\r\n");
server_sendf (server, "SERVLIST");
return 0;
}
@@ -1875,10 +1875,10 @@ irc_cmd_send_squery (t_irc_server *server, t_irc_channel *channel,
{
pos++;
}
server_sendf (server, "SQUERY %s :%s\r\n", arguments, pos);
server_sendf (server, "SQUERY %s :%s", arguments, pos);
}
else
server_sendf (server, "SQUERY %s\r\n", arguments);
server_sendf (server, "SQUERY %s", arguments);
return 0;
}
@@ -1894,7 +1894,7 @@ irc_cmd_send_squit (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "SQUIT %s\r\n", arguments);
server_sendf (server, "SQUIT %s", arguments);
return 0;
}
@@ -1910,9 +1910,9 @@ irc_cmd_send_stats (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "STATS %s\r\n", arguments);
server_sendf (server, "STATS %s", arguments);
else
server_sendf (server, "STATS\r\n");
server_sendf (server, "STATS");
return 0;
}
@@ -1928,7 +1928,7 @@ irc_cmd_send_summon (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "SUMMON %s\r\n", arguments);
server_sendf (server, "SUMMON %s", arguments);
return 0;
}
@@ -1944,9 +1944,9 @@ irc_cmd_send_time (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "TIME %s\r\n", arguments);
server_sendf (server, "TIME %s", arguments);
else
server_sendf (server, "TIME\r\n");
server_sendf (server, "TIME");
return 0;
}
@@ -2002,12 +2002,12 @@ irc_cmd_send_topic (t_irc_server *server, t_irc_channel *channel,
if (new_topic)
{
if (strcmp (new_topic, "-delete") == 0)
server_sendf (server, "TOPIC %s :\r\n", channel_name);
server_sendf (server, "TOPIC %s :", channel_name);
else
server_sendf (server, "TOPIC %s :%s\r\n", channel_name, new_topic);
server_sendf (server, "TOPIC %s :%s", channel_name, new_topic);
}
else
server_sendf (server, "TOPIC %s\r\n", channel_name);
server_sendf (server, "TOPIC %s", channel_name);
return 0;
}
@@ -2024,9 +2024,9 @@ irc_cmd_send_trace (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "TRACE %s\r\n", arguments);
server_sendf (server, "TRACE %s", arguments);
else
server_sendf (server, "TRACE\r\n");
server_sendf (server, "TRACE");
return 0;
}
@@ -2092,7 +2092,7 @@ irc_cmd_send_unban (t_irc_server *server, t_irc_channel *channel,
while (pos2[0] == ' ')
pos2++;
}
server_sendf (server, "MODE %s -b %s\r\n", pos_channel, pos);
server_sendf (server, "MODE %s -b %s", pos_channel, pos);
pos = pos2;
}
}
@@ -2118,7 +2118,7 @@ irc_cmd_send_userhost (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "USERHOST %s\r\n", arguments);
server_sendf (server, "USERHOST %s", arguments);
return 0;
}
@@ -2134,9 +2134,9 @@ irc_cmd_send_users (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "USERS %s\r\n", arguments);
server_sendf (server, "USERS %s", arguments);
else
server_sendf (server, "USERS\r\n");
server_sendf (server, "USERS");
return 0;
}
@@ -2156,10 +2156,10 @@ irc_cmd_send_version (t_irc_server *server, t_irc_channel *channel,
{
if (BUFFER_IS_CHANNEL(buffer) &&
nick_search (CHANNEL(buffer), arguments))
server_sendf (server, "PRIVMSG %s :\01VERSION\01\r\n",
server_sendf (server, "PRIVMSG %s :\01VERSION\01",
arguments);
else
server_sendf (server, "VERSION %s\r\n",
server_sendf (server, "VERSION %s",
arguments);
}
else
@@ -2168,7 +2168,7 @@ irc_cmd_send_version (t_irc_server *server, t_irc_channel *channel,
gui_printf (server->buffer, _("%s, compiled on %s %s\n"),
PACKAGE_STRING,
__DATE__, __TIME__);
server_sendf (server, "VERSION\r\n");
server_sendf (server, "VERSION");
}
return 0;
}
@@ -2188,7 +2188,7 @@ irc_cmd_send_voice (t_irc_server *server, t_irc_channel *channel,
if (BUFFER_IS_CHANNEL(buffer))
{
if (argc == 0)
server_sendf (server, "MODE %s +v %s\r\n",
server_sendf (server, "MODE %s +v %s",
CHANNEL(buffer)->name,
server->nick);
else
@@ -2218,7 +2218,7 @@ irc_cmd_send_wallops (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "WALLOPS :%s\r\n", arguments);
server_sendf (server, "WALLOPS :%s", arguments);
return 0;
}
@@ -2234,9 +2234,9 @@ irc_cmd_send_who (t_irc_server *server, t_irc_channel *channel,
(void) channel;
if (arguments)
server_sendf (server, "WHO %s\r\n", arguments);
server_sendf (server, "WHO %s", arguments);
else
server_sendf (server, "WHO\r\n");
server_sendf (server, "WHO");
return 0;
}
@@ -2251,7 +2251,7 @@ irc_cmd_send_whois (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "WHOIS %s\r\n", arguments);
server_sendf (server, "WHOIS %s", arguments);
return 0;
}
@@ -2266,6 +2266,6 @@ irc_cmd_send_whowas (t_irc_server *server, t_irc_channel *channel,
/* make gcc happy */
(void) channel;
server_sendf (server, "WHOWAS %s\r\n", arguments);
server_sendf (server, "WHOWAS %s", arguments);
return 0;
}
+215 -86
View File
@@ -49,6 +49,10 @@
#include "../common/weeconfig.h"
#include "../gui/gui.h"
#ifdef PLUGINS
#include "../plugins/plugins.h"
#endif
t_irc_server *irc_servers = NULL;
t_irc_server *last_irc_server = NULL;
@@ -553,8 +557,80 @@ server_send (t_irc_server *server, char *buffer, int size_buf)
return send (server->sock, buffer, size_buf, 0);
}
/*
* server_send_one_msg: send one message to IRC server
*/
int
server_send_one_msg (t_irc_server *server, char *message)
{
static char buffer[4096];
char *new_msg, *ptr_msg, *pos;
int rc;
rc = 1;
gui_printf_raw_data (server, 1, 0, message);
#ifdef DEBUG
gui_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n", message);
#endif
#ifdef PLUGINS
new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
server->name,
message);
#else
new_msg = NULL;
#endif
/* no changes in new message */
if (new_msg && (strcmp (buffer, new_msg) == 0))
{
free (new_msg);
new_msg = NULL;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
{
ptr_msg = (new_msg) ? new_msg : message;
while (rc && ptr_msg && ptr_msg[0])
{
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
if (new_msg)
gui_printf_raw_data (server, 1, 1, ptr_msg);
snprintf (buffer, sizeof (buffer) - 1, "%s\r\n", ptr_msg);
if (server_send (server, buffer, strlen (buffer)) <= 0)
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf (server->buffer, _("%s error sending data to IRC server\n"),
WEECHAT_ERROR);
rc = 0;
}
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
}
}
else
gui_printf_raw_data (server, 1, 1, _("(message dropped)"));
if (new_msg)
free (new_msg);
return rc;
}
/*
* server_sendf: send formatted data to IRC server
* many messages may be sent, separated by '\n'
*/
void
@@ -562,34 +638,81 @@ server_sendf (t_irc_server *server, char *fmt, ...)
{
va_list args;
static char buffer[4096];
int size_buf;
char *ptr_buf, *pos;
int rc;
if (!server)
return;
va_start (args, fmt);
size_buf = vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
va_end (args);
if ((size_buf == 0) || (strcmp (buffer, "\r\n") == 0))
return;
vsnprintf (buffer, sizeof (buffer) - 1, fmt, args);
va_end (args);
buffer[sizeof (buffer) - 1] = '\0';
if ((size_buf < 0) || (size_buf > (int) (sizeof (buffer) - 1)))
size_buf = strlen (buffer);
buffer[size_buf - 2] = '\0';
gui_printf_raw_data (server, 1, buffer);
#ifdef DEBUG
gui_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n", buffer);
#endif
buffer[size_buf - 2] = '\r';
if (server_send (server, buffer, strlen (buffer)) <= 0)
ptr_buf = buffer;
while (ptr_buf && ptr_buf[0])
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf (server->buffer, _("%s error sending data to IRC server\n"),
WEECHAT_ERROR);
pos = strchr (ptr_buf, '\n');
if (pos)
pos[0] = '\0';
rc = server_send_one_msg (server, ptr_buf);
if (pos)
{
pos[0] = '\n';
ptr_buf = pos + 1;
}
else
ptr_buf = NULL;
if (!rc)
ptr_buf = NULL;
}
}
/*
* server_parse_message: parse IRC message and return pointer to
* host, command and arguments (if any)
*/
void
server_parse_message (char *message, char **host, char **command, char **args)
{
char *pos, *pos2;
*host = NULL;
*command = NULL;
*args = NULL;
if (message[0] == ':')
{
pos = strchr (message, ' ');
if (pos)
{
*host = strndup (message + 1, pos - (message + 1));
pos++;
}
else
pos = message;
}
else
pos = message;
if (pos && pos[0])
{
while (pos[0] == ' ')
pos++;
pos2 = strchr (pos, ' ');
if (pos2)
{
*command = strndup (pos, pos2 - pos);
pos2++;
while (pos2[0] == ' ')
pos2++;
if (pos2[0] == ':')
pos2++;
*args = strdup (pos2);
}
}
}
@@ -735,7 +858,7 @@ void
server_msgq_flush ()
{
t_irc_message *next;
char *entire_line, *ptr_data, *pos, *pos2;
char *ptr_data, *new_msg, *ptr_msg, *pos;
char *host, *command, *args;
while (recv_msgq)
@@ -745,84 +868,90 @@ server_msgq_flush ()
#ifdef DEBUG
gui_printf (gui_current_window->buffer, "[DEBUG] %s\n", recv_msgq->data);
#endif
ptr_data = recv_msgq->data;
entire_line = strdup (ptr_data);
while (ptr_data[0] == ' ')
ptr_data++;
if (ptr_data && ptr_data[0])
if (ptr_data[0])
{
gui_printf_raw_data (recv_msgq->server, 0, ptr_data);
gui_printf_raw_data (recv_msgq->server, 0, 0, ptr_data);
#ifdef DEBUG
gui_printf (NULL, "[DEBUG] data received from server: %s\n", ptr_data);
#endif
host = NULL;
command = NULL;
args = ptr_data;
if (ptr_data[0] == ':')
#ifdef PLUGINS
new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN,
recv_msgq->server->name,
ptr_data);
#else
new_msg = NULL;
#endif
/* no changes in new message */
if (new_msg && (strcmp (ptr_data, new_msg) == 0))
{
pos = strchr (ptr_data, ' ');
if (pos)
free (new_msg);
new_msg = NULL;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
{
/* use new message (returned by plugin) */
ptr_msg = (new_msg) ? new_msg : ptr_data;
while (ptr_msg && ptr_msg[0])
{
pos[0] = '\0';
host = ptr_data + 1;
pos++;
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
if (new_msg)
gui_printf_raw_data (recv_msgq->server, 0, 1, ptr_msg);
server_parse_message (ptr_msg, &host, &command, &args);
switch (irc_recv_command (recv_msgq->server, ptr_msg, host, command, args))
{
case -1:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Command \"%s\" failed!\n"), WEECHAT_ERROR, command);
break;
case -2:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s No command to execute!\n"), WEECHAT_ERROR);
break;
case -3:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Unknown command: cmd=\"%s\", host=\"%s\", args=\"%s\"\n"),
WEECHAT_WARNING, command, host, args);
break;
}
if (host)
free (host);
if (command)
free (command);
if (args)
free (args);
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
}
else
pos = ptr_data;
}
else
pos = ptr_data;
if (pos && pos[0])
{
while (pos[0] == ' ')
pos++;
pos2 = strchr (pos, ' ');
if (pos2)
{
pos2[0] = '\0';
command = strdup (pos);
pos2++;
while (pos2[0] == ' ')
pos2++;
args = (pos2[0] == ':') ? pos2 + 1 : pos2;
}
}
switch (irc_recv_command (recv_msgq->server, entire_line, host,
command, args))
{
case -1:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Command \"%s\" failed!\n"), WEECHAT_ERROR, command);
break;
case -2:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s No command to execute!\n"), WEECHAT_ERROR);
break;
case -3:
irc_display_prefix (recv_msgq->server,
recv_msgq->server->buffer, PREFIX_ERROR);
gui_printf (recv_msgq->server->buffer,
_("%s Unknown command: cmd=\"%s\", host=\"%s\", args=\"%s\"\n"),
WEECHAT_WARNING, command, host, args);
break;
}
if (command)
free (command);
gui_printf_raw_data (recv_msgq->server, 0, 1, _("(message dropped)"));
if (new_msg)
free (new_msg);
}
free (entire_line);
free (recv_msgq->data);
}
+3
View File
@@ -50,6 +50,8 @@
#define PREFIX_QUIT "<--"
#define PREFIX_ERROR "=!="
#define PREFIX_PLUGIN "-P-"
#define PREFIX_RECV_MOD "==>"
#define PREFIX_SEND_MOD "<=="
#define DEFAULT_IRC_PORT 6667
@@ -345,6 +347,7 @@ extern char *server_get_charset_decode_utf (t_irc_server *);
extern char *server_get_charset_encode (t_irc_server *);
extern int server_send (t_irc_server *, char *, int);
extern void server_sendf (t_irc_server *, char *, ...);
extern void server_parse_message (char *, char **, char **, char **);
extern void server_recv (t_irc_server *);
extern void server_child_read (t_irc_server *);
extern int server_connect (t_irc_server *);
+40
View File
@@ -356,6 +356,46 @@ weechat_plugin_handler_remove_all (t_weechat_plugin *plugin)
plugin_handler_remove_all (plugin);
}
/*
* weechat_plugin_modifier_add: add a IRC message modifier
*/
t_plugin_modifier *
weechat_plugin_modifier_add (t_weechat_plugin *plugin,
char *type, char *message,
t_plugin_modifier_func *modifier_func,
char *modifier_args, void *modifier_pointer)
{
if (plugin && type && modifier_func)
return plugin_modifier_add (plugin, type, message, modifier_func,
modifier_args, modifier_pointer);
return NULL;
}
/*
* weechat_plugin_modifier_remove: remove a WeeChat modifier
*/
void
weechat_plugin_modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
{
if (plugin && modifier)
plugin_modifier_remove (plugin, modifier);
}
/*
* weechat_plugin_modifier_remove_all: remove all WeeChat modifiers
*/
void
weechat_plugin_modifier_remove_all (t_weechat_plugin *plugin)
{
if (plugin)
plugin_modifier_remove_all (plugin);
}
/*
* weechat_plugin_exec_command: execute a command (simulate user entry)
*/
+251 -14
View File
@@ -180,7 +180,7 @@ plugin_cmd_handler_search (char *command)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command, command) == 0))
return ptr_handler;
}
@@ -212,7 +212,7 @@ plugin_msg_handler_add (t_weechat_plugin *plugin, char *irc_command,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_MESSAGE;
new_handler->type = PLUGIN_HANDLER_MESSAGE;
new_handler->irc_command = strdup (irc_command);
new_handler->command = NULL;
new_handler->description = NULL;
@@ -295,7 +295,7 @@ plugin_cmd_handler_add (t_weechat_plugin *plugin, char *command,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_COMMAND;
new_handler->type = PLUGIN_HANDLER_COMMAND;
new_handler->irc_command = NULL;
new_handler->command = strdup (command);
new_handler->description = (description) ? strdup (description) : NULL;
@@ -355,7 +355,7 @@ plugin_timer_handler_add (t_weechat_plugin *plugin, int interval,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_TIMER;
new_handler->type = PLUGIN_HANDLER_TIMER;
new_handler->irc_command = NULL;
new_handler->command = NULL;
new_handler->description = NULL;
@@ -411,7 +411,7 @@ plugin_keyboard_handler_add (t_weechat_plugin *plugin,
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
if (new_handler)
{
new_handler->type = HANDLER_KEYBOARD;
new_handler->type = PLUGIN_HANDLER_KEYBOARD;
new_handler->irc_command = NULL;
new_handler->command = NULL;
new_handler->description = NULL;
@@ -471,7 +471,7 @@ plugin_msg_handler_exec (char *server, char *irc_command, char *irc_message)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_MESSAGE)
if ((ptr_handler->type == PLUGIN_HANDLER_MESSAGE)
&& (ascii_strcasecmp (ptr_handler->irc_command, irc_command) == 0))
{
if (ptr_handler->running == 0)
@@ -523,7 +523,7 @@ plugin_cmd_handler_exec (char *server, char *command, char *arguments)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
&& (ascii_strcasecmp (ptr_handler->command, command) == 0))
{
if (ptr_handler->running == 0)
@@ -564,7 +564,7 @@ plugin_timer_handler_exec ()
for (ptr_handler = ptr_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->remaining--;
if (ptr_handler->remaining <= 0)
@@ -610,7 +610,7 @@ plugin_keyboard_handler_exec (char *key, char *input_before, char *input_after)
for (ptr_handler = ptr_plugin->handlers;
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == HANDLER_KEYBOARD)
if (ptr_handler->type == PLUGIN_HANDLER_KEYBOARD)
{
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
3, argv,
@@ -650,7 +650,7 @@ plugin_handler_remove (t_weechat_plugin *plugin,
(handler->next_handler)->prev_handler = handler->prev_handler;
/* remove command from WeeChat command list, if command handler */
if (handler->type == HANDLER_COMMAND)
if (handler->type == PLUGIN_HANDLER_COMMAND)
weelist_remove (&index_commands, &last_index_command,
weelist_search (index_commands, handler->command));
@@ -682,6 +682,199 @@ plugin_handler_remove_all (t_weechat_plugin *plugin)
plugin_handler_remove (plugin, plugin->handlers);
}
/*
* plugin_modifier_add: add a IRC handler
* arguments:
* 1. the plugin pointer
* 2. type of modifier
* 3. message ("*" means all)
* 4. the modifier function
* 5. modifier args: a string given to
* modifier when called (used by scripts)
* 6. modifier pointer: a pointer given to
* modifier when called (used by scripts)
*/
t_plugin_modifier *
plugin_modifier_add (t_weechat_plugin *plugin, char *type, char *command,
t_plugin_modifier_func *modifier_func,
char *modifier_args, void *modifier_pointer)
{
t_plugin_modifier *new_modifier;
int type_int;
if (ascii_strcasecmp (type, PLUGIN_MODIFIER_IRC_IN_STR) == 0)
type_int = PLUGIN_MODIFIER_IRC_IN;
else if (ascii_strcasecmp (type, PLUGIN_MODIFIER_IRC_USER_STR) == 0)
type_int = PLUGIN_MODIFIER_IRC_USER;
else if (ascii_strcasecmp (type, PLUGIN_MODIFIER_IRC_OUT_STR) == 0)
type_int = PLUGIN_MODIFIER_IRC_OUT;
else
return NULL;
new_modifier = (t_plugin_modifier *)malloc (sizeof (t_plugin_modifier));
if (new_modifier)
{
new_modifier->type = type_int;
new_modifier->command = (command) ? strdup (command) : strdup ("*");
new_modifier->modifier = modifier_func;
new_modifier->modifier_args = (modifier_args) ? strdup (modifier_args) : NULL;
new_modifier->modifier_pointer = modifier_pointer;
new_modifier->running = 0;
/* add new modifier to list */
new_modifier->prev_modifier = plugin->last_modifier;
new_modifier->next_modifier = NULL;
if (plugin->modifiers)
(plugin->last_modifier)->next_modifier = new_modifier;
else
plugin->modifiers = new_modifier;
plugin->last_modifier = new_modifier;
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s plugin %s: unable to add modifier (not enough memory)\n"),
WEECHAT_ERROR, plugin->name);
return NULL;
}
return new_modifier;
}
/*
* plugin_modifier_exec: execute a modifier
* return: NULL if no modifier was applied on message
* "" (empty string) if message has been dropped by a modifier
* other string if message has been modified
*/
char *
plugin_modifier_exec (t_plugin_modifier_type type,
char *server, char *message)
{
t_weechat_plugin *ptr_plugin;
t_plugin_modifier *ptr_modifier;
char *argv[2] = { NULL, NULL };
char *new_msg, *pos, *command;
int length_command;
argv[0] = server;
argv[1] = message;
command = NULL;
length_command = 0;
if ((type == PLUGIN_MODIFIER_IRC_IN) || (type == PLUGIN_MODIFIER_IRC_OUT))
{
/* look for command in message */
if (message[0] == ':')
{
pos = strchr (message, ' ');
if (pos)
{
while (pos[0] == ' ')
pos++;
command = pos;
}
}
else
command = message;
if (command)
{
pos = strchr (command, ' ');
if (pos)
length_command = pos - command;
else
length_command = strlen (command);
}
}
new_msg = NULL;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
for (ptr_modifier = ptr_plugin->modifiers;
ptr_modifier; ptr_modifier = ptr_modifier->next_modifier)
{
if (ptr_modifier->type == type)
{
if (ptr_modifier->running == 0)
{
if (((type != PLUGIN_MODIFIER_IRC_IN) && (type != PLUGIN_MODIFIER_IRC_OUT))
|| (ascii_strcasecmp (ptr_modifier->command, "*") == 0)
|| (command && (ascii_strncasecmp (ptr_modifier->command, command, length_command) == 0)))
{
ptr_modifier->running = 1;
new_msg = ((char *) (ptr_modifier->modifier) (ptr_plugin,
2, argv,
ptr_modifier->modifier_args,
ptr_modifier->modifier_pointer));
ptr_modifier->running = 0;
/* message dropped? */
if (new_msg && !new_msg[0])
return new_msg;
/* new message => keep it as base for next modifier */
if (new_msg)
{
/* free any new message allocated before by another modifier */
if (argv[1] != message)
free (argv[1]);
argv[1] = new_msg;
}
}
}
}
}
}
return new_msg;
}
/*
* plugin_modifier_remove: remove a modifier for a plugin
*/
void
plugin_modifier_remove (t_weechat_plugin *plugin,
t_plugin_modifier *modifier)
{
t_plugin_modifier *new_modifiers;
/* remove modifier from list */
if (plugin->last_modifier == modifier)
plugin->last_modifier = modifier->prev_modifier;
if (modifier->prev_modifier)
{
(modifier->prev_modifier)->next_modifier = modifier->next_modifier;
new_modifiers = plugin->modifiers;
}
else
new_modifiers = modifier->next_modifier;
if (modifier->next_modifier)
(modifier->next_modifier)->prev_modifier = modifier->prev_modifier;
/* free data */
if (modifier->command)
free (modifier->command);
plugin->modifiers = new_modifiers;
}
/*
* plugin_modifier_remove_all: remove all modifiers for a plugin
*/
void
plugin_modifier_remove_all (t_weechat_plugin *plugin)
{
while (plugin->modifiers)
plugin_modifier_remove (plugin, plugin->modifiers);
}
/*
* plugin_search_full_name: search the full name of a file with a part of name
* and look in WeeChat user's dir, then WeeChat global lib dir
@@ -857,6 +1050,9 @@ plugin_load (char *filename)
new_plugin->keyboard_handler_add = &weechat_plugin_keyboard_handler_add;
new_plugin->handler_remove = &weechat_plugin_handler_remove;
new_plugin->handler_remove_all = &weechat_plugin_handler_remove_all;
new_plugin->modifier_add = &weechat_plugin_modifier_add;
new_plugin->modifier_remove = &weechat_plugin_modifier_remove;
new_plugin->modifier_remove_all = &weechat_plugin_modifier_remove_all;
new_plugin->print = &weechat_plugin_print;
new_plugin->print_server = &weechat_plugin_print_server;
new_plugin->print_infobar = &weechat_plugin_print_infobar;
@@ -889,6 +1085,10 @@ plugin_load (char *filename)
new_plugin->handlers = NULL;
new_plugin->last_handler = NULL;
/* modifiers */
new_plugin->modifiers = NULL;
new_plugin->last_modifier = NULL;
/* add new plugin to list */
new_plugin->prev_plugin = last_weechat_plugin;
new_plugin->next_plugin = NULL;
@@ -936,11 +1136,12 @@ plugin_load (char *filename)
}
/*
* plugin_auto_load_file: load a file found by plugin_aut_load,
* plugin_auto_load_file: load a file found by plugin_auto_load,
* but only it this is really a dynamic library
*/
int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
int
plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
{
char *pos;
@@ -965,7 +1166,8 @@ int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename)
* plugin_auto_load: auto-load WeeChat plugins
*/
void plugin_auto_load ()
void
plugin_auto_load ()
{
char *ptr_home, *dir_name, *plugins_path, *plugins_path2;
char *list_plugins, *pos, *pos2;
@@ -1049,8 +1251,11 @@ plugin_remove (t_weechat_plugin *plugin)
if (plugin->next_plugin)
(plugin->next_plugin)->prev_plugin = plugin->prev_plugin;
/* free data */
/* remove all handlers and modifiers */
plugin_handler_remove_all (plugin);
plugin_modifier_remove_all (plugin);
/* free data */
if (plugin->filename)
free (plugin->filename);
dlclose (plugin->handle);
@@ -1116,6 +1321,38 @@ plugin_unload_all ()
plugin_unload (last_weechat_plugin);
}
/*
* plugin_reload_name: reload a WeeChat plugin by name
*/
void
plugin_reload_name (char *name)
{
t_weechat_plugin *ptr_plugin;
char *filename;
ptr_plugin = plugin_search (name);
if (ptr_plugin)
{
filename = strdup (ptr_plugin->filename);
if (filename)
{
plugin_unload (ptr_plugin);
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
gui_printf (NULL, _("Plugin \"%s\" unloaded.\n"), name);
plugin_load (filename);
free (filename);
}
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s plugin \"%s\" not found\n"),
WEECHAT_ERROR, name);
}
}
/*
* plugin_init: init plugin support
*/
+9
View File
@@ -68,12 +68,21 @@ extern int plugin_keyboard_handler_exec (char *, char *, char *);
extern void plugin_handler_remove (t_weechat_plugin *,
t_plugin_handler *);
extern void plugin_handler_remove_all (t_weechat_plugin *);
extern t_plugin_modifier *plugin_modifier_add (t_weechat_plugin *,
char *, char *,
t_plugin_modifier_func *,
char *, void *);
extern char *plugin_modifier_exec (t_plugin_modifier_type, char *, char *);
extern void plugin_modifier_remove (t_weechat_plugin *,
t_plugin_modifier *);
extern void plugin_modifier_remove_all (t_weechat_plugin *);
extern t_weechat_plugin *plugin_load (char *);
extern void plugin_auto_load ();
extern void plugin_remove (t_weechat_plugin *);
extern void plugin_unload (t_weechat_plugin *);
extern void plugin_unload_name (char *);
extern void plugin_unload_all ();
extern void plugin_reload_name (char *);
extern void plugin_init (int);
extern void plugin_end ();
+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;
@@ -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
@@ -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 *);
+67 -9
View File
@@ -183,25 +183,25 @@ struct t_plugin_buffer_line
typedef struct t_weechat_plugin t_weechat_plugin;
typedef int (t_plugin_handler_func) (t_weechat_plugin *, int, char **, char *, void *);
/* handlers */
typedef enum t_handler_type t_handler_type;
typedef int (t_plugin_handler_func) (t_weechat_plugin *, int, char **, char *, void *);
enum t_handler_type
typedef enum t_plugin_handler_type t_plugin_handler_type;
enum t_plugin_handler_type
{
HANDLER_MESSAGE = 0, /* IRC message handler */
HANDLER_COMMAND, /* command handler */
HANDLER_TIMER, /* timer handler */
HANDLER_KEYBOARD /* keyboard handler */
PLUGIN_HANDLER_MESSAGE = 0, /* IRC message handler */
PLUGIN_HANDLER_COMMAND, /* command handler */
PLUGIN_HANDLER_TIMER, /* timer handler */
PLUGIN_HANDLER_KEYBOARD /* keyboard handler */
};
typedef struct t_plugin_handler t_plugin_handler;
struct t_plugin_handler
{
t_handler_type type; /* handler type */
t_plugin_handler_type type; /* handler type */
/* data for message handler */
char *irc_command; /* name of IRC command (PRIVMSG, ..) */
@@ -229,6 +229,46 @@ struct t_plugin_handler
t_plugin_handler *next_handler; /* link to next handler */
};
/* modifiers */
typedef char * (t_plugin_modifier_func) (t_weechat_plugin *, int, char **, char *, void *);
typedef enum t_plugin_modifier_type t_plugin_modifier_type;
enum t_plugin_modifier_type
{
PLUGIN_MODIFIER_IRC_IN = 0, /* incoming IRC msg (server > user) */
PLUGIN_MODIFIER_IRC_USER, /* outgoing IRC msg (user > server) */
/* after user input (before 'out' mod.) */
PLUGIN_MODIFIER_IRC_OUT /* outgoing IRC msg (user > server) */
/* immediately before sending to server */
};
#define PLUGIN_MODIFIER_IRC_IN_STR "irc_in"
#define PLUGIN_MODIFIER_IRC_USER_STR "irc_user"
#define PLUGIN_MODIFIER_IRC_OUT_STR "irc_out"
typedef struct t_plugin_modifier t_plugin_modifier;
struct t_plugin_modifier
{
t_plugin_modifier_type type; /* modifier type */
/* data for IRC modifier */
char *command; /* IRC command */
/* data common to all modifiers */
t_plugin_modifier_func *modifier; /* pointer to modifier */
char *modifier_args; /* arguments sent to modifier */
void *modifier_pointer; /* pointer sent to modifier */
/* for internal use */
int running; /* 1 if currently running */
/* (used to prevent circular call) */
t_plugin_modifier *prev_modifier; /* link to previous modifier */
t_plugin_modifier *next_modifier; /* link to next modifier */
};
/* plugin, a WeeChat plugin, which is a dynamic library */
struct t_weechat_plugin
@@ -243,6 +283,10 @@ struct t_weechat_plugin
/* plugin handlers */
t_plugin_handler *handlers; /* pointer to first handler */
t_plugin_handler *last_handler; /* pointer to last handler */
/* plugin modifiers */
t_plugin_modifier *modifiers; /* pointer to first modifier */
t_plugin_modifier *last_modifier; /* pointer to last modifier */
/* links to previous/next plugins */
t_weechat_plugin *prev_plugin; /* link to previous plugin */
@@ -283,6 +327,12 @@ struct t_weechat_plugin
char *, void *);
void (*handler_remove) (t_weechat_plugin *, t_plugin_handler *);
void (*handler_remove_all) (t_weechat_plugin *);
t_plugin_modifier *(*modifier_add) (t_weechat_plugin *, char *, char *,
t_plugin_modifier_func *,
char *, void *);
void (*modifier_remove) (t_weechat_plugin *, t_plugin_modifier *);
void (*modifier_remove_all) (t_weechat_plugin *);
void (*exec_command) (t_weechat_plugin *, char *, char *, char *);
char *(*get_info) (t_weechat_plugin *, char *, char *);
@@ -351,6 +401,14 @@ extern t_plugin_handler *weechat_plugin_keyboard_handler_add (t_weechat_plugin *
extern void weechat_plugin_handler_remove (t_weechat_plugin *, t_plugin_handler *);
extern void weechat_plugin_handler_remove_all (t_weechat_plugin *);
/* modifier functions */
extern t_plugin_modifier *weechat_plugin_modifier_add (t_weechat_plugin *,
char *, char *,
t_plugin_modifier_func *,
char *, void *);
extern void weechat_plugin_modifier_remove (t_weechat_plugin *, t_plugin_modifier *);
extern void weechat_plugin_modifier_remove_all (t_weechat_plugin *);
/* other functions */
extern void weechat_plugin_exec_command (t_weechat_plugin *, char *, char *, char *);
extern char *weechat_plugin_get_info (t_weechat_plugin *, char *, char *);