From b23514fd642eb0a4f63a565ac1e6ae44902395fc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 22 Nov 2023 21:27:51 +0300 Subject: minor fix for receiving multiple bbCodes --- protocols/Telegram/src/utils.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index b2a1c9c3eb..7212a04d1d 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -76,6 +76,8 @@ static CMStringA getFormattedText(TD::object_ptr &pText) { if (pText->get_id() == TD::formattedText::ID) { CMStringW ret(Utf2T(pText->text_.c_str())); + unsigned offset = 0; + for (auto &it : pText->entities_) { int iCode; switch (it->type_->get_id()) { @@ -87,8 +89,10 @@ static CMStringA getFormattedText(TD::object_ptr &pText) continue; } - ret.Insert(it->offset_ + it->length_, bbCodes[iCode].end); - ret.Insert(it->offset_, bbCodes[iCode].begin); + auto &bb = bbCodes[iCode]; + ret.Insert(offset + it->offset_ + it->length_, bb.end); + ret.Insert(offset + it->offset_, bb.begin); + offset += bb.len1 + bb.len2; } return T2Utf(ret).get(); } -- cgit v1.2.3