tg_cli: spvf test command.

GitOrigin-RevId: bf510aedd54e819029a662a27618fd4c07a1dc41
This commit is contained in:
levlam 2018-01-10 19:59:38 +03:00
parent f82ac0be6e
commit ad33af5a2a

View File

@ -284,8 +284,9 @@ class CliClient final : public Actor {
}
int64 get_history_chat_id = 0;
int64 search_chat_id = 0;
void on_get_messages(const td_api::messages &messages) {
if (get_history_chat_id > 0) {
if (get_history_chat_id != 0) {
int64 last_message_id = 0;
for (auto &m : messages.messages_) {
// LOG(PLAIN) << to_string(m);
@ -301,6 +302,17 @@ class CliClient final : public Actor {
get_history_chat_id = 0;
}
}
if (search_chat_id != 0) {
if (!messages.messages_.empty()) {
auto last_message_id = messages.messages_.back()->id_;
LOG(ERROR) << (last_message_id >> 20);
send_request(
make_tl_object<td_api::searchChatMessages>(search_chat_id, "", 0, last_message_id, 0, 100,
make_tl_object<td_api::searchMessagesFilterPhotoAndVideo>()));
} else {
search_chat_id = 0;
}
}
}
void on_get_message(const td_api::message &message) {
@ -1203,6 +1215,11 @@ class CliClient final : public Actor {
send_request(make_tl_object<td_api::getChatHistory>(get_history_chat_id, std::numeric_limits<int64>::max(), 0,
100, false));
} else if (op == "spvf") {
search_chat_id = as_chat_id(args);
send_request(make_tl_object<td_api::searchChatMessages>(
search_chat_id, "", 0, 0, 0, 100, make_tl_object<td_api::searchMessagesFilterPhotoAndVideo>()));
} else if (op == "Search") {
string from_date;
string limit;