From d6ff87d7322f48e298d01fe7cc14d96b0f6468ef Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Jun 2023 21:41:21 +0300 Subject: =?UTF-8?q?fixes=20#3548=20(Telegram:=20=D0=BF=D0=BE=D0=B4=D0=B4?= =?UTF-8?q?=D0=B5=D1=80=D0=B6=D0=BA=D0=B0=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=BE=20=D0=BF=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D1=80=D1=82=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/utils.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 17286c3649..79e897bf3f 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -339,6 +339,13 @@ static const TD::photoSize* GetBiggestPhoto(const TD::photo *pPhoto) return nullptr; } +static const char *getFormattedText(TD::object_ptr &pText) +{ + if (pText->get_id() == TD::formattedText::ID) + return pText->text_.c_str(); + return nullptr; +} + CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg) { const TD::MessageContent *pBody = pMsg->content_.get(); @@ -449,10 +456,20 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg return GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt); } + case TD::messageInvoice::ID: + { + auto *pInvoice = ((TD::messageInvoice *)pBody); + CMStringA ret(FORMAT, "%s: %.2lf %s", TranslateU("You received an invoice"), double(pInvoice->total_amount_)/100.0, pInvoice->currency_.c_str()); + if (!pInvoice->title_.empty()) + ret.AppendFormat("\r\n%s: %s", TranslateU("Title"), pInvoice->title_.c_str()); + if (auto *pszText = getFormattedText(pInvoice->description_)) + ret.AppendFormat("\r\n%s", ((TD::formattedText *)pInvoice->description_.get())->text_.c_str()); + return ret; + } + case TD::messageText::ID: - auto pText = ((TD::messageText *)pBody)->text_.get(); - if (pText->get_id() == TD::formattedText::ID) - return CMStringA(((TD::formattedText *)pText)->text_.c_str()); + if (auto *pszText = getFormattedText(((TD::messageText *)pBody)->text_)) + return CMStringA(pszText); break; } -- cgit v1.2.3