summaryrefslogtreecommitdiff
path: root/doc/en
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-10-25 13:09:11 +0200
committerSebastien Helleu <flashcode@flashtux.org>2010-10-25 13:09:11 +0200
commit4e6c4ceb5f350e0e54257ead8bc527492378f489 (patch)
treeb8bc95e76ab3599795f302e13cc3e5a59ba3daff /doc/en
parente5afd593ab1342b265b373169ce7a62a9c6cbf1a (diff)
downloadweechat-4e6c4ceb5f350e0e54257ead8bc527492378f489.zip
Add irc modifier and irc_parse_message in scripting guide
Diffstat (limited to 'doc/en')
-rw-r--r--doc/en/weechat_scripting.en.txt45
1 files changed, 42 insertions, 3 deletions
diff --git a/doc/en/weechat_scripting.en.txt b/doc/en/weechat_scripting.en.txt
index 49af78bf7..157471160 100644
--- a/doc/en/weechat_scripting.en.txt
+++ b/doc/en/weechat_scripting.en.txt
@@ -270,9 +270,10 @@ List of functions in script API:
prnt_date_tags), print_y (for python: prnt_y), log_print
| hooks |
hook_command, hook_command_run, hook_timer, hook_fd, hook_process,
- hook_connect, hook_print, hook_signal, hook_signal_send, hook_config,
- hook_completion, hook_completion_list_add, hook_modifier, hook_modifier_exec,
- hook_info, hook_info_hashtable, hook_infolist, unhook, unhook_all
+ hook_connect, hook_print, hook_signal, hook_signal_send, hook_hsignal,
+ hook_hsignal_send, hook_config, hook_completion, hook_completion_list_add,
+ hook_modifier, hook_modifier_exec, hook_info, hook_info_hashtable,
+ hook_infolist, unhook, unhook_all
| buffers |
buffer_new, current_buffer, buffer_search, buffer_search_main, buffer_clear,
buffer_close, buffer_merge, buffer_unmerge, buffer_get_integer,
@@ -683,6 +684,44 @@ def join_cb(data, signal, signal_data):
weechat.hook_signal("*,irc_in2_join", "join_cb", "")
----------------------------------------
+[[irc_modify_messages]]
+Modify messages
+^^^^^^^^^^^^^^^
+
+IRC plugin sends a "modifier" called "irc_in_xxx" ("xxx" is IRC command) for a
+message received, so that you can modify it.
+
+[source,python]
+----------------------------------------
+def modifier_cb(data, modifier, modifier_data, string):
+ # add server name to all messages received
+ # (ok that's not very useful, but that's just an example!)
+ return "%s %s" % (string, modifier_data)
+
+weechat.hook_modifier("irc_in_privmsg", "modifier_cb", "")
+----------------------------------------
+
+[WARNING]
+A malformed message could crash WeeChat or cause severe problems!
+
+[[irc_parse_message]]
+Parse message
+^^^^^^^^^^^^^
+
+_New in version 0.3.4._
+
+You can parse an IRC message with info_hashtable called "irc_parse_message".
+
+[source,python]
+----------------------------------------
+dict = weechat.info_get_hashtable("irc_parse_message",
+ { "message": ":nick!user@host PRIVMSG #weechat :message here" })
+weechat.prnt("", "dict: %s" % dict)
+
+# output:
+# dict: {'nick': 'nick', 'host': 'nick!user@host', 'command': 'PRIVMSG', 'arguments': '#weechat :message here', 'channel': '#weechat'}
+----------------------------------------
+
[[infos]]
Infos
~~~~~