summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/utils.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2017-02-12 21:43:13 +0100
committerTobias Weimer <wishmaster51@googlemail.com>2017-02-12 21:43:13 +0100
commit36c32a13878d3bd94e88bd9c764f1eadb05ea1ed (patch)
tree3407b05620aa32471e95499c2635d5f6de2ce776 /protocols/Discord/src/utils.cpp
parent646630b565d4fa2d95fd73143198b2d46deb937d (diff)
parent2651148625bef56f1fe32c638259d20abb001d68 (diff)
Merge branch 'master' of https://github.com/miranda-ng/miranda-ng
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);
+ }
+ }
+ }
+}