diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 4d14538..e5e0f31 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -11412,15 +11412,25 @@ td::Status Client::process_get_available_gifts_query(PromisedQueryPtr &query) { td::Status Client::process_send_gift_query(PromisedQueryPtr &query) { auto gift_id = td::to_integer(query->arg("gift_id")); auto pay_for_upgrade = to_bool(query->arg("pay_for_upgrade")); - TRY_RESULT(user_id, get_user_id(query.get())); TRY_RESULT(text, get_formatted_text(query->arg("text").str(), query->arg("text_parse_mode").str(), get_input_entities(query.get(), "text_entities"))); - check_user(user_id, std::move(query), - [this, gift_id, pay_for_upgrade, user_id, text = std::move(text)](PromisedQueryPtr query) mutable { - send_request(make_object(gift_id, make_object(user_id), - std::move(text), false, pay_for_upgrade), - td::make_unique(std::move(query))); - }); + if (query->has_arg("chat_id") && !query->arg("chat_id").empty()) { + auto chat_id = query->arg("chat_id"); + check_chat(chat_id, AccessRights::Read, std::move(query), + [this, gift_id, pay_for_upgrade, text = std::move(text)](int64 chat_id, PromisedQueryPtr query) mutable { + send_request(make_object(gift_id, make_object(chat_id), + std::move(text), false, pay_for_upgrade), + td::make_unique(std::move(query))); + }); + } else { + TRY_RESULT(user_id, get_user_id(query.get())); + check_user(user_id, std::move(query), + [this, gift_id, pay_for_upgrade, user_id, text = std::move(text)](PromisedQueryPtr query) mutable { + send_request(make_object(gift_id, make_object(user_id), + std::move(text), false, pay_for_upgrade), + td::make_unique(std::move(query))); + }); + } return td::Status::OK(); }