Add messageDice.need_success_animation.
GitOrigin-RevId: 1c308f71d628d896321ce331c634a6868f504bc0
This commit is contained in:
parent
c1a5285b47
commit
8109988247
@ -1385,7 +1385,8 @@ messageContact contact:contact = MessageContent;
|
|||||||
//@final_state_sticker The animated sticker with the final dice animation; may be null if unknown. updateMessageContent will be sent when the sticker became known
|
//@final_state_sticker The animated sticker with the final dice animation; may be null if unknown. updateMessageContent will be sent when the sticker became known
|
||||||
//@emoji Emoji on which the dice throw animation is based
|
//@emoji Emoji on which the dice throw animation is based
|
||||||
//@value The dice value. If the value is 0, the dice don't have final state yet
|
//@value The dice value. If the value is 0, the dice don't have final state yet
|
||||||
messageDice initial_state_sticker:sticker final_state_sticker:sticker emoji:string value:int32 = MessageContent;
|
//@need_success_animation True, if a success animation like a shower of confetti needs to be shown on updateMessageSendSucceeded
|
||||||
|
messageDice initial_state_sticker:sticker final_state_sticker:sticker emoji:string value:int32 need_success_animation:Bool = MessageContent;
|
||||||
|
|
||||||
//@description A message with a game @game The game description
|
//@description A message with a game @game The game description
|
||||||
messageGame game:game = MessageContent;
|
messageGame game:game = MessageContent;
|
||||||
|
Binary file not shown.
@ -1292,6 +1292,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
string wallet_config;
|
string wallet_config;
|
||||||
string ignored_restriction_reasons;
|
string ignored_restriction_reasons;
|
||||||
string dice_emojis;
|
string dice_emojis;
|
||||||
|
string dice_success_values;
|
||||||
if (config->get_id() == telegram_api::jsonObject::ID) {
|
if (config->get_id() == telegram_api::jsonObject::ID) {
|
||||||
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
||||||
Slice key = key_value->key_;
|
Slice key = key_value->key_;
|
||||||
@ -1363,6 +1364,26 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (key == "emojies_send_dice_success") {
|
||||||
|
if (value->get_id() == telegram_api::jsonArray::ID) {
|
||||||
|
auto success_values = std::move(static_cast<telegram_api::jsonArray *>(value)->value_);
|
||||||
|
for (auto &success_value : success_values) {
|
||||||
|
CHECK(success_value != nullptr);
|
||||||
|
if (success_value->get_id() == telegram_api::jsonNumber::ID) {
|
||||||
|
int32 dice_value = static_cast<int32>(static_cast<telegram_api::jsonNumber *>(success_value.get())->value_);
|
||||||
|
if (!dice_success_values.empty()) {
|
||||||
|
dice_success_values += ',';
|
||||||
|
}
|
||||||
|
dice_success_values += to_string(dice_value);
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive unexpected dice success value " << to_string(success_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive unexpected emojies_send_dice_success " << to_string(*value);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
new_values.push_back(std::move(key_value));
|
new_values.push_back(std::move(key_value));
|
||||||
}
|
}
|
||||||
@ -1397,6 +1418,9 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
if (!dice_emojis.empty()) {
|
if (!dice_emojis.empty()) {
|
||||||
shared_config.set_option_string("dice_emojis", dice_emojis);
|
shared_config.set_option_string("dice_emojis", dice_emojis);
|
||||||
}
|
}
|
||||||
|
if (!dice_success_values.empty()) {
|
||||||
|
shared_config.set_option_string("dice_success_values", dice_success_values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -4499,8 +4499,9 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
|||||||
auto initial_state = td->stickers_manager_->get_dice_sticker_object(m->emoji, 0);
|
auto initial_state = td->stickers_manager_->get_dice_sticker_object(m->emoji, 0);
|
||||||
auto final_state =
|
auto final_state =
|
||||||
m->dice_value == 0 ? nullptr : td->stickers_manager_->get_dice_sticker_object(m->emoji, m->dice_value);
|
m->dice_value == 0 ? nullptr : td->stickers_manager_->get_dice_sticker_object(m->emoji, m->dice_value);
|
||||||
|
auto need_success_animation = td->stickers_manager_->need_dice_success_animation(m->emoji, m->dice_value);
|
||||||
return make_tl_object<td_api::messageDice>(std::move(initial_state), std::move(final_state), m->emoji,
|
return make_tl_object<td_api::messageDice>(std::move(initial_state), std::move(final_state), m->emoji,
|
||||||
m->dice_value);
|
m->dice_value, need_success_animation);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -1377,6 +1377,21 @@ tl_object_ptr<td_api::sticker> StickersManager::get_dice_sticker_object(const st
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StickersManager::need_dice_success_animation(const string &emoji, int32 value) const {
|
||||||
|
if (td_->auth_manager_->is_bot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (value == 0 || !td::contains(dice_emojis_, emoji)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto pos = static_cast<size_t>(std::find(dice_emojis_.begin(), dice_emojis_.end(), emoji) - dice_emojis_.begin());
|
||||||
|
if (pos >= dice_success_values_.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dice_success_values_[pos] == value;
|
||||||
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::stickerSet> StickersManager::get_sticker_set_object(StickerSetId sticker_set_id) const {
|
tl_object_ptr<td_api::stickerSet> StickersManager::get_sticker_set_object(StickerSetId sticker_set_id) const {
|
||||||
const StickerSet *sticker_set = get_sticker_set(sticker_set_id);
|
const StickerSet *sticker_set = get_sticker_set(sticker_set_id);
|
||||||
CHECK(sticker_set != nullptr);
|
CHECK(sticker_set != nullptr);
|
||||||
@ -3370,6 +3385,15 @@ void StickersManager::on_update_dice_emojis() {
|
|||||||
send_closure(G()->td(), &Td::send_update, get_update_dice_emojis_object());
|
send_closure(G()->td(), &Td::send_update, get_update_dice_emojis_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StickersManager::on_update_dice_success_values() {
|
||||||
|
auto dice_success_values_str = G()->shared_config().get_option_string("dice_success_values", "0,0");
|
||||||
|
if (dice_success_values_str == dice_success_values_str_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dice_success_values_str_ = std::move(dice_success_values_str);
|
||||||
|
dice_success_values_ = transform(full_split(dice_success_values_str_, ','), to_integer<int32>);
|
||||||
|
}
|
||||||
|
|
||||||
void StickersManager::on_update_sticker_sets() {
|
void StickersManager::on_update_sticker_sets() {
|
||||||
// TODO better support
|
// TODO better support
|
||||||
archived_sticker_set_ids_[0].clear();
|
archived_sticker_set_ids_[0].clear();
|
||||||
|
@ -54,6 +54,8 @@ class StickersManager : public Actor {
|
|||||||
|
|
||||||
tl_object_ptr<td_api::sticker> get_dice_sticker_object(const string &emoji, int32 value) const;
|
tl_object_ptr<td_api::sticker> get_dice_sticker_object(const string &emoji, int32 value) const;
|
||||||
|
|
||||||
|
bool need_dice_success_animation(const string &emoji, int32 value) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::stickerSet> get_sticker_set_object(StickerSetId sticker_set_id) const;
|
tl_object_ptr<td_api::stickerSet> get_sticker_set_object(StickerSetId sticker_set_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::stickerSets> get_sticker_sets_object(int32 total_count,
|
tl_object_ptr<td_api::stickerSets> get_sticker_sets_object(int32 total_count,
|
||||||
@ -131,6 +133,8 @@ class StickersManager : public Actor {
|
|||||||
|
|
||||||
void on_update_dice_emojis();
|
void on_update_dice_emojis();
|
||||||
|
|
||||||
|
void on_update_dice_success_values();
|
||||||
|
|
||||||
void on_update_sticker_sets();
|
void on_update_sticker_sets();
|
||||||
|
|
||||||
void on_update_sticker_sets_order(bool is_masks, const vector<StickerSetId> &sticker_set_ids);
|
void on_update_sticker_sets_order(bool is_masks, const vector<StickerSetId> &sticker_set_ids);
|
||||||
@ -710,6 +714,9 @@ class StickersManager : public Actor {
|
|||||||
|
|
||||||
string dice_emojis_str_;
|
string dice_emojis_str_;
|
||||||
vector<string> dice_emojis_;
|
vector<string> dice_emojis_;
|
||||||
|
|
||||||
|
string dice_success_values_str_;
|
||||||
|
vector<int32> dice_success_values_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -3457,7 +3457,7 @@ bool Td::is_internal_config_option(Slice name) {
|
|||||||
return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" ||
|
return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" ||
|
||||||
name == "channels_read_media_period";
|
name == "channels_read_media_period";
|
||||||
case 'd':
|
case 'd':
|
||||||
return name == "dc_txt_domain_name" || name == "dice_emojis";
|
return name == "dc_txt_domain_name" || name == "dice_emojis" || name == "dice_success_values";
|
||||||
case 'e':
|
case 'e':
|
||||||
return name == "edit_time_limit";
|
return name == "edit_time_limit";
|
||||||
case 'i':
|
case 'i':
|
||||||
@ -3546,6 +3546,8 @@ void Td::on_config_option_updated(const string &name) {
|
|||||||
return send_closure(contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed);
|
return send_closure(contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed);
|
||||||
} else if (name == "dice_emojis") {
|
} else if (name == "dice_emojis") {
|
||||||
return send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_emojis);
|
return send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_emojis);
|
||||||
|
} else if (name == "dice_success_values") {
|
||||||
|
return send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_success_values);
|
||||||
} else if (is_internal_config_option(name)) {
|
} else if (is_internal_config_option(name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user