From ad33af5a2a430591dfb8b7436e1c6e67cf84a3c6 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 10 Jan 2018 19:59:38 +0300 Subject: [PATCH] tg_cli: spvf test command. GitOrigin-RevId: bf510aedd54e819029a662a27618fd4c07a1dc41 --- td/telegram/cli.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index d77c9167a..172820056 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -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(search_chat_id, "", 0, last_message_id, 0, 100, + make_tl_object())); + } 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(get_history_chat_id, std::numeric_limits::max(), 0, 100, false)); + } else if (op == "spvf") { + search_chat_id = as_chat_id(args); + + send_request(make_tl_object( + search_chat_id, "", 0, 0, 0, 100, make_tl_object())); } else if (op == "Search") { string from_date; string limit;