From bee924a7a231b0f41803dd9779656c31d42d5728 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 8 Oct 2019 18:19:35 +0300 Subject: [PATCH] tg_cli: more arguments trim. GitOrigin-RevId: ac437108a47582b7a697113b93f26569f47e4d3c --- td/telegram/cli.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index bea56e2df..338fc5a1c 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -452,7 +452,7 @@ class CliClient final : public Actor { } vector as_chat_ids(Slice chat_ids, char delimiter = ' ') const { - return transform(full_split(chat_ids, delimiter), [this](Slice str) { return as_chat_id(str); }); + return transform(full_split(trim(chat_ids), delimiter), [this](Slice str) { return as_chat_id(str); }); } static int64 as_message_id(Slice str) { @@ -464,7 +464,7 @@ class CliClient final : public Actor { } static vector as_message_ids(Slice message_ids, char delimiter = ' ') { - return transform(full_split(message_ids, delimiter), as_message_id); + return transform(full_split(trim(message_ids), delimiter), as_message_id); } int32 as_user_id(Slice str) const { @@ -516,11 +516,11 @@ class CliClient final : public Actor { return static_cast(result); } - static int32 as_file_id(string str) { - return to_integer(trim(std::move(str))); + static int32 as_file_id(Slice str) { + return to_integer(trim(str)); } - static td_api::object_ptr as_input_file_id(string str) { + static td_api::object_ptr as_input_file_id(Slice str) { return td_api::make_object(as_file_id(str)); } @@ -538,10 +538,11 @@ class CliClient final : public Actor { } static tl_object_ptr as_input_file(string str) { + str = trim(str); if ((str.size() >= 20 && is_base64url(str)) || begins_with(str, "http")) { return as_remote_file(str); } - auto r_id = to_integer_safe(trim(str)); + auto r_id = to_integer_safe(str); if (r_id.is_ok()) { return as_input_file_id(str); } @@ -573,7 +574,7 @@ class CliClient final : public Actor { } static bool as_bool(string str) { - str = to_lower(str); + str = to_lower(trim(str)); return str == "true" || str == "1"; }