diff options
40 files changed, 708 insertions, 163 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index b65458b59..cd141b0c6 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -37,6 +37,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] weechat.look.buffer_time_format is set to empty string (closes #441) * fifo: fix send error on Cygwin when something is received in the pipe (closes #436) +* irc: decode/encode only text in IRC messages and not the headers + (bug #29886, closes #218, closes #451) * irc: fix crash with commands /allchan, /allpv and /allserv if the executed command closes buffers (closes #445) * irc: do not open auto-joined channels buffers when option "-nojoin" is used diff --git a/doc/de/autogen/plugin_api/infos_hashtable.asciidoc b/doc/de/autogen/plugin_api/infos_hashtable.asciidoc index 97f6aa408..f0374c2f2 100644 --- a/doc/de/autogen/plugin_api/infos_hashtable.asciidoc +++ b/doc/de/autogen/plugin_api/infos_hashtable.asciidoc @@ -6,7 +6,7 @@ |=== | Erweiterung | Name | Beschreibung | Hashtable (Eingabe) | Hashtable (Ausgabe) -| irc | irc_message_parse | Parse eine IRC Nachricht | "message": IRC Nachricht, "server": Servername (optional) | "tags": Tags, "message_without_tags": Nachrichten ohne Tags, "nick": Nick, "host": Host, "command": Befehl, "channel": Channel, "arguments": Argumente (schließt Channel ein) +| irc | irc_message_parse | Parse eine IRC Nachricht | "message": IRC Nachricht, "server": Servername (optional) | "tags": tags, "message_without_tags": message without the tags, "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel), "text": text (for example user message), "pos_text": index of text in message ("-1" if no text found) | irc | irc_message_split | dient zum Aufteilen einer überlangen IRC Nachricht (in maximal 512 Bytes große Nachrichten) | "message": IRC Nachricht, "server": Servername (optional) | "msg1" ... "msgN": Nachrichten die versendet werden sollen (ohne abschließendes "\r\n"), "args1" ... "argsN": Argumente für Nachrichten, "count": Anzahl der Nachrichten diff --git a/doc/de/weechat_scripting.de.asciidoc b/doc/de/weechat_scripting.de.asciidoc index 7b191e6f7..dae199a7c 100644 --- a/doc/de/weechat_scripting.de.asciidoc +++ b/doc/de/weechat_scripting.de.asciidoc @@ -918,16 +918,72 @@ Eine fehlerhafte Nachricht kann WeeChat zum Absturz bringen oder andere ernsthaf _Neu seit Version 0.3.4._ -Man kann IRC Nachrichten mittels einer info_hashtable mit dem Namen "irc_message_parse" parsen. +Man kann IRC Nachrichten mittels einer info_hashtable mit dem Namen +"irc_message_parse" parsen. + +// TRANSLATION MISSING +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]] diff --git a/doc/de/weechat_user.de.asciidoc b/doc/de/weechat_user.de.asciidoc index de3b81674..423ea7edf 100644 --- a/doc/de/weechat_user.de.asciidoc +++ b/doc/de/weechat_user.de.asciidoc @@ -3320,6 +3320,10 @@ und die Daten in einer Hashtable gesichert: | command | string | IRC Befehl (Beispiel: "PRIVMSG", "NOTICE", ...) | channel | string | IRC Channel | arguments | string | Argumente des Befehls (Beinhaltet Wert von 'channel') +// TRANSLATION MISSING +| text | string | Text (for example user message) +// TRANSLATION MISSING +| pos_text | string | The index of text in message ("-1" if text was not found) |=== // TRANSLATION MISSING diff --git a/doc/en/autogen/plugin_api/infos_hashtable.asciidoc b/doc/en/autogen/plugin_api/infos_hashtable.asciidoc index 705a68bd1..8987746c6 100644 --- a/doc/en/autogen/plugin_api/infos_hashtable.asciidoc +++ b/doc/en/autogen/plugin_api/infos_hashtable.asciidoc @@ -6,7 +6,7 @@ |=== | Plugin | Name | Description | Hashtable (input) | Hashtable (output) -| irc | irc_message_parse | parse an IRC message | "message": IRC message, "server": server name (optional) | "tags": tags, "message_without_tags": message without the tags, "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel) +| irc | irc_message_parse | parse an IRC message | "message": IRC message, "server": server name (optional) | "tags": tags, "message_without_tags": message without the tags, "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel), "text": text (for example user message), "pos_text": index of text in message ("-1" if no text found) | irc | irc_message_split | split an IRC message (to fit in 512 bytes) | "message": IRC message, "server": server name (optional) | "msg1" ... "msgN": messages to send (without final "\r\n"), "args1" ... "argsN": arguments of messages, "count": number of messages diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc index ae81a8f3b..cca10ff35 100644 --- a/doc/en/weechat_plugin_api.en.asciidoc +++ b/doc/en/weechat_plugin_api.en.asciidoc @@ -12902,23 +12902,33 @@ hashtable_in = weechat_hashtable_new (8, NULL); if (hashtable_in) { - weechat_hashtable_set (hashtable_in, "message", - ":nick!user@host PRIVMSG #weechat :message here"); + weechat_hashtable_set ( + hashtable_in, + "message", + "@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"); hashtable_out = weechat_info_get_hashtable ("irc_message_parse", hashtable_in); /* * now hashtable_out has following keys/values: - * "nick" : "nick" - * "host" : "nick!user@host" - * "command" : "PRIVMSG" - * "channel" : "#weechat" - * "arguments": "#weechat :message here" + * "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" */ weechat_hashtable_free (hashtable_in); weechat_hashtable_free (hashtable_out); } ---- +[NOTE] +See the 'WeeChat Scripting Guide' for more info about "irc_message_parse" +output. + Script (Python): [source,python] 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]] diff --git a/doc/en/weechat_user.en.asciidoc b/doc/en/weechat_user.en.asciidoc index b638262ce..a07c4db23 100644 --- a/doc/en/weechat_user.en.asciidoc +++ b/doc/en/weechat_user.en.asciidoc @@ -3236,6 +3236,8 @@ is added in hashtable: | command | string | IRC command (example: "PRIVMSG", "NOTICE", ...) | channel | string | IRC channel | arguments | string | Arguments of command (includes value of 'channel') +| text | string | Text (for example user message) +| pos_text | string | The index of text in message ("-1" if text was not found) |=== When the data is a pointer, the variable `tg_signal_data` can be used like this diff --git a/doc/fr/autogen/plugin_api/infos_hashtable.asciidoc b/doc/fr/autogen/plugin_api/infos_hashtable.asciidoc index a6c076e09..7d84565b5 100644 --- a/doc/fr/autogen/plugin_api/infos_hashtable.asciidoc +++ b/doc/fr/autogen/plugin_api/infos_hashtable.asciidoc @@ -6,7 +6,7 @@ |=== | Extension | Nom | Description | Table de hachage (entrée) | Table de hachage (sortie) -| irc | irc_message_parse | analyse un message IRC | "message" : message IRC, "server" : nom du serveur (optionnel) | "tags" : étiquettes, "message_without_tags" : message sans les étiquettes, "nick" : pseudo, "host" : nom d'hôte, "command" : commande, "channel" : canal, "arguments" : paramètres (inclut le canal) +| irc | irc_message_parse | analyse un message IRC | "message" : message IRC, "server" : nom du serveur (optionnel) | "tags" : étiquettes, "message_without_tags" : message sans les étiquettes, "nick" : pseudo, "host" : nom d'hôte, "command" : commande, "channel" : canal, "arguments" : paramètres (inclut le canal), "text" : texte (par exemple message utilisateur), "pos_text" : index du texte dans le message ("-1" si aucun texte n'a été trouvé) | irc | irc_message_split | découper un message IRC (pour tenir dans les 512 octets) | "message" : message IRC, "server" : nom du serveur (optionnel) | "msg1" ... "msgN" : messages à envoyer (sans le "\r\n" final), "args1" ... "argsN" : paramètres des messages, "count" : nombre de messages diff --git a/doc/fr/weechat_plugin_api.fr.asciidoc b/doc/fr/weechat_plugin_api.fr.asciidoc index 4a3a1070a..026c1da74 100644 --- a/doc/fr/weechat_plugin_api.fr.asciidoc +++ b/doc/fr/weechat_plugin_api.fr.asciidoc @@ -13151,23 +13151,33 @@ hashtable_in = weechat_hashtable_new (8, NULL); if (hashtable_in) { - weechat_hashtable_set (hashtable_in, "message", - ":nick!user@host PRIVMSG #weechat :message ici"); + weechat_hashtable_set ( + hashtable_in, + "message", + "@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"); hashtable_out = weechat_info_get_hashtable ("irc_message_parse", hashtable_in); /* * maintenant hashtable_out a les clés/valeurs suivantes : - * "nick" : "nick" - * "host" : "nick!user@host" - * "command" : "PRIVMSG" - * "channel" : "#weechat" - * "arguments": "#weechat :message ici" + * "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" */ weechat_hashtable_free (hashtable_in); weechat_hashtable_free (hashtable_out); } ---- +[NOTE] +Voir le 'Guide pour Scripts WeeChat' pour plus d'infos sur la sortie de +"irc_message_parse". + Script (Python) : [source,python] diff --git a/doc/fr/weechat_scripting.fr.asciidoc b/doc/fr/weechat_scripting.fr.asciidoc index b4a992ba9..bcbd659f6 100644 --- a/doc/fr/weechat_scripting.fr.asciidoc +++ b/doc/fr/weechat_scripting.fr.asciidoc @@ -922,14 +922,69 @@ _Nouveau dans la version 0.3.4._ Vous pouvez analyser un message IRC avec l'info_hashtable appelée "irc_message_parse". +Le résultat est une table de hachage avec les clés suivantes +(les exemples de valeurs sont construits avec ce message : +`@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!`): + +[width="100%",cols="1,^2,10,8",options="header"] +|=== +| Clé | Version de WeeChat | Description | Exemple + +| tags | ≥ 0.4.0 | + Les étiquettes dans le message (peut être vide) | + `time=2015-06-27T16:40:35.000Z` + +| message_without_tags | ≥ 0.4.0 | + Le message sans les étiquettes (la même chose que le message s'il n'y a pas + d'étiquettes) | + `:nick!user@host PRIVMSG #weechat :hello!` + +| nick | ≥ 0.3.4 | + Le pseudo d'origine | + `nick` + +| host | ≥ 0.3.4 | + L'hôte d'origine (incluant le pseudo) | + `nick!user@host` + +| command | ≥ 0.3.4 | + La commande ('PRIVMSG', 'NOTICE', ...) | + `PRIVMSG` + +| channel | ≥ 0.3.4 | + Le canal cible | + `#weechat` + +| arguments | ≥ 0.3.4 | + Les paramètres de la commande (incluant le canal) | + `#weechat :hello!` + +| text | ≥ 1.3 | + Le texte (par exemple un message utilisateur) | + `hello!` + +| pos_text | ≥ 1.3 | + La position du texte dans le message ("-1" si le texte n'a pas été trouvé) | + `65` +|=== + [source,python] ---- -dict = weechat.info_get_hashtable("irc_message_parse", - {"message": ":nick!user@host PRIVMSG #weechat :message ici"}) -weechat.prnt("", "dict: %s" % dict) - -# output: -# dict: {'nick': 'nick', 'host': 'nick!user@host', 'command': 'PRIVMSG', 'arguments': '#weechat :message ici', '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]] diff --git a/doc/fr/weechat_user.fr.asciidoc b/doc/fr/weechat_user.fr.asciidoc index c3724a4a4..de247317e 100644 --- a/doc/fr/weechat_user.fr.asciidoc +++ b/doc/fr/weechat_user.fr.asciidoc @@ -3339,6 +3339,8 @@ suivantes sont ajoutées dans la table de hachage : | command | chaîne | Commande IRC (exemple : "PRIVMSG", "NOTICE", ...) | channel | chaîne | Canal IRC | arguments | chaîne | Paramètres de la commande (inclut la valeur de 'channel') +| text | string | Texte (par exemple message utilisateur) +| pos_text | string | L'index du texte dans le message ("-1" si le texte n'a pas été trouvé) |=== Lorsque la donnée est un pointeur, la variable `tg_signal_data` peut être diff --git a/doc/it/autogen/plugin_api/infos_hashtable.asciidoc b/doc/it/autogen/plugin_api/infos_hashtable.asciidoc index 54ccb8408..02cc07e31 100644 --- a/doc/it/autogen/plugin_api/infos_hashtable.asciidoc +++ b/doc/it/autogen/plugin_api/infos_hashtable.asciidoc @@ -6,7 +6,7 @@ |=== | Plugin | Nome | Descrizione | Tabella hash (input) | Tabella hash (output) -| irc | irc_message_parse | controlla un messaggio IRC | "message": messaggio IRC, "server": nome server (opzionale) | "tags": tag, "message_without_tags": messaggio senza tag, "nick": nick, "host": nome host, "command": comando, "channel": canale, "arguments": argomenti (include il canale) +| irc | irc_message_parse | controlla un messaggio IRC | "message": messaggio IRC, "server": nome server (opzionale) | "tags": tags, "message_without_tags": message without the tags, "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel), "text": text (for example user message), "pos_text": index of text in message ("-1" if no text found) | irc | irc_message_split | divide un messaggio IRC (per adattarlo in 512 byte) | "message": messaggio IRC, "server": nome server (opzionale) | "msg1" ... "msgN": messaggio da inviare (senza "\r\n" finale), "args1" ... "argsN": argomenti dei messaggi, "count": numero di messaggi diff --git a/doc/it/weechat_plugin_api.it.asciidoc b/doc/it/weechat_plugin_api.it.asciidoc index 25b34f5f7..9cbac6eca 100644 --- a/doc/it/weechat_plugin_api.it.asciidoc +++ b/doc/it/weechat_plugin_api.it.asciidoc @@ -13304,23 +13304,34 @@ hashtable_in = weechat_hashtable_new (8, NULL); if (hashtable_in) { - weechat_hashtable_set (hashtable_in, "message", - ":nick!user@host PRIVMSG #weechat :message here"); + weechat_hashtable_set ( + hashtable_in, + "message", + "@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"); hashtable_out = weechat_info_get_hashtable ("irc_message_parse", hashtable_in); /* * now hashtable_out has following keys/values: - * "nick" : "nick" - * "host" : "nick!user@host" - * "command" : "PRIVMSG" - * "channel" : "#weechat" - * "arguments": "#weechat :message here" + * "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" */ weechat_hashtable_free (hashtable_in); weechat_hashtable_free (hashtable_out); } ---- +// TRANSLATION MISSING +[NOTE] +See the 'WeeChat Scripting Guide' for more info about "irc_message_parse" +output. + Script (Python): [source,python] diff --git a/doc/it/weechat_scripting.it.asciidoc b/doc/it/weechat_scripting.it.asciidoc index 2084fddf5..527543129 100644 --- a/doc/it/weechat_scripting.it.asciidoc +++ b/doc/it/weechat_scripting.it.asciidoc @@ -927,14 +927,69 @@ _Novità nella versione 0.3.4._ È possibile verificare un messaggio irc con una info_hashtable chiamata "irc_message_parse". +// TRANSLATION MISSING +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]] diff --git a/doc/it/weechat_user.it.asciidoc b/doc/it/weechat_user.it.asciidoc index 4aefefc63..48d2b052e 100644 --- a/doc/it/weechat_user.it.asciidoc +++ b/doc/it/weechat_user.it.asciidoc @@ -3397,6 +3397,8 @@ is added in hashtable: | command | string | IRC command (example: "PRIVMSG", "NOTICE", ...) | channel | string | IRC channel | arguments | string | Arguments of command (includes value of 'channel') +| text | string | Text (for example user message) +| pos_text | string | The index of text in message ("-1" if text was not found) |=== When the data is a pointer, the variable `tg_signal_data` can be used like this diff --git a/doc/ja/autogen/plugin_api/infos_hashtable.asciidoc b/doc/ja/autogen/plugin_api/infos_hashtable.asciidoc index b60a5c304..189070678 100644 --- a/doc/ja/autogen/plugin_api/infos_hashtable.asciidoc +++ b/doc/ja/autogen/plugin_api/infos_hashtable.asciidoc @@ -6,7 +6,7 @@ |=== | プラグイン | 名前 | 説明 | ハッシュテーブル (入力) | ハッシュテーブル (出力) -| irc | irc_message_parse | IRC メッセージを解析 | "message": IRC メッセージ、"server": サーバ名 (任意) | "tags": タグ、"message_without_tags": タグを含まないメッセージ、"nick": ニックネーム、"host": ホスト名、"command": コマンド、"channel": チャンネル、"arguments": 引数 (チャンネルを含む) +| irc | irc_message_parse | IRC メッセージを解析 | "message": IRC メッセージ、"server": サーバ名 (任意) | "tags": tags, "message_without_tags": message without the tags, "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel), "text": text (for example user message), "pos_text": index of text in message ("-1" if no text found) | irc | irc_message_split | IRC メッセージを分割 (512 バイトに収める) | "message": IRC メッセージ、"server": サーバ名 (任意) | "msg1" ... "msgN": 送信メッセージ (最後の "\r\n" は無し), "args1" ... "argsN": メッセージの引数、"count": メッセージの数 diff --git a/doc/ja/weechat_plugin_api.ja.asciidoc b/doc/ja/weechat_plugin_api.ja.asciidoc index 4a943113d..091018eba 100644 --- a/doc/ja/weechat_plugin_api.ja.asciidoc +++ b/doc/ja/weechat_plugin_api.ja.asciidoc @@ -12901,23 +12901,34 @@ hashtable_in = weechat_hashtable_new (8, NULL); if (hashtable_in) { - weechat_hashtable_set (hashtable_in, "message", - ":nick!user@host PRIVMSG #weechat :message here"); + weechat_hashtable_set ( + hashtable_in, + "message", + "@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"); hashtable_out = weechat_info_get_hashtable ("irc_message_parse", hashtable_in); /* * now hashtable_out has following keys/values: - * "nick" : "nick" - * "host" : "nick!user@host" - * "command" : "PRIVMSG" - * "channel" : "#weechat" - * "arguments": "#weechat :message here" + * "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" */ weechat_hashtable_free (hashtable_in); weechat_hashtable_free (hashtable_out); } ---- +// TRANSLATION MISSING +[NOTE] +See the 'WeeChat Scripting Guide' for more info about "irc_message_parse" +output. + スクリプト (Python) での使用例: [source,python] diff --git a/doc/ja/weechat_scripting.ja.asciidoc b/doc/ja/weechat_scripting.ja.asciidoc index 9db3410ac..8ec667104 100644 --- a/doc/ja/weechat_scripting.ja.asciidoc +++ b/doc/ja/weechat_scripting.ja.asciidoc @@ -902,14 +902,69 @@ _バージョン 0.3.4 の新機能_ "irc_message_parse" と呼ばれる info_hashtable を使って IRC メッセージを構文解析できます。 +// TRANSLATION MISSING +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) - -# 出力: -# 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]] diff --git a/doc/ja/weechat_user.ja.asciidoc b/doc/ja/weechat_user.ja.asciidoc index e49aa6d4a..8d309ec0d 100644 --- a/doc/ja/weechat_user.ja.asciidoc +++ b/doc/ja/weechat_user.ja.asciidoc @@ -3235,6 +3235,10 @@ ${tg_highlight} || ${tg_msg_pv} | command | string | IRC コマンド (例: "PRIVMSG"、"NOTICE"、...) | channel | string | IRC チャンネル | arguments | string | コマンドの引数 ('channel' の値を含みます) +// TRANSLATION MISSING +| text | string | Text (for example user message) +// TRANSLATION MISSING +| pos_text | string | The index of text in message ("-1" if text was not found) |=== // TRANSLATION MISSING diff --git a/doc/pl/autogen/plugin_api/infos_hashtable.asciidoc b/doc/pl/autogen/plugin_api/infos_hashtable.asciidoc index 76185e81d..bd2e73944 100644 --- a/doc/pl/autogen/plugin_api/infos_hashtable.asciidoc +++ b/doc/pl/autogen/plugin_api/infos_hashtable.asciidoc @@ -6,7 +6,7 @@ |=== | Wtyczka | Nazwa | Opis | Hashtable (wejście) | Hashtable (wyjście) -| irc | irc_message_parse | przetwarza wiadomość IRC | "message": wiadomość IRC, "server": nazwa serwera (opcjonalne) | "tags": tagi, "message_without_tags": wiadomość bez tagów, "nick": nick, "host": host, "command": komenda, "channel": kanał, "arguments": argumenty (razem z kanałem) +| irc | irc_message_parse | przetwarza wiadomość IRC | "message": wiadomość IRC, "server": nazwa serwera (opcjonalne) | "tags": tags, "message_without_tags": message without the tags, "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel), "text": text (for example user message), "pos_text": index of text in message ("-1" if no text found) | irc | irc_message_split | dziel wiadomość IRC (aby zmieściła się w 512 bajtach) | "message": wiadomość IRC, "server": nazwa serwera (opcjonalne) | "msg1" ... "msgN": wiadomości do wysłania (bez kończącego "\r\n"), "args1" ... "argsN": argumenty wiadomości, "count": ilość wiadomości diff --git a/doc/pl/weechat_scripting.pl.asciidoc b/doc/pl/weechat_scripting.pl.asciidoc index 2414af300..e98461282 100644 --- a/doc/pl/weechat_scripting.pl.asciidoc +++ b/doc/pl/weechat_scripting.pl.asciidoc @@ -900,16 +900,72 @@ Zniekształcone wiadomości mogą uszkodzić WeeChat, lub spowodować wiele prob _Nowe w wersji 0.3.4._ -Można przetwarzać wiadomości IRC za pomocą info_hashtable zwanej "irc_message_parse". +Można przetwarzać wiadomości IRC za pomocą info_hashtable zwanej +"irc_message_parse". + +// TRANSLATION MISSING +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) - -# wyjście: -# 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]] diff --git a/doc/pl/weechat_user.pl.asciidoc b/doc/pl/weechat_user.pl.asciidoc index 391ff6c92..914db2898 100644 --- a/doc/pl/weechat_user.pl.asciidoc +++ b/doc/pl/weechat_user.pl.asciidoc @@ -3265,6 +3265,10 @@ są dodawane do tablicy hashy: | command | ciąg | Komendy IRC (na przykład: "PRIVMSG", "NOTICE", ...) | channel | ciąg | Kanał IRC | arguments | ciąg | Argumenty komendy (razem z wartością 'channel') +// TRANSLATION MISSING +| text | ciąg | Text (for example user message) +// TRANSLATION MISSING +| pos_text | ciąg | The index of text in message ("-1" if text was not found) |=== // TRANSLATION MISSING @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7562,7 +7562,9 @@ msgstr "" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"nick\": přezdívka, \"host\": host, \"command\": příkaz, \"channel\": " "kanál, \"arguments\": argumenty (včetně kanálu)" @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-06-26 23:27+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <>\n" @@ -8764,10 +8764,13 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"message\": IRC Nachricht, \"server\": Servername (optional)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"tags\": Tags, \"message_without_tags\": Nachrichten ohne Tags, \"nick\": " "Nick, \"host\": Host, \"command\": Befehl, \"channel\": Channel, \"arguments" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7856,10 +7856,13 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"message\": mensaje IRC, \"server\": nombre del servidor (opcional)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"tags\": etiquetas, \"message_without_tags\": mensaje sin etiquetas, \"nick" "\": apodo, \"host\": host, \"command\": comando, \"channel\": canal, " @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" -"PO-Revision-Date: 2015-06-27 08:06+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" +"PO-Revision-Date: 2015-06-27 16:50+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -8544,11 +8544,15 @@ msgstr "\"message\" : message IRC, \"server\" : nom du serveur (optionnel)" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"tags\" : étiquettes, \"message_without_tags\" : message sans les " "étiquettes, \"nick\" : pseudo, \"host\" : nom d'hôte, \"command\" : " -"commande, \"channel\" : canal, \"arguments\" : paramètres (inclut le canal)" +"commande, \"channel\" : canal, \"arguments\" : paramètres (inclut le canal), " +"\"text\" : texte (par exemple message utilisateur), \"pos_text\" : index du " +"texte dans le message (\"-1\" si aucun texte n'a été trouvé)" msgid "split an IRC message (to fit in 512 bytes)" msgstr "découper un message IRC (pour tenir dans les 512 octets)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7000,7 +7000,9 @@ msgstr "" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" msgid "split an IRC message (to fit in 512 bytes)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8019,10 +8019,13 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"message\": messaggio IRC, \"server\": nome server (opzionale)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"tags\": tag, \"message_without_tags\": messaggio senza tag, \"nick\": " "nick, \"host\": nome host, \"command\": comando, \"channel\": canale, " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-06-21 22:54+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/translation_ja>\n" @@ -8183,10 +8183,13 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"message\": IRC メッセージ、\"server\": サーバ名 (任意)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"tags\": タグ、\"message_without_tags\": タグを含まないメッセージ、\"nick" "\": ニックネーム、\"host\": ホスト名、\"command\": コマンド、\"channel\": " @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-05-09 14:00+0100\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8367,10 +8367,13 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"message\": wiadomość IRC, \"server\": nazwa serwera (opcjonalne)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"tags\": tagi, \"message_without_tags\": wiadomość bez tagów, \"nick\": " "nick, \"host\": host, \"command\": komenda, \"channel\": kanał, \"arguments" diff --git a/po/pt_BR.po b/po/pt_BR.po index d756d4739..d8e5dbfee 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Eduardo Elias <camponez@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7396,7 +7396,9 @@ msgstr "\"mensagem\": mensagem IRC, \"servidor\": nome do servidor (opcional)" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" "\"nick\": apelido, \"host\": host, \"command\": comando, \"channel\": canal, " "\"arguments\": argumentos (inclui canal)" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7029,7 +7029,9 @@ msgstr "" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" msgid "split an IRC message (to fit in 512 bytes)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2015-03-10 21:33+0100\n" "Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6279,7 +6279,9 @@ msgstr "" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" msgid "split an IRC message (to fit in 512 bytes)" diff --git a/po/weechat.pot b/po/weechat.pot index 9fbca0153..e916c34e7 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-27 08:02+0200\n" +"POT-Creation-Date: 2015-06-27 16:44+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6210,7 +6210,9 @@ msgstr "" msgid "" "\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" "\": nick, \"host\": host, \"command\": command, \"channel\": channel, " -"\"arguments\": arguments (includes channel)" +"\"arguments\": arguments (includes channel), \"text\": text (for example " +"user message), \"pos_text\": index of text in message (\"-1\" if no text " +"found)" msgstr "" msgid "split an IRC message (to fit in 512 bytes)" diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index 469bc6e25..b235e1f50 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -846,7 +846,9 @@ irc_info_init () /* TRANSLATORS: please do not translate key names (enclosed by quotes) */ N_("\"tags\": tags, \"message_without_tags\": message without the " "tags, \"nick\": nick, \"host\": host, \"command\": command, " - "\"channel\": channel, \"arguments\": arguments (includes channel)"), + "\"channel\": channel, \"arguments\": arguments (includes channel), " + "\"text\": text (for example user message), \"pos_text\": index of " + "text in message (\"-1\" if no text found)"), &irc_info_info_hashtable_irc_message_parse_cb, NULL); weechat_hook_info_hashtable ( "irc_message_split", diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index ccf456cb1..01ffcc17f 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -30,21 +30,37 @@ /* - * Parses an IRC message and returns pointers to: - * - tags - * - message without tags - * - host - * - command - * - channel - * - target nick - * - arguments (if any) + * Parses an IRC message and returns: + * - tags (string) + * - message without tags (string) + * - nick (string) + * - host (string) + * - command (string) + * - channel (string) + * - arguments (string) + * - text (string) + * - pos_text (integer: text index in message) + * + * Example: + * @time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello! + * + * Result: + * tags: "time=2015-06-27T16:40:35.000Z" + * msg_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 */ void irc_message_parse (struct t_irc_server *server, const char *message, char **tags, char **message_without_tags, char **nick, char **host, char **command, char **channel, - char **arguments) + char **arguments, char **text, int *pos_text) { const char *ptr_message, *pos, *pos2, *pos3, *pos4; @@ -62,6 +78,10 @@ irc_message_parse (struct t_irc_server *server, const char *message, *channel = NULL; if (arguments) *arguments = NULL; + if (text) + *text = NULL; + if (pos_text) + *pos_text = -1; if (!message) return; @@ -71,7 +91,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, /* * we will use this message as example: * - * @tags :FlashCode!n=flash@host.com PRIVMSG #channel :hello! + * @time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello! */ if (ptr_message[0] == '@') @@ -85,7 +105,10 @@ irc_message_parse (struct t_irc_server *server, const char *message, if (pos) { if (tags) - *tags = weechat_strndup (message + 1, pos - (message + 1)); + { + *tags = weechat_strndup (ptr_message + 1, + pos - (ptr_message + 1)); + } ptr_message = pos + 1; while (ptr_message[0] == ' ') { @@ -97,7 +120,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, if (message_without_tags) *message_without_tags = strdup (ptr_message); - /* now we have: ptr_message --> ":FlashCode!n=flash@host.com PRIVMSG #channel :hello!" */ + /* now we have: ptr_message --> ":nick!user@host PRIVMSG #weechat :hello!" */ if (ptr_message[0] == ':') { /* read host/nick */ @@ -135,7 +158,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, } } - /* now we have: ptr_message --> "PRIVMSG #channel :hello!" */ + /* now we have: ptr_message --> "PRIVMSG #weechat :hello!" */ if (ptr_message[0]) { pos = strchr (ptr_message, ' '); @@ -148,7 +171,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, { pos++; } - /* now we have: pos --> "#channel :hello!" */ + /* now we have: pos --> "#weechat :hello!" */ if (arguments) *arguments = strdup (pos); if ((pos[0] == ':') @@ -157,7 +180,14 @@ irc_message_parse (struct t_irc_server *server, const char *message, { pos++; } - if (pos[0] != ':') + if (pos[0] == ':') + { + if (text) + *text = strdup (pos + 1); + if (pos_text) + *pos_text = pos - message + 1; + } + else { if (irc_channel_is_channel (server, pos)) { @@ -169,6 +199,19 @@ irc_message_parse (struct t_irc_server *server, const char *message, else *channel = strdup (pos); } + if (pos2) + { + while (pos2[0] == ' ') + { + pos2++; + } + if (pos2[0] == ':') + pos2++; + if (text) + *text = strdup (pos2); + if (pos_text) + *pos_text = pos2 - message; + } } else { @@ -198,6 +241,19 @@ irc_message_parse (struct t_irc_server *server, const char *message, else *channel = strdup (pos2); } + if (pos4) + { + while (pos4[0] == ' ') + { + pos4++; + } + if (pos4[0] == ':') + pos4++; + if (text) + *text = strdup (pos4); + if (pos_text) + *pos_text = pos4 - message; + } } else if (channel && !*channel) { @@ -224,6 +280,8 @@ irc_message_parse (struct t_irc_server *server, const char *message, * - command * - channel * - arguments + * - text + * - pos_text * * Note: hashtable must be freed after use. */ @@ -233,12 +291,14 @@ irc_message_parse_to_hashtable (struct t_irc_server *server, const char *message) { char *tags,*message_without_tags, *nick, *host, *command, *channel; - char *arguments; + char *arguments, *text, str_pos_text[32]; char empty_str[1] = { '\0' }; + int pos_text; struct t_hashtable *hashtable; irc_message_parse (server, message, &tags, &message_without_tags, &nick, - &host, &command, &channel, &arguments); + &host, &command, &channel, &arguments, &text, + &pos_text); hashtable = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, @@ -262,6 +322,10 @@ irc_message_parse_to_hashtable (struct t_irc_server *server, (channel) ? channel : empty_str); weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str); + weechat_hashtable_set (hashtable, "text", + (text) ? text : empty_str); + snprintf (str_pos_text, sizeof (str_pos_text), "%d", pos_text); + weechat_hashtable_set (hashtable, "pos_text", str_pos_text); if (tags) free (tags); @@ -277,11 +341,48 @@ irc_message_parse_to_hashtable (struct t_irc_server *server, free (channel); if (arguments) free (arguments); + if (text) + free (text); return hashtable; } /* + * Encodes/decodes an IRC message using a charset. + */ + +char * +irc_message_convert_charset (const char *message, int pos_start, + const char *modifier, const char *modifier_data) +{ + char *text, *msg_result; + int length; + + text = weechat_hook_modifier_exec (modifier, modifier_data, + message + pos_start); + if (!text) + return NULL; + + length = pos_start + strlen (text) + 1; + msg_result = malloc (length); + if (msg_result) + { + msg_result[0] = '\0'; + if (pos_start > 0) + { + memcpy (msg_result, message, pos_start); + msg_result[pos_start] = '\0'; + } + strcat (msg_result, text); + } + + free (text); + + return msg_result; +} + + +/* * Gets nick from host in an IRC message. */ diff --git a/src/plugins/irc/irc-message.h b/src/plugins/irc/irc-message.h index 1e7b2cde7..bb3051d57 100644 --- a/src/plugins/irc/irc-message.h +++ b/src/plugins/irc/irc-message.h @@ -26,9 +26,14 @@ struct t_irc_channel; extern void irc_message_parse (struct t_irc_server *server, const char *message, char **tags, char **message_without_tags, char **nick, char **host, char **command, - char **channel, char **arguments); + char **channel, char **arguments, char **text, + int *pos_text); extern struct t_hashtable *irc_message_parse_to_hashtable (struct t_irc_server *server, const char *message); +extern char *irc_message_convert_charset (const char *message, + int pos_start, + const char *modifier, + const char *modifier_data); extern const char *irc_message_get_nick_from_host (const char *host); extern const char *irc_message_get_address_from_host (const char *host); extern char *irc_message_replace_vars (struct t_irc_server *server, diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c index c1a0575f0..653df5a11 100644 --- a/src/plugins/irc/irc-notify.c +++ b/src/plugins/irc/irc-notify.c @@ -835,7 +835,7 @@ irc_notify_hsignal_cb (void *data, const char *signal, for (i = 0; i < num_messages; i++) { irc_message_parse (ptr_server, messages[i], NULL, NULL, NULL, - NULL, NULL, NULL, &arguments); + NULL, NULL, NULL, &arguments, NULL, NULL); if (arguments) { pos = strchr (arguments, ' '); @@ -917,7 +917,8 @@ irc_notify_hsignal_cb (void *data, const char *signal, for (i = 0; i < num_messages; i++) { irc_message_parse (ptr_server, messages[0], NULL, NULL, - NULL, NULL, &irc_cmd, NULL, &arguments); + NULL, NULL, &irc_cmd, NULL, &arguments, + NULL, NULL); if (irc_cmd && arguments) { if (strcmp (irc_cmd, "401") == 0) diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 346680c23..e40f86f40 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -2051,7 +2051,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, const char *ptr_msg, *ptr_chan_nick; char *new_msg, *pos, *tags_to_send, *msg_encoded; char str_modifier[128], modifier_data[256]; - int rc, queue_msg, add_to_queue, first_message, anti_flood; + int rc, queue_msg, add_to_queue, first_message, anti_flood, pos_text; time_t time_now; struct t_irc_redirect *ptr_redirect; @@ -2079,25 +2079,30 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags, ptr_msg = (new_msg) ? new_msg : message; msg_encoded = NULL; - ptr_chan_nick = (channel) ? channel : nick; - if (ptr_chan_nick) + irc_message_parse (server, ptr_msg, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, &pos_text); + if (pos_text >= 0) { - snprintf (modifier_data, sizeof (modifier_data), - "%s.%s.%s", - weechat_plugin->name, - server->name, - ptr_chan_nick); - } - else - { - snprintf (modifier_data, sizeof (modifier_data), - "%s.%s", - weechat_plugin->name, - server->name); + ptr_chan_nick = (channel) ? channel : nick; + if (ptr_chan_nick) + { + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + server->name, + ptr_chan_nick); + } + else + { + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s", + weechat_plugin->name, + server->name); + } + msg_encoded = irc_message_convert_charset (ptr_msg, pos_text, + "charset_encode", + modifier_data); } - msg_encoded = weechat_hook_modifier_exec ("charset_encode", - modifier_data, - ptr_msg); if (msg_encoded) ptr_msg = msg_encoded; @@ -2270,7 +2275,7 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags, { /* run modifier "irc_out1_xxx" (like "irc_out_xxx", but before split) */ irc_message_parse (server, items[i], NULL, NULL, - &nick, NULL, &command, &channel, NULL); + &nick, NULL, &command, &channel, NULL, NULL, NULL); snprintf (str_modifier, sizeof (str_modifier), "irc_out1_%s", (command) ? command : "unknown"); @@ -2507,6 +2512,7 @@ irc_server_msgq_flush () char *tags, *nick, *host, *command, *channel, *arguments; char *msg_decoded, *msg_decoded_without_color; char str_modifier[128], modifier_data[256]; + int pos_text; while (irc_recv_msgq) { @@ -2528,7 +2534,7 @@ irc_server_msgq_flush () irc_message_parse (irc_recv_msgq->server, ptr_data, NULL, NULL, NULL, NULL, - &command, NULL, NULL); + &command, NULL, NULL, NULL, NULL); snprintf (str_modifier, sizeof (str_modifier), "irc_in_%s", (command) ? command : "unknown"); @@ -2568,41 +2574,47 @@ irc_server_msgq_flush () irc_message_parse (irc_recv_msgq->server, ptr_msg, &tags, NULL, &nick, &host, - &command, &channel, &arguments); + &command, &channel, &arguments, + NULL, &pos_text); - /* convert charset for message */ - if (channel - && irc_channel_is_channel (irc_recv_msgq->server, - channel)) + msg_decoded = NULL; + if (pos_text >= 0) { - snprintf (modifier_data, sizeof (modifier_data), - "%s.%s.%s", - weechat_plugin->name, - irc_recv_msgq->server->name, - channel); - } - else - { - if (nick && (!host || (strcmp (nick, host) != 0))) + /* convert charset for message */ + if (channel + && irc_channel_is_channel (irc_recv_msgq->server, + channel)) { - snprintf (modifier_data, - sizeof (modifier_data), + snprintf (modifier_data, sizeof (modifier_data), "%s.%s.%s", weechat_plugin->name, irc_recv_msgq->server->name, - nick); + channel); } else { - snprintf (modifier_data, - sizeof (modifier_data), - "%s.%s", - weechat_plugin->name, - irc_recv_msgq->server->name); + if (nick && (!host || (strcmp (nick, host) != 0))) + { + snprintf (modifier_data, + sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + irc_recv_msgq->server->name, + nick); + } + else + { + snprintf (modifier_data, + sizeof (modifier_data), + "%s.%s", + weechat_plugin->name, + irc_recv_msgq->server->name); + } } + msg_decoded = irc_message_convert_charset ( + ptr_msg, pos_text, + "charset_decode", modifier_data); } - msg_decoded = weechat_hook_modifier_exec ( - "charset_decode", modifier_data, ptr_msg); /* replace WeeChat internal color codes by "?" */ msg_decoded_without_color = |