summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-07 21:41:21 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-07 21:41:21 +0300
commitd6ff87d7322f48e298d01fe7cc14d96b0f6468ef (patch)
treec2d1569f36d696833cda37e2293de48e6dcbf0ab
parent9721b22f613c57526c92a3d41295374a22595f84 (diff)
fixes #3548 (Telegram: поддержка сообщений о пожертвовании )
-rw-r--r--protocols/Telegram/src/utils.cpp23
1 files 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<TD::formattedText> &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;
}