Rename message TTL to auto-delete timer when appropriate.

This commit is contained in:
levlam 2022-12-28 17:02:41 +03:00
parent a19f55b116
commit 1ff40ce132
10 changed files with 97 additions and 94 deletions

View File

@ -1058,9 +1058,9 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool n
//@reply_in_chat_id If non-zero, the identifier of the chat to which the replied message belongs; Currently, only messages in the Replies chat can have different reply_in_chat_id and chat_id
//@reply_to_message_id If non-zero, the identifier of the message this message is replying to; can be the identifier of a deleted message
//@message_thread_id If non-zero, the identifier of the message thread the message belongs to; unique within the chat to which the message belongs
//@ttl For self-destructing messages, the message's TTL (Time To Live), in seconds; 0 if none. TDLib will send updateDeleteMessages or updateMessageContent once the TTL expires
//@ttl_expires_in Time left before the message expires, in seconds. If the TTL timer isn't started yet, equals to the value of the ttl field
//@auto_delete_in Time left before the message will be automatically deleted by message_ttl setting of the chat, in seconds; 0 if never. TDLib will send updateDeleteMessages or updateMessageContent once the time expires
//@ttl For self-destructing messages, the message's self-destruct timer, in seconds; 0 if none. TDLib will send updateDeleteMessages or updateMessageContent once the time expires
//@ttl_expires_in Time left before the message expires, in seconds. If the self-destruct timer isn't started yet, equals to the value of the ttl field
//@auto_delete_in Time left before the message will be automatically deleted by message_auto_delete_timer setting of the chat, in seconds; 0 if never. TDLib will send updateDeleteMessages or updateMessageContent once the time expires
//@via_bot_user_id If non-zero, the user identifier of the bot through which this message was sent
//@author_signature For channel posts and anonymous group messages, optional author signature
//@media_album_id Unique identifier of an album this message belongs to. Only audios, documents, photos and videos can be grouped together in albums
@ -1283,7 +1283,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
//@unread_reaction_count Number of messages with unread reactions in the chat
//@notification_settings Notification settings for the chat
//@available_reactions Types of reaction, available in the chat
//@message_ttl Current message Time To Live setting (self-destruct timer) for the chat; 0 if not defined. TTL is counted from the time message or its content is viewed in secret chats and from the send date in other chats
//@message_auto_delete_timer Current message auto-delete or self-destruct timer setting for the chat, in seconds; 0 if disabled. Self-destruct timer in secret chats is counted from the time message or its content is viewed. Auto-delete timer in other chats is counted from the send date
//@theme_name If non-empty, name of a theme, set for the chat
//@action_bar Information about actions which must be possible to do through the chat action bar; may be null
//@video_chat Information about video chat of the chat
@ -1291,7 +1291,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
//@draft_message A draft of a message in the chat; may be null
//@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender has_protected_content:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_ttl:int32 theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender has_protected_content:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings available_reactions:ChatAvailableReactions message_auto_delete_timer:int32 theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
//@description Represents a list of chats @total_count Approximate total number of chats found @chat_ids List of chat identifiers
chats total_count:int32 chat_ids:vector<int53> = Chats;
@ -2385,8 +2385,8 @@ messageScreenshotTaken = MessageContent;
//@description A theme in the chat has been changed @theme_name If non-empty, name of a new theme, set for the chat. Otherwise chat theme was reset to the default one
messageChatSetTheme theme_name:string = MessageContent;
//@description The TTL (Time To Live) setting for messages in the chat has been changed @ttl New message TTL @from_user_id If not 0, a user identifier, which default setting was automatically applied
messageChatSetTtl ttl:int32 from_user_id:int53 = MessageContent;
//@description The auto-delete or self-destruct timer setting for messages in the chat has been changed @auto_delete_timer New value auto-delete or self-destruct timer, in seconds; 0 if disabled @from_user_id If not 0, a user identifier, which default setting was automatically applied
messageChatSetMessageAutoDeleteTimer auto_delete_timer:int32 from_user_id:int53 = MessageContent;
//@description A forum topic has been created @name Name of the topic @icon Icon of the topic
messageForumTopicCreated name:string icon:forumTopicIcon = MessageContent;
@ -2605,7 +2605,7 @@ inputMessageDocument document:InputFile thumbnail:inputThumbnail disable_content
//@width Photo width
//@height Photo height
//@caption Photo caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters
//@ttl Photo TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats
//@ttl Photo self-destruct timer, in seconds (0-60). A non-zero self-destruct timer can be specified only in private chats
//@has_spoiler True, if the photo preview must be covered by a spoiler animation; not supported in secret chats
inputMessagePhoto photo:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> width:int32 height:int32 caption:formattedText ttl:int32 has_spoiler:Bool = InputMessageContent;
@ -2626,7 +2626,7 @@ inputMessageSticker sticker:InputFile thumbnail:inputThumbnail width:int32 heigh
//@height Video height
//@supports_streaming True, if the video is supposed to be streamed
//@caption Video caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters
//@ttl Video TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats
//@ttl Video self-destruct timer, in seconds (0-60). A non-zero self-destruct timer can be specified only in private chats
//@has_spoiler True, if the video preview must be covered by a spoiler animation; not supported in secret chats
inputMessageVideo video:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> duration:int32 width:int32 height:int32 supports_streaming:Bool caption:formattedText ttl:int32 has_spoiler:Bool = InputMessageContent;
@ -3484,8 +3484,8 @@ chatEventLinkedChatChanged old_linked_chat_id:int53 new_linked_chat_id:int53 = C
//@description The supergroup location was changed @old_location Previous location; may be null @new_location New location; may be null
chatEventLocationChanged old_location:chatLocation new_location:chatLocation = ChatEventAction;
//@description The message TTL was changed @old_message_ttl Previous value of message_ttl @new_message_ttl New value of message_ttl
chatEventMessageTtlChanged old_message_ttl:int32 new_message_ttl:int32 = ChatEventAction;
//@description The message auto-delete timer was changed @old_message_auto_delete_timer Previous value of message_auto_delete_timer @new_message_auto_delete_timer New value of message_auto_delete_timer
chatEventMessageAutoDeleteTimerChanged old_message_auto_delete_timer:int32 new_message_auto_delete_timer:int32 = ChatEventAction;
//@description The chat permissions was changed @old_permissions Previous chat permissions @new_permissions New chat permissions
chatEventPermissionsChanged old_permissions:chatPermissions new_permissions:chatPermissions = ChatEventAction;
@ -4236,8 +4236,8 @@ userPrivacySettingAllowPrivateVoiceAndVideoNoteMessages = UserPrivacySetting;
accountTtl days:int32 = AccountTtl;
//@description Contains default message Time To Live setting (self-destruct timer) for new chats @ttl Message TTL setting, in seconds. If 0, then messages aren't deleted automatically
messageTtl ttl:int32 = MessageTtl;
//@description Contains default auto-delete timer setting for new chats @auto_delete_timer Message auto-delete timer setting, in seconds. If 0, then messages aren't deleted automatically
messageAutoDeleteTimer auto_delete_timer:int32 = MessageAutoDeleteTimer;
//@class SessionType @description Represents the type of a session
@ -5001,7 +5001,7 @@ updateMessageIsPinned chat_id:int53 message_id:int53 is_pinned:Bool = Update;
//@description The information about interactions with a message has changed @chat_id Chat identifier @message_id Message identifier @interaction_info New information about interactions with the message; may be null
updateMessageInteractionInfo chat_id:int53 message_id:int53 interaction_info:messageInteractionInfo = Update;
//@description The message content was opened. Updates voice note messages to "listened", video note messages to "viewed" and starts the TTL timer for self-destructing messages @chat_id Chat identifier @message_id Message identifier
//@description The message content was opened. Updates voice note messages to "listened", video note messages to "viewed" and starts the self-destruct timer @chat_id Chat identifier @message_id Message identifier
updateMessageContentOpened chat_id:int53 message_id:int53 = Update;
//@description A message with an unread mention was read @chat_id Chat identifier @message_id Message identifier @unread_mention_count The new number of unread mention messages left in the chat
@ -5063,8 +5063,8 @@ updateChatDraftMessage chat_id:int53 draft_message:draftMessage positions:vector
//@description The message sender that is selected to send messages in a chat has changed @chat_id Chat identifier @message_sender_id New value of message_sender_id; may be null if the user can't change message sender
updateChatMessageSender chat_id:int53 message_sender_id:MessageSender = Update;
//@description The message Time To Live setting for a chat was changed @chat_id Chat identifier @message_ttl New value of message_ttl
updateChatMessageTtl chat_id:int53 message_ttl:int32 = Update;
//@description The message auto-delete or self-destruct timer setting for a chat was changed @chat_id Chat identifier @message_auto_delete_timer New value of message_auto_delete_timer
updateChatMessageAutoDeleteTimer chat_id:int53 message_auto_delete_timer:int32 = Update;
//@description Notification settings for a chat were changed @chat_id Chat identifier @notification_settings The new notification settings
updateChatNotificationSettings chat_id:int53 notification_settings:chatNotificationSettings = Update;
@ -6402,17 +6402,17 @@ createSecretChat secret_chat_id:int32 = Chat;
//@description Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. Returns the newly created chat
//@user_ids Identifiers of users to be added to the basic group
//@title Title of the new basic group; 1-128 characters
//@message_ttl Message TTL value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
createNewBasicGroupChat user_ids:vector<int53> title:string message_ttl:int32 = Chat;
//@message_auto_delete_timer Message auto-delete timer value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
createNewBasicGroupChat user_ids:vector<int53> title:string message_auto_delete_timer:int32 = Chat;
//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat
//@title Title of the new chat; 1-128 characters
//@is_channel Pass true to create a channel chat
//@param_description Chat description; 0-255 characters
//@location Chat location if a location-based supergroup is being created; pass null to create an ordinary supergroup chat
//@message_ttl Message TTL value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
//@message_auto_delete_timer Message auto-delete timer value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
//@for_import Pass true to create a supergroup for importing messages using importMessage
createNewSupergroupChat title:string is_channel:Bool description:string location:chatLocation message_ttl:int32 for_import:Bool = Chat;
createNewSupergroupChat title:string is_channel:Bool description:string location:chatLocation message_auto_delete_timer:int32 for_import:Bool = Chat;
//@description Creates a new secret chat. Returns the newly created chat @user_id Identifier of the target user
createNewSecretChat user_id:int53 = Chat;
@ -6461,11 +6461,11 @@ setChatTitle chat_id:int53 title:string = Ok;
//@photo New chat photo; pass null to delete the chat photo
setChatPhoto chat_id:int53 photo:InputChatPhoto = Ok;
//@description Changes the message TTL in a chat. Requires change_info administrator right in basic groups, supergroups and channels
//-Message TTL can't be changed in a chat with the current user (Saved Messages) and the chat 777000 (Telegram).
//@description Changes the message auto-delete or self-destruct (for secret chats) timer in a chat. Requires change_info administrator right in basic groups, supergroups and channels
//-Message auto-delete timer can't be changed in a chat with the current user (Saved Messages) and the chat 777000 (Telegram).
//@chat_id Chat identifier
//@ttl New TTL value, in seconds; unless the chat is secret, it must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
setChatMessageTtl chat_id:int53 ttl:int32 = Ok;
//@message_auto_delete_timer New timer value, in seconds; unless the chat is secret, it must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
setChatMessageAutoDeleteTimer chat_id:int53 message_auto_delete_timer:int32 = Ok;
//@description Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right
//@chat_id Chat identifier
@ -7518,11 +7518,11 @@ getAccountTtl = AccountTtl;
deleteAccount reason:string password:string = Ok;
//@description Changes the default message Time To Live setting (self-destruct timer) for new chats @ttl New message TTL; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
setDefaultMessageTtl ttl:messageTtl = Ok;
//@description Changes the default message auto-delete timer for new chats @message_auto_delete_timer New message auto-delete timer; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
setDefaultMessageAutoDeleteTimer message_auto_delete_timer:messageAutoDeleteTimer = Ok;
//@description Returns default message Time To Live setting (self-destruct timer) for new chats
getDefaultMessageTtl = MessageTtl;
//@description Returns default message auto-delete timer setting for new chats
getDefaultMessageAutoDeleteTimer = MessageAutoDeleteTimer;
//@description Removes a chat action bar without any other action @chat_id Chat identifier

View File

@ -343,8 +343,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeHistoryTTL>(action_ptr);
auto old_value = MessageTtl(clamp(action->prev_value_, 0, 86400 * 366));
auto new_value = MessageTtl(clamp(action->new_value_, 0, 86400 * 366));
return td_api::make_object<td_api::chatEventMessageTtlChanged>(old_value.get_message_ttl_object(),
new_value.get_message_ttl_object());
return td_api::make_object<td_api::chatEventMessageAutoDeleteTimerChanged>(
old_value.get_message_auto_delete_timer_object(), new_value.get_message_auto_delete_timer_object());
}
case telegram_api::channelAdminLogEventActionToggleNoForwards::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleNoForwards>(action_ptr);

View File

@ -5494,7 +5494,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
return make_tl_object<td_api::messageScreenshotTaken>();
case MessageContentType::ChatSetTtl: {
const auto *m = static_cast<const MessageChatSetTtl *>(content);
return make_tl_object<td_api::messageChatSetTtl>(
return make_tl_object<td_api::messageChatSetMessageAutoDeleteTimer>(
m->ttl, td->contacts_manager_->get_user_id_object(m->from_user_id, "MessageChatSetTtl"));
}
case MessageContentType::Call: {

View File

@ -12,7 +12,7 @@ bool MessageTtl::is_empty() const {
return period_ == 0;
}
int32 MessageTtl::get_message_ttl_object() const {
int32 MessageTtl::get_message_auto_delete_timer_object() const {
return period_;
}

View File

@ -32,7 +32,7 @@ class MessageTtl {
bool is_empty() const;
int32 get_message_ttl_object() const;
int32 get_message_auto_delete_timer_object() const;
int32 get_input_ttl_period() const;

View File

@ -21891,7 +21891,7 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(),
d->last_read_outbox_message_id.get(), d->unread_mention_count, d->unread_reaction_count,
get_chat_notification_settings_object(&d->notification_settings), std::move(available_reactions),
d->message_ttl.get_message_ttl_object(), get_dialog_theme_name(d), get_chat_action_bar_object(d),
d->message_ttl.get_message_auto_delete_timer_object(), get_dialog_theme_name(d), get_chat_action_bar_object(d),
get_video_chat_object(d), get_chat_join_requests_info_object(d), d->reply_markup_message_id.get(),
std::move(draft_message), d->client_data);
}
@ -31786,13 +31786,13 @@ void MessagesManager::send_update_chat_message_sender(const Dialog *d) {
td_api::make_object<td_api::updateChatMessageSender>(d->dialog_id.get(), get_default_message_sender_object(d)));
}
void MessagesManager::send_update_chat_message_ttl(const Dialog *d) {
void MessagesManager::send_update_chat_message_auto_delete_timer(const Dialog *d) {
CHECK(d != nullptr);
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_message_ttl";
on_dialog_updated(d->dialog_id, "send_update_chat_message_ttl");
send_closure(
G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatMessageTtl>(d->dialog_id.get(), d->message_ttl.get_message_ttl_object()));
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_message_auto_delete_timer";
on_dialog_updated(d->dialog_id, "send_update_chat_message_auto_delete_timer");
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatMessageAutoDeleteTimer>(
d->dialog_id.get(), d->message_ttl.get_message_auto_delete_timer_object()));
}
void MessagesManager::send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion) {
@ -33293,7 +33293,7 @@ void MessagesManager::set_dialog_message_ttl(Dialog *d, MessageTtl message_ttl)
if (d->message_ttl != message_ttl) {
d->message_ttl = message_ttl;
d->is_message_ttl_inited = true;
send_update_chat_message_ttl(d);
send_update_chat_message_auto_delete_timer(d);
}
if (!d->is_message_ttl_inited) {
d->is_message_ttl_inited = true;

View File

@ -2556,7 +2556,7 @@ class MessagesManager final : public Actor {
void send_update_chat_message_sender(const Dialog *d);
void send_update_chat_message_ttl(const Dialog *d);
void send_update_chat_message_auto_delete_timer(const Dialog *d);
void send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion);

View File

@ -4456,26 +4456,26 @@ void Td::on_request(uint64 id, td_api::setUserPrivacySettingRules &request) {
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getDefaultMessageTtl &request) {
void Td::on_request(uint64 id, const td_api::getDefaultMessageAutoDeleteTimer &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<int32> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
promise.set_value(td_api::make_object<td_api::messageTtl>(result.ok()));
promise.set_value(td_api::make_object<td_api::messageAutoDeleteTimer>(result.ok()));
}
});
get_default_message_ttl(this, std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::setDefaultMessageTtl &request) {
void Td::on_request(uint64 id, const td_api::setDefaultMessageAutoDeleteTimer &request) {
CHECK_IS_USER();
if (request.ttl_ == nullptr) {
if (request.message_auto_delete_timer_ == nullptr) {
return send_error_raw(id, 400, "New default message TTL must be non-empty");
}
CREATE_OK_REQUEST_PROMISE();
set_default_message_ttl(this, request.ttl_->ttl_, std::move(promise));
set_default_message_ttl(this, request.message_auto_delete_timer_->auto_delete_timer_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getAccountTtl &request) {
@ -5701,7 +5701,7 @@ void Td::on_request(uint64 id, td_api::createNewBasicGroupChat &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.title_);
CREATE_REQUEST(CreateNewGroupChatRequest, UserId::get_user_ids(request.user_ids_), std::move(request.title_),
request.message_ttl_);
request.message_auto_delete_timer_);
}
void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
@ -5710,7 +5710,7 @@ void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
CLEAN_INPUT_STRING(request.description_);
CREATE_REQUEST(CreateNewSupergroupChatRequest, std::move(request.title_), !request.is_channel_,
std::move(request.description_), std::move(request.location_), request.for_import_,
request.message_ttl_);
request.message_auto_delete_timer_);
}
void Td::on_request(uint64 id, td_api::createNewSecretChat &request) {
@ -6128,9 +6128,10 @@ void Td::on_request(uint64 id, const td_api::setChatPhoto &request) {
messages_manager_->set_dialog_photo(DialogId(request.chat_id_), request.photo_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setChatMessageTtl &request) {
void Td::on_request(uint64 id, const td_api::setChatMessageAutoDeleteTimer &request) {
CREATE_OK_REQUEST_PROMISE();
messages_manager_->set_dialog_message_ttl(DialogId(request.chat_id_), request.ttl_, std::move(promise));
messages_manager_->set_dialog_message_ttl(DialogId(request.chat_id_), request.message_auto_delete_timer_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setChatPermissions &request) {

View File

@ -470,9 +470,9 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::setUserPrivacySettingRules &request);
void on_request(uint64 id, const td_api::getDefaultMessageTtl &request);
void on_request(uint64 id, const td_api::getDefaultMessageAutoDeleteTimer &request);
void on_request(uint64 id, const td_api::setDefaultMessageTtl &request);
void on_request(uint64 id, const td_api::setDefaultMessageAutoDeleteTimer &request);
void on_request(uint64 id, const td_api::getAccountTtl &request);
@ -892,7 +892,7 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::setChatPhoto &request);
void on_request(uint64 id, const td_api::setChatMessageTtl &request);
void on_request(uint64 id, const td_api::setChatMessageAutoDeleteTimer &request);
void on_request(uint64 id, const td_api::setChatPermissions &request);

View File

@ -2521,12 +2521,13 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setOption>(name, td_api::make_object<td_api::optionValueString>(value)));
} else if (op == "me") {
send_request(td_api::make_object<td_api::getMe>());
} else if (op == "sdmttl") {
int32 ttl;
get_args(args, ttl);
send_request(td_api::make_object<td_api::setDefaultMessageTtl>(td_api::make_object<td_api::messageTtl>(ttl)));
} else if (op == "gdmttl") {
send_request(td_api::make_object<td_api::getDefaultMessageTtl>());
} else if (op == "sdmadt") {
int32 auto_delete_timer;
get_args(args, auto_delete_timer);
send_request(td_api::make_object<td_api::setDefaultMessageAutoDeleteTimer>(
td_api::make_object<td_api::messageAutoDeleteTimer>(auto_delete_timer)));
} else if (op == "gdmadt") {
send_request(td_api::make_object<td_api::getDefaultMessageAutoDeleteTimer>());
} else if (op == "sattl") {
int32 days;
get_args(args, days);
@ -3693,9 +3694,9 @@ class CliClient final : public Actor {
message = string(4097, 'a');
}
if (op[3] == 'p') {
send_message(chat_id,
td_api::make_object<td_api::inputMessagePhoto>(as_local_file("rgb.jpg"), nullptr, Auto(), 0, 0,
as_caption(message), message_ttl_, has_spoiler_));
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
as_local_file("rgb.jpg"), nullptr, Auto(), 0, 0, as_caption(message),
message_auto_delete_timer_, has_spoiler_));
} else {
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true));
}
@ -3714,8 +3715,8 @@ class CliClient final : public Actor {
get_args(args, message_thread_id_);
} else if (op == "shs") {
has_spoiler_ = as_bool(args);
} else if (op == "smttl") {
message_ttl_ = to_integer<int32>(args);
} else if (op == "smadt") {
message_auto_delete_timer_ = to_integer<int32>(args);
} else if (op == "gcams") {
ChatId chat_id;
get_args(args, chat_id);
@ -3771,9 +3772,9 @@ class CliClient final : public Actor {
get_args(args, reply_to_message_id, args);
}
auto input_message_contents = transform(full_split(args), [this](const string &photo) {
td_api::object_ptr<td_api::InputMessageContent> content =
td_api::make_object<td_api::inputMessagePhoto>(as_input_file(photo), nullptr, Auto(), 0, 0, as_caption(""),
rand_bool() ? message_ttl_ : 0, has_spoiler_ && rand_bool());
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessagePhoto>(
as_input_file(photo), nullptr, Auto(), 0, 0, as_caption(""), rand_bool() ? message_auto_delete_timer_ : 0,
has_spoiler_ && rand_bool());
return content;
});
send_request(td_api::make_object<td_api::sendMessageAlbum>(
@ -3852,7 +3853,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::editMessageMedia>(
chat_id, message_id, nullptr,
td_api::make_object<td_api::inputMessagePhoto>(as_input_file(photo), as_input_thumbnail(photo), Auto(), 0, 0,
as_caption(""), message_ttl_, has_spoiler_)));
as_caption(""), message_auto_delete_timer_, has_spoiler_)));
} else if (op == "emvt") {
ChatId chat_id;
MessageId message_id;
@ -3862,7 +3863,8 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::editMessageMedia>(
chat_id, message_id, nullptr,
td_api::make_object<td_api::inputMessageVideo>(as_input_file(video), as_input_thumbnail(thumbnail), Auto(), 1,
2, 3, true, as_caption(""), message_ttl_, has_spoiler_)));
2, 3, true, as_caption(""), message_auto_delete_timer_,
has_spoiler_)));
} else if (op == "emll") {
ChatId chat_id;
MessageId message_id;
@ -4178,7 +4180,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, photo, caption, sticker_file_ids);
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
as_input_file(photo), nullptr, to_integers<int32>(sticker_file_ids), 0, 0,
as_caption(caption), message_ttl_, has_spoiler_));
as_caption(caption), message_auto_delete_timer_, has_spoiler_));
} else if (op == "spg") {
ChatId chat_id;
string photo_path;
@ -4187,7 +4189,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, photo_path, conversion, expected_size);
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
as_generated_file(photo_path, conversion, expected_size), nullptr, vector<int32>(), 0,
0, as_caption(""), message_ttl_, has_spoiler_));
0, as_caption(""), message_auto_delete_timer_, has_spoiler_));
} else if (op == "spt") {
ChatId chat_id;
string photo_path;
@ -4195,7 +4197,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, photo_path, thumbnail_path);
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
as_input_file(photo_path), as_input_thumbnail(thumbnail_path, 90, 89), vector<int32>(),
0, 0, as_caption(""), message_ttl_, has_spoiler_));
0, 0, as_caption(""), message_auto_delete_timer_, has_spoiler_));
} else if (op == "sptg") {
ChatId chat_id;
string photo_path;
@ -4205,7 +4207,7 @@ class CliClient final : public Actor {
send_message(chat_id,
td_api::make_object<td_api::inputMessagePhoto>(
as_input_file(photo_path), as_input_thumbnail(thumbnail_path, thumbnail_conversion, 90, 89),
vector<int32>(), 0, 0, as_caption(""), message_ttl_, has_spoiler_));
vector<int32>(), 0, 0, as_caption(""), message_auto_delete_timer_, has_spoiler_));
} else if (op == "spgtg") {
ChatId chat_id;
string photo_path;
@ -4216,14 +4218,14 @@ class CliClient final : public Actor {
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
as_generated_file(photo_path, conversion),
as_input_thumbnail(thumbnail_path, thumbnail_conversion, 90, 89), vector<int32>(), 0, 0,
as_caption(""), message_ttl_, has_spoiler_));
as_caption(""), message_auto_delete_timer_, has_spoiler_));
} else if (op == "spid") {
ChatId chat_id;
string file_id;
get_args(args, chat_id, file_id);
send_message(chat_id,
td_api::make_object<td_api::inputMessagePhoto>(as_input_file_id(file_id), nullptr, vector<int32>(),
0, 0, as_caption(""), message_ttl_, has_spoiler_));
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(as_input_file_id(file_id), nullptr,
vector<int32>(), 0, 0, as_caption(""),
message_auto_delete_timer_, has_spoiler_));
} else if (op == "ss") {
ChatId chat_id;
string sticker_path;
@ -4255,9 +4257,9 @@ class CliClient final : public Actor {
} else {
sticker_file_ids = to_integers<int32>(sticker_file_ids_str);
}
send_message(chat_id, td_api::make_object<td_api::inputMessageVideo>(as_input_file(video_path), nullptr,
std::move(sticker_file_ids), 1, 2, 3, true,
as_caption(""), message_ttl_, has_spoiler_));
send_message(chat_id, td_api::make_object<td_api::inputMessageVideo>(
as_input_file(video_path), nullptr, std::move(sticker_file_ids), 1, 2, 3, true,
as_caption(""), message_auto_delete_timer_, has_spoiler_));
} else if (op == "svt") {
ChatId chat_id;
string video;
@ -4265,7 +4267,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, video, thumbnail);
send_message(chat_id, td_api::make_object<td_api::inputMessageVideo>(
as_input_file(video), as_input_thumbnail(thumbnail), vector<int32>(), 0, 0, 0, true,
as_caption(""), message_ttl_, has_spoiler_));
as_caption(""), message_auto_delete_timer_, has_spoiler_));
} else if (op == "svn") {
ChatId chat_id;
string video_path;
@ -4315,16 +4317,16 @@ class CliClient final : public Actor {
} else if (op == "cnbgc") {
string user_ids_string;
string title;
int32 message_ttl;
get_args(args, user_ids_string, title, message_ttl);
send_request(
td_api::make_object<td_api::createNewBasicGroupChat>(as_user_ids(user_ids_string), title, message_ttl));
} else if (op == "cnchc" || op == "cnchcttl") {
int32 message_auto_delete_timer;
get_args(args, user_ids_string, title, message_auto_delete_timer);
send_request(td_api::make_object<td_api::createNewBasicGroupChat>(as_user_ids(user_ids_string), title,
message_auto_delete_timer));
} else if (op == "cnchc" || op == "cnchcadt") {
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, true, "Description", nullptr,
op == "cnchcttl" ? 86400 : 0, false));
} else if (op == "cnsgc" || op == "cnsgcttl") {
op == "cnchcadt" ? 86400 : 0, false));
} else if (op == "cnsgc" || op == "cnsgcadt") {
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, "Description", nullptr,
op == "cnsgcttl" ? 86400 : 0, false));
op == "cnsgcadt" ? 86400 : 0, false));
} else if (op == "cnsgcloc") {
send_request(td_api::make_object<td_api::createNewSupergroupChat>(
args, false, "Description",
@ -4434,9 +4436,9 @@ class CliClient final : public Actor {
to_double(main_frame_timestamp))));
} else if (op == "scmt") {
ChatId chat_id;
int32 ttl;
get_args(args, chat_id, ttl);
send_request(td_api::make_object<td_api::setChatMessageTtl>(chat_id, ttl));
int32 auto_delete_timer;
get_args(args, chat_id, auto_delete_timer);
send_request(td_api::make_object<td_api::setChatMessageAutoDeleteTimer>(chat_id, auto_delete_timer));
} else if (op == "scperm") {
ChatId chat_id;
string permissions;
@ -5342,7 +5344,7 @@ class CliClient final : public Actor {
string schedule_date_;
MessageThreadId message_thread_id_;
bool has_spoiler_ = false;
int32 message_ttl_ = 0;
int32 message_auto_delete_timer_ = 0;
int64 opened_chat_id_ = 0;
ConcurrentScheduler *scheduler_{nullptr};