summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-06 16:47:34 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-06 16:47:34 +0300
commit4f258796441a53b02dcf60daf13d0c6bd3cb2cdd (patch)
tree6c001f4ac268083af9b5b6e007c7952a5179026a /protocols
parente6ceeb9d5fe3f9f904d9c87d759ec8459ce24e33 (diff)
fixes #4712 (Telegram: оформить предпросмотр ссылки как цитату)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/utils.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index c1a648e35b..0db0a430cd 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -746,8 +746,13 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
ret = GetFormattedText(pText->text_);
if (auto *pWeb = pText->link_preview_.get()) {
- if (!pWeb->display_url_.empty() && m_bUrlPreview)
- ret.AppendFormat("\r\n[url]%s[/url]", pWeb->display_url_.c_str());
+ CMStringA szDescr;
+
+ if (!pWeb->display_url_.empty())
+ szDescr.AppendFormat("[b]%s[/b]\r\n", pWeb->display_url_.c_str());
+
+ if (!pWeb->site_name_.empty())
+ szDescr.AppendFormat("%s\r\n", pWeb->site_name_.c_str());
if (pWeb->type_->get_id() == TD::linkPreviewTypePhoto::ID) {
auto *pPhoto = ((TD::linkPreviewTypePhoto *)pWeb->type_.get())->photo_.get();
@@ -760,11 +765,14 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
pSize = pPhoto->sizes_[0].get();
if (auto szText = GetMessagePreview(pSize->photo_.get()))
- ret.AppendFormat("\r\n[img=%s][/img]", szText.c_str());
+ szDescr.AppendFormat("[img=%s][/img]\r\n", szText.c_str());
}
if (auto szText = GetFormattedText(pWeb->description_))
- ret.AppendFormat("\r\n%s", szText.c_str());
+ szDescr.AppendFormat("%s\r\n", szText.c_str());
+
+ if (!szDescr.IsEmpty())
+ ret += "\r\n[quote]" + szDescr.Trim() + "[/quote]";
}
}
break;