diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 716f34427..47081b348 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -672,8 +672,16 @@ class CliClient final : public Actor { return as_input_thumbnail(as_generated_file(original_path, conversion), width, height); } - static int32 as_call_id(string str) { - return to_integer(trim(std::move(str))); + struct CallId { + int32 call_id = 0; + + operator int32() const { + return call_id; + } + }; + + void get_args(string &args, CallId &arg) const { + arg.call_id = to_integer(trim(args)); } static int32 as_group_call_id(string str) { @@ -2991,18 +2999,21 @@ class CliClient final : public Actor { user_id, td_api::make_object(true, true, 65, 65, vector{"2.6", "3.0"}), rand_bool())); } else if (op == "ac" || op == "AcceptCall") { + CallId call_id; + get_args(args, call_id); send_request(td_api::make_object( - as_call_id(args), - td_api::make_object(true, true, 65, 65, vector{"2.6", "3.0"}))); + call_id, td_api::make_object(true, true, 65, 65, vector{"2.6", "3.0"}))); } else if (op == "scsd") { - send_request(td_api::make_object(as_call_id(args), "abacaba")); + CallId call_id; + get_args(args, call_id); + send_request(td_api::make_object(call_id, "abacaba")); } else if (op == "dc" || op == "DiscardCall") { - string call_id; + CallId call_id; bool is_disconnected; get_args(args, call_id, is_disconnected); - send_request(td_api::make_object(as_call_id(call_id), is_disconnected, 0, rand_bool(), 0)); + send_request(td_api::make_object(call_id, is_disconnected, 0, rand_bool(), 0)); } else if (op == "scr" || op == "SendCallRating") { - string call_id; + CallId call_id; int32 rating; get_args(args, call_id, rating); vector> problems; @@ -3014,10 +3025,12 @@ class CliClient final : public Actor { problems.emplace_back(td_api::make_object()); problems.emplace_back(td_api::make_object()); problems.emplace_back(td_api::make_object()); - send_request(td_api::make_object( - as_call_id(call_id), rating, "Wow, such good call! (TDLib test)", std::move(problems))); + send_request(td_api::make_object(call_id, rating, "Wow, such good call! (TDLib test)", + std::move(problems))); } else if (op == "scdi" || op == "SendCallDebugInformation") { - send_request(td_api::make_object(as_call_id(args), "{}")); + CallId call_id; + get_args(args, call_id); + send_request(td_api::make_object(call_id, "{}")); } else if (op == "gvcap") { ChatId chat_id; get_args(args, chat_id);