From d64e5077246b36d9b82be18a1ce2205a2d3029da Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 31 Dec 2021 10:25:40 +0300 Subject: [PATCH] tg_cli: use get_args instead of to_integer. --- td/telegram/cli.cpp | 48 +++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index ed0d2c37c..cf71d01ea 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2247,14 +2247,17 @@ class CliClient final : public Actor { } else if (op == "me") { send_request(td_api::make_object()); } else if (op == "sattl") { - send_request( - td_api::make_object(td_api::make_object(to_integer(args)))); + int32 days; + get_args(args, days); + send_request(td_api::make_object(td_api::make_object(days))); } else if (op == "gattl") { send_request(td_api::make_object()); } else if (op == "GetActiveSessions" || op == "devices" || op == "sessions") { send_request(td_api::make_object()); } else if (op == "TerminateSession") { - send_request(td_api::make_object(to_integer(args))); + int64 session_id; + get_args(args, session_id); + send_request(td_api::make_object(session_id)); } else if (op == "TerminateAllOtherSessions") { send_request(td_api::make_object()); } else if (op == "tscac") { @@ -2268,11 +2271,15 @@ class CliClient final : public Actor { get_args(args, session_id, can_accept_secret_chats); send_request(td_api::make_object(session_id, can_accept_secret_chats)); } else if (op == "sist") { - send_request(td_api::make_object(to_integer(args))); + int32 inactive_session_ttl_days; + get_args(args, inactive_session_ttl_days); + send_request(td_api::make_object(inactive_session_ttl_days)); } else if (op == "gcw") { send_request(td_api::make_object()); } else if (op == "dw") { - send_request(td_api::make_object(to_integer(args))); + int64 website_id; + get_args(args, website_id); + send_request(td_api::make_object(website_id)); } else if (op == "daw") { send_request(td_api::make_object()); } else if (op == "gbgs") { @@ -2359,7 +2366,9 @@ class CliClient final : public Actor { td_api::make_object(background_id), get_solid_pattern_background(0xabcdef, 49, true), op == "sbgpidd")); } else if (op == "rbg") { - send_request(td_api::make_object(to_integer(args))); + int64 background_id; + get_args(args, background_id); + send_request(td_api::make_object(background_id)); } else if (op == "rbgs") { send_request(td_api::make_object()); } else if (op == "gcos") { @@ -2396,7 +2405,9 @@ class CliClient final : public Actor { get_args(args, query); send_request(td_api::make_object(query.query, query.limit)); } else if (op == "gss") { - send_request(td_api::make_object(to_integer(args))); + int64 sticker_set_id; + get_args(args, sticker_set_id); + send_request(td_api::make_object(sticker_set_id)); } else if (op == "giss") { send_request(td_api::make_object(as_bool(args))); } else if (op == "gass") { @@ -2414,7 +2425,9 @@ class CliClient final : public Actor { } else if (op == "gatss") { send_request(td_api::make_object(as_file_id(args))); } else if (op == "storage") { - send_request(td_api::make_object(to_integer(args))); + int32 chat_limit; + get_args(args, chat_limit); + send_request(td_api::make_object(chat_limit)); } else if (op == "storage_fast") { send_request(td_api::make_object()); } else if (op == "database") { @@ -2718,9 +2731,9 @@ class CliClient final : public Actor { width, height, scale, as_chat_id(chat_id))); } else if (op == "df" || op == "DownloadFile" || op == "dff" || op == "dfs") { string file_id; - int32 priority; int32 offset; - string limit; + int32 limit; + int32 priority; get_args(args, file_id, offset, limit, priority); if (priority <= 0) { priority = 1; @@ -2728,8 +2741,7 @@ class CliClient final : public Actor { int32 max_file_id = as_file_id(file_id); int32 min_file_id = (op == "dff" ? 1 : max_file_id); for (int32 i = min_file_id; i <= max_file_id; i++) { - send_request( - td_api::make_object(i, priority, offset, to_integer(limit), op == "dfs")); + send_request(td_api::make_object(i, priority, offset, limit, op == "dfs")); } } else if (op == "cdf") { send_request(td_api::make_object(as_file_id(args), false)); @@ -4189,8 +4201,10 @@ class CliClient final : public Actor { get_args(args, url, force_full); send_request(td_api::make_object(url, force_full)); } else if (op == "sppp") { + int64 profile_photo_id; + get_args(args, profile_photo_id); send_request(td_api::make_object( - td_api::make_object(to_integer(args)))); + td_api::make_object(profile_photo_id))); } else if (op == "spp") { send_request(td_api::make_object( td_api::make_object(as_input_file(args)))); @@ -4243,7 +4257,9 @@ class CliClient final : public Actor { send_request(td_api::make_object( args.empty() ? nullptr : td_api::make_object(-1, args))); } else if (op == "dpp") { - send_request(td_api::make_object(to_integer(args))); + int64 profile_photo_id; + get_args(args, profile_photo_id); + send_request(td_api::make_object(profile_photo_id)); } else if (op == "gcnse" || op == "gcnses") { send_request(td_api::make_object( get_notification_settings_scope(args), op == "gcnses")); @@ -4454,7 +4470,9 @@ class CliClient final : public Actor { } else if (op == "gls") { execute(td_api::make_object()); } else if (op == "slvl") { - execute(td_api::make_object(to_integer(args))); + int32 new_verbosity_level; + get_args(args, new_verbosity_level); + execute(td_api::make_object(new_verbosity_level)); } else if (op == "glvl") { execute(td_api::make_object()); } else if (op == "gtags" || op == "glt") {