diff options
author | George Hazan <ghazan@miranda.im> | 2017-02-02 21:20:40 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-02-02 21:20:40 +0300 |
commit | 38d7885b91b6026b1a518e8c7d34172a08da4c87 (patch) | |
tree | e687f597a185097e43f2815600a6ded03e157075 /protocols/Discord/src/utils.cpp | |
parent | b8b21e44668a2528932dd134f3791f2eabf68cf2 (diff) |
Discord: message formatting now includes the list of attachments (if present)
Diffstat (limited to 'protocols/Discord/src/utils.cpp')
-rw-r--r-- | protocols/Discord/src/utils.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index de86bef956..8a2041c534 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -215,6 +215,29 @@ CDiscordUser* CDiscordProto::PrepareUser(const JSONNode &user) ///////////////////////////////////////////////////////////////////////////////////////// +CMStringW PrepareMessageText(const JSONNode &pRoot) +{ + CMStringW wszText = pRoot["content"].as_mstring(); + + bool bDelimiterAdded = false; + const JSONNode &pAttaches = pRoot["attachments"]; + for (auto it = pAttaches.begin(); it != pAttaches.end(); ++it) { + const JSONNode &p = *it; + CMStringW wszUrl = p["url"].as_mstring(); + if (!wszUrl.IsEmpty()) { + if (!bDelimiterAdded) { + bDelimiterAdded = true; + wszText.Append(L"\n-----------------"); + } + wszText.AppendFormat(L"\n%s: %s", TranslateT("Attachment"), wszUrl); + } + } + + return wszText; +} + +///////////////////////////////////////////////////////////////////////////////////////// + void CDiscordProto::ProcessType(CDiscordUser *pUser, const JSONNode &pRoot) { switch (pRoot["type"].as_int()) { |