Files
tdesktop/Telegram/SourceFiles/ui/item_text_options.cpp
allhaileris afb81b8278
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
init
2026-02-16 15:50:16 +03:00

71 lines
1.7 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/item_text_options.h"
#include "history/history.h"
#include "history/history_item.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_user.h"
namespace Ui {
namespace {
bool UseBotTextOptions(
not_null<History*> history,
not_null<PeerData*> author) {
if (const auto user = history->peer->asUser()) {
if (user->isBot()) {
return true;
}
} else if (const auto chat = history->peer->asChat()) {
if (chat->botStatus >= 0) {
return true;
}
} else if (const auto group = history->peer->asMegagroup()) {
if (group->mgInfo->botStatus >= 0) {
return true;
}
}
if (const auto user = author->asUser()) {
if (user->isBot()) {
return true;
}
}
return false;
}
} // namespace
const TextParseOptions &ItemTextOptions(
not_null<History*> history,
not_null<PeerData*> author) {
return UseBotTextOptions(history, author)
? ItemTextBotDefaultOptions()
: ItemTextDefaultOptions();
}
const TextParseOptions &ItemTextOptions(not_null<const HistoryItem*> item) {
return ItemTextOptions(item->history(), item->author());
}
const TextParseOptions &ItemTextNoMonoOptions(
not_null<History*> history,
not_null<PeerData*> author) {
return UseBotTextOptions(history, author)
? ItemTextBotNoMonoOptions()
: ItemTextNoMonoOptions();
}
const TextParseOptions &ItemTextNoMonoOptions(
not_null<const HistoryItem*> item) {
return ItemTextNoMonoOptions(item->history(), item->author());
}
} // namespace Ui