tg_cli: simplify message TTL testing.

This commit is contained in:
levlam 2022-12-16 16:36:51 +03:00
parent 0b8e1747a5
commit 9d4517ab26

View File

@ -3686,7 +3686,7 @@ class CliClient final : public Actor {
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), 0, has_spoiler_));
as_caption(message), message_ttl_, has_spoiler_));
} else {
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true));
}
@ -3705,6 +3705,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 == "gcams") {
ChatId chat_id;
get_args(args, chat_id);
@ -3761,7 +3763,7 @@ class CliClient final : public Actor {
}
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(""), 0, has_spoiler_);
as_input_file(photo), nullptr, Auto(), 0, 0, as_caption(""), message_ttl_, has_spoiler_);
return content;
});
send_request(td_api::make_object<td_api::sendMessageAlbum>(
@ -3832,7 +3834,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::inputMessageDocument>(as_input_file(document), nullptr, false, as_caption(""))));
} else if (op == "emp" || op == "empttl") {
} else if (op == "emp") {
ChatId chat_id;
MessageId message_id;
string photo;
@ -3840,7 +3842,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(""), op == "empttl" ? 10 : 0, has_spoiler_)));
as_caption(""), message_ttl_, has_spoiler_)));
} else if (op == "emvt") {
ChatId chat_id;
MessageId message_id;
@ -3850,7 +3852,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::inputMessageVideo>(as_input_file(video), as_input_thumbnail(thumbnail), Auto(), 1,
2, 3, true, as_caption(""), 0, has_spoiler_)));
2, 3, true, as_caption(""), message_ttl_, has_spoiler_)));
} else if (op == "emll") {
ChatId chat_id;
MessageId message_id;
@ -4156,7 +4158,7 @@ class CliClient final : public Actor {
}
send_message(chat_id, td_api::make_object<td_api::inputMessagePoll>(question, std::move(options), op != "spollp",
std::move(poll_type), 0, 0, false));
} else if (op == "sp" || op == "spttl") {
} else if (op == "sp") {
ChatId chat_id;
string photo;
string caption;
@ -4164,8 +4166,8 @@ 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), op == "spttl" ? 10 : 0, has_spoiler_));
} else if (op == "spg" || op == "spgttl") {
as_caption(caption), message_ttl_, has_spoiler_));
} else if (op == "spg") {
ChatId chat_id;
string photo_path;
string conversion;
@ -4173,7 +4175,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(""), op == "spgttl" ? 10 : 0, has_spoiler_));
0, as_caption(""), message_ttl_, has_spoiler_));
} else if (op == "spt") {
ChatId chat_id;
string photo_path;
@ -4181,7 +4183,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(""), 0, has_spoiler_));
0, 0, as_caption(""), message_ttl_, has_spoiler_));
} else if (op == "sptg") {
ChatId chat_id;
string photo_path;
@ -4191,7 +4193,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(""), 0, has_spoiler_));
vector<int32>(), 0, 0, as_caption(""), message_ttl_, has_spoiler_));
} else if (op == "spgtg") {
ChatId chat_id;
string photo_path;
@ -4202,14 +4204,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(""), 0, has_spoiler_));
as_caption(""), message_ttl_, 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(""), 0, has_spoiler_));
0, 0, as_caption(""), message_ttl_, has_spoiler_));
} else if (op == "ss") {
ChatId chat_id;
string sticker_path;
@ -4230,7 +4232,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, file_id, emoji);
send_message(chat_id,
td_api::make_object<td_api::inputMessageSticker>(as_input_file_id(file_id), nullptr, 0, 0, emoji));
} else if (op == "sv" || op == "svttl") {
} else if (op == "sv") {
ChatId chat_id;
string video_path;
string sticker_file_ids_str;
@ -4241,17 +4243,17 @@ 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(""), op == "svttl" ? 10 : 0, has_spoiler_));
} else if (op == "svt" || op == "svtttl") {
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_));
} else if (op == "svt") {
ChatId chat_id;
string video;
string thumbnail;
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(""), op == "svtttl" ? 10 : 0, has_spoiler_));
as_caption(""), message_ttl_, has_spoiler_));
} else if (op == "svn") {
ChatId chat_id;
string video_path;
@ -5322,6 +5324,7 @@ class CliClient final : public Actor {
string schedule_date_;
MessageThreadId message_thread_id_;
bool has_spoiler_ = false;
int32 message_ttl_ = 0;
int64 opened_chat_id_ = 0;
ConcurrentScheduler *scheduler_{nullptr};