From 0ff8d7b5439ee543fae8eb4c4080ec4ccf905b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 27 Jun 2015 17:00:53 +0200 Subject: irc: decode/encode only text in IRC messages and not the headers (bug #29886, closes #218, closes #451) --- doc/en/weechat_scripting.en.asciidoc | 66 ++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 6 deletions(-) (limited to 'doc/en/weechat_scripting.en.asciidoc') diff --git a/doc/en/weechat_scripting.en.asciidoc b/doc/en/weechat_scripting.en.asciidoc index b8864a26d..3fc5e5f12 100644 --- a/doc/en/weechat_scripting.en.asciidoc +++ b/doc/en/weechat_scripting.en.asciidoc @@ -899,14 +899,68 @@ _New in version 0.3.4._ You can parse an IRC message with info_hashtable called "irc_message_parse". +The result is a hashtable with following keys +(the example values are built with this message: +`@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!`): + +[width="100%",cols="1,^2,10,8",options="header"] +|=== +| Key | WeeChat version | Description | Example + +| tags | ≥ 0.4.0 | + The tags in message (can be empty) | + `time=2015-06-27T16:40:35.000Z` + +| message_without_tags | ≥ 0.4.0 | + The message without the tags (the same as message if there are no tags) | + `:nick!user@host PRIVMSG #weechat :hello!` + +| nick | ≥ 0.3.4 | + The origin nick | + `nick` + +| host | ≥ 0.3.4 | + The origin host (includes the nick) | + `nick!user@host` + +| command | ≥ 0.3.4 | + The command ('PRIVMSG', 'NOTICE', ...) | + `PRIVMSG` + +| channel | ≥ 0.3.4 | + The target channel | + `#weechat` + +| arguments | ≥ 0.3.4 | + The command arguments (includes the channel) | + `#weechat :hello!` + +| text | ≥ 1.3 | + The text (for example user message) | + `hello!` + +| pos_text | ≥ 1.3 | + The index of text in message ("-1" if text was not found) | + `65` +|=== + [source,python] ---- -dict = weechat.info_get_hashtable("irc_message_parse", - {"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'} +dict = weechat.info_get_hashtable( + "irc_message_parse", + {"message": "@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"}) + +# dict == { +# "tags": "time=2015-06-27T16:40:35.000Z", +# "message_without_tags": ":nick!user@host PRIVMSG #weechat :hello!", +# "nick": "nick", +# "host": "nick!user@host", +# "command": "PRIVMSG", +# "channel": "#weechat", +# "arguments": "#weechat :hello!", +# "text": "hello!", +# "pos_text": "65", +# } ---- [[infos]] -- cgit v1.2.3