Add textEntityTypeCustomEmoji.
This commit is contained in:
parent
7cd65d06a1
commit
fb0689545d
@ -2086,6 +2086,9 @@ textEntityTypeTextUrl url:string = TextEntityType;
|
|||||||
//@description A text shows instead of a raw mention of the user (e.g., when the user has no username) @user_id Identifier of the mentioned user
|
//@description A text shows instead of a raw mention of the user (e.g., when the user has no username) @user_id Identifier of the mentioned user
|
||||||
textEntityTypeMentionName user_id:int53 = TextEntityType;
|
textEntityTypeMentionName user_id:int53 = TextEntityType;
|
||||||
|
|
||||||
|
//@description A custom emoji. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji @custom_emoji_id Unique identifier of the custom emoji
|
||||||
|
textEntityTypeCustomEmoji custom_emoji_id:int64 = TextEntityType;
|
||||||
|
|
||||||
//@description A media timestamp @media_timestamp Timestamp from which a video/audio/video note/voice note playing must start, in seconds. The media can be in the content or the web page preview of the current message, or in the same places in the replied message
|
//@description A media timestamp @media_timestamp Timestamp from which a video/audio/video note/voice note playing must start, in seconds. The media can be in the content or the web page preview of the current message, or in the same places in the replied message
|
||||||
textEntityTypeMediaTimestamp media_timestamp:int32 = TextEntityType;
|
textEntityTypeMediaTimestamp media_timestamp:int32 = TextEntityType;
|
||||||
|
|
||||||
|
@ -29,12 +29,27 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
int MessageEntity::get_type_priority(Type type) {
|
int MessageEntity::get_type_priority(Type type) {
|
||||||
static const int priorities[] = {
|
static const int priorities[] = {50 /*Mention*/,
|
||||||
50 /*Mention*/, 50 /*Hashtag*/, 50 /*BotCommand*/, 50 /*Url*/,
|
50 /*Hashtag*/,
|
||||||
50 /*EmailAddress*/, 90 /*Bold*/, 91 /*Italic*/, 20 /*Code*/,
|
50 /*BotCommand*/,
|
||||||
11 /*Pre*/, 10 /*PreCode*/, 49 /*TextUrl*/, 49 /*MentionName*/,
|
50 /*Url*/,
|
||||||
50 /*Cashtag*/, 50 /*PhoneNumber*/, 92 /*Underline*/, 93 /*Strikethrough*/,
|
50 /*EmailAddress*/,
|
||||||
0 /*BlockQuote*/, 50 /*BankCardNumber*/, 50 /*MediaTimestamp*/, 94 /*Spoiler*/};
|
90 /*Bold*/,
|
||||||
|
91 /*Italic*/,
|
||||||
|
20 /*Code*/,
|
||||||
|
11 /*Pre*/,
|
||||||
|
10 /*PreCode*/,
|
||||||
|
49 /*TextUrl*/,
|
||||||
|
49 /*MentionName*/,
|
||||||
|
50 /*Cashtag*/,
|
||||||
|
50 /*PhoneNumber*/,
|
||||||
|
92 /*Underline*/,
|
||||||
|
93 /*Strikethrough*/,
|
||||||
|
0 /*BlockQuote*/,
|
||||||
|
50 /*BankCardNumber*/,
|
||||||
|
50 /*MediaTimestamp*/,
|
||||||
|
94 /*Spoiler*/,
|
||||||
|
99 /*CustomEmoji*/};
|
||||||
static_assert(sizeof(priorities) / sizeof(priorities[0]) == static_cast<size_t>(MessageEntity::Type::Size), "");
|
static_assert(sizeof(priorities) / sizeof(priorities[0]) == static_cast<size_t>(MessageEntity::Type::Size), "");
|
||||||
return priorities[static_cast<int32>(type)];
|
return priorities[static_cast<int32>(type)];
|
||||||
}
|
}
|
||||||
@ -81,6 +96,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageEntity::Ty
|
|||||||
return string_builder << "MediaTimestamp";
|
return string_builder << "MediaTimestamp";
|
||||||
case MessageEntity::Type::Spoiler:
|
case MessageEntity::Type::Spoiler:
|
||||||
return string_builder << "Spoiler";
|
return string_builder << "Spoiler";
|
||||||
|
case MessageEntity::Type::CustomEmoji:
|
||||||
|
return string_builder << "CustomEmoji";
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return string_builder << "Impossible";
|
return string_builder << "Impossible";
|
||||||
@ -146,6 +163,8 @@ tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object
|
|||||||
return make_tl_object<td_api::textEntityTypeMediaTimestamp>(media_timestamp);
|
return make_tl_object<td_api::textEntityTypeMediaTimestamp>(media_timestamp);
|
||||||
case MessageEntity::Type::Spoiler:
|
case MessageEntity::Type::Spoiler:
|
||||||
return make_tl_object<td_api::textEntityTypeSpoiler>();
|
return make_tl_object<td_api::textEntityTypeSpoiler>();
|
||||||
|
case MessageEntity::Type::CustomEmoji:
|
||||||
|
return make_tl_object<td_api::textEntityTypeCustomEmoji>(document_id);
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -1423,7 +1442,8 @@ static constexpr int32 get_continuous_entities_mask() {
|
|||||||
get_entity_type_mask(MessageEntity::Type::MentionName) | get_entity_type_mask(MessageEntity::Type::Cashtag) |
|
get_entity_type_mask(MessageEntity::Type::MentionName) | get_entity_type_mask(MessageEntity::Type::Cashtag) |
|
||||||
get_entity_type_mask(MessageEntity::Type::PhoneNumber) |
|
get_entity_type_mask(MessageEntity::Type::PhoneNumber) |
|
||||||
get_entity_type_mask(MessageEntity::Type::BankCardNumber) |
|
get_entity_type_mask(MessageEntity::Type::BankCardNumber) |
|
||||||
get_entity_type_mask(MessageEntity::Type::MediaTimestamp);
|
get_entity_type_mask(MessageEntity::Type::MediaTimestamp) |
|
||||||
|
get_entity_type_mask(MessageEntity::Type::CustomEmoji);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int32 get_pre_entities_mask() {
|
static constexpr int32 get_pre_entities_mask() {
|
||||||
@ -1434,7 +1454,7 @@ static constexpr int32 get_pre_entities_mask() {
|
|||||||
static constexpr int32 get_user_entities_mask() {
|
static constexpr int32 get_user_entities_mask() {
|
||||||
return get_splittable_entities_mask() | get_blockquote_entities_mask() |
|
return get_splittable_entities_mask() | get_blockquote_entities_mask() |
|
||||||
get_entity_type_mask(MessageEntity::Type::TextUrl) | get_entity_type_mask(MessageEntity::Type::MentionName) |
|
get_entity_type_mask(MessageEntity::Type::TextUrl) | get_entity_type_mask(MessageEntity::Type::MentionName) |
|
||||||
get_pre_entities_mask();
|
get_entity_type_mask(MessageEntity::Type::CustomEmoji) | get_pre_entities_mask();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32 is_splittable_entity(MessageEntity::Type type) {
|
static int32 is_splittable_entity(MessageEntity::Type type) {
|
||||||
@ -1782,6 +1802,8 @@ string get_first_url(Slice text, const vector<MessageEntity> &entities) {
|
|||||||
break;
|
break;
|
||||||
case MessageEntity::Type::Spoiler:
|
case MessageEntity::Type::Spoiler:
|
||||||
break;
|
break;
|
||||||
|
case MessageEntity::Type::CustomEmoji:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -3312,6 +3334,11 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
|
|||||||
case td_api::textEntityTypeSpoiler::ID:
|
case td_api::textEntityTypeSpoiler::ID:
|
||||||
entities.emplace_back(MessageEntity::Type::Spoiler, offset, length);
|
entities.emplace_back(MessageEntity::Type::Spoiler, offset, length);
|
||||||
break;
|
break;
|
||||||
|
case td_api::textEntityTypeCustomEmoji::ID: {
|
||||||
|
auto entity = static_cast<td_api::textEntityTypeCustomEmoji *>(input_entity->type_.get());
|
||||||
|
entities.emplace_back(MessageEntity::Type::CustomEmoji, offset, length, entity->custom_emoji_id_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -3446,8 +3473,11 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
|
|||||||
entities.emplace_back(entity->offset_, entity->length_, user_id);
|
entities.emplace_back(entity->offset_, entity->length_, user_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case telegram_api::messageEntityCustomEmoji::ID:
|
case telegram_api::messageEntityCustomEmoji::ID: {
|
||||||
|
auto entity = static_cast<const telegram_api::messageEntityCustomEmoji *>(server_entity.get());
|
||||||
|
entities.emplace_back(MessageEntity::Type::CustomEmoji, entity->offset_, entity->length_, entity->document_id_);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -4253,6 +4283,10 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
|
|||||||
r_input_user.move_as_ok()));
|
r_input_user.move_as_ok()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MessageEntity::Type::CustomEmoji:
|
||||||
|
result.push_back(
|
||||||
|
make_tl_object<telegram_api::messageEntityCustomEmoji>(entity.offset, entity.length, entity.document_id));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ class MessageEntity {
|
|||||||
BankCardNumber,
|
BankCardNumber,
|
||||||
MediaTimestamp,
|
MediaTimestamp,
|
||||||
Spoiler,
|
Spoiler,
|
||||||
|
CustomEmoji,
|
||||||
Size
|
Size
|
||||||
};
|
};
|
||||||
Type type = Type::Size;
|
Type type = Type::Size;
|
||||||
@ -57,6 +58,7 @@ class MessageEntity {
|
|||||||
int32 media_timestamp = -1;
|
int32 media_timestamp = -1;
|
||||||
string argument;
|
string argument;
|
||||||
UserId user_id;
|
UserId user_id;
|
||||||
|
int64 document_id = 0;
|
||||||
|
|
||||||
MessageEntity() = default;
|
MessageEntity() = default;
|
||||||
|
|
||||||
@ -70,6 +72,10 @@ class MessageEntity {
|
|||||||
: type(type), offset(offset), length(length), media_timestamp(media_timestamp) {
|
: type(type), offset(offset), length(length), media_timestamp(media_timestamp) {
|
||||||
CHECK(type == Type::MediaTimestamp);
|
CHECK(type == Type::MediaTimestamp);
|
||||||
}
|
}
|
||||||
|
MessageEntity(Type type, int32 offset, int32 length, int64 document_id)
|
||||||
|
: type(type), offset(offset), length(length), document_id(document_id) {
|
||||||
|
CHECK(type == Type::CustomEmoji);
|
||||||
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::textEntity> get_text_entity_object() const;
|
tl_object_ptr<td_api::textEntity> get_text_entity_object() const;
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ void MessageEntity::store(StorerT &storer) const {
|
|||||||
if (type == Type::MediaTimestamp) {
|
if (type == Type::MediaTimestamp) {
|
||||||
store(media_timestamp, storer);
|
store(media_timestamp, storer);
|
||||||
}
|
}
|
||||||
|
if (type == Type::CustomEmoji) {
|
||||||
|
store(document_id, storer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
@ -44,6 +47,9 @@ void MessageEntity::parse(ParserT &parser) {
|
|||||||
if (type == Type::MediaTimestamp) {
|
if (type == Type::MediaTimestamp) {
|
||||||
parse(media_timestamp, parser);
|
parse(media_timestamp, parser);
|
||||||
}
|
}
|
||||||
|
if (type == Type::CustomEmoji) {
|
||||||
|
parse(document_id, parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
|
@ -3628,6 +3628,19 @@ class CliClient final : public Actor {
|
|||||||
}
|
}
|
||||||
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true),
|
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true),
|
||||||
op == "sms", false, reply_to_message_id);
|
op == "sms", false, reply_to_message_id);
|
||||||
|
} else if (op == "smce") {
|
||||||
|
ChatId chat_id;
|
||||||
|
get_args(args, chat_id);
|
||||||
|
vector<td_api::object_ptr<td_api::textEntity>> entities;
|
||||||
|
entities.push_back(
|
||||||
|
td_api::make_object<td_api::textEntity>(0, 2, td_api::make_object<td_api::textEntityTypeCustomEmoji>(1)));
|
||||||
|
entities.push_back(
|
||||||
|
td_api::make_object<td_api::textEntity>(3, 2, td_api::make_object<td_api::textEntityTypeCustomEmoji>(2)));
|
||||||
|
entities.push_back(
|
||||||
|
td_api::make_object<td_api::textEntity>(6, 5, td_api::make_object<td_api::textEntityTypeCustomEmoji>(3)));
|
||||||
|
auto text = as_formatted_text("👍 😉 🧑🚒", std::move(entities));
|
||||||
|
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(std::move(text), false, true), false, false,
|
||||||
|
0);
|
||||||
} else if (op == "alm" || op == "almr") {
|
} else if (op == "alm" || op == "almr") {
|
||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
string sender_id;
|
string sender_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user