mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-11 09:19:35 +00:00
Add cashtags and bot allowed service messages.
This commit is contained in:
parent
6726826c17
commit
3c4c466f8e
@ -793,6 +793,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_action_payment_done_for" = "You have just successfully transferred {amount} to {user} for {invoice}";
|
||||
"lng_action_took_screenshot" = "{from} took a screenshot!";
|
||||
"lng_action_you_took_screenshot" = "You took a screenshot!";
|
||||
"lng_action_bot_allowed_from_domain" = "You allowed this bot to message you when you logged in on {domain}.";
|
||||
|
||||
"lng_ttl_photo_received" = "{from} sent you a self-destructing photo. Please view it on your mobile.";
|
||||
"lng_ttl_photo_sent" = "You sent a self-destructing photo.";
|
||||
|
@ -270,6 +270,7 @@ messageActionPaymentSent#40699cd0 currency:string total_amount:long = MessageAct
|
||||
messageActionPhoneCall#80e11a7f flags:# call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction;
|
||||
messageActionScreenshotTaken#4792929b = MessageAction;
|
||||
messageActionCustomAction#fae69f56 message:string = MessageAction;
|
||||
messageActionBotAllowed#abe9affe domain:string = MessageAction;
|
||||
|
||||
dialog#e4def5db flags:# pinned:flags.2?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage = Dialog;
|
||||
dialogFeed#36086d42 flags:# pinned:flags.2?true peer:Peer top_message:int feed_id:int feed_other_channels:Vector<int> read_max_position:flags.3?FeedPosition unread_count:int unread_muted_count:int = Dialog;
|
||||
@ -463,7 +464,7 @@ upload.fileCdnRedirect#ea52fe5a dc_id:int file_token:bytes encryption_key:bytes
|
||||
|
||||
dcOption#5d8c6cc flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true id:int ip_address:string port:int = DcOption;
|
||||
|
||||
config#9c840964 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured:flags.4?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int chat_big_size:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string suggested_lang_code:flags.2?string lang_pack_version:flags.2?int disabled_features:Vector<DisabledFeature> = Config;
|
||||
config#9c840964 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured:flags.4?true ignore_phone_entities:flags.5?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int chat_big_size:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string suggested_lang_code:flags.2?string lang_pack_version:flags.2?int disabled_features:Vector<DisabledFeature> = Config;
|
||||
|
||||
nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc;
|
||||
|
||||
@ -555,7 +556,7 @@ accountDaysTTL#b8d0afdf days:int = AccountDaysTTL;
|
||||
documentAttributeImageSize#6c37c15c w:int h:int = DocumentAttribute;
|
||||
documentAttributeAnimated#11b58939 = DocumentAttribute;
|
||||
documentAttributeSticker#6319d612 flags:# mask:flags.1?true alt:string stickerset:InputStickerSet mask_coords:flags.0?MaskCoords = DocumentAttribute;
|
||||
documentAttributeVideo#ef02ce6 flags:# round_message:flags.0?true duration:int w:int h:int = DocumentAttribute;
|
||||
documentAttributeVideo#ef02ce6 flags:# round_message:flags.0?true supports_streaming:flags.1?true duration:int w:int h:int = DocumentAttribute;
|
||||
documentAttributeAudio#9852f9c6 flags:# voice:flags.10?true duration:int title:flags.0?string performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute;
|
||||
documentAttributeFilename#15590068 file_name:string = DocumentAttribute;
|
||||
documentAttributeHasStickers#9801d2f7 = DocumentAttribute;
|
||||
@ -644,6 +645,8 @@ messageEntityPre#73924be0 offset:int length:int language:string = MessageEntity;
|
||||
messageEntityTextUrl#76a6d327 offset:int length:int url:string = MessageEntity;
|
||||
messageEntityMentionName#352dca58 offset:int length:int user_id:int = MessageEntity;
|
||||
inputMessageEntityMentionName#208e68c9 offset:int length:int user_id:InputUser = MessageEntity;
|
||||
messageEntityPhone#9b69e34b offset:int length:int = MessageEntity;
|
||||
messageEntityCashtag#4c4e743f offset:int length:int = MessageEntity;
|
||||
|
||||
inputChannelEmpty#ee8c1e86 = InputChannel;
|
||||
inputChannel#afeb712e channel_id:int access_hash:long = InputChannel;
|
||||
@ -937,7 +940,7 @@ recentMeUrlStickerSet#bc0a57dc url:string set:StickerSetCovered = RecentMeUrl;
|
||||
|
||||
help.recentMeUrls#e0310d7 urls:Vector<RecentMeUrl> chats:Vector<Chat> users:Vector<User> = help.RecentMeUrls;
|
||||
|
||||
inputSingleMedia#31bc3d25 media:InputMedia flags:# random_id:long message:string entities:flags.0?Vector<MessageEntity> = InputSingleMedia;
|
||||
inputSingleMedia#1cc6e91f flags:# media:InputMedia random_id:long message:string entities:flags.0?Vector<MessageEntity> = InputSingleMedia;
|
||||
|
||||
feedPosition#5059dc73 date:int peer:Peer id:int = FeedPosition;
|
||||
|
||||
@ -960,6 +963,10 @@ webAuthorization#cac943f2 hash:long bot_id:int domain:string browser:string plat
|
||||
|
||||
account.webAuthorizations#ed56c9fc authorizations:Vector<WebAuthorization> users:Vector<User> = account.WebAuthorizations;
|
||||
|
||||
inputMessageID#a676a322 id:int = InputMessage;
|
||||
inputMessageReplyTo#bad88395 id:int = InputMessage;
|
||||
inputMessagePinned#86872538 = InputMessage;
|
||||
|
||||
---functions---
|
||||
|
||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||
@ -1036,7 +1043,7 @@ contacts.getTopPeers#d4982db5 flags:# correspondents:flags.0?true bots_pm:flags.
|
||||
contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = Bool;
|
||||
contacts.resetSaved#879537f1 = Bool;
|
||||
|
||||
messages.getMessages#4222fa74 id:Vector<int> = messages.Messages;
|
||||
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
|
||||
messages.getDialogs#5c0fae2 flags:# exclude_pinned:flags.0?true feed_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int = messages.Dialogs;
|
||||
messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
|
||||
messages.search#8614ef68 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
|
||||
@ -1164,7 +1171,7 @@ channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool;
|
||||
channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector<int> = messages.AffectedMessages;
|
||||
channels.deleteUserHistory#d10dd71b channel:InputChannel user_id:InputUser = messages.AffectedHistory;
|
||||
channels.reportSpam#fe087810 channel:InputChannel user_id:InputUser id:Vector<int> = Bool;
|
||||
channels.getMessages#93d7b347 channel:InputChannel id:Vector<int> = messages.Messages;
|
||||
channels.getMessages#ad8c9a23 channel:InputChannel id:Vector<InputMessage> = messages.Messages;
|
||||
channels.getParticipants#123e05e9 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:int = channels.ChannelParticipants;
|
||||
channels.getParticipant#546dd7a6 channel:InputChannel user_id:InputUser = channels.ChannelParticipant;
|
||||
channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
|
||||
|
@ -224,12 +224,12 @@ void ApiWrap::requestMessageData(ChannelData *channel, MsgId msgId, RequestMessa
|
||||
if (!req.requestId) _messageDataResolveDelayed.call();
|
||||
}
|
||||
|
||||
QVector<MTPint> ApiWrap::collectMessageIds(const MessageDataRequests &requests) {
|
||||
auto result = QVector<MTPint>();
|
||||
QVector<MTPInputMessage> ApiWrap::collectMessageIds(const MessageDataRequests &requests) {
|
||||
auto result = QVector<MTPInputMessage>();
|
||||
result.reserve(requests.size());
|
||||
for (auto i = requests.cbegin(), e = requests.cend(); i != e; ++i) {
|
||||
if (i.value().requestId > 0) continue;
|
||||
result.push_back(MTP_int(i.key()));
|
||||
result.push_back(MTP_inputMessageID(MTP_int(i.key())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -252,7 +252,7 @@ void ApiWrap::resolveMessageDatas() {
|
||||
auto ids = collectMessageIds(_messageDataRequests);
|
||||
if (!ids.isEmpty()) {
|
||||
auto requestId = request(MTPmessages_GetMessages(
|
||||
MTP_vector<MTPint>(ids)
|
||||
MTP_vector<MTPInputMessage>(ids)
|
||||
)).done([this](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
||||
gotMessageDatas(nullptr, result, requestId);
|
||||
}).fail([this](const RPCError &error, mtpRequestId requestId) {
|
||||
@ -273,7 +273,7 @@ void ApiWrap::resolveMessageDatas() {
|
||||
auto channel = j.key();
|
||||
auto requestId = request(MTPchannels_GetMessages(
|
||||
j.key()->inputChannel,
|
||||
MTP_vector<MTPint>(ids)
|
||||
MTP_vector<MTPInputMessage>(ids)
|
||||
)).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
||||
gotMessageDatas(channel, result, requestId);
|
||||
}).fail([=](const RPCError &error, mtpRequestId requestId) {
|
||||
@ -1920,8 +1920,8 @@ void ApiWrap::clearWebPageRequests() {
|
||||
}
|
||||
|
||||
void ApiWrap::resolveWebPages() {
|
||||
auto ids = QVector<MTPint>(); // temp_req_id = -1
|
||||
using IndexAndMessageIds = QPair<int32, QVector<MTPint>>;
|
||||
auto ids = QVector<MTPInputMessage>(); // temp_req_id = -1
|
||||
using IndexAndMessageIds = QPair<int32, QVector<MTPInputMessage>>;
|
||||
using MessageIdsByChannel = QMap<ChannelData*, IndexAndMessageIds>;
|
||||
MessageIdsByChannel idsByChannel; // temp_req_id = -index - 2
|
||||
|
||||
@ -1933,7 +1933,7 @@ void ApiWrap::resolveWebPages() {
|
||||
const auto item = _session->data().findWebPageItem(i.key());
|
||||
if (item) {
|
||||
if (item->channelId() == NoChannel) {
|
||||
ids.push_back(MTP_int(item->id));
|
||||
ids.push_back(MTP_inputMessageID(MTP_int(item->id)));
|
||||
i.value() = -1;
|
||||
} else {
|
||||
auto channel = item->history()->peer->asChannel();
|
||||
@ -1943,9 +1943,12 @@ void ApiWrap::resolveWebPages() {
|
||||
channel,
|
||||
IndexAndMessageIds(
|
||||
idsByChannel.size(),
|
||||
QVector<MTPint>(1, MTP_int(item->id))));
|
||||
QVector<MTPInputMessage>(
|
||||
1,
|
||||
MTP_inputMessageID(MTP_int(item->id)))));
|
||||
} else {
|
||||
channelMap.value().second.push_back(MTP_int(item->id));
|
||||
channelMap.value().second.push_back(
|
||||
MTP_inputMessageID(MTP_int(item->id)));
|
||||
}
|
||||
i.value() = -channelMap.value().first - 2;
|
||||
}
|
||||
@ -1957,13 +1960,18 @@ void ApiWrap::resolveWebPages() {
|
||||
|
||||
auto requestId = mtpRequestId(0);
|
||||
if (!ids.isEmpty()) {
|
||||
requestId = request(MTPmessages_GetMessages(MTP_vector<MTPint>(ids))).done([this](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
||||
requestId = request(MTPmessages_GetMessages(
|
||||
MTP_vector<MTPInputMessage>(ids)
|
||||
)).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
||||
gotWebPages(nullptr, result, requestId);
|
||||
}).afterDelay(kSmallDelayMs).send();
|
||||
}
|
||||
QVector<mtpRequestId> reqsByIndex(idsByChannel.size(), 0);
|
||||
for (auto i = idsByChannel.cbegin(), e = idsByChannel.cend(); i != e; ++i) {
|
||||
reqsByIndex[i.value().first] = request(MTPchannels_GetMessages(i.key()->inputChannel, MTP_vector<MTPint>(i.value().second))).done([this, channel = i.key()](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
||||
reqsByIndex[i.value().first] = request(MTPchannels_GetMessages(
|
||||
i.key()->inputChannel,
|
||||
MTP_vector<MTPInputMessage>(i.value().second)
|
||||
)).done([=, channel = i.key()](const MTPmessages_Messages &result, mtpRequestId requestId) {
|
||||
gotWebPages(channel, result, requestId);
|
||||
}).afterDelay(kSmallDelayMs).send();
|
||||
}
|
||||
@ -3655,8 +3663,8 @@ void ApiWrap::sendAlbumWithUploaded(
|
||||
: MTPDinputSingleMedia::Flag(0);
|
||||
|
||||
itemIt->media = MTP_inputSingleMedia(
|
||||
media,
|
||||
MTP_flags(flags),
|
||||
media,
|
||||
MTP_long(randomId),
|
||||
MTP_string(caption.text),
|
||||
sentEntities);
|
||||
|
@ -280,7 +280,7 @@ private:
|
||||
ChannelData *channel,
|
||||
mtpRequestId requestId);
|
||||
|
||||
QVector<MTPint> collectMessageIds(const MessageDataRequests &requests);
|
||||
QVector<MTPInputMessage> collectMessageIds(const MessageDataRequests &requests);
|
||||
MessageDataRequests *messageDataRequests(ChannelData *channel, bool onlyExisting = false);
|
||||
void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs);
|
||||
void historyDialogEntryApplied(not_null<History*> history);
|
||||
|
@ -65,6 +65,20 @@ bool UrlRequiresConfirmation(const QUrl &url) {
|
||||
|
||||
} // namespace
|
||||
|
||||
UrlClickHandler::UrlClickHandler(const QString &url, bool fullDisplayed)
|
||||
: TextClickHandler(fullDisplayed)
|
||||
, _originalUrl(url) {
|
||||
if (isEmail()) {
|
||||
_readable = _originalUrl;
|
||||
} else {
|
||||
const auto original = QUrl(_originalUrl);
|
||||
const auto good = QUrl(original.isValid()
|
||||
? original.toEncoded()
|
||||
: QString());
|
||||
_readable = good.isValid() ? good.toDisplayString() : _originalUrl;
|
||||
}
|
||||
}
|
||||
|
||||
QString UrlClickHandler::copyToClipboardContextItemText() const {
|
||||
return lang(isEmail() ? lng_context_copy_email : lng_context_copy_link);
|
||||
}
|
||||
@ -230,6 +244,23 @@ TextWithEntities HashtagClickHandler::getExpandedLinkTextWithEntities(ExpandLink
|
||||
return simpleTextWithEntity({ EntityInTextHashtag, entityOffset, textPart.size() });
|
||||
}
|
||||
|
||||
QString CashtagClickHandler::copyToClipboardContextItemText() const {
|
||||
return lang(lng_context_copy_hashtag);
|
||||
}
|
||||
|
||||
void CashtagClickHandler::onClick(Qt::MouseButton button) const {
|
||||
if (button == Qt::LeftButton || button == Qt::MiddleButton) {
|
||||
App::searchByHashtag(_tag, Ui::getPeerForMouseAction());
|
||||
}
|
||||
}
|
||||
|
||||
TextWithEntities CashtagClickHandler::getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const {
|
||||
return simpleTextWithEntity({ EntityInTextCashtag, entityOffset, textPart.size() });
|
||||
}
|
||||
|
||||
PeerData *BotCommandClickHandler::_peer = nullptr;
|
||||
UserData *BotCommandClickHandler::_bot = nullptr;
|
||||
void BotCommandClickHandler::onClick(Qt::MouseButton button) const {
|
||||
|
@ -12,7 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
class TextClickHandler : public ClickHandler {
|
||||
public:
|
||||
|
||||
TextClickHandler(bool fullDisplayed = true) : _fullDisplayed(fullDisplayed) {
|
||||
TextClickHandler(bool fullDisplayed = true)
|
||||
: _fullDisplayed(fullDisplayed) {
|
||||
}
|
||||
|
||||
QString copyToClipboardText() const override {
|
||||
@ -39,22 +40,21 @@ protected:
|
||||
|
||||
class UrlClickHandler : public TextClickHandler {
|
||||
public:
|
||||
UrlClickHandler(const QString &url, bool fullDisplayed = true) : TextClickHandler(fullDisplayed), _originalUrl(url) {
|
||||
if (isEmail()) {
|
||||
_readable = _originalUrl;
|
||||
} else {
|
||||
QUrl u(_originalUrl), good(u.isValid() ? u.toEncoded() : QString());
|
||||
_readable = good.isValid() ? good.toDisplayString() : _originalUrl;
|
||||
}
|
||||
}
|
||||
UrlClickHandler(const QString &url, bool fullDisplayed = true);
|
||||
|
||||
QString copyToClipboardContextItemText() const override;
|
||||
|
||||
QString dragText() const override {
|
||||
return url();
|
||||
}
|
||||
|
||||
QString getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const override;
|
||||
QString getExpandedLinkText(
|
||||
ExpandLinksMode mode,
|
||||
const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
static void doOpen(QString url);
|
||||
void onClick(Qt::MouseButton button) const override {
|
||||
@ -99,14 +99,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
QString getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const override;
|
||||
QString getExpandedLinkText(
|
||||
ExpandLinksMode mode,
|
||||
const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
};
|
||||
|
||||
class BotGameUrlClickHandler : public UrlClickHandler {
|
||||
public:
|
||||
BotGameUrlClickHandler(UserData *bot, QString url) : UrlClickHandler(url, false), _bot(bot) {
|
||||
BotGameUrlClickHandler(UserData *bot, QString url)
|
||||
: UrlClickHandler(url, false)
|
||||
, _bot(bot) {
|
||||
}
|
||||
void onClick(Qt::MouseButton button) const override;
|
||||
|
||||
@ -128,7 +135,10 @@ public:
|
||||
|
||||
QString copyToClipboardContextItemText() const override;
|
||||
|
||||
TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
protected:
|
||||
QString url() const override {
|
||||
@ -150,7 +160,10 @@ public:
|
||||
|
||||
void onClick(Qt::MouseButton button) const override;
|
||||
|
||||
TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
QString tooltip() const override;
|
||||
|
||||
@ -174,7 +187,38 @@ public:
|
||||
|
||||
QString copyToClipboardContextItemText() const override;
|
||||
|
||||
TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
protected:
|
||||
QString url() const override {
|
||||
return _tag;
|
||||
}
|
||||
|
||||
private:
|
||||
QString _tag;
|
||||
|
||||
};
|
||||
|
||||
class CashtagClickHandler : public TextClickHandler {
|
||||
public:
|
||||
CashtagClickHandler(const QString &tag) : _tag(tag) {
|
||||
}
|
||||
|
||||
void onClick(Qt::MouseButton button) const override;
|
||||
|
||||
QString dragText() const override {
|
||||
return _tag;
|
||||
}
|
||||
|
||||
QString copyToClipboardContextItemText() const override;
|
||||
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
protected:
|
||||
QString url() const override {
|
||||
@ -206,7 +250,10 @@ public:
|
||||
_bot = bot;
|
||||
}
|
||||
|
||||
TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const override;
|
||||
TextWithEntities getExpandedLinkTextWithEntities(
|
||||
ExpandLinksMode mode,
|
||||
int entityOffset,
|
||||
const QStringRef &textPart) const override;
|
||||
|
||||
protected:
|
||||
QString url() const override {
|
||||
|
@ -157,6 +157,15 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||
return result;
|
||||
};
|
||||
|
||||
auto prepareBotAllowed = [&](const MTPDmessageActionBotAllowed &action) {
|
||||
auto result = PreparedText{};
|
||||
const auto domain = qs(action.vdomain);
|
||||
result.text = lng_action_bot_allowed_from_domain(
|
||||
lt_domain,
|
||||
textcmdLink(qstr("http://") + domain, domain));
|
||||
return result;
|
||||
};
|
||||
|
||||
auto messageText = PreparedText {};
|
||||
|
||||
switch (action.type()) {
|
||||
@ -177,6 +186,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
||||
case mtpc_messageActionPaymentSent: messageText = preparePaymentSentText(); break;
|
||||
case mtpc_messageActionScreenshotTaken: messageText = prepareScreenshotTaken(); break;
|
||||
case mtpc_messageActionCustomAction: messageText = prepareCustomAction(action.c_messageActionCustomAction()); break;
|
||||
case mtpc_messageActionBotAllowed: messageText = prepareBotAllowed(action.c_messageActionBotAllowed()); break;
|
||||
default: messageText.text = lang(lng_message_empty); break;
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,7 @@ public:
|
||||
|| type == EntityInTextEmail
|
||||
|| type == EntityInTextMention
|
||||
|| type == EntityInTextHashtag
|
||||
|| type == EntityInTextCashtag
|
||||
|| type == EntityInTextBotCommand) {
|
||||
linkType = type;
|
||||
linkData = QString(start + waitingEntity->offset(), waitingEntity->length());
|
||||
@ -520,6 +521,7 @@ public:
|
||||
auto type = preparsed.at(i).type();
|
||||
if (((type == EntityInTextMention || type == EntityInTextMentionName) && !parseMentions) ||
|
||||
(type == EntityInTextHashtag && !parseHashtags) ||
|
||||
(type == EntityInTextCashtag && !parseHashtags) ||
|
||||
(type == EntityInTextBotCommand && !parseBotCommands) ||
|
||||
((type == EntityInTextBold || type == EntityInTextItalic || type == EntityInTextCode || type == EntityInTextPre) && !parseMarkdown)) {
|
||||
continue;
|
||||
@ -543,6 +545,7 @@ public:
|
||||
EntityInTextCustomUrl,
|
||||
EntityInTextEmail,
|
||||
EntityInTextHashtag,
|
||||
EntityInTextCashtag,
|
||||
EntityInTextMention,
|
||||
EntityInTextMentionName,
|
||||
EntityInTextBotCommand
|
||||
@ -630,6 +633,9 @@ public:
|
||||
handler = std::make_shared<HashtagClickHandler>(link.data);
|
||||
}
|
||||
break;
|
||||
case EntityInTextCashtag:
|
||||
handler = std::make_shared<CashtagClickHandler>(link.data);
|
||||
break;
|
||||
case EntityInTextMention:
|
||||
if (options.flags & TextTwitterMentions) {
|
||||
handler = std::make_shared<UrlClickHandler>(qsl("https://twitter.com/") + link.data.mid(1), true);
|
||||
|
@ -1449,6 +1449,8 @@ EntitiesInText EntitiesFromMTP(const QVector<MTPMessageEntity> &entities) {
|
||||
case mtpc_messageEntityTextUrl: { auto &d = entity.c_messageEntityTextUrl(); result.push_back(EntityInText(EntityInTextCustomUrl, d.voffset.v, d.vlength.v, Clean(qs(d.vurl)))); } break;
|
||||
case mtpc_messageEntityEmail: { auto &d = entity.c_messageEntityEmail(); result.push_back(EntityInText(EntityInTextEmail, d.voffset.v, d.vlength.v)); } break;
|
||||
case mtpc_messageEntityHashtag: { auto &d = entity.c_messageEntityHashtag(); result.push_back(EntityInText(EntityInTextHashtag, d.voffset.v, d.vlength.v)); } break;
|
||||
case mtpc_messageEntityCashtag: { auto &d = entity.c_messageEntityCashtag(); result.push_back(EntityInText(EntityInTextCashtag, d.voffset.v, d.vlength.v)); } break;
|
||||
case mtpc_messageEntityPhone: break; // Skipping phones.
|
||||
case mtpc_messageEntityMention: { auto &d = entity.c_messageEntityMention(); result.push_back(EntityInText(EntityInTextMention, d.voffset.v, d.vlength.v)); } break;
|
||||
case mtpc_messageEntityMentionName: {
|
||||
auto &d = entity.c_messageEntityMentionName();
|
||||
@ -1509,6 +1511,7 @@ MTPVector<MTPMessageEntity> EntitiesToMTP(const EntitiesInText &entities, Conver
|
||||
case EntityInTextCustomUrl: v.push_back(MTP_messageEntityTextUrl(offset, length, MTP_string(entity.data()))); break;
|
||||
case EntityInTextEmail: v.push_back(MTP_messageEntityEmail(offset, length)); break;
|
||||
case EntityInTextHashtag: v.push_back(MTP_messageEntityHashtag(offset, length)); break;
|
||||
case EntityInTextCashtag: v.push_back(MTP_messageEntityCashtag(offset, length)); break;
|
||||
case EntityInTextMention: v.push_back(MTP_messageEntityMention(offset, length)); break;
|
||||
case EntityInTextMentionName: {
|
||||
auto inputUser = ([](const QString &data) -> MTPInputUser {
|
||||
|
@ -14,6 +14,7 @@ enum EntityInTextType {
|
||||
EntityInTextCustomUrl,
|
||||
EntityInTextEmail,
|
||||
EntityInTextHashtag,
|
||||
EntityInTextCashtag,
|
||||
EntityInTextMention,
|
||||
EntityInTextMentionName,
|
||||
EntityInTextBotCommand,
|
||||
|
Loading…
Reference in New Issue
Block a user