diff options
author | George Hazan <george.hazan@gmail.com> | 2024-09-30 18:21:55 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-09-30 18:21:55 +0300 |
commit | 2cde8069f2d7c2963ae10cca5f520462ac3a4a49 (patch) | |
tree | 2f6e61b2f62b2b1b0673912870e8894d0be0f4ea | |
parent | 3ea151ed7440be73dccc664c0464e0dfc8e72ad0 (diff) |
fixes #4700 (Telegram: не доходят входящие сообщения, содержащие цитату)
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 22 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 17 |
2 files changed, 24 insertions, 15 deletions
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index 589016b072..bb3c4ecfca 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -204,13 +204,20 @@ static void AppendString(CMStringW &buf, const wchar_t *p, ItemData *pItem) buf.AppendFormat(L"</font>");
}
else if (!wcsncmp(p, L"code]", 5)) {
+ p += 4;
+ buf.AppendFormat(L"<pre>");
+ }
+ else if (!wcsncmp(p, L"/code]", 6)) {
p += 5;
-
- if (auto *p1 = wcsstr(p, L"[/code]")) {
- CMStringW wszUrl(p, int(p1 - p));
- buf.AppendFormat(L"<pre>%s</pre>", wszUrl.c_str());
- p = p1 + 6;
- }
+ buf.AppendFormat(L"</pre>");
+ }
+ else if (!wcsncmp(p, L"quote]", 6)) {
+ p += 5;
+ buf.AppendFormat(L"<div class=\"quote\">");
+ }
+ else if (!wcsncmp(p, L"/quote]", 7)) {
+ p += 6;
+ buf.AppendFormat(L"</div>");
}
else {
buf.AppendChar('[');
@@ -237,8 +244,7 @@ CMStringW ItemData::formatHtml(const wchar_t *pwszStr) str.AppendFormat(L"body {margin: 0px; text-align: left; %s; color: NSText; overflow: auto;}\n", font2html(F.lf, szFont));
str.AppendFormat(L".nick {color: #%06X }\n", color2html(g_colorTable[(dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl));
str.AppendFormat(L".link {color: #%06X }\n", color2html(g_colorTable[COLOR_LINK].cl));
- if (qtext)
- str.AppendFormat(L".quote {border-left: 4px solid #%06X; padding-left: 8px; }\n", color2html(g_colorTable[COLOR_QUOTE].cl));
+ str.AppendFormat(L".quote {border-left: 4px solid #%06X; padding-left: 8px; }\n", color2html(g_colorTable[COLOR_QUOTE].cl));
str.Append(L"</style></head><body class=\"body\">\n");
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index c823896051..c1a648e35b 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. enum class BBCODE
{
- BOLD, ITALIC, STRIKE, UNDERLINE, URL, CODE
+ BOLD, ITALIC, STRIKE, UNDERLINE, URL, CODE, QUOTE
};
struct
@@ -30,12 +30,13 @@ struct }
static bbCodes[] =
{
- { BBCODE::BOLD, L"[b]", L"[/b]", 3, 4 },
- { BBCODE::ITALIC, L"[i]", L"[/i]", 3, 4 },
- { BBCODE::STRIKE, L"[s]", L"[/s]", 3, 4 },
- { BBCODE::UNDERLINE, L"[u]", L"[/u]", 3, 4 },
- { BBCODE::URL, L"[url]", L"[/url]", 5, 6 },
- { BBCODE::CODE, L"[code]", L"[/code]", 6, 7 },
+ { BBCODE::BOLD, L"[b]", L"[/b]", 3, 4 },
+ { BBCODE::ITALIC, L"[i]", L"[/i]", 3, 4 },
+ { BBCODE::STRIKE, L"[s]", L"[/s]", 3, 4 },
+ { BBCODE::UNDERLINE, L"[u]", L"[/u]", 3, 4 },
+ { BBCODE::URL, L"[url]", L"[/url]", 5, 6 },
+ { BBCODE::CODE, L"[code]", L"[/code]", 6, 7 },
+ { BBCODE::QUOTE, L"[quote]", L"[/quote]", 7, 8 },
};
TD::object_ptr<TD::formattedText> formatBbcodes(const char *pszText)
@@ -68,6 +69,7 @@ TD::object_ptr<TD::formattedText> formatBbcodes(const char *pszText) case BBCODE::URL: pNew = TD::make_object<TD::textEntityTypeUrl>(); break;
case BBCODE::CODE: pNew = TD::make_object<TD::textEntityTypeCode>(); break;
case BBCODE::BOLD: pNew = TD::make_object<TD::textEntityTypeBold>(); break;
+ case BBCODE::QUOTE: pNew = TD::make_object<TD::textEntityTypeBlockQuote>(); break;
case BBCODE::ITALIC: pNew = TD::make_object<TD::textEntityTypeItalic>(); break;
case BBCODE::STRIKE: pNew = TD::make_object<TD::textEntityTypeStrikethrough>(); break;
case BBCODE::UNDERLINE: pNew = TD::make_object<TD::textEntityTypeUnderline>(); break;
@@ -95,6 +97,7 @@ CMStringA CTelegramProto::GetFormattedText(TD::object_ptr<TD::formattedText> &pT case TD::textEntityTypeStrikethrough::ID: iCode = 2; break;
case TD::textEntityTypeUnderline::ID: iCode = 3; break;
case TD::textEntityTypeCode::ID: iCode = 5; break;
+ case TD::textEntityTypeBlockQuote::ID: iCode = 6; break;
case TD::textEntityTypeUrl::ID:
if (!m_bUrlPreview)
continue;
|