summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-02-12 21:04:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-02-12 21:04:12 +0300
commit2651148625bef56f1fe32c638259d20abb001d68 (patch)
tree84515d43d4856003866e02f888128a6369e92f32 /protocols/Discord/src/utils.cpp
parent23764bc5bfbe6986a1c9a087510e6eeb2521c330 (diff)
support for Discord message markup
Diffstat (limited to 'protocols/Discord/src/utils.cpp')
-rw-r--r--protocols/Discord/src/utils.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp
index f84ecfb61a..b1390a9ec0 100644
--- a/protocols/Discord/src/utils.cpp
+++ b/protocols/Discord/src/utils.cpp
@@ -268,3 +268,29 @@ void CDiscordProto::ProcessType(CDiscordUser *pUser, const JSONNode &pRoot)
break;
}
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CDiscordProto::ParseSpecialChars(SESSION_INFO *si, CMStringW &str)
+{
+ for (int i = 0; (i = str.Find('<', i)) != -1; i++) {
+ int iEnd = str.Find('>', i + 1);
+ if (iEnd == -1)
+ return;
+
+ CMStringW wszWord = str.Mid(i + 1, iEnd - i - 1);
+ if (wszWord[0] == '@' && wszWord[1] == '!') { // member highlight
+ USERINFO *ui = pci->UM_FindUser(si->pUsers, wszWord.c_str()+2);
+ if (ui != nullptr)
+ str.Replace(L"<" + wszWord + L">", CMStringW('@') + ui->pszNick);
+ }
+ else if (wszWord[0] == '#') {
+ CDiscordUser *pUser = FindUserByChannel(_wtoi64(wszWord.c_str() + 1));
+ if (pUser != nullptr) {
+ ptrW wszNick(getWStringA(pUser->hContact, "Nick"));
+ if (wszNick != NULL)
+ str.Replace(L"<" + wszWord + L">", wszNick);
+ }
+ }
+ }
+}