From 4cd1942694e6142c943a04eebfe1c0bd91a64ac2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 2 Feb 2025 17:29:21 +0300 Subject: small but full bbcode parser, too tired to parse all that crap manually --- protocols/Steam/src/steam_utils.cpp | 85 ------------------------------------- 1 file changed, 85 deletions(-) (limited to 'protocols/Steam/src/steam_utils.cpp') diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp index 7f1275add3..2b8c3263db 100644 --- a/protocols/Steam/src/steam_utils.cpp +++ b/protocols/Steam/src/steam_utils.cpp @@ -20,91 +20,6 @@ bool IsNull(const ProtobufCBinaryData &buf) ///////////////////////////////////////////////////////////////////////////////////////// -void EncodeBbcodes(SESSION_INFO *si, CMStringW &wszText) -{ - int idx = wszText.Find(':'); - if (idx != -1) { - CMStringW wszNick(wszText.Left(idx)); - for (auto &it : si->getUserList()) { - if (wszNick == it->pszNick) { - wszText.Delete(0, idx+1); - - CMStringW wszReplace(FORMAT, L"[mention=%lld]@%s[/mention]", SteamIdToAccountId(_wtoi64(it->pszUID)), it->pszNick); - wszText = wszReplace + wszText; - break; - } - } - } -} - -void DecodeBbcodes(SESSION_INFO *si, CMStringA &szText) -{ - for (int idx = 0; idx != -1; idx = szText.Find('[', idx+1)) { - bool isClosing = false; - idx++; - if (szText[idx] == '/') { - isClosing = true; - idx++; - } - - int iEnd = szText.Find(']', idx + 1); - if (iEnd == -1) - return; - - bool bPlaceFirst = false; - CMStringA szReplace; - - auto *p = szText.c_str() + idx; - if (!strncmp(p, "emoticon", 8) || !strncmp(p, "sticker", 7)) - szReplace = ":"; - - if (!isClosing) { - if (!strncmp(p, "mention=", 8)) { - CMStringW wszId(FORMAT, L"%lld", AccountIdToSteamId(_atoi64(p + 8))); - if (auto *pUser = g_chatApi.UM_FindUser(si, wszId)) { - int iEnd2 = szText.Find("[/mention]", iEnd); - if (iEnd2 == -1) - return; - - iEnd = iEnd2 + 10; - szReplace.Format("%s:", T2Utf(pUser->pszNick).get()); - bPlaceFirst = true; - } - } - else if (!strncmp(p, "lobbyinvite ", 12)) { - szReplace = TranslateU("You were invited to play a game"); - } - else if (!strncmp(p, "sticker ", 8)) { - std::regex regex("type=\"(.+?)\""); - std::smatch match; - std::string content(p + 8); - if (std::regex_search(content, match, regex)) { - std::string szType = match[1]; - szReplace += szType.c_str(); - szReplace.Replace(" ", "_"); - } - iEnd++; - } - else iEnd++; - } - else iEnd++, idx--; - - idx--; - szText.Delete(idx, iEnd - idx); - - if (!szReplace.IsEmpty()) { - if (bPlaceFirst) - szText = szReplace + szText; - else - szText.Insert(idx, szReplace); - } - iEnd -= iEnd - idx; - idx = iEnd; - } -} - -///////////////////////////////////////////////////////////////////////////////////////// - MBinBuffer createMachineID(const char *accName) { uint8_t hashOut[MIR_SHA1_HASH_SIZE]; -- cgit v1.2.3