diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-11-23 21:31:22 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-11-23 21:31:22 +0100 |
commit | 53b8cdfef328017b08bc575854d5f6a5ad6ef1d3 (patch) | |
tree | 674e9f63a467b127e0ee6b284925a653afc0f791 | |
parent | 777f977ea516bbf367c01deb7db4120ec70d5839 (diff) | |
download | weechat-53b8cdfef328017b08bc575854d5f6a5ad6ef1d3.zip |
irc: add support of tags in messages, add support of "server-time" capability (task #12255)
For a server called "znc" in WeeChat, following command will enable the
"server-time" capability:
/set irc.server.znc.capabilities "znc.in/server-time"
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/de/autogen/plugin_api/infos_hashtable.txt | 2 | ||||
-rw-r--r-- | doc/en/autogen/plugin_api/infos_hashtable.txt | 2 | ||||
-rw-r--r-- | doc/fr/autogen/plugin_api/infos_hashtable.txt | 2 | ||||
-rw-r--r-- | doc/it/autogen/plugin_api/infos_hashtable.txt | 2 | ||||
-rw-r--r-- | doc/ja/autogen/plugin_api/infos_hashtable.txt | 2 | ||||
-rw-r--r-- | po/cs.po | 6 | ||||
-rw-r--r-- | po/de.po | 6 | ||||
-rw-r--r-- | po/es.po | 6 | ||||
-rw-r--r-- | po/fr.po | 8 | ||||
-rw-r--r-- | po/hu.po | 5 | ||||
-rw-r--r-- | po/it.po | 6 | ||||
-rw-r--r-- | po/ja.po | 6 | ||||
-rw-r--r-- | po/pl.po | 6 | ||||
-rw-r--r-- | po/pt_BR.po | 6 | ||||
-rw-r--r-- | po/ru.po | 5 | ||||
-rw-r--r-- | po/weechat.pot | 5 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 254 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.h | 10 | ||||
-rw-r--r-- | src/plugins/irc/irc-info.c | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-message.c | 248 | ||||
-rw-r--r-- | src/plugins/irc/irc-message.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-notify.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 2923 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.h | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 35 |
26 files changed, 1952 insertions, 1618 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.4.0-dev, 2012-11-22 +v0.4.0-dev, 2012-11-23 Version 0.4.0 (under dev!) @@ -32,6 +32,8 @@ Version 0.4.0 (under dev!) aspell.check.suggestions (task #12061) * aspell: fix creation of spellers when number of dictionaries is different between two buffers +* irc: add support of "server-time" capability (task #12255) +* irc: add support of tags in messages * irc: fix crash on /upgrade (free channels before server data when a server is destroyed) (bug #37736) * irc: fix crash when decoding IRC colors in strings (bug #37704) diff --git a/doc/de/autogen/plugin_api/infos_hashtable.txt b/doc/de/autogen/plugin_api/infos_hashtable.txt index 8ac84cc79..b670e88b4 100644 --- a/doc/de/autogen/plugin_api/infos_hashtable.txt +++ b/doc/de/autogen/plugin_api/infos_hashtable.txt @@ -2,7 +2,7 @@ |======================================== | Erweiterung | Name | Beschreibung | Hashtable (Eingabe) | Hashtable (Ausgabe) -| irc | irc_message_parse | Parse eine IRC Nachricht | "message": IRC Nachricht, "server": Servername (optional) | "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (beinhaltet Channel) +| 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) | 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/en/autogen/plugin_api/infos_hashtable.txt b/doc/en/autogen/plugin_api/infos_hashtable.txt index 82de00793..e870dfa67 100644 --- a/doc/en/autogen/plugin_api/infos_hashtable.txt +++ b/doc/en/autogen/plugin_api/infos_hashtable.txt @@ -2,7 +2,7 @@ |======================================== | Plugin | Name | Description | Hashtable (input) | Hashtable (output) -| irc | irc_message_parse | parse an IRC message | "message": IRC message, "server": server name (optional) | "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) | 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/fr/autogen/plugin_api/infos_hashtable.txt b/doc/fr/autogen/plugin_api/infos_hashtable.txt index 102721b19..0f3d1061d 100644 --- a/doc/fr/autogen/plugin_api/infos_hashtable.txt +++ b/doc/fr/autogen/plugin_api/infos_hashtable.txt @@ -2,7 +2,7 @@ |======================================== | Extension | Nom | Description | Hashtable (entrée) | Hashtable (sortie) -| irc | irc_message_parse | analyse un message IRC | "message": message IRC, "server": nom du serveur (optionnel) | "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) | 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/it/autogen/plugin_api/infos_hashtable.txt b/doc/it/autogen/plugin_api/infos_hashtable.txt index c45c65b46..dada8a738 100644 --- a/doc/it/autogen/plugin_api/infos_hashtable.txt +++ b/doc/it/autogen/plugin_api/infos_hashtable.txt @@ -2,7 +2,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) | "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) | 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/ja/autogen/plugin_api/infos_hashtable.txt b/doc/ja/autogen/plugin_api/infos_hashtable.txt index 2adea3751..c6c593860 100644 --- a/doc/ja/autogen/plugin_api/infos_hashtable.txt +++ b/doc/ja/autogen/plugin_api/infos_hashtable.txt @@ -2,7 +2,7 @@ |======================================== | プラグイン | 名前 | 説明 | ハッシュテーブル (入力) | ハッシュテーブル (出力) -| irc | irc_message_parse | IRC メッセージを解析 | "message": IRC メッセージ、"server": サーバ名 (オプション) | "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) | irc | irc_message_split | IRC メッセージを分割 (512バイトに収める) | "message": IRC メッセージ、"server": サーバ名 (オプション) | "msg1" ... "msgN": 送信メッセージ (最後の "\r\n" は無し), "args1" ... "argsN": メッセージの引数、"count": メッセージの数 @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:42+0200\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6280,8 +6280,10 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": přezdívka, \"host\": host, \"command\": příkaz, \"channel\": " @@ -23,7 +23,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-05 13:19+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-11-04 15:41+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <weechatter@arcor.de>\n" @@ -6927,8 +6927,10 @@ 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 "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:42+0200\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6539,8 +6539,10 @@ 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 "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": apodo, \"host\": host, \"command\": comando, \"channel\": canal, " @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" -"PO-Revision-Date: 2012-11-04 10:55+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" +"PO-Revision-Date: 2012-11-23 20:20+0100\n" "Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: French\n" @@ -6722,9 +6722,11 @@ msgstr "\"message\": message IRC, \"server\": nom du serveur (optionnel)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" 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)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:42+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5840,7 +5840,8 @@ msgstr "" #. TRANSLATORS: please do not translate key names (enclosed by quotes) msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:42+0200\n" "Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6540,8 +6540,10 @@ 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 "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": nick, \"host\": nome host, \"command\": comando, \"channel\": " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:42+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/WeeChat>\n" @@ -6390,8 +6390,10 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"message\": IRC メッセージ、\"server\": サーバ名 (オプション)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": ニックネーム、\"host\": ホスト名、\"command\": コマンド、\"channel" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:42+0200\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6505,8 +6505,10 @@ 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 "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": nick, \"host\": host, \"komenda\": komenda, \"kanał\": kanał, " diff --git a/po/pt_BR.po b/po/pt_BR.po index 24f8427f1..92f1f06d7 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:43+0200\n" "Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5992,8 +5992,10 @@ msgid "\"message\": IRC message, \"server\": server name (optional)" msgstr "\"mensagem\": mensagem IRC, \"servidor\": nome do servidor (opcional)" #. TRANSLATORS: please do not translate key names (enclosed by quotes) +#, fuzzy msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" "\"nick\": apelido, \"host\": host, \"command\": comando, \"channel\": canal, " @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: 2012-09-29 11:43+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5864,7 +5864,8 @@ msgstr "" #. TRANSLATORS: please do not translate key names (enclosed by quotes) msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index b0b03561e..a469b470c 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-11-04 11:49+0100\n" +"POT-Creation-Date: 2012-11-23 20:19+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -5068,7 +5068,8 @@ msgstr "" #. TRANSLATORS: please do not translate key names (enclosed by quotes) msgid "" -"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, " +"\"tags\": tags, \"message_without_tags\": message without the tags, \"nick" +"\": nick, \"host\": host, \"command\": command, \"channel\": channel, " "\"arguments\": arguments (includes channel)" msgstr "" diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 860177eed..7d90351b1 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -111,6 +111,7 @@ irc_ctcp_get_reply (struct t_irc_server *server, const char *ctcp) void irc_ctcp_display_request (struct t_irc_server *server, + time_t date, const char *command, struct t_irc_channel *channel, const char *nick, const char *ctcp, @@ -122,21 +123,22 @@ irc_ctcp_display_request (struct t_irc_server *server, && !weechat_config_boolean (irc_config_look_display_ctcp_blocked)) return; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick, - NULL, "ctcp", - (channel) ? channel->buffer : NULL), - irc_protocol_tags (command, "irc_ctcp", NULL), - _("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_message (server, NULL, nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - ctcp, - IRC_COLOR_RESET, - (arguments) ? " " : "", - (arguments) ? arguments : "", - (reply && !reply[0]) ? _(" (blocked)") : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, nick, + NULL, "ctcp", + (channel) ? channel->buffer : NULL), + date, + irc_protocol_tags (command, "irc_ctcp", NULL), + _("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + ctcp, + IRC_COLOR_RESET, + (arguments) ? " " : "", + (arguments) ? arguments : "", + (reply && !reply[0]) ? _(" (blocked)") : ""); } /* @@ -144,7 +146,7 @@ irc_ctcp_display_request (struct t_irc_server *server, */ void -irc_ctcp_display_reply_from_nick (struct t_irc_server *server, +irc_ctcp_display_reply_from_nick (struct t_irc_server *server, time_t date, const char *command, const char *nick, char *arguments) { @@ -182,74 +184,77 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server, difftime = ((sec2 * 1000000) + usec2) - ((sec1 * 1000000) + usec1); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, - nick, + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, + nick, + NULL, + "ctcp", + NULL), + date, + irc_protocol_tags (command, + "irc_ctcp", + NULL), + _("%sCTCP reply from %s%s%s: %s%s%s " + "%ld.%ld %s"), + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, - "ctcp", - NULL), - irc_protocol_tags (command, - "irc_ctcp", - NULL), - _("%sCTCP reply from %s%s%s: %s%s%s " - "%ld.%ld %s"), - weechat_prefix ("network"), - irc_nick_color_for_message (server, - NULL, - nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - arguments + 1, - IRC_COLOR_RESET, - difftime / 1000000, - (difftime % 1000000) / 1000, - (NG_("second", "seconds", - (difftime / 1000000)))); + nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + arguments + 1, + IRC_COLOR_RESET, + difftime / 1000000, + (difftime % 1000000) / 1000, + (NG_("second", "seconds", + (difftime / 1000000)))); pos_usec[0] = ' '; } } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, - nick, - NULL, - "ctcp", - NULL), - irc_protocol_tags (command, - "irc_ctcp", - NULL), - _("%sCTCP reply from %s%s%s: %s%s%s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_message (server, NULL, - nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - arguments + 1, - IRC_COLOR_RESET, - " ", - pos_args); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, + nick, + NULL, + "ctcp", + NULL), + date, + irc_protocol_tags (command, + "irc_ctcp", + NULL), + _("%sCTCP reply from %s%s%s: %s%s%s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, + nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + arguments + 1, + IRC_COLOR_RESET, + " ", + pos_args); } pos_space[0] = ' '; } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick, - NULL, "ctcp", - NULL), - irc_protocol_tags (command, NULL, NULL), - _("%sCTCP reply from %s%s%s: %s%s%s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_message (server, NULL, - nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - arguments + 1, - "", - "", - ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, nick, + NULL, "ctcp", + NULL), + date, + irc_protocol_tags (command, NULL, NULL), + _("%sCTCP reply from %s%s%s: %s%s%s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, + nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + arguments + 1, + "", + "", + ""); } if (pos_end) @@ -895,7 +900,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick, */ void -irc_ctcp_recv (struct t_irc_server *server, const char *command, +irc_ctcp_recv (struct t_irc_server *server, time_t date, const char *command, struct t_irc_channel *channel, const char *address, const char *nick, const char *remote_nick, char *arguments, char *message) @@ -940,20 +945,21 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command, irc_channel_nick_speaking_time_remove_old (channel); irc_channel_nick_speaking_time_add (server, channel, nick, time (NULL)); - weechat_printf_tags (channel->buffer, - irc_protocol_tags (command, - (nick_is_me) ? - "irc_action,notify_none,no_highlight" : - "irc_action,notify_message", - nick), - "%s%s%s%s%s%s%s", - weechat_prefix ("action"), - irc_nick_mode_for_display (server, ptr_nick, 0), - (ptr_nick) ? ptr_nick->color : ((nick) ? irc_nick_find_color (nick) : IRC_COLOR_CHAT_NICK), - nick, - (pos_args) ? IRC_COLOR_RESET : "", - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (channel->buffer, + date, + irc_protocol_tags (command, + (nick_is_me) ? + "irc_action,notify_none,no_highlight" : + "irc_action,notify_message", + nick), + "%s%s%s%s%s%s%s", + weechat_prefix ("action"), + irc_nick_mode_for_display (server, ptr_nick, 0), + (ptr_nick) ? ptr_nick->color : ((nick) ? irc_nick_find_color (nick) : IRC_COLOR_CHAT_NICK), + nick, + (pos_args) ? IRC_COLOR_RESET : "", + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); } else { @@ -977,20 +983,21 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command, if (!ptr_channel->topic) irc_channel_set_topic (ptr_channel, address); - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, - (nick_is_me) ? - "irc_action,notify_none,no_highlight" : - "irc_action,notify_private", - nick), - "%s%s%s%s%s%s", - weechat_prefix ("action"), - (nick_is_me) ? - IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick), - nick, - (pos_args) ? IRC_COLOR_RESET : "", - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, + (nick_is_me) ? + "irc_action,notify_none,no_highlight" : + "irc_action,notify_private", + nick), + "%s%s%s%s%s%s", + weechat_prefix ("action"), + (nick_is_me) ? + IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick), + nick, + (pos_args) ? IRC_COLOR_RESET : "", + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); weechat_hook_signal_send ("irc_pv", WEECHAT_HOOK_SIGNAL_STRING, message); @@ -1001,7 +1008,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command, else if (strcmp (arguments + 1, "PING") == 0) { reply = irc_ctcp_get_reply (server, arguments + 1); - irc_ctcp_display_request (server, command, channel, nick, + irc_ctcp_display_request (server, date, command, channel, nick, arguments + 1, pos_args, reply); if (!reply || reply[0]) { @@ -1020,7 +1027,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command, reply = irc_ctcp_get_reply (server, arguments + 1); if (reply) { - irc_ctcp_display_request (server, command, channel, nick, + irc_ctcp_display_request (server, date, command, channel, nick, arguments + 1, pos_args, reply); if (reply[0]) @@ -1038,27 +1045,28 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command, { if (weechat_config_boolean (irc_config_look_display_ctcp_unknown)) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, - nick, + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, + nick, + NULL, + "ctcp", + (channel) ? channel->buffer : NULL), + date, + irc_protocol_tags (command, + "irc_ctcp", + NULL), + _("%sUnknown CTCP requested by %s%s%s: " + "%s%s%s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, - "ctcp", - (channel) ? channel->buffer : NULL), - irc_protocol_tags (command, - "irc_ctcp", - NULL), - _("%sUnknown CTCP requested by %s%s%s: " - "%s%s%s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_message (server, - NULL, - nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - arguments + 1, - (pos_args) ? IRC_COLOR_RESET : "", - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + arguments + 1, + (pos_args) ? IRC_COLOR_RESET : "", + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); } } } diff --git a/src/plugins/irc/irc-ctcp.h b/src/plugins/irc/irc-ctcp.h index 393d47bf3..66fbb735e 100644 --- a/src/plugins/irc/irc-ctcp.h +++ b/src/plugins/irc/irc-ctcp.h @@ -31,12 +31,14 @@ struct t_irc_ctcp_reply extern const char *irc_ctcp_get_default_reply (const char *ctcp); extern void irc_ctcp_display_reply_from_nick (struct t_irc_server *server, + time_t date, const char *command, const char *nick, char *arguments); -extern void irc_ctcp_recv (struct t_irc_server *server, const char *command, - struct t_irc_channel *channel, const char *address, - const char *nick, const char *remote_nick, - char *arguments, char *message); +extern void irc_ctcp_recv (struct t_irc_server *server, time_t date, + const char *command, struct t_irc_channel *channel, + const char *address, const char *nick, + const char *remote_nick, char *arguments, + char *message); #endif /* __WEECHAT_IRC_CTCP_H */ diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index 1e86d229f..d6ac145cb 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -622,9 +622,11 @@ irc_info_init () N_("\"message\": IRC message, " "\"server\": server name (optional)"), /* TRANSLATORS: please do not translate key names (enclosed by quotes) */ - N_("\"nick\": nick, \"host\": host, " - "\"command\": command, \"channel\": channel, " - "\"arguments\": arguments (includes channel)"), + N_("\"tags\": tags, \"message_without_tags\": " + "message without the tags, \"nick\": nick, " + "\"host\": host, \"command\": command, " + "\"channel\": channel, \"arguments\": " + "arguments (includes channel)"), &irc_info_get_info_hashtable_cb, NULL); weechat_hook_info_hashtable ("irc_message_split", N_("split an IRC message (to fit in 512 bytes)"), diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index cfdca3c3f..fc59d8e24 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -32,17 +32,23 @@ /* - * irc_message_parse: parse IRC message and return pointer to host, command, - * channel, target nick and arguments (if any) + * irc_message_parse: parse IRC message and return pointer to tags, message + * without tags, host, command, channel, target nick and + * arguments (if any) */ void irc_message_parse (struct t_irc_server *server, const char *message, - char **nick, char **host, char **command, char **channel, + char **tags, char **message_without_tags, char **nick, + char **host, char **command, char **channel, char **arguments) { - const char *pos, *pos2, *pos3, *pos4, *pos5; + const char *ptr_message, *pos, *pos2, *pos3, *pos4; + if (tags) + *tags = NULL; + if (message_without_tags) + *message_without_tags = NULL; if (nick) *nick = NULL; if (host) @@ -57,101 +63,126 @@ irc_message_parse (struct t_irc_server *server, const char *message, if (!message) return; + ptr_message = message; + /* * we will use this message as example: - * :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello! + * + * @tags :FlashCode!n=flash@host.com PRIVMSG #channel :hello! */ - if (message[0] == ':') + + if (ptr_message[0] == '@') { - pos2 = strchr (message, '!'); - pos = strchr (message, ' '); + /* + * read tags (they are optional and enabled only if client enabled + * a server capability, see: + * http://ircv3.atheme.org/specification/message-tags-3.2) + */ + pos = strchr (ptr_message, ' '); + if (pos) + { + if (tags) + *tags = weechat_strndup (message + 1, pos - (message + 1)); + ptr_message = pos + 1; + while (ptr_message[0] == ' ') + { + ptr_message++; + } + } + } + + if (message_without_tags) + *message_without_tags = strdup (ptr_message); + + /* now we have: ptr_message --> ":FlashCode!n=flash@host.com PRIVMSG #channel :hello!" */ + if (ptr_message[0] == ':') + { + /* read host/nick */ + pos2 = strchr (ptr_message, '!'); + pos = strchr (ptr_message, ' '); if (pos2 && (!pos || pos > pos2)) { if (nick) - *nick = weechat_strndup (message + 1, pos2 - (message + 1)); + *nick = weechat_strndup (ptr_message + 1, pos2 - (ptr_message + 1)); } else if (pos) { if (nick) - *nick = weechat_strndup (message + 1, pos - (message + 1)); + *nick = weechat_strndup (ptr_message + 1, pos - (ptr_message + 1)); } if (pos) { if (host) - *host = weechat_strndup (message + 1, pos - (message + 1)); - pos++; + *host = weechat_strndup (ptr_message + 1, pos - (ptr_message + 1)); + ptr_message = pos + 1; + while (ptr_message[0] == ' ') + { + ptr_message++; + } } - else - pos = message; } - else - pos = message; - /* pos is pointer on PRIVMSG #channel :hello! */ - if (pos && pos[0]) + /* now we have: ptr_message --> "PRIVMSG #channel :hello!" */ + if (ptr_message[0]) { - while (pos[0] == ' ') - { - pos++; - } - pos2 = strchr (pos, ' '); - if (pos2) + pos = strchr (ptr_message, ' '); + if (pos) { - /* pos2 is pointer on #channel :hello! */ if (command) - *command = weechat_strndup (pos, pos2 - pos); - pos2++; - while (pos2[0] == ' ') + *command = weechat_strndup (ptr_message, pos - ptr_message); + pos++; + while (pos[0] == ' ') { - pos2++; + pos++; } + /* now we have: pos --> "#channel :hello!" */ if (arguments) - *arguments = strdup (pos2); - if (pos2[0] != ':') + *arguments = strdup (pos); + if (pos[0] != ':') { - if (irc_channel_is_channel (server, pos2)) + if (irc_channel_is_channel (server, pos)) { - pos3 = strchr (pos2, ' '); + pos2 = strchr (pos, ' '); if (channel) { - if (pos3) - *channel = weechat_strndup (pos2, pos3 - pos2); + if (pos2) + *channel = weechat_strndup (pos, pos2 - pos); else - *channel = strdup (pos2); + *channel = strdup (pos); } } else { - pos3 = strchr (pos2, ' '); + pos2 = strchr (pos, ' '); if (nick && !*nick) { - if (pos3) - *nick = weechat_strndup (pos2, pos3 - pos2); + if (pos2) + *nick = weechat_strndup (pos, pos2 - pos); else - *nick = strdup (pos2); + *nick = strdup (pos); } - if (pos3) + if (pos2) { - pos4 = pos3; - pos3++; - while (pos3[0] == ' ') + pos3 = pos2; + pos2++; + while (pos2[0] == ' ') { - pos3++; + pos2++; } - if (irc_channel_is_channel (server, pos3)) + if (irc_channel_is_channel (server, pos2)) { - pos5 = strchr (pos3, ' '); + pos4 = strchr (pos2, ' '); if (channel) { - if (pos5) - *channel = weechat_strndup (pos3, pos5 - pos3); + if (pos4) + *channel = weechat_strndup (pos2, pos4 - pos2); else - *channel = strdup (pos3); + *channel = strdup (pos2); } } else if (channel && !*channel) { - *channel = weechat_strndup (pos2, pos4 - pos2); + *channel = weechat_strndup (pos, pos3 - pos); } } } @@ -160,7 +191,7 @@ irc_message_parse (struct t_irc_server *server, const char *message, else { if (command) - *command = strdup (pos); + *command = strdup (ptr_message); } } } @@ -176,12 +207,13 @@ struct t_hashtable * irc_message_parse_to_hashtable (struct t_irc_server *server, const char *message) { - char *nick, *host, *command, *channel, *arguments; + char *tags,*message_without_tags, *nick, *host, *command, *channel; + char *arguments; char empty_str[1] = { '\0' }; struct t_hashtable *hashtable; - irc_message_parse (server, message, &nick, &host, &command, &channel, - &arguments); + irc_message_parse (server, message, &tags, &message_without_tags, &nick, + &host, &command, &channel, &arguments); hashtable = weechat_hashtable_new (8, WEECHAT_HASHTABLE_STRING, @@ -191,12 +223,18 @@ irc_message_parse_to_hashtable (struct t_irc_server *server, if (!hashtable) return NULL; + weechat_hashtable_set (hashtable, "tags", (tags) ? tags : empty_str); + weechat_hashtable_set (hashtable, "message_without_tags", (message_without_tags) ? message_without_tags : empty_str); weechat_hashtable_set (hashtable, "nick", (nick) ? nick : empty_str); weechat_hashtable_set (hashtable, "host", (host) ? host : empty_str); weechat_hashtable_set (hashtable, "command", (command) ? command : empty_str); weechat_hashtable_set (hashtable, "channel", (channel) ? channel : empty_str); weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str); + if (tags) + free (tags); + if (message_without_tags) + free (message_without_tags); if (nick) free (nick); if (host) @@ -348,20 +386,30 @@ irc_message_replace_vars (struct t_irc_server *server, void irc_message_split_add (struct t_hashtable *hashtable, int number, - const char *message, const char *arguments) + const char *tags, const char *message, + const char *arguments) { - char key[32], value[32]; + char key[32], value[32], *buf; + int length; if (message) { - snprintf (key, sizeof (key), "msg%d", number); - weechat_hashtable_set (hashtable, key, message); - if (weechat_irc_plugin->debug >= 2) + length = ((tags) ? strlen (tags) : 0) + strlen (message) + 1; + buf = malloc (length); + if (buf) { - weechat_printf (NULL, - "irc_message_split_add >> %s='%s' (%d bytes)", - key, message, - strlen (message)); + snprintf (key, sizeof (key), "msg%d", number); + snprintf (buf, length, "%s%s", + (tags) ? tags : "", + message); + weechat_hashtable_set (hashtable, key, buf); + if (weechat_irc_plugin->debug >= 2) + { + weechat_printf (NULL, + "irc_message_split_add >> %s='%s' (%d bytes)", + key, buf, length - 1); + } + free (buf); } } if (arguments) @@ -389,6 +437,7 @@ irc_message_split_add (struct t_hashtable *hashtable, int number, int irc_message_split_string (struct t_hashtable *hashtable, + const char *tags, const char *host, const char *command, const char *target, @@ -444,10 +493,10 @@ irc_message_split_string (struct t_hashtable *hashtable, if (weechat_irc_plugin->debug >= 2) { weechat_printf (NULL, - "irc_message_split_string: host='%s', command='%s', " - "target='%s', prefix='%s', arguments='%s', " - "suffix='%s', max_length=%d", - host, command, target, prefix, arguments, suffix, + "irc_message_split_string: tags='%s', host='%s', " + "command='%s', target='%s', prefix='%s', " + "arguments='%s', suffix='%s', max_length=%d", + tags, host, command, target, prefix, arguments, suffix, max_length); } @@ -463,7 +512,7 @@ irc_message_split_string (struct t_hashtable *hashtable, (target && target[0]) ? " " : "", (prefix) ? prefix : "", (suffix) ? suffix : ""); - irc_message_split_add (hashtable, 1, message, ""); + irc_message_split_add (hashtable, 1, tags, message, ""); return 1; } @@ -495,7 +544,8 @@ irc_message_split_string (struct t_hashtable *hashtable, (prefix) ? prefix : "", dup_arguments, (suffix) ? suffix : ""); - irc_message_split_add (hashtable, number, message, dup_arguments); + irc_message_split_add (hashtable, number, tags, message, + dup_arguments); number++; free (dup_arguments); } @@ -513,7 +563,8 @@ irc_message_split_string (struct t_hashtable *hashtable, int irc_message_split_join (struct t_hashtable *hashtable, - const char *host, const char *arguments) + const char *tags, const char *host, + const char *arguments) { int number, channels_count, keys_count, length, length_no_channel; int length_to_add, index_channel; @@ -582,6 +633,7 @@ irc_message_split_join (struct t_hashtable *hashtable, { strcat (msg_to_send, keys_to_add); irc_message_split_add (hashtable, number, + tags, msg_to_send, msg_to_send + length_no_channel + 1); number++; @@ -597,6 +649,7 @@ irc_message_split_join (struct t_hashtable *hashtable, { strcat (msg_to_send, keys_to_add); irc_message_split_add (hashtable, number, + tags, msg_to_send, msg_to_send + length_no_channel + 1); } @@ -618,8 +671,9 @@ irc_message_split_join (struct t_hashtable *hashtable, int irc_message_split_privmsg_notice (struct t_hashtable *hashtable, - char *host, char *command, char *target, - char *arguments, int max_length_host) + char *tags, char *host, char *command, + char *target, char *arguments, + int max_length_host) { char prefix[512], suffix[2], *pos, saved_char; int length, rc; @@ -656,7 +710,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable, if (!prefix[0]) strcpy (prefix, ":"); - rc = irc_message_split_string (hashtable, host, command, target, + rc = irc_message_split_string (hashtable, tags, host, command, target, prefix, arguments, suffix, ' ', max_length_host); @@ -670,7 +724,8 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable, int irc_message_split_005 (struct t_hashtable *hashtable, - char *host, char *command, char *target, char *arguments) + char *tags, char *host, char *command, char *target, + char *arguments) { char *pos, suffix[512]; @@ -691,14 +746,16 @@ irc_message_split_005 (struct t_hashtable *hashtable, pos[0] = '\0'; } - return irc_message_split_string (hashtable, host, command, target, + return irc_message_split_string (hashtable, tags, host, command, target, NULL, arguments, suffix, ' ', -1); } /* * irc_message_split: split an IRC message about to be sent to IRC server * The maximum length of an IRC message is 510 bytes for - * user data + final "\r\n", so full size is 512 bytes. + * user data + final "\r\n", so full size is 512 bytes + * (the user data does not include the optional tags before + * the host). * The split takes care about type of message to do a split * at best place in message. * The hashtable returned contains keys "msg1", "msg2", ..., @@ -714,10 +771,12 @@ struct t_hashtable * irc_message_split (struct t_irc_server *server, const char *message) { struct t_hashtable *hashtable; - char **argv, **argv_eol, *host, *command, *arguments, target[512]; + char **argv, **argv_eol, *tags, *host, *command, *arguments, target[512]; + char *pos; int split_ok, argc, index_args, max_length_nick, max_length_host; split_ok = 0; + tags = NULL; host = NULL; command = NULL; arguments = NULL; @@ -740,6 +799,16 @@ irc_message_split (struct t_irc_server *server, const char *message) if (!message || !message[0]) goto end; + if (message[0] == '@') + { + pos = strchr (message, ' '); + if (pos) + { + tags = weechat_strndup (message, pos - message + 1); + message = pos + 1; + } + } + argv = weechat_string_split (message, " ", 0, 0, &argc); argv_eol = weechat_string_split (message, " ", 2, 0, NULL); @@ -773,7 +842,7 @@ irc_message_split (struct t_irc_server *server, const char *message) if ((weechat_strcasecmp (command, "ison") == 0) || (weechat_strcasecmp (command, "wallops") == 0)) { - split_ok = irc_message_split_string (hashtable, host, command, + split_ok = irc_message_split_string (hashtable, tags, host, command, NULL, ":", (argv_eol[index_args][0] == ':') ? argv_eol[index_args] + 1 : argv_eol[index_args], @@ -783,7 +852,10 @@ irc_message_split (struct t_irc_server *server, const char *message) { /* split join (if it's more than 510 bytes) */ if (strlen (message) > 510) - split_ok = irc_message_split_join (hashtable, host, arguments); + { + split_ok = irc_message_split_join (hashtable, tags, host, + arguments); + } } else if ((weechat_strcasecmp (command, "privmsg") == 0) || (weechat_strcasecmp (command, "notice") == 0)) @@ -791,7 +863,7 @@ irc_message_split (struct t_irc_server *server, const char *message) /* split privmsg/notice */ if (index_args + 1 <= argc - 1) { - split_ok = irc_message_split_privmsg_notice (hashtable, host, + split_ok = irc_message_split_privmsg_notice (hashtable, tags, host, command, argv[index_args], (argv_eol[index_args + 1][0] == ':') ? @@ -804,7 +876,7 @@ irc_message_split (struct t_irc_server *server, const char *message) /* split 005 (isupport) */ if (index_args + 1 <= argc - 1) { - split_ok = irc_message_split_005 (hashtable, host, command, + split_ok = irc_message_split_005 (hashtable, tags, host, command, argv[index_args], (argv_eol[index_args + 1][0] == ':') ? argv_eol[index_args + 1] + 1 : argv_eol[index_args + 1]); @@ -822,8 +894,8 @@ irc_message_split (struct t_irc_server *server, const char *message) { snprintf (target, sizeof (target), "%s %s", argv[index_args], argv[index_args + 1]); - split_ok = irc_message_split_string (hashtable, host, command, - target, ":", + split_ok = irc_message_split_string (hashtable, tags, host, + command, target, ":", (argv_eol[index_args + 2][0] == ':') ? argv_eol[index_args + 2] + 1 : argv_eol[index_args + 2], NULL, ' ', -1); @@ -835,8 +907,8 @@ irc_message_split (struct t_irc_server *server, const char *message) snprintf (target, sizeof (target), "%s %s %s", argv[index_args], argv[index_args + 1], argv[index_args + 2]); - split_ok = irc_message_split_string (hashtable, host, command, - target, ":", + split_ok = irc_message_split_string (hashtable, tags, host, + command, target, ":", (argv_eol[index_args + 3][0] == ':') ? argv_eol[index_args + 3] + 1 : argv_eol[index_args + 3], NULL, ' ', -1); @@ -846,10 +918,12 @@ irc_message_split (struct t_irc_server *server, const char *message) } end: + if (tags) + free (tags); if (!split_ok || (weechat_hashtable_get_integer (hashtable, "items_count") == 0)) { - irc_message_split_add (hashtable, 1, message, arguments); + irc_message_split_add (hashtable, 1, tags, message, arguments); } if (argv) diff --git a/src/plugins/irc/irc-message.h b/src/plugins/irc/irc-message.h index 656f5c932..af43a6190 100644 --- a/src/plugins/irc/irc-message.h +++ b/src/plugins/irc/irc-message.h @@ -24,6 +24,7 @@ struct t_irc_server; 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); extern struct t_hashtable *irc_message_parse_to_hashtable (struct t_irc_server *server, diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c index 546e707b4..12547461d 100644 --- a/src/plugins/irc/irc-notify.c +++ b/src/plugins/irc/irc-notify.c @@ -700,7 +700,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, &arguments); + NULL, NULL, NULL, &arguments); if (arguments) { pos = strchr (arguments, ' '); @@ -780,7 +780,7 @@ 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, - &irc_cmd, NULL, &arguments); + NULL, NULL, &irc_cmd, NULL, &arguments); if (irc_cmd && arguments) { if (strcmp (irc_cmd, "401") == 0) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 81c9d0fab..859986e5d 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -220,11 +220,12 @@ IRC_PROTOCOL_CALLBACK(cap) if (argc > 4) { ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; - weechat_printf (server->buffer, - _("%s%s: client capability, server supports: %s"), - weechat_prefix ("network"), - IRC_PLUGIN_NAME, - ptr_caps); + weechat_printf_date_tags (server->buffer, date, NULL, + _("%s%s: client capability, server " + "supports: %s"), + weechat_prefix ("network"), + IRC_PLUGIN_NAME, + ptr_caps); /* auto-enable capabilities only when connecting to server */ if (!server->is_connected) @@ -306,10 +307,10 @@ IRC_PROTOCOL_CALLBACK(cap) if (argc > 4) { ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; - weechat_printf (server->buffer, - _("%s%s: client capability, enabled: %s"), - weechat_prefix ("network"), IRC_PLUGIN_NAME, - ptr_caps); + weechat_printf_date_tags (server->buffer, date, NULL, + _("%s%s: client capability, enabled: %s"), + weechat_prefix ("network"), IRC_PLUGIN_NAME, + ptr_caps); sasl_to_do = 0; caps_supported = weechat_string_split (ptr_caps, " ", 0, 0, &num_caps_supported); @@ -360,10 +361,10 @@ IRC_PROTOCOL_CALLBACK(cap) if (argc > 4) { ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; - weechat_printf (server->buffer, - _("%s%s: client capability, refused: %s"), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - ptr_caps); + weechat_printf_date_tags (server->buffer, date, NULL, + _("%s%s: client capability, refused: %s"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + ptr_caps); if (!server->is_connected) irc_server_sendf (server, 0, NULL, "CAP END"); } @@ -389,13 +390,14 @@ IRC_PROTOCOL_CALLBACK(error) ptr_args = (argv_eol[1][0] == ':') ? argv_eol[1] + 1 : argv_eol[1]; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, NULL, NULL), - "%s%s", - weechat_prefix ("error"), - ptr_args); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, NULL, NULL), + "%s%s", + weechat_prefix ("error"), + ptr_args); if (strncmp (ptr_args, "Closing Link", 12) == 0) { @@ -445,20 +447,21 @@ IRC_PROTOCOL_CALLBACK(generic_error) ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, NULL, NULL), - "%s%s%s%s%s%s", - weechat_prefix ("network"), - (ptr_channel && chan_nick - && (irc_server_strcasecmp (server, chan_nick, - ptr_channel->name) == 0)) ? - IRC_COLOR_CHAT_CHANNEL : "", - (chan_nick) ? chan_nick : "", - IRC_COLOR_RESET, - (chan_nick) ? ": " : "", - args); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, NULL, NULL), + "%s%s%s%s%s%s", + weechat_prefix ("network"), + (ptr_channel && chan_nick + && (irc_server_strcasecmp (server, chan_nick, + ptr_channel->name) == 0)) ? + IRC_COLOR_CHAT_CHANNEL : "", + (chan_nick) ? chan_nick : "", + IRC_COLOR_RESET, + (chan_nick) ? ": " : "", + args); return WEECHAT_RC_OK; } @@ -479,19 +482,20 @@ IRC_PROTOCOL_CALLBACK(invite) if (!ignored) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick, - command, NULL, - NULL), - irc_protocol_tags (command, "notify_highlight", NULL), - _("%sYou have been invited to %s%s%s by " - "%s%s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - (argv[3][0] == ':') ? argv[3] + 1 : argv[3], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, nick), - nick, - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, nick, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "notify_highlight", NULL), + _("%sYou have been invited to %s%s%s by " + "%s%s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + (argv[3][0] == ':') ? argv[3] + 1 : argv[3], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, nick), + nick, + IRC_COLOR_RESET); } return WEECHAT_RC_OK; } @@ -581,30 +585,31 @@ IRC_PROTOCOL_CALLBACK(join) display_host = (local_join) ? weechat_config_boolean (irc_config_look_display_host_join_local) : weechat_config_boolean (irc_config_look_display_host_join); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, - (local_join - || !weechat_config_boolean (irc_config_look_smart_filter) - || !weechat_config_boolean (irc_config_look_smart_filter_join) - || ptr_nick_speaking) ? - NULL : "irc_smart_filter", - nick), - _("%s%s%s%s%s%s%s%s%s%s has joined %s%s%s"), - weechat_prefix ("join"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (display_host) ? address : "", - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? ")" : "", - IRC_COLOR_MESSAGE_JOIN, - IRC_COLOR_CHAT_CHANNEL, - pos_channel, - IRC_COLOR_MESSAGE_JOIN); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, + (local_join + || !weechat_config_boolean (irc_config_look_smart_filter) + || !weechat_config_boolean (irc_config_look_smart_filter_join) + || ptr_nick_speaking) ? + NULL : "irc_smart_filter", + nick), + _("%s%s%s%s%s%s%s%s%s%s has joined %s%s%s"), + weechat_prefix ("join"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (display_host) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? ")" : "", + IRC_COLOR_MESSAGE_JOIN, + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_MESSAGE_JOIN); /* display message in private if private has flag "has_quit_server" */ if (!local_join) @@ -644,37 +649,39 @@ IRC_PROTOCOL_CALLBACK(kick) if (pos_comment) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%s%s%s has kicked %s%s%s %s(%s%s%s)"), - weechat_prefix ("quit"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (server, ptr_nick_kicked, argv[3]), - argv[3], - IRC_COLOR_MESSAGE_QUIT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%s%s%s has kicked %s%s%s %s(%s%s%s)"), + weechat_prefix ("quit"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_MESSAGE_QUIT, + irc_nick_color_for_server_message (server, ptr_nick_kicked, argv[3]), + argv[3], + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%s%s%s has kicked %s%s%s"), - weechat_prefix ("quit"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (server, ptr_nick_kicked, argv[3]), - argv[3], - IRC_COLOR_MESSAGE_QUIT); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%s%s%s has kicked %s%s%s"), + weechat_prefix ("quit"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_MESSAGE_QUIT, + irc_nick_color_for_server_message (server, ptr_nick_kicked, argv[3]), + argv[3], + IRC_COLOR_MESSAGE_QUIT); } if (irc_server_strcasecmp (server, argv[3], server->nick) == 0) @@ -744,33 +751,35 @@ IRC_PROTOCOL_CALLBACK(kill) if (pos_comment) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%sYou were killed by %s%s%s %s(%s%s%s)"), - weechat_prefix ("quit"), - IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_MESSAGE_QUIT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%sYou were killed by %s%s%s %s(%s%s%s)"), + weechat_prefix ("quit"), + IRC_COLOR_MESSAGE_QUIT, + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%sYou were killed by %s%s%s"), - weechat_prefix ("quit"), - IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_MESSAGE_QUIT); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%sYou were killed by %s%s%s"), + weechat_prefix ("quit"), + IRC_COLOR_MESSAGE_QUIT, + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_MESSAGE_QUIT); } if (irc_server_strcasecmp (server, argv[2], server->nick) == 0) @@ -823,37 +832,39 @@ IRC_PROTOCOL_CALLBACK(mode) irc_mode_channel_set (server, ptr_channel, pos_modes); ptr_nick = irc_nick_search (server, ptr_channel, nick); ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, NULL, NULL), - _("%sMode %s%s %s[%s%s%s]%s by %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - (ptr_channel) ? ptr_channel->name : argv[2], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_modes, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%sMode %s%s %s[%s%s%s]%s by %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + (ptr_channel) ? ptr_channel->name : argv[2], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_modes, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, NULL, NULL), - _("%sUser mode %s[%s%s%s]%s by %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_modes, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, nick), - nick); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, NULL, NULL), + _("%sUser mode %s[%s%s%s]%s by %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_modes, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, nick), + nick); irc_mode_user_set (server, pos_modes, 0); } @@ -933,14 +944,15 @@ IRC_PROTOCOL_CALLBACK(nick) irc_nick_change (server, ptr_channel, ptr_nick, new_nick); if (local_nick) { - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, NULL, NULL), - _("%sYou are now known as " - "%s%s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK_SELF, - new_nick, - IRC_COLOR_RESET); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, NULL, NULL), + _("%sYou are now known as " + "%s%s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK_SELF, + new_nick, + IRC_COLOR_RESET); } else { @@ -950,23 +962,24 @@ IRC_PROTOCOL_CALLBACK(nick) ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter)) && (weechat_config_boolean (irc_config_look_smart_filter_nick))) ? irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL; - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, - (!weechat_config_boolean (irc_config_look_smart_filter) - || !weechat_config_boolean (irc_config_look_smart_filter_nick) - || ptr_nick_speaking) ? - NULL : "irc_smart_filter", - NULL), - _("%s%s%s%s is now known as " - "%s%s%s"), - weechat_prefix ("network"), - weechat_config_boolean(irc_config_look_color_nicks_in_server_messages) ? - old_color : IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_RESET, - irc_nick_color_for_message (server, ptr_nick, new_nick), - new_nick, - IRC_COLOR_RESET); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, + (!weechat_config_boolean (irc_config_look_smart_filter) + || !weechat_config_boolean (irc_config_look_smart_filter_nick) + || ptr_nick_speaking) ? + NULL : "irc_smart_filter", + NULL), + _("%s%s%s%s is now known as " + "%s%s%s"), + weechat_prefix ("network"), + weechat_config_boolean(irc_config_look_color_nicks_in_server_messages) ? + old_color : IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_RESET, + irc_nick_color_for_message (server, ptr_nick, new_nick), + new_nick, + IRC_COLOR_RESET); } irc_channel_nick_speaking_rename (ptr_channel, nick, new_nick); @@ -1048,7 +1061,7 @@ IRC_PROTOCOL_CALLBACK(notice) if (nick && (pos_args[0] == '\01') && (pos_args[strlen (pos_args) - 1] == '\01')) { - irc_ctcp_display_reply_from_nick (server, command, nick, pos_args); + irc_ctcp_display_reply_from_nick (server, date, command, nick, pos_args); } else { @@ -1057,22 +1070,23 @@ IRC_PROTOCOL_CALLBACK(notice) /* notice for channel */ ptr_channel = irc_channel_search (server, pos_target); ptr_nick = irc_nick_search (server, ptr_channel, nick); - weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer, - irc_protocol_tags (command, - "notify_message", - nick), - "%s%s%s%s%s(%s%s%s)%s: %s", - weechat_prefix ("network"), - IRC_COLOR_NOTICE, - /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ - _("Notice"), - (notice_op) ? "Op" : ((notice_voice) ? "Voice" : ""), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_message (server, ptr_nick, nick), - (nick && nick[0]) ? nick : "?", - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_args); + weechat_printf_date_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer, + date, + irc_protocol_tags (command, + "notify_message", + nick), + "%s%s%s%s%s(%s%s%s)%s: %s", + weechat_prefix ("network"), + IRC_COLOR_NOTICE, + /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ + _("Notice"), + (notice_op) ? "Op" : ((notice_voice) ? "Voice" : ""), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_message (server, ptr_nick, nick), + (nick && nick[0]) ? nick : "?", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_args); } else { @@ -1112,17 +1126,18 @@ IRC_PROTOCOL_CALLBACK(notice) if (!ptr_channel->topic) irc_channel_set_topic (ptr_channel, address); - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, - "notify_private", - nick), - "%s%s%s%s: %s", - weechat_prefix ("network"), - irc_nick_color_for_message (server, NULL, - nick), - nick, - IRC_COLOR_RESET, - pos_args); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, + "notify_private", + nick), + "%s%s%s%s: %s", + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, + nick), + nick, + IRC_COLOR_RESET, + pos_args); if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) && ptr_channel->has_quit_server) { @@ -1140,70 +1155,74 @@ IRC_PROTOCOL_CALLBACK(notice) */ if (nick && (irc_server_strcasecmp (server, server->nick, nick) == 0)) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, - (notify_private) ? "notify_private" : NULL, - server->nick), - "%s%s%s%s -> %s%s%s: %s", - weechat_prefix ("network"), - IRC_COLOR_NOTICE, - /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ - _("Notice"), - IRC_COLOR_RESET, - irc_nick_color_for_message (server, - NULL, - pos_target), - pos_target, - IRC_COLOR_RESET, - pos_args); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, + (notify_private) ? "notify_private" : NULL, + server->nick), + "%s%s%s%s -> %s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_NOTICE, + /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ + _("Notice"), + IRC_COLOR_RESET, + irc_nick_color_for_message (server, + NULL, + pos_target), + pos_target, + IRC_COLOR_RESET, + pos_args); } else { if (address && address[0]) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, - (notify_private) ? "notify_private" : NULL, - nick), - "%s%s%s %s(%s%s%s)%s: %s", - weechat_prefix ("network"), - irc_nick_color_for_message (server, - NULL, - nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - address, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_args); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, + (notify_private) ? "notify_private" : NULL, + nick), + "%s%s%s %s(%s%s%s)%s: %s", + weechat_prefix ("network"), + irc_nick_color_for_message (server, + NULL, + nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + address, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_args); } else { if (nick && nick[0]) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, - (notify_private) ? "notify_private" : NULL, - nick), - "%s%s%s%s: %s", - weechat_prefix ("network"), - irc_nick_color_for_message (server, - NULL, - nick), - nick, - IRC_COLOR_RESET, - pos_args); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, + (notify_private) ? "notify_private" : NULL, + nick), + "%s%s%s%s: %s", + weechat_prefix ("network"), + irc_nick_color_for_message (server, + NULL, + nick), + nick, + IRC_COLOR_RESET, + pos_args); } else { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, - (notify_private) ? "notify_private" : NULL, - NULL), - "%s%s", - weechat_prefix ("network"), - pos_args); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, + (notify_private) ? "notify_private" : NULL, + NULL), + "%s%s", + weechat_prefix ("network"), + pos_args); } } } @@ -1262,65 +1281,67 @@ IRC_PROTOCOL_CALLBACK(part) display_host = weechat_config_boolean (irc_config_look_display_host_quit); if (pos_comment) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, - (local_part - || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) - || !weechat_config_boolean (irc_config_look_smart_filter) - || !weechat_config_boolean (irc_config_look_smart_filter_quit) - || ptr_nick_speaking) ? - NULL : "irc_smart_filter", - nick), - _("%s%s%s%s%s%s%s%s%s%s has left %s%s%s " - "%s(%s%s%s)"), - weechat_prefix ("quit"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (display_host) ? address : "", - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? ")" : "", - IRC_COLOR_MESSAGE_QUIT, - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_MESSAGE_QUIT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_REASON_QUIT, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, + (local_part + || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) + || !weechat_config_boolean (irc_config_look_smart_filter) + || !weechat_config_boolean (irc_config_look_smart_filter_quit) + || ptr_nick_speaking) ? + NULL : "irc_smart_filter", + nick), + _("%s%s%s%s%s%s%s%s%s%s has left %s%s%s " + "%s(%s%s%s)"), + weechat_prefix ("quit"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (display_host) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? ")" : "", + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_REASON_QUIT, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, - (local_part - || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) - || !weechat_config_boolean (irc_config_look_smart_filter) - || !weechat_config_boolean (irc_config_look_smart_filter_quit) - || ptr_nick_speaking) ? - NULL : "irc_smart_filter", - nick), - _("%s%s%s%s%s%s%s%s%s%s has left " - "%s%s%s"), - weechat_prefix ("quit"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (display_host) ? address : "", - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? ")" : "", - IRC_COLOR_MESSAGE_QUIT, - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_MESSAGE_QUIT); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, + (local_part + || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) + || !weechat_config_boolean (irc_config_look_smart_filter) + || !weechat_config_boolean (irc_config_look_smart_filter_quit) + || ptr_nick_speaking) ? + NULL : "irc_smart_filter", + nick), + _("%s%s%s%s%s%s%s%s%s%s has left " + "%s%s%s"), + weechat_prefix ("quit"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (display_host) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? ")" : "", + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_MESSAGE_QUIT); } } @@ -1482,7 +1503,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) if ((pos_args[0] == '\01') && (pos_args[strlen (pos_args) - 1] == '\01')) { - irc_ctcp_recv (server, command, ptr_channel, + irc_ctcp_recv (server, date, command, ptr_channel, address, nick, NULL, pos_args, argv_eol[0]); return WEECHAT_RC_OK; @@ -1497,20 +1518,21 @@ IRC_PROTOCOL_CALLBACK(privmsg) if (msg_op || msg_voice) { /* message to channel ops/voiced (to "@#channel" or "+#channel") */ - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, - "notify_message", - nick), - "%s%s%s%s(%s%s%s)%s: %s", - weechat_prefix ("network"), - "Msg", - (msg_op) ? "Op" : ((msg_voice) ? "Voice" : ""), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_message (server, ptr_nick, nick), - (nick && nick[0]) ? nick : "?", - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_args); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, + "notify_message", + nick), + "%s%s%s%s(%s%s%s)%s: %s", + weechat_prefix ("network"), + "Msg", + (msg_op) ? "Op" : ((msg_voice) ? "Voice" : ""), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_message (server, ptr_nick, nick), + (nick && nick[0]) ? nick : "?", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_args); } else { @@ -1521,13 +1543,14 @@ IRC_PROTOCOL_CALLBACK(privmsg) (str_color) ? str_color : "default"); if (str_color) free (str_color); - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, str_tags, nick), - "%s%s", - irc_nick_as_prefix (server, ptr_nick, - (ptr_nick) ? NULL : nick, - NULL), - pos_args); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, str_tags, nick), + "%s%s", + irc_nick_as_prefix (server, ptr_nick, + (ptr_nick) ? NULL : nick, + NULL), + pos_args); } irc_channel_nick_speaking_add (ptr_channel, @@ -1549,7 +1572,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) if ((pos_args[0] == '\01') && (pos_args[strlen (pos_args) - 1] == '\01')) { - irc_ctcp_recv (server, command, NULL, + irc_ctcp_recv (server, date, command, NULL, address, nick, remote_nick, pos_args, argv_eol[0]); return WEECHAT_RC_OK; @@ -1591,13 +1614,14 @@ IRC_PROTOCOL_CALLBACK(privmsg) (str_color) ? str_color : "default"); if (str_color) free (str_color); - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, str_tags, nick), - "%s%s", - irc_nick_as_prefix (server, NULL, nick, - (nick_is_me) ? - IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick)), - pos_args); + weechat_printf_date_tags (ptr_channel->buffer, + date, + irc_protocol_tags (command, str_tags, nick), + "%s%s", + irc_nick_as_prefix (server, NULL, nick, + (nick_is_me) ? + IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick)), + pos_args); if (ptr_channel->has_quit_server) ptr_channel->has_quit_server = 0; @@ -1662,60 +1686,62 @@ IRC_PROTOCOL_CALLBACK(quit) display_host = weechat_config_boolean (irc_config_look_display_host_quit); if (pos_comment && pos_comment[0]) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, - (local_quit - || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) - || !weechat_config_boolean (irc_config_look_smart_filter) - || !weechat_config_boolean (irc_config_look_smart_filter_quit) - || ptr_nick_speaking) ? - NULL : "irc_smart_filter", - nick), - _("%s%s%s%s%s%s%s%s%s%s has quit " - "%s(%s%s%s)"), - weechat_prefix ("quit"), - (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ? - irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (display_host) ? address : "", - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? ")" : "", - IRC_COLOR_MESSAGE_QUIT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_REASON_QUIT, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, + (local_quit + || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) + || !weechat_config_boolean (irc_config_look_smart_filter) + || !weechat_config_boolean (irc_config_look_smart_filter_quit) + || ptr_nick_speaking) ? + NULL : "irc_smart_filter", + nick), + _("%s%s%s%s%s%s%s%s%s%s has quit " + "%s(%s%s%s)"), + weechat_prefix ("quit"), + (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ? + irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (display_host) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? ")" : "", + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_REASON_QUIT, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, - (local_quit - || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) - || !weechat_config_boolean (irc_config_look_smart_filter) - || !weechat_config_boolean (irc_config_look_smart_filter_quit) - || ptr_nick_speaking) ? - NULL : "irc_smart_filter", - nick), - _("%s%s%s%s%s%s%s%s%s%s has quit"), - weechat_prefix ("quit"), - (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ? - irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (display_host) ? address : "", - IRC_COLOR_CHAT_DELIMITERS, - (display_host) ? ")" : "", - IRC_COLOR_MESSAGE_QUIT); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, + (local_quit + || (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL) + || !weechat_config_boolean (irc_config_look_smart_filter) + || !weechat_config_boolean (irc_config_look_smart_filter_quit) + || ptr_nick_speaking) ? + NULL : "irc_smart_filter", + nick), + _("%s%s%s%s%s%s%s%s%s%s has quit"), + weechat_prefix ("quit"), + (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ? + irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (display_host) ? address : "", + IRC_COLOR_CHAT_DELIMITERS, + (display_host) ? ")" : "", + IRC_COLOR_MESSAGE_QUIT); } } if (ptr_nick) @@ -1749,14 +1775,15 @@ IRC_PROTOCOL_CALLBACK(server_mode_reason) pos_args = (argc > 3) ? ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; } - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s: %s", - weechat_prefix ("network"), - pos_mode, - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s: %s", + weechat_prefix ("network"), + pos_mode, + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -1781,13 +1808,14 @@ IRC_PROTOCOL_CALLBACK(numeric) pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]; } - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s", - weechat_prefix ("network"), - pos_args); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s", + weechat_prefix ("network"), + pos_args); return WEECHAT_RC_OK; } @@ -1834,46 +1862,48 @@ IRC_PROTOCOL_CALLBACK(topic) { old_topic_color = irc_color_decode (ptr_channel->topic, weechat_config_boolean (irc_config_network_colors_receive)); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%s%s%s has changed topic for %s%s%s " - "from \"%s%s%s\" to \"%s%s%s\""), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - argv[2], - IRC_COLOR_RESET, - IRC_COLOR_TOPIC_OLD, - (old_topic_color) ? old_topic_color : ptr_channel->topic, - IRC_COLOR_RESET, - IRC_COLOR_TOPIC_NEW, - (topic_color) ? topic_color : pos_topic, - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%s%s%s has changed topic for %s%s%s " + "from \"%s%s%s\" to \"%s%s%s\""), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + argv[2], + IRC_COLOR_RESET, + IRC_COLOR_TOPIC_OLD, + (old_topic_color) ? old_topic_color : ptr_channel->topic, + IRC_COLOR_RESET, + IRC_COLOR_TOPIC_NEW, + (topic_color) ? topic_color : pos_topic, + IRC_COLOR_RESET); if (old_topic_color) free (old_topic_color); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%s%s%s has changed topic for %s%s%s " - "to \"%s%s%s\""), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - argv[2], - IRC_COLOR_RESET, - IRC_COLOR_TOPIC_NEW, - (topic_color) ? topic_color : pos_topic, - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%s%s%s has changed topic for %s%s%s " + "to \"%s%s%s\""), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + argv[2], + IRC_COLOR_RESET, + IRC_COLOR_TOPIC_NEW, + (topic_color) ? topic_color : pos_topic, + IRC_COLOR_RESET); } if (topic_color) free (topic_color); @@ -1885,39 +1915,41 @@ IRC_PROTOCOL_CALLBACK(topic) { old_topic_color = irc_color_decode (ptr_channel->topic, weechat_config_boolean (irc_config_network_colors_receive)); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%s%s%s has unset topic for %s%s%s " - "(old topic: \"%s%s%s\")"), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - argv[2], - IRC_COLOR_RESET, - IRC_COLOR_TOPIC_OLD, - (old_topic_color) ? old_topic_color : ptr_channel->topic, - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%s%s%s has unset topic for %s%s%s " + "(old topic: \"%s%s%s\")"), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + argv[2], + IRC_COLOR_RESET, + IRC_COLOR_TOPIC_OLD, + (old_topic_color) ? old_topic_color : ptr_channel->topic, + IRC_COLOR_RESET); if (old_topic_color) free (old_topic_color); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, NULL, NULL), - _("%s%s%s%s has unset topic for %s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, ptr_nick, nick), - nick, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - argv[2], - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, NULL, NULL), + _("%s%s%s%s has unset topic for %s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, ptr_nick, nick), + nick, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + argv[2], + IRC_COLOR_RESET); } } @@ -1943,20 +1975,21 @@ IRC_PROTOCOL_CALLBACK(wallops) if (ignored) return WEECHAT_RC_OK; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick, - command, NULL, - NULL), - irc_protocol_tags (command, NULL, nick), - _("%sWallops from %s%s %s(%s%s%s)%s: %s"), - weechat_prefix ("network"), - irc_nick_color_for_message (server, NULL, nick), - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - address, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, nick, + command, NULL, + NULL), + date, + irc_protocol_tags (command, NULL, nick), + _("%sWallops from %s%s %s(%s%s%s)%s: %s"), + weechat_prefix ("network"), + irc_nick_color_for_message (server, NULL, nick), + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + address, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]); return WEECHAT_RC_OK; } @@ -1982,7 +2015,7 @@ IRC_PROTOCOL_CALLBACK(001) irc_server_set_nick (server, argv[2]); irc_protocol_cb_numeric (server, - nick, address, host, command, + date, nick, address, host, command, ignored, argc, argv, argv_eol); /* connection to IRC server is ok! */ @@ -2063,7 +2096,7 @@ IRC_PROTOCOL_CALLBACK(005) IRC_PROTOCOL_MIN_ARGS(4); irc_protocol_cb_numeric (server, - nick, address, host, command, + date, nick, address, host, command, ignored, argc, argv, argv_eol); /* save prefix */ @@ -2186,19 +2219,20 @@ IRC_PROTOCOL_CALLBACK(221) IRC_PROTOCOL_MIN_ARGS(4); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[2], - command, NULL, NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sUser mode for %s%s%s is %s[%s%s%s]"), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, NULL, - argv[2]), - argv[2], - IRC_COLOR_RESET, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3], - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[2], + command, NULL, NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sUser mode for %s%s%s is %s[%s%s%s]"), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, NULL, + argv[2]), + argv[2], + IRC_COLOR_RESET, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3], + IRC_COLOR_CHAT_DELIMITERS); if (irc_server_strcasecmp (server, argv[2], server->nick) == 0) { @@ -2241,20 +2275,21 @@ IRC_PROTOCOL_CALLBACK(301) || (strcmp (ptr_channel->away_message, pos_away_msg) != 0)) { ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s]%s is away: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, - NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_away_msg); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s]%s is away: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, + NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_away_msg); if (ptr_channel) { if (ptr_channel->away_message) @@ -2280,13 +2315,14 @@ IRC_PROTOCOL_CALLBACK(303) IRC_PROTOCOL_MIN_ARGS(4); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sUsers online: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sUsers online: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); return WEECHAT_RC_OK; } @@ -2306,13 +2342,14 @@ IRC_PROTOCOL_CALLBACK(305) if (argc > 3) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "unaway", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s", - weechat_prefix ("network"), - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "unaway", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s", + weechat_prefix ("network"), + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); } server->is_away = 0; @@ -2338,13 +2375,14 @@ IRC_PROTOCOL_CALLBACK(306) if (argc > 3) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "away", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s", - weechat_prefix ("network"), - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "away", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s", + weechat_prefix ("network"), + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); } server->is_away = 1; @@ -2368,19 +2406,20 @@ IRC_PROTOCOL_CALLBACK(whois_nick_msg) IRC_PROTOCOL_MIN_ARGS(5); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -2398,19 +2437,20 @@ IRC_PROTOCOL_CALLBACK(whowas_nick_msg) IRC_PROTOCOL_MIN_ARGS(5); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whowas", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whowas", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -2428,23 +2468,24 @@ IRC_PROTOCOL_CALLBACK(311) IRC_PROTOCOL_MIN_ARGS(8); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); return WEECHAT_RC_OK; } @@ -2462,23 +2503,24 @@ IRC_PROTOCOL_CALLBACK(312) IRC_PROTOCOL_MIN_ARGS(6); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s %s(%s%s%s)", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - argv[4], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s %s(%s%s%s)", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + argv[4], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + IRC_COLOR_CHAT_DELIMITERS); return WEECHAT_RC_OK; } @@ -2496,23 +2538,24 @@ IRC_PROTOCOL_CALLBACK(314) IRC_PROTOCOL_MIN_ARGS(8); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whowas", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whowas", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); return WEECHAT_RC_OK; } @@ -2539,18 +2582,19 @@ IRC_PROTOCOL_CALLBACK(315) } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "who", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s]%s %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "who", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s]%s %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); } return WEECHAT_RC_OK; @@ -2586,65 +2630,67 @@ IRC_PROTOCOL_CALLBACK(317) if (day > 0) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s]%s idle: %s%d %s%s, " - "%s%02d %s%s %s%02d %s%s %s%02d " - "%s%s, signon at: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - day, - IRC_COLOR_RESET, - NG_("day", "days", day), - IRC_COLOR_CHAT_CHANNEL, - hour, - IRC_COLOR_RESET, - NG_("hour", "hours", hour), - IRC_COLOR_CHAT_CHANNEL, - min, - IRC_COLOR_RESET, - NG_("minute", "minutes", min), - IRC_COLOR_CHAT_CHANNEL, - sec, - IRC_COLOR_RESET, - NG_("second", "seconds", sec), - IRC_COLOR_CHAT_CHANNEL, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s]%s idle: %s%d %s%s, " + "%s%02d %s%s %s%02d %s%s %s%02d " + "%s%s, signon at: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + day, + IRC_COLOR_RESET, + NG_("day", "days", day), + IRC_COLOR_CHAT_CHANNEL, + hour, + IRC_COLOR_RESET, + NG_("hour", "hours", hour), + IRC_COLOR_CHAT_CHANNEL, + min, + IRC_COLOR_RESET, + NG_("minute", "minutes", min), + IRC_COLOR_CHAT_CHANNEL, + sec, + IRC_COLOR_RESET, + NG_("second", "seconds", sec), + IRC_COLOR_CHAT_CHANNEL, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s]%s idle: %s%02d %s%s " - "%s%02d %s%s %s%02d %s%s, " - "signon at: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - hour, - IRC_COLOR_RESET, - NG_("hour", "hours", hour), - IRC_COLOR_CHAT_CHANNEL, - min, - IRC_COLOR_RESET, - NG_("minute", "minutes", min), - IRC_COLOR_CHAT_CHANNEL, - sec, - IRC_COLOR_RESET, - NG_("second", "seconds", sec), - IRC_COLOR_CHAT_CHANNEL, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s]%s idle: %s%02d %s%s " + "%s%02d %s%s %s%02d %s%s, " + "signon at: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + hour, + IRC_COLOR_RESET, + NG_("hour", "hours", hour), + IRC_COLOR_CHAT_CHANNEL, + min, + IRC_COLOR_RESET, + NG_("minute", "minutes", min), + IRC_COLOR_CHAT_CHANNEL, + sec, + IRC_COLOR_RESET, + NG_("second", "seconds", sec), + IRC_COLOR_CHAT_CHANNEL, + weechat_util_get_time_string (&datetime)); } return WEECHAT_RC_OK; @@ -2668,15 +2714,16 @@ IRC_PROTOCOL_CALLBACK(321) pos_args = (argc > 4) ? ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "list", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s%s%s", - weechat_prefix ("network"), - argv[3], - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "list", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s%s%s", + weechat_prefix ("network"), + argv[3], + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -2702,21 +2749,22 @@ IRC_PROTOCOL_CALLBACK(322) if (!server->cmd_list_regexp || (regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0)) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "list", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s%s%s(%s%s%s)%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - argv[4], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (pos_topic && pos_topic[0]) ? ": " : "", - (pos_topic && pos_topic[0]) ? pos_topic : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "list", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s%s%s(%s%s%s)%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + argv[4], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (pos_topic && pos_topic[0]) ? ": " : "", + (pos_topic && pos_topic[0]) ? pos_topic : ""); } return WEECHAT_RC_OK; @@ -2740,13 +2788,14 @@ IRC_PROTOCOL_CALLBACK(323) pos_args = (argc > 3) ? ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "list", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s", - weechat_prefix ("network"), - (pos_args && pos_args[0]) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "list", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s", + weechat_prefix ("network"), + (pos_args && pos_args[0]) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -2776,19 +2825,20 @@ IRC_PROTOCOL_CALLBACK(324) ptr_channel->modes); } } - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - (ptr_channel) ? ptr_channel->buffer : NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sMode %s%s %s[%s%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argc > 4) ? - ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : "", - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + (ptr_channel) ? ptr_channel->buffer : NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sMode %s%s %s[%s%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argc > 4) ? + ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : "", + IRC_COLOR_CHAT_DELIMITERS); return WEECHAT_RC_OK; } @@ -2817,37 +2867,39 @@ IRC_PROTOCOL_CALLBACK(327) if (pos_realname && pos_realname[0]) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s %s %s(%s%s%s)", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - pos_realname, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s %s %s(%s%s%s)", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + pos_realname, + IRC_COLOR_CHAT_DELIMITERS); } else { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5]); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5]); } return WEECHAT_RC_OK; @@ -2871,17 +2923,18 @@ IRC_PROTOCOL_CALLBACK(328) ptr_channel = irc_channel_search (server, argv[3]); if (ptr_channel) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sURL for %s%s%s: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - (argv_eol[4][0] == ':') ? - argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sURL for %s%s%s: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + (argv_eol[4][0] == ':') ? + argv_eol[4] + 1 : argv_eol[4]); } return WEECHAT_RC_OK; @@ -2910,28 +2963,30 @@ IRC_PROTOCOL_CALLBACK(329) if (ptr_channel) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "created on" is a date */ - _("%sChannel created on %s"), - weechat_prefix ("network"), - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "created on" is a date */ + _("%sChannel created on %s"), + weechat_prefix ("network"), + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "created on" is a date */ - _("%sChannel %s%s%s created on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "created on" is a date */ + _("%sChannel %s%s%s created on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } return WEECHAT_RC_OK; @@ -2960,41 +3015,43 @@ IRC_PROTOCOL_CALLBACK(330_343) if (argc >= 6) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - irc_nick_color_for_server_message (server, NULL, - argv[4]), - argv[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + irc_nick_color_for_server_message (server, NULL, + argv[4]), + argv[4]); } else { ptr_channel = (irc_channel_is_channel (server, argv[3])) ? irc_channel_search (server, argv[3]) : NULL; ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); } return WEECHAT_RC_OK; @@ -3018,14 +3075,15 @@ IRC_PROTOCOL_CALLBACK(331) ptr_channel = irc_channel_search (server, argv[3]); ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, NULL, - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sNo topic set for channel %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sNo topic set for channel %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3]); return WEECHAT_RC_OK; } @@ -3075,17 +3133,18 @@ IRC_PROTOCOL_CALLBACK(332) topic_color = irc_color_decode (pos_topic, (weechat_config_boolean (irc_config_network_colors_receive)) ? 1 : 0); } - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sTopic for %s%s%s is \"%s%s\""), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - (topic_color) ? topic_color : ((pos_topic) ? pos_topic : ""), - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sTopic for %s%s%s is \"%s%s\""), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + (topic_color) ? topic_color : ((pos_topic) ? pos_topic : ""), + IRC_COLOR_RESET); if (topic_color) free (topic_color); @@ -3132,74 +3191,78 @@ IRC_PROTOCOL_CALLBACK(333) { if (topic_nick) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%sTopic set by %s%s%s%s%s%s%s%s%s on %s"), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, ptr_nick, topic_nick), - topic_nick, - IRC_COLOR_CHAT_DELIMITERS, - (topic_address && topic_address[0]) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (topic_address) ? topic_address : "", - IRC_COLOR_CHAT_DELIMITERS, - (topic_address && topic_address[0]) ? ")" : "", - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%sTopic set by %s%s%s%s%s%s%s%s%s on %s"), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, ptr_nick, topic_nick), + topic_nick, + IRC_COLOR_CHAT_DELIMITERS, + (topic_address && topic_address[0]) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (topic_address) ? topic_address : "", + IRC_COLOR_CHAT_DELIMITERS, + (topic_address && topic_address[0]) ? ")" : "", + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - ptr_channel->buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%sTopic set on %s"), - weechat_prefix ("network"), - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + ptr_channel->buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%sTopic set on %s"), + weechat_prefix ("network"), + weechat_util_get_time_string (&datetime)); } } else { if (topic_nick) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%sTopic for %s%s%s set by %s%s%s%s%s%s%s%s%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, ptr_nick, topic_nick), - topic_nick, - IRC_COLOR_CHAT_DELIMITERS, - (topic_address && topic_address[0]) ? " (" : "", - IRC_COLOR_CHAT_HOST, - (topic_address) ? topic_address : "", - IRC_COLOR_CHAT_DELIMITERS, - (topic_address && topic_address[0]) ? ")" : "", - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%sTopic for %s%s%s set by %s%s%s%s%s%s%s%s%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, ptr_nick, topic_nick), + topic_nick, + IRC_COLOR_CHAT_DELIMITERS, + (topic_address && topic_address[0]) ? " (" : "", + IRC_COLOR_CHAT_HOST, + (topic_address) ? topic_address : "", + IRC_COLOR_CHAT_DELIMITERS, + (topic_address && topic_address[0]) ? ")" : "", + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%sTopic for %s%s%s set on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%sTopic for %s%s%s set on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } } @@ -3219,21 +3282,22 @@ IRC_PROTOCOL_CALLBACK(338) IRC_PROTOCOL_MIN_ARGS(6); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s]%s %s %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - IRC_COLOR_CHAT_HOST, - argv[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s]%s %s %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + IRC_COLOR_CHAT_HOST, + argv[4]); return WEECHAT_RC_OK; } @@ -3251,22 +3315,23 @@ IRC_PROTOCOL_CALLBACK(341) IRC_PROTOCOL_MIN_ARGS(5); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[2], - command, NULL, NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s%s%s has invited %s%s%s to %s%s%s"), - weechat_prefix ("network"), - irc_nick_color_for_server_message (server, NULL, - argv[2]), - argv[2], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - argv[3]), - argv[3], - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - argv[4], - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[2], + command, NULL, NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s%s%s has invited %s%s%s to %s%s%s"), + weechat_prefix ("network"), + irc_nick_color_for_server_message (server, NULL, + argv[2]), + argv[2], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + argv[3]), + argv[3], + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + argv[4], + IRC_COLOR_RESET); return WEECHAT_RC_OK; } @@ -3284,17 +3349,18 @@ IRC_PROTOCOL_CALLBACK(344) IRC_PROTOCOL_MIN_ARGS(5); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "reop", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sChannel reop %s%s%s: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - IRC_COLOR_CHAT_HOST, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "reop", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sChannel reop %s%s%s: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + IRC_COLOR_CHAT_HOST, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -3312,16 +3378,17 @@ IRC_PROTOCOL_CALLBACK(345) IRC_PROTOCOL_MIN_ARGS(5); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "reop", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s%s%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "reop", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -3356,71 +3423,74 @@ IRC_PROTOCOL_CALLBACK(346) if (argc >= 7) { datetime = (time_t)(atol (argv[6])); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "invitelist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%s%s[%s%s%s] %s%s%s invited by " - "%s%s %s(%s%s%s)%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - invite_nick), - invite_nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - invite_address, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "invitelist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%s%s[%s%s%s] %s%s%s invited by " + "%s%s %s(%s%s%s)%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + invite_nick), + invite_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + invite_address, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "invitelist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s] %s%s%s invited by " - "%s%s %s(%s%s%s)"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - invite_nick), - invite_nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - invite_address, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "invitelist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s] %s%s%s invited by " + "%s%s %s(%s%s%s)"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + invite_nick), + invite_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + invite_address, + IRC_COLOR_CHAT_DELIMITERS); } } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "invitelist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s] %s%s%s invited"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_RESET); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "invitelist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s] %s%s%s invited"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_RESET); } return WEECHAT_RC_OK; @@ -3449,19 +3519,20 @@ IRC_PROTOCOL_CALLBACK(347) ptr_channel = irc_channel_search (server, argv[3]); ptr_buffer = (ptr_channel && ptr_channel->nicks) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "invitelist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s]%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "invitelist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s]%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -3493,47 +3564,49 @@ IRC_PROTOCOL_CALLBACK(348) exception_nick = irc_message_get_nick_from_host (argv[5]); exception_address = irc_message_get_address_from_host (argv[5]); datetime = (time_t)(atol (argv[6])); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "exceptionlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%s%s[%s%s%s]%s exception %s%s%s " - "by %s%s %s(%s%s%s)%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - exception_nick), - exception_nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - exception_address, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "exceptionlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%s%s[%s%s%s]%s exception %s%s%s " + "by %s%s %s(%s%s%s)%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + exception_nick), + exception_nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + exception_address, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "exceptionlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s]%s exception %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_HOST, - argv[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "exceptionlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s]%s exception %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_HOST, + argv[4]); } return WEECHAT_RC_OK; @@ -3562,19 +3635,20 @@ IRC_PROTOCOL_CALLBACK(349) ptr_channel = irc_channel_search (server, argv[3]); ptr_buffer = (ptr_channel && ptr_channel->nicks) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "exceptionlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s]%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "exceptionlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s]%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -3599,22 +3673,24 @@ IRC_PROTOCOL_CALLBACK(351) if (argc > 5) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s %s (%s)", - weechat_prefix ("network"), - argv[3], - argv[4], - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s %s (%s)", + weechat_prefix ("network"), + argv[3], + argv[4], + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]); } else { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s %s", - weechat_prefix ("network"), - argv[3], - argv[4]); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s %s", + weechat_prefix ("network"), + argv[3], + argv[4]); } return WEECHAT_RC_OK; @@ -3688,31 +3764,32 @@ IRC_PROTOCOL_CALLBACK(352) /* display output of who (manual who from user) */ if (!ptr_channel || (ptr_channel->checking_away <= 0)) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "who", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s " - "%s%s%s%s(%s)", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (server, NULL, - argv[7]), - argv[7], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (pos_attr) ? pos_attr : "", - (pos_attr) ? " " : "", - (pos_hopcount) ? pos_hopcount : "", - (pos_hopcount) ? " " : "", - (pos_realname) ? pos_realname : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "who", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s " + "%s%s%s%s(%s)", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_server_message (server, NULL, + argv[7]), + argv[7], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (pos_attr) ? pos_attr : "", + (pos_attr) ? " " : "", + (pos_hopcount) ? pos_hopcount : "", + (pos_hopcount) ? " " : "", + (pos_realname) ? pos_realname : ""); } return WEECHAT_RC_OK; @@ -3798,20 +3875,21 @@ IRC_PROTOCOL_CALLBACK(353) if (!ptr_channel) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "names", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sNicks %s%s%s: %s[%s%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_channel, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (argv_eol[args][0] == ':') ? - argv_eol[args] + 1 : argv_eol[args], - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "names", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sNicks %s%s%s: %s[%s%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (argv_eol[args][0] == ':') ? + argv_eol[args] + 1 : argv_eol[args], + IRC_COLOR_CHAT_DELIMITERS); } return WEECHAT_RC_OK; @@ -3910,18 +3988,19 @@ IRC_PROTOCOL_CALLBACK(366) i++; } } - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "names", - ptr_channel->buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sNicks %s%s%s: %s[%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_DELIMITERS, - string, - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "names", + ptr_channel->buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sNicks %s%s%s: %s[%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_DELIMITERS, + string, + IRC_COLOR_CHAT_DELIMITERS); free (string); } } @@ -3931,38 +4010,39 @@ IRC_PROTOCOL_CALLBACK(366) /* display number of nicks, ops, halfops & voices on the channel */ irc_nick_count (server, ptr_channel, &num_nicks, &num_op, &num_halfop, &num_voice, &num_normal); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "names", - ptr_channel->buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sChannel %s%s%s: %s%d%s %s %s(%s%d%s %s, " - "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_RESET, - IRC_COLOR_CHAT_CHANNEL, - num_nicks, - IRC_COLOR_RESET, - NG_("nick", "nicks", num_nicks), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - num_op, - IRC_COLOR_RESET, - NG_("op", "ops", num_op), - IRC_COLOR_CHAT_CHANNEL, - num_halfop, - IRC_COLOR_RESET, - NG_("halfop", "halfops", num_halfop), - IRC_COLOR_CHAT_CHANNEL, - num_voice, - IRC_COLOR_RESET, - NG_("voice", "voices", num_voice), - IRC_COLOR_CHAT_CHANNEL, - num_normal, - IRC_COLOR_RESET, - NG_("normal", "normals", num_normal), - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "names", + ptr_channel->buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sChannel %s%s%s: %s%d%s %s %s(%s%d%s %s, " + "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_RESET, + IRC_COLOR_CHAT_CHANNEL, + num_nicks, + IRC_COLOR_RESET, + NG_("nick", "nicks", num_nicks), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + num_op, + IRC_COLOR_RESET, + NG_("op", "ops", num_op), + IRC_COLOR_CHAT_CHANNEL, + num_halfop, + IRC_COLOR_RESET, + NG_("halfop", "halfops", num_halfop), + IRC_COLOR_CHAT_CHANNEL, + num_voice, + IRC_COLOR_RESET, + NG_("voice", "voices", num_voice), + IRC_COLOR_CHAT_CHANNEL, + num_normal, + IRC_COLOR_RESET, + NG_("normal", "normals", num_normal), + IRC_COLOR_CHAT_DELIMITERS); if (!ptr_channel->names_received) { @@ -3973,16 +4053,17 @@ IRC_PROTOCOL_CALLBACK(366) } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "names", - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s%s%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_RESET, - (argv[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "names", + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_RESET, + (argv[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); } if (ptr_channel) @@ -4014,54 +4095,56 @@ IRC_PROTOCOL_CALLBACK(367) if (argc >= 7) { datetime = (time_t)(atol (argv[6])); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "banlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%s%s[%s%s%s] %s%s%s banned by " - "%s%s %s(%s%s%s)%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - irc_message_get_nick_from_host (argv[5])), - irc_message_get_nick_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "banlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%s%s[%s%s%s] %s%s%s banned by " + "%s%s %s(%s%s%s)%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + irc_message_get_nick_from_host (argv[5])), + irc_message_get_nick_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_message_get_address_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "banlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s] %s%s%s banned by " - "%s%s %s(%s%s%s)"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - irc_message_get_nick_from_host (argv[5])), - irc_message_get_nick_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "banlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s] %s%s%s banned by " + "%s%s %s(%s%s%s)"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + irc_message_get_nick_from_host (argv[5])), + irc_message_get_nick_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_message_get_address_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS); } return WEECHAT_RC_OK; @@ -4090,19 +4173,20 @@ IRC_PROTOCOL_CALLBACK(368) ptr_channel = irc_channel_search (server, argv[3]); ptr_buffer = (ptr_channel && ptr_channel->nicks) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "banlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s]%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "banlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s]%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -4122,7 +4206,7 @@ IRC_PROTOCOL_CALLBACK(432) */ irc_protocol_cb_generic_error (server, - nick, address, host, command, + date, nick, address, host, command, ignored, argc, argv, argv_eol); if (!server->is_connected) @@ -4133,21 +4217,21 @@ IRC_PROTOCOL_CALLBACK(432) alternate_nick = irc_server_get_alternate_nick (server); if (!alternate_nick) { - weechat_printf (ptr_buffer, - _("%s%s: all declared nicknames are " - "already in use or invalid, closing " - "connection with server"), - weechat_prefix ("error"), - IRC_PLUGIN_NAME); + weechat_printf_date_tags (ptr_buffer, date, NULL, + _("%s%s: all declared nicknames are " + "already in use or invalid, closing " + "connection with server"), + weechat_prefix ("error"), + IRC_PLUGIN_NAME); irc_server_disconnect (server, 0, 1); return WEECHAT_RC_OK; } - weechat_printf (ptr_buffer, - _("%s%s: nickname \"%s\" is invalid, " - "trying nickname \"%s\""), - weechat_prefix ("error"), - IRC_PLUGIN_NAME, server->nick, alternate_nick); + weechat_printf_date_tags (ptr_buffer, date, NULL, + _("%s%s: nickname \"%s\" is invalid, " + "trying nickname \"%s\""), + weechat_prefix ("error"), + IRC_PLUGIN_NAME, server->nick, alternate_nick); irc_server_set_nick (server, alternate_nick); @@ -4179,21 +4263,21 @@ IRC_PROTOCOL_CALLBACK(433) alternate_nick = irc_server_get_alternate_nick (server); if (!alternate_nick) { - weechat_printf (ptr_buffer, - _("%s%s: all declared nicknames are " - "already in use, closing " - "connection with server"), - weechat_prefix ("error"), - IRC_PLUGIN_NAME); + weechat_printf_date_tags (ptr_buffer, date, NULL, + _("%s%s: all declared nicknames are " + "already in use, closing " + "connection with server"), + weechat_prefix ("error"), + IRC_PLUGIN_NAME); irc_server_disconnect (server, 0, 1); return WEECHAT_RC_OK; } - weechat_printf (ptr_buffer, - _("%s%s: nickname \"%s\" is already in use, " - "trying nickname \"%s\""), - weechat_prefix ("network"), - IRC_PLUGIN_NAME, server->nick, alternate_nick); + weechat_printf_date_tags (ptr_buffer, date, NULL, + _("%s%s: nickname \"%s\" is already in use, " + "trying nickname \"%s\""), + weechat_prefix ("network"), + IRC_PLUGIN_NAME, server->nick, alternate_nick); irc_server_set_nick (server, alternate_nick); @@ -4202,8 +4286,9 @@ IRC_PROTOCOL_CALLBACK(433) else { return irc_protocol_cb_generic_error (server, - nick, address, host, command, - ignored, argc, argv, argv_eol); + date, nick, address, host, + command, ignored, argc, argv, + argv_eol); } return WEECHAT_RC_OK; @@ -4225,7 +4310,7 @@ IRC_PROTOCOL_CALLBACK(437) */ irc_protocol_cb_generic_error (server, - nick, address, host, command, + date, nick, address, host, command, ignored, argc, argv, argv_eol); if (!server->is_connected) @@ -4239,21 +4324,21 @@ IRC_PROTOCOL_CALLBACK(437) alternate_nick = irc_server_get_alternate_nick (server); if (!alternate_nick) { - weechat_printf (ptr_buffer, - _("%s%s: all declared nicknames are " - "already in use or invalid, closing " - "connection with server"), - weechat_prefix ("error"), - IRC_PLUGIN_NAME); + weechat_printf_date_tags (ptr_buffer, date, NULL, + _("%s%s: all declared nicknames are " + "already in use or invalid, closing " + "connection with server"), + weechat_prefix ("error"), + IRC_PLUGIN_NAME); irc_server_disconnect (server, 0, 1); return WEECHAT_RC_OK; } - weechat_printf (ptr_buffer, - _("%s%s: nickname \"%s\" is unavailable, " - "trying nickname \"%s\""), - weechat_prefix ("error"), - IRC_PLUGIN_NAME, server->nick, alternate_nick); + weechat_printf_date_tags (ptr_buffer, date, NULL, + _("%s%s: nickname \"%s\" is unavailable, " + "trying nickname \"%s\""), + weechat_prefix ("error"), + IRC_PLUGIN_NAME, server->nick, alternate_nick); irc_server_set_nick (server, alternate_nick); @@ -4285,22 +4370,24 @@ IRC_PROTOCOL_CALLBACK(438) if (argc >= 5) { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s (%s => %s)", - weechat_prefix ("network"), - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4], - argv[2], - argv[3]); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s (%s => %s)", + weechat_prefix ("network"), + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4], + argv[2], + argv[3]); } else { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s %s", - weechat_prefix ("network"), - argv[2], - argv[3]); + weechat_printf_date_tags (ptr_buffer, + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s %s", + weechat_prefix ("network"), + argv[2], + argv[3]); } return WEECHAT_RC_OK; @@ -4329,54 +4416,56 @@ IRC_PROTOCOL_CALLBACK(728) if (argc >= 8) { datetime = (time_t)(atol (argv[7])); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "quietlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - /* TRANSLATORS: "%s" after "on" is a date */ - _("%s%s[%s%s%s] %s%s%s quieted by " - "%s%s %s(%s%s%s)%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[5], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - irc_message_get_nick_from_host (argv[6])), - irc_message_get_nick_from_host (argv[6]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[6]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - weechat_util_get_time_string (&datetime)); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "quietlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + /* TRANSLATORS: "%s" after "on" is a date */ + _("%s%s[%s%s%s] %s%s%s quieted by " + "%s%s %s(%s%s%s)%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[5], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + irc_message_get_nick_from_host (argv[6])), + irc_message_get_nick_from_host (argv[6]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_message_get_address_from_host (argv[6]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + weechat_util_get_time_string (&datetime)); } else { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "quietlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - _("%s%s[%s%s%s] %s%s%s quieted by " - "%s%s %s(%s%s%s)"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[5], - IRC_COLOR_RESET, - irc_nick_color_for_server_message (server, NULL, - irc_message_get_nick_from_host (argv[6])), - irc_message_get_nick_from_host (argv[6]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[6]), - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "quietlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%s%s[%s%s%s] %s%s%s quieted by " + "%s%s %s(%s%s%s)"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[5], + IRC_COLOR_RESET, + irc_nick_color_for_server_message (server, NULL, + irc_message_get_nick_from_host (argv[6])), + irc_message_get_nick_from_host (argv[6]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_message_get_address_from_host (argv[6]), + IRC_COLOR_CHAT_DELIMITERS); } return WEECHAT_RC_OK; @@ -4405,19 +4494,20 @@ IRC_PROTOCOL_CALLBACK(729) ptr_channel = irc_channel_search (server, argv[3]); ptr_buffer = (ptr_channel && ptr_channel->nicks) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "quietlist", - ptr_buffer), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s]%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, "quietlist", + ptr_buffer), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s[%s%s%s]%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -4435,17 +4525,18 @@ IRC_PROTOCOL_CALLBACK(900) IRC_PROTOCOL_MIN_ARGS(6); - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s %s(%s%s%s)", - weechat_prefix ("network"), - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[3], - IRC_COLOR_CHAT_DELIMITERS); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s %s(%s%s%s)", + weechat_prefix ("network"), + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[3], + IRC_COLOR_CHAT_DELIMITERS); return WEECHAT_RC_OK; } @@ -4465,18 +4556,19 @@ IRC_PROTOCOL_CALLBACK(901) if (argc >= 7) { - weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL, - NULL), - irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s", - weechat_prefix ("network"), - (argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]); + weechat_printf_date_tags (irc_msgbuffer_get_target_buffer (server, NULL, + command, NULL, + NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL), + "%s%s", + weechat_prefix ("network"), + (argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]); } else { irc_protocol_cb_numeric (server, - nick, address, host, command, + date, nick, address, host, command, ignored, argc, argv, argv_eol); } @@ -4497,7 +4589,7 @@ IRC_PROTOCOL_CALLBACK(sasl_end) */ irc_protocol_cb_numeric (server, - nick, address, host, command, + date, nick, address, host, command, ignored, argc, argv, argv_eol); if (!server->is_connected) @@ -4507,16 +4599,114 @@ IRC_PROTOCOL_CALLBACK(sasl_end) } /* - * irc_protocol_recv_command: executes action when receiving IRC command - * return: 0 = all ok, command executed - * -1 = command failed - * -2 = no command to execute - * -3 = command not found + * irc_protocol_get_message_tags: return hashtable with tags for an IRC message + * example, if tags == "aaa=bbb;ccc;example.com/ddd=eee" + * hashtable will have following keys/values: + * "aaa" => "bbb" + * "ccc" => NULL + * "example.com/ddd" => "eee" + */ + +struct t_hashtable * +irc_protocol_get_message_tags (const char *tags) +{ + struct t_hashtable *hashtable; + char **items, *pos, *key; + int num_items, i; + + if (!tags || !tags[0]) + return NULL; + + hashtable = weechat_hashtable_new (8, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); + if (!hashtable) + return NULL; + + items = weechat_string_split (tags, ";", 0, 0, &num_items); + if (items) + { + for (i = 0; i < num_items; i++) + { + pos = strchr (items[i], '='); + if (pos) + { + /* format: "tag=value" */ + key = weechat_strndup (items[i], pos - items[i]); + if (key) + { + weechat_hashtable_set (hashtable, key, pos + 1); + free (key); + } + } + else + { + /* format: "tag" */ + weechat_hashtable_set (hashtable, items[i], NULL); + } + } + weechat_string_free_split (items); + } + + return hashtable; +} + +/* + * irc_protocol_get_message_tag_time: get value of time in tags + * if no tag "time" is in tags, value 0 is + * returned + */ + +time_t +irc_protocol_get_message_tag_time (struct t_hashtable *tags) +{ + const char *tag_time; + char *tag_time2, *pos, *error; + int value; + time_t time_value; + + if (!tags) + return 0; + + time_value = 0; + + tag_time = weechat_hashtable_get (tags, "time"); + if (tag_time) + { + tag_time2 = strdup (tag_time); + if (tag_time2) + { + pos = tag_time2; + while (isdigit ((unsigned char)pos[0])) + { + pos++; + } + pos[0] = '\0'; + if (tag_time2[0]) + { + value = (int)strtol (tag_time2, &error, 10); + if (error && !error[0] && (value >= 0)) + time_value = (time_t)value; + } + free (tag_time2); + } + } + + return time_value; +} + +/* + * irc_protocol_recv_command: execute action when an IRC message is received + * Argument "irc_message" is the full message + * without optional tags. */ void irc_protocol_recv_command (struct t_irc_server *server, const char *irc_message, + const char *msg_tags, const char *msg_command, const char *msg_channel) { @@ -4526,9 +4716,11 @@ irc_protocol_recv_command (struct t_irc_server *server, struct t_irc_channel *ptr_channel; t_irc_recv_func *cmd_recv_func; const char *cmd_name; + time_t date; const char *nick1, *address1, *host1; char *nick, *address, *address_color, *host, *host_no_color, *host_color; char **argv, **argv_eol; + struct t_hashtable *hash_tags; struct t_irc_protocol_msg irc_protocol_messages[] = { { "authenticate", /* authenticate */ 1, 0, &irc_protocol_cb_authenticate }, { "cap", /* client capability */ 1, 0, &irc_protocol_cb_cap }, @@ -4677,6 +4869,16 @@ irc_protocol_recv_command (struct t_irc_server *server, dup_irc_message = NULL; argv = NULL; argv_eol = NULL; + hash_tags = NULL; + date = 0; + + /* get tags as hashtable */ + if (msg_tags) + { + hash_tags = irc_protocol_get_message_tags (msg_tags); + if (hash_tags) + date = irc_protocol_get_message_tag_time (hash_tags); + } /* get nick/host/address from IRC message */ nick1 = NULL; @@ -4781,9 +4983,10 @@ irc_protocol_recv_command (struct t_irc_server *server, 1 + keep_trailing_spaces, 0, NULL); return_code = (int) (cmd_recv_func) (server, - nick, address_color, host_color, - cmd_name, message_ignored, - argc, argv, argv_eol); + date, nick, address_color, + host_color, cmd_name, + message_ignored, argc, argv, + argv_eol); if (return_code == WEECHAT_RC_ERROR) { @@ -4828,4 +5031,6 @@ end: weechat_string_free_split (argv); if (argv_eol) weechat_string_free_split (argv_eol); + if (hash_tags) + weechat_hashtable_free (hash_tags); } diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h index f23dc3a4a..9a4c03e99 100644 --- a/src/plugins/irc/irc-protocol.h +++ b/src/plugins/irc/irc-protocol.h @@ -23,6 +23,7 @@ #define IRC_PROTOCOL_CALLBACK(__command) \ int \ irc_protocol_cb_##__command (struct t_irc_server *server, \ + time_t date, \ const char *nick, \ const char *address, \ const char *host, \ @@ -33,6 +34,7 @@ char **argv_eol) #define IRC_PROTOCOL_MIN_ARGS(__min_args) \ + (void) date; \ (void) nick; \ (void) address; \ (void) host; \ @@ -65,8 +67,9 @@ struct t_irc_server; typedef int (t_irc_recv_func)(struct t_irc_server *server, - const char *nick, const char *address, - const char *host, const char *command, + time_t date, const char *nick, + const char *address, const char *host, + const char *command, int ignored, int argc, char **argv, char **argv_eol); @@ -82,6 +85,7 @@ extern const char *irc_protocol_tags (const char *command, const char *tags, const char *nick); extern void irc_protocol_recv_command (struct t_irc_server *server, const char *irc_message, + const char *msg_tags, const char *msg_command, const char *msg_channel); diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 43d4dbec9..194bb768f 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -2072,7 +2072,7 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags, for (i = 0; i < items_count; i++) { /* run modifier "irc_out1_xxx" (like "irc_out_xxx", but before split) */ - irc_message_parse (server, items[i], + irc_message_parse (server, items[i], NULL, NULL, &nick, NULL, &command, &channel, NULL); snprintf (str_modifier, sizeof (str_modifier), "irc_out1_%s", @@ -2301,8 +2301,8 @@ void irc_server_msgq_flush () { struct t_irc_message *next; - char *ptr_data, *new_msg, *new_msg2, *ptr_msg, *ptr_msg2, *pos; - char *nick, *host, *command, *channel, *arguments; + char *ptr_data, *new_msg, *new_msg2, *ptr_msg, *ptr_msg2, *ptr_msg3, *pos; + char *tags, *nick, *host, *command, *channel, *arguments; char *msg_decoded, *msg_decoded_without_color; char str_modifier[128], modifier_data[256]; @@ -2325,8 +2325,8 @@ irc_server_msgq_flush () ptr_data); irc_message_parse (irc_recv_msgq->server, - ptr_data, NULL, NULL, &command, NULL, - NULL); + ptr_data, NULL, NULL, NULL, NULL, + &command, NULL, NULL); snprintf (str_modifier, sizeof (str_modifier), "irc_in_%s", (command) ? command : "unknown"); @@ -2362,9 +2362,9 @@ irc_server_msgq_flush () ptr_msg); } - irc_message_parse (irc_recv_msgq->server, - ptr_msg, &nick, &host, &command, - &channel, &arguments); + irc_message_parse (irc_recv_msgq->server, ptr_msg, + &tags, NULL, &nick, &host, + &command, &channel, &arguments); /* convert charset for message */ if (channel @@ -2436,8 +2436,25 @@ irc_server_msgq_flush () else { /* message not redirected, display it */ + ptr_msg3 = ptr_msg2; + if (ptr_msg3[0] == '@') + { + /* skip tags in message */ + ptr_msg3 = strchr (ptr_msg3, ' '); + if (ptr_msg3) + { + while (ptr_msg3[0] == ' ') + { + ptr_msg3++; + } + } + else + ptr_msg3 = ptr_msg2; + } irc_protocol_recv_command (irc_recv_msgq->server, - ptr_msg2, command, + ptr_msg3, + tags, + command, channel); } } |