mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-11-08 21:37:04 +01:00
Update TDLib to 1.7.8.
This commit is contained in:
parent
9461e3c2ae
commit
0034afbcba
2
td
2
td
@ -1 +1 @@
|
||||
Subproject commit c582ab0bbfaa9ed2566de501f7e03b65a4c3613c
|
||||
Subproject commit 0126cec2686e3b95cc1b6dfb5676d364da0e091b
|
@ -323,7 +323,7 @@ class Client::JsonDatedFiles : public Jsonable {
|
||||
|
||||
class Client::JsonUser : public Jsonable {
|
||||
public:
|
||||
JsonUser(int32 user_id, const Client *client, bool full_bot_info = false)
|
||||
JsonUser(int64 user_id, const Client *client, bool full_bot_info = false)
|
||||
: user_id_(user_id), client_(client), full_bot_info_(full_bot_info) {
|
||||
}
|
||||
void store(JsonValueScope *scope) const {
|
||||
@ -350,14 +350,14 @@ class Client::JsonUser : public Jsonable {
|
||||
}
|
||||
|
||||
private:
|
||||
int32 user_id_;
|
||||
int64 user_id_;
|
||||
const Client *client_;
|
||||
bool full_bot_info_;
|
||||
};
|
||||
|
||||
class Client::JsonUsers : public Jsonable {
|
||||
public:
|
||||
JsonUsers(const td::vector<int32> &user_ids, const Client *client) : user_ids_(user_ids), client_(client) {
|
||||
JsonUsers(const td::vector<int64> &user_ids, const Client *client) : user_ids_(user_ids), client_(client) {
|
||||
}
|
||||
void store(JsonValueScope *scope) const {
|
||||
auto array = scope->enter_array();
|
||||
@ -367,7 +367,7 @@ class Client::JsonUsers : public Jsonable {
|
||||
}
|
||||
|
||||
private:
|
||||
const td::vector<int32> &user_ids_;
|
||||
const td::vector<int64> &user_ids_;
|
||||
const Client *client_;
|
||||
};
|
||||
|
||||
@ -459,7 +459,8 @@ class Client::JsonVectorEntities : public Jsonable {
|
||||
auto array = scope->enter_array();
|
||||
for (auto &entity : entities_) {
|
||||
auto entity_type = entity->type_->get_id();
|
||||
if (entity_type != td_api::textEntityTypeBankCardNumber::ID && entity_type != td_api::textEntityTypeMediaTimestamp::ID) {
|
||||
if (entity_type != td_api::textEntityTypeBankCardNumber::ID &&
|
||||
entity_type != td_api::textEntityTypeMediaTimestamp::ID) {
|
||||
array << JsonEntity(entity.get(), client_);
|
||||
}
|
||||
}
|
||||
@ -1726,7 +1727,7 @@ void Client::JsonMessage::store(JsonValueScope *scope) const {
|
||||
}
|
||||
case td_api::messageChatAddMembers::ID: {
|
||||
auto message_add_members = static_cast<const td_api::messageChatAddMembers *>(message_->content.get());
|
||||
int32 user_id = client_->choose_added_member_id(message_add_members);
|
||||
int64 user_id = client_->choose_added_member_id(message_add_members);
|
||||
if (user_id > 0) {
|
||||
object("new_chat_participant", JsonUser(user_id, client_));
|
||||
object("new_chat_member", JsonUser(user_id, client_));
|
||||
@ -1746,7 +1747,7 @@ void Client::JsonMessage::store(JsonValueScope *scope) const {
|
||||
}
|
||||
case td_api::messageChatDeleteMember::ID: {
|
||||
auto message_delete_member = static_cast<const td_api::messageChatDeleteMember *>(message_->content.get());
|
||||
int32 user_id = message_delete_member->user_id_;
|
||||
int64 user_id = message_delete_member->user_id_;
|
||||
object("left_chat_participant", JsonUser(user_id, client_));
|
||||
object("left_chat_member", JsonUser(user_id, client_));
|
||||
break;
|
||||
@ -1928,7 +1929,7 @@ class Client::JsonMessageId : public Jsonable {
|
||||
|
||||
class Client::JsonInlineQuery : public Jsonable {
|
||||
public:
|
||||
JsonInlineQuery(int64 inline_query_id, int32 sender_user_id, const td_api::location *user_location,
|
||||
JsonInlineQuery(int64 inline_query_id, int64 sender_user_id, const td_api::location *user_location,
|
||||
const td_api::ChatType *chat_type, const td::string &query, const td::string &offset,
|
||||
const Client *client)
|
||||
: inline_query_id_(inline_query_id)
|
||||
@ -1984,7 +1985,7 @@ class Client::JsonInlineQuery : public Jsonable {
|
||||
|
||||
private:
|
||||
int64 inline_query_id_;
|
||||
int32 sender_user_id_;
|
||||
int64 sender_user_id_;
|
||||
const td_api::location *user_location_;
|
||||
const td_api::ChatType *chat_type_;
|
||||
const td::string &query_;
|
||||
@ -1994,7 +1995,7 @@ class Client::JsonInlineQuery : public Jsonable {
|
||||
|
||||
class Client::JsonChosenInlineResult : public Jsonable {
|
||||
public:
|
||||
JsonChosenInlineResult(int32 sender_user_id, const td_api::location *user_location, const td::string &query,
|
||||
JsonChosenInlineResult(int64 sender_user_id, const td_api::location *user_location, const td::string &query,
|
||||
const td::string &result_id, const td::string &inline_message_id, const Client *client)
|
||||
: sender_user_id_(sender_user_id)
|
||||
, user_location_(user_location)
|
||||
@ -2018,7 +2019,7 @@ class Client::JsonChosenInlineResult : public Jsonable {
|
||||
}
|
||||
|
||||
private:
|
||||
int32 sender_user_id_;
|
||||
int64 sender_user_id_;
|
||||
const td_api::location *user_location_;
|
||||
const td::string &query_;
|
||||
const td::string &result_id_;
|
||||
@ -2028,7 +2029,7 @@ class Client::JsonChosenInlineResult : public Jsonable {
|
||||
|
||||
class Client::JsonCallbackQuery : public Jsonable {
|
||||
public:
|
||||
JsonCallbackQuery(int64 callback_query_id, int32 sender_user_id, int64 chat_id, int64 message_id,
|
||||
JsonCallbackQuery(int64 callback_query_id, int64 sender_user_id, int64 chat_id, int64 message_id,
|
||||
const MessageInfo *message_info, int64 chat_instance, td_api::CallbackQueryPayload *payload,
|
||||
const Client *client)
|
||||
: callback_query_id_(callback_query_id)
|
||||
@ -2056,7 +2057,7 @@ class Client::JsonCallbackQuery : public Jsonable {
|
||||
|
||||
private:
|
||||
int64 callback_query_id_;
|
||||
int32 sender_user_id_;
|
||||
int64 sender_user_id_;
|
||||
int64 chat_id_;
|
||||
int64 message_id_;
|
||||
const MessageInfo *message_info_;
|
||||
@ -2067,7 +2068,7 @@ class Client::JsonCallbackQuery : public Jsonable {
|
||||
|
||||
class Client::JsonInlineCallbackQuery : public Jsonable {
|
||||
public:
|
||||
JsonInlineCallbackQuery(int64 callback_query_id, int32 sender_user_id, const td::string &inline_message_id,
|
||||
JsonInlineCallbackQuery(int64 callback_query_id, int64 sender_user_id, const td::string &inline_message_id,
|
||||
int64 chat_instance, td_api::CallbackQueryPayload *payload, const Client *client)
|
||||
: callback_query_id_(callback_query_id)
|
||||
, sender_user_id_(sender_user_id)
|
||||
@ -2088,7 +2089,7 @@ class Client::JsonInlineCallbackQuery : public Jsonable {
|
||||
|
||||
private:
|
||||
int64 callback_query_id_;
|
||||
int32 sender_user_id_;
|
||||
int64 sender_user_id_;
|
||||
const td::string &inline_message_id_;
|
||||
int64 chat_instance_;
|
||||
td_api::CallbackQueryPayload *payload_;
|
||||
@ -2974,7 +2975,7 @@ class Client::TdOnGetEditedMessageCallback : public TdQueryCallback {
|
||||
|
||||
class Client::TdOnGetCallbackQueryMessageCallback : public TdQueryCallback {
|
||||
public:
|
||||
TdOnGetCallbackQueryMessageCallback(Client *client, int32 user_id, int state)
|
||||
TdOnGetCallbackQueryMessageCallback(Client *client, int64 user_id, int state)
|
||||
: client_(client), user_id_(user_id), state_(state) {
|
||||
}
|
||||
|
||||
@ -2993,13 +2994,13 @@ class Client::TdOnGetCallbackQueryMessageCallback : public TdQueryCallback {
|
||||
|
||||
private:
|
||||
Client *client_;
|
||||
int32 user_id_;
|
||||
int64 user_id_;
|
||||
int state_;
|
||||
};
|
||||
|
||||
class Client::TdOnGetStickerSetCallback : public TdQueryCallback {
|
||||
public:
|
||||
TdOnGetStickerSetCallback(Client *client, int64 set_id, int32 new_callback_query_user_id, int64 new_message_chat_id)
|
||||
TdOnGetStickerSetCallback(Client *client, int64 set_id, int64 new_callback_query_user_id, int64 new_message_chat_id)
|
||||
: client_(client)
|
||||
, set_id_(set_id)
|
||||
, new_callback_query_user_id_(new_callback_query_user_id)
|
||||
@ -3025,7 +3026,7 @@ class Client::TdOnGetStickerSetCallback : public TdQueryCallback {
|
||||
private:
|
||||
Client *client_;
|
||||
int64 set_id_;
|
||||
int32 new_callback_query_user_id_;
|
||||
int64 new_callback_query_user_id_;
|
||||
int64 new_message_chat_id_;
|
||||
};
|
||||
|
||||
@ -3539,7 +3540,7 @@ void Client::on_get_edited_message(object_ptr<td_api::message> edited_message) {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::on_get_callback_query_message(object_ptr<td_api::message> message, int32 user_id, int state) {
|
||||
void Client::on_get_callback_query_message(object_ptr<td_api::message> message, int64 user_id, int state) {
|
||||
CHECK(user_id != 0);
|
||||
auto &queue = new_callback_query_queues_[user_id];
|
||||
CHECK(queue.has_active_request_);
|
||||
@ -3573,7 +3574,7 @@ void Client::on_get_callback_query_message(object_ptr<td_api::message> message,
|
||||
process_new_callback_query_queue(user_id, state + 1);
|
||||
}
|
||||
|
||||
void Client::on_get_sticker_set(int64 set_id, int32 new_callback_query_user_id, int64 new_message_chat_id,
|
||||
void Client::on_get_sticker_set(int64 set_id, int64 new_callback_query_user_id, int64 new_message_chat_id,
|
||||
object_ptr<td_api::stickerSet> sticker_set) {
|
||||
if (new_callback_query_user_id != 0) {
|
||||
auto &queue = new_callback_query_queues_[new_callback_query_user_id];
|
||||
@ -3623,7 +3624,7 @@ void Client::check_user_read_access(const UserInfo *user_info, PromisedQueryPtr
|
||||
}
|
||||
|
||||
template <class OnSuccess>
|
||||
void Client::check_user(int32 user_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||
void Client::check_user(int64 user_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||
const UserInfo *user_info = get_user_info(user_id);
|
||||
if (user_info != nullptr) {
|
||||
return check_user_read_access(user_info, std::move(query), std::move(on_success));
|
||||
@ -3633,7 +3634,7 @@ void Client::check_user(int32 user_id, PromisedQueryPtr query, OnSuccess on_succ
|
||||
}
|
||||
|
||||
template <class OnSuccess>
|
||||
void Client::check_user_no_fail(int32 user_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||
void Client::check_user_no_fail(int64 user_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||
const UserInfo *user_info = get_user_info(user_id);
|
||||
if (user_info != nullptr) {
|
||||
on_success(std::move(query));
|
||||
@ -3933,7 +3934,7 @@ void Client::resolve_inline_query_results_bot_usernames(td::vector<object_ptr<td
|
||||
on_success(std::move(results), std::move(query));
|
||||
}
|
||||
|
||||
void Client::on_resolve_bot_username(const td::string &username, int32 user_id) {
|
||||
void Client::on_resolve_bot_username(const td::string &username, int64 user_id) {
|
||||
auto query_ids_it = awaiting_bot_resolve_queries_.find(username);
|
||||
CHECK(query_ids_it != awaiting_bot_resolve_queries_.end());
|
||||
CHECK(!query_ids_it->second.empty());
|
||||
@ -3968,7 +3969,7 @@ void Client::on_resolve_bot_username(const td::string &username, int32 user_id)
|
||||
}
|
||||
|
||||
template <class OnSuccess>
|
||||
void Client::get_chat_member(int64 chat_id, int32 user_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||
void Client::get_chat_member(int64 chat_id, int64 user_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||
check_user_no_fail(
|
||||
user_id, std::move(query),
|
||||
[this, chat_id, user_id, on_success = std::move(on_success)](PromisedQueryPtr query) mutable {
|
||||
@ -4325,17 +4326,15 @@ void Client::on_update(object_ptr<td_api::Object> result) {
|
||||
my_id_ = -1;
|
||||
} else {
|
||||
CHECK(update->value_->get_id() == td_api::optionValueInteger::ID);
|
||||
my_id_ = static_cast<int32>(move_object_as<td_api::optionValueInteger>(update->value_)->value_);
|
||||
my_id_ = move_object_as<td_api::optionValueInteger>(update->value_)->value_;
|
||||
}
|
||||
}
|
||||
if (name == "group_anonymous_bot_user_id" && update->value_->get_id() == td_api::optionValueInteger::ID) {
|
||||
group_anonymous_bot_user_id_ =
|
||||
static_cast<int32>(move_object_as<td_api::optionValueInteger>(update->value_)->value_);
|
||||
group_anonymous_bot_user_id_ = move_object_as<td_api::optionValueInteger>(update->value_)->value_;
|
||||
}
|
||||
if (name == "telegram_service_notifications_chat_id" &&
|
||||
update->value_->get_id() == td_api::optionValueInteger::ID) {
|
||||
service_notifications_user_id_ =
|
||||
static_cast<int32>(move_object_as<td_api::optionValueInteger>(update->value_)->value_);
|
||||
service_notifications_user_id_ = move_object_as<td_api::optionValueInteger>(update->value_)->value_;
|
||||
}
|
||||
if (name == "authorization_date") {
|
||||
if (update->value_->get_id() == td_api::optionValueEmpty::ID) {
|
||||
@ -4635,7 +4634,7 @@ td::Result<td_api::object_ptr<td_api::inlineKeyboardButton>> Client::get_inline_
|
||||
TRY_RESULT(request_write_access, get_json_object_bool_field(login_url_object, "request_write_access"));
|
||||
TRY_RESULT(forward_text, get_json_object_string_field(login_url_object, "forward_text"));
|
||||
|
||||
int32 bot_user_id = 0;
|
||||
int64 bot_user_id = 0;
|
||||
if (bot_username.empty()) {
|
||||
bot_user_id = my_id_;
|
||||
} else {
|
||||
@ -5490,7 +5489,7 @@ td::Result<Client::BotCommandScope> Client::get_bot_command_scope(JsonValue &&va
|
||||
return BotCommandScope(make_object<td_api::botCommandScopeChatAdministrators>(0), std::move(chat_id));
|
||||
}
|
||||
|
||||
TRY_RESULT(user_id, get_json_object_int_field(object, "user_id", false));
|
||||
TRY_RESULT(user_id, get_json_object_long_field(object, "user_id", false));
|
||||
if (user_id <= 0) {
|
||||
return Status::Error(400, "Invalid user_id specified");
|
||||
}
|
||||
@ -5829,7 +5828,7 @@ td::Result<td_api::object_ptr<td_api::TextEntityType>> Client::get_text_entity_t
|
||||
if (type == "text_mention") {
|
||||
TRY_RESULT(user, get_json_object_field(object, "user", JsonValue::Type::Object, false));
|
||||
CHECK(user.type() == JsonValue::Type::Object);
|
||||
TRY_RESULT(user_id, get_json_object_int_field(user.get_object(), "id", false));
|
||||
TRY_RESULT(user_id, get_json_object_long_field(user.get_object(), "id", false));
|
||||
return make_object<td_api::textEntityTypeMentionName>(user_id);
|
||||
}
|
||||
if (type == "mention" || type == "hashtag" || type == "cashtag" || type == "bot_command" || type == "url" ||
|
||||
@ -6186,8 +6185,8 @@ td::Result<td::Slice> Client::get_inline_message_id(const Query *query, Slice fi
|
||||
return s_arg;
|
||||
}
|
||||
|
||||
td::Result<td::int32> Client::get_user_id(const Query *query, Slice field_name) {
|
||||
int32 user_id = get_integer_arg(query, field_name, 0, 0);
|
||||
td::Result<td::int64> Client::get_user_id(const Query *query, Slice field_name) {
|
||||
int64 user_id = td::max(td::to_integer<int64>(query->arg(field_name)), static_cast<int64>(0));
|
||||
if (user_id == 0) {
|
||||
return Status::Error(400, PSLICE() << "Invalid " << field_name << " specified");
|
||||
}
|
||||
@ -6236,9 +6235,9 @@ void Client::on_message_send_succeeded(object_ptr<td_api::message> &&message, in
|
||||
auto &query = pending_send_message_queries_[query_id];
|
||||
if (query.is_multisend) {
|
||||
query.messages.push_back(td::json_encode<td::string>(JsonMessage(message_info, true, "sent message", this)));
|
||||
query.awaited_messages--;
|
||||
query.awaited_message_count--;
|
||||
|
||||
if (query.awaited_messages == 0) {
|
||||
if (query.awaited_message_count == 0) {
|
||||
if (query.error == nullptr) {
|
||||
answer_query(JsonMessages(query.messages), std::move(query.query));
|
||||
} else {
|
||||
@ -6247,7 +6246,7 @@ void Client::on_message_send_succeeded(object_ptr<td_api::message> &&message, in
|
||||
pending_send_message_queries_.erase(query_id);
|
||||
}
|
||||
} else {
|
||||
CHECK(query.awaited_messages == 1);
|
||||
CHECK(query.awaited_message_count == 1);
|
||||
if (query.query->method() == "copymessage") {
|
||||
answer_query(JsonMessageId(new_message_id), std::move(query.query));
|
||||
} else {
|
||||
@ -6266,14 +6265,14 @@ void Client::on_message_send_failed(int64 chat_id, int64 old_message_id, int64 n
|
||||
if (query.error == nullptr) {
|
||||
query.error = std::move(error);
|
||||
}
|
||||
query.awaited_messages--;
|
||||
query.awaited_message_count--;
|
||||
|
||||
if (query.awaited_messages == 0) {
|
||||
if (query.awaited_message_count == 0) {
|
||||
fail_query_with_error(std::move(query.query), std::move(query.error));
|
||||
pending_send_message_queries_.erase(query_id);
|
||||
}
|
||||
} else {
|
||||
CHECK(query.awaited_messages == 1);
|
||||
CHECK(query.awaited_message_count == 1);
|
||||
fail_query_with_error(std::move(query.query), std::move(error));
|
||||
pending_send_message_queries_.erase(query_id);
|
||||
}
|
||||
@ -8030,7 +8029,7 @@ void Client::on_sent_message(object_ptr<td_api::message> &&message, int64 query_
|
||||
yet_unsent_message.send_message_query_id = query_id;
|
||||
auto emplace_result = yet_unsent_messages_.emplace(yet_unsent_message_id, yet_unsent_message);
|
||||
CHECK(emplace_result.second);
|
||||
pending_send_message_queries_[query_id].awaited_messages++;
|
||||
pending_send_message_queries_[query_id].awaited_message_count++;
|
||||
}
|
||||
|
||||
void Client::abort_long_poll(bool from_set_webhook) {
|
||||
@ -8195,7 +8194,7 @@ void Client::long_poll_wakeup(bool force_flag) {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::add_user(std::unordered_map<int32, UserInfo> &users, object_ptr<td_api::user> &&user) {
|
||||
void Client::add_user(std::unordered_map<int64, UserInfo> &users, object_ptr<td_api::user> &&user) {
|
||||
auto user_info = &users[user->id_];
|
||||
user_info->first_name = std::move(user->first_name_);
|
||||
user_info->last_name = std::move(user->last_name_);
|
||||
@ -8228,17 +8227,17 @@ void Client::add_user(std::unordered_map<int32, UserInfo> &users, object_ptr<td_
|
||||
}
|
||||
}
|
||||
|
||||
const Client::UserInfo *Client::get_user_info(int32 user_id) const {
|
||||
const Client::UserInfo *Client::get_user_info(int64 user_id) const {
|
||||
auto it = users_.find(user_id);
|
||||
return it == users_.end() ? nullptr : &it->second;
|
||||
}
|
||||
|
||||
void Client::set_user_bio(int32 user_id, td::string &&bio) {
|
||||
void Client::set_user_bio(int64 user_id, td::string &&bio) {
|
||||
auto user_info = &users_[user_id];
|
||||
user_info->bio = std::move(bio);
|
||||
}
|
||||
|
||||
void Client::add_group(std::unordered_map<int32, GroupInfo> &groups, object_ptr<td_api::basicGroup> &&group) {
|
||||
void Client::add_group(std::unordered_map<int64, GroupInfo> &groups, object_ptr<td_api::basicGroup> &&group) {
|
||||
auto group_info = &groups[group->id_];
|
||||
group_info->member_count = group->member_count_;
|
||||
group_info->left = group->status_->get_id() == td_api::chatMemberStatusLeft::ID;
|
||||
@ -8250,22 +8249,22 @@ void Client::add_group(std::unordered_map<int32, GroupInfo> &groups, object_ptr<
|
||||
}
|
||||
}
|
||||
|
||||
const Client::GroupInfo *Client::get_group_info(int32 group_id) const {
|
||||
const Client::GroupInfo *Client::get_group_info(int64 group_id) const {
|
||||
auto it = groups_.find(group_id);
|
||||
return it == groups_.end() ? nullptr : &it->second;
|
||||
}
|
||||
|
||||
void Client::set_group_description(int32 group_id, td::string &&descripton) {
|
||||
void Client::set_group_description(int64 group_id, td::string &&descripton) {
|
||||
auto group_info = &groups_[group_id];
|
||||
group_info->description = std::move(descripton);
|
||||
}
|
||||
|
||||
void Client::set_group_invite_link(int32 group_id, td::string &&invite_link) {
|
||||
void Client::set_group_invite_link(int64 group_id, td::string &&invite_link) {
|
||||
auto group_info = &groups_[group_id];
|
||||
group_info->invite_link = std::move(invite_link);
|
||||
}
|
||||
|
||||
void Client::add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergroups,
|
||||
void Client::add_supergroup(std::unordered_map<int64, SupergroupInfo> &supergroups,
|
||||
object_ptr<td_api::supergroup> &&supergroup) {
|
||||
auto supergroup_info = &supergroups[supergroup->id_];
|
||||
supergroup_info->username = std::move(supergroup->username_);
|
||||
@ -8275,42 +8274,42 @@ void Client::add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergrou
|
||||
supergroup_info->has_location = supergroup->has_location_;
|
||||
}
|
||||
|
||||
void Client::set_supergroup_description(int32 supergroup_id, td::string &&descripton) {
|
||||
void Client::set_supergroup_description(int64 supergroup_id, td::string &&descripton) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->description = std::move(descripton);
|
||||
}
|
||||
|
||||
void Client::set_supergroup_invite_link(int32 supergroup_id, td::string &&invite_link) {
|
||||
void Client::set_supergroup_invite_link(int64 supergroup_id, td::string &&invite_link) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->invite_link = std::move(invite_link);
|
||||
}
|
||||
|
||||
void Client::set_supergroup_sticker_set_id(int32 supergroup_id, int64 sticker_set_id) {
|
||||
void Client::set_supergroup_sticker_set_id(int64 supergroup_id, int64 sticker_set_id) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->sticker_set_id = sticker_set_id;
|
||||
}
|
||||
|
||||
void Client::set_supergroup_can_set_sticker_set(int32 supergroup_id, bool can_set_sticker_set) {
|
||||
void Client::set_supergroup_can_set_sticker_set(int64 supergroup_id, bool can_set_sticker_set) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->can_set_sticker_set = can_set_sticker_set;
|
||||
}
|
||||
|
||||
void Client::set_supergroup_slow_mode_delay(int32 supergroup_id, int32 slow_mode_delay) {
|
||||
void Client::set_supergroup_slow_mode_delay(int64 supergroup_id, int32 slow_mode_delay) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->slow_mode_delay = slow_mode_delay;
|
||||
}
|
||||
|
||||
void Client::set_supergroup_linked_chat_id(int32 supergroup_id, int64 linked_chat_id) {
|
||||
void Client::set_supergroup_linked_chat_id(int64 supergroup_id, int64 linked_chat_id) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->linked_chat_id = linked_chat_id;
|
||||
}
|
||||
|
||||
void Client::set_supergroup_location(int32 supergroup_id, object_ptr<td_api::chatLocation> location) {
|
||||
void Client::set_supergroup_location(int64 supergroup_id, object_ptr<td_api::chatLocation> location) {
|
||||
auto supergroup_info = &supergroups_[supergroup_id];
|
||||
supergroup_info->location = std::move(location);
|
||||
}
|
||||
|
||||
const Client::SupergroupInfo *Client::get_supergroup_info(int32 supergroup_id) const {
|
||||
const Client::SupergroupInfo *Client::get_supergroup_info(int64 supergroup_id) const {
|
||||
auto it = supergroups_.find(supergroup_id);
|
||||
return it == supergroups_.end() ? nullptr : &it->second;
|
||||
}
|
||||
@ -8643,7 +8642,7 @@ void Client::add_update_poll_answer(object_ptr<td_api::updatePollAnswer> &&updat
|
||||
add_update(UpdateType::PollAnswer, JsonPollAnswer(update.get(), this), 86400, update->poll_id_);
|
||||
}
|
||||
|
||||
void Client::add_new_inline_query(int64 inline_query_id, int32 sender_user_id, object_ptr<td_api::location> location,
|
||||
void Client::add_new_inline_query(int64 inline_query_id, int64 sender_user_id, object_ptr<td_api::location> location,
|
||||
object_ptr<td_api::ChatType> chat_type, const td::string &query,
|
||||
const td::string &offset) {
|
||||
add_update(UpdateType::InlineQuery,
|
||||
@ -8651,7 +8650,7 @@ void Client::add_new_inline_query(int64 inline_query_id, int32 sender_user_id, o
|
||||
sender_user_id + (static_cast<int64>(1) << 33));
|
||||
}
|
||||
|
||||
void Client::add_new_chosen_inline_result(int32 sender_user_id, object_ptr<td_api::location> location,
|
||||
void Client::add_new_chosen_inline_result(int64 sender_user_id, object_ptr<td_api::location> location,
|
||||
const td::string &query, const td::string &result_id,
|
||||
const td::string &inline_message_id) {
|
||||
add_update(UpdateType::ChosenInlineResult,
|
||||
@ -8670,7 +8669,7 @@ void Client::add_new_callback_query(object_ptr<td_api::updateNewCallbackQuery> &
|
||||
process_new_callback_query_queue(user_id, 0);
|
||||
}
|
||||
|
||||
void Client::process_new_callback_query_queue(int32 user_id, int state) {
|
||||
void Client::process_new_callback_query_queue(int64 user_id, int state) {
|
||||
auto &queue = new_callback_query_queues_[user_id];
|
||||
if (queue.has_active_request_) {
|
||||
CHECK(state == 0);
|
||||
@ -8786,7 +8785,7 @@ void Client::add_update_chat_member(object_ptr<td_api::updateChatMember> &&updat
|
||||
}
|
||||
}
|
||||
|
||||
td::int32 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const {
|
||||
td::int64 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const {
|
||||
CHECK(message_add_members != nullptr);
|
||||
for (auto &member_user_id : message_add_members->member_user_ids_) {
|
||||
if (member_user_id == my_id_) {
|
||||
@ -9561,12 +9560,12 @@ td::int32 Client::as_client_message_id(int64 message_id) {
|
||||
return result;
|
||||
}
|
||||
|
||||
td::int64 Client::get_supergroup_chat_id(int32 supergroup_id) {
|
||||
return static_cast<td::int64>(-1000000000000ll) - static_cast<int64>(supergroup_id);
|
||||
td::int64 Client::get_supergroup_chat_id(int64 supergroup_id) {
|
||||
return static_cast<td::int64>(-1000000000000ll) - supergroup_id;
|
||||
}
|
||||
|
||||
td::int64 Client::get_basic_group_chat_id(int32 basic_group_id) {
|
||||
return -static_cast<int64>(basic_group_id);
|
||||
td::int64 Client::get_basic_group_chat_id(int64 basic_group_id) {
|
||||
return -basic_group_id;
|
||||
}
|
||||
|
||||
constexpr Client::int64 Client::GREAT_MINDS_SET_ID;
|
||||
|
@ -191,9 +191,9 @@ class Client : public WebhookActor::Callback {
|
||||
|
||||
void on_get_edited_message(object_ptr<td_api::message> edited_message);
|
||||
|
||||
void on_get_callback_query_message(object_ptr<td_api::message> message, int32 user_id, int state);
|
||||
void on_get_callback_query_message(object_ptr<td_api::message> message, int64 user_id, int state);
|
||||
|
||||
void on_get_sticker_set(int64 set_id, int32 new_callback_query_user_id, int64 new_message_chat_id,
|
||||
void on_get_sticker_set(int64 set_id, int64 new_callback_query_user_id, int64 new_message_chat_id,
|
||||
object_ptr<td_api::stickerSet> sticker_set);
|
||||
|
||||
void on_get_sticker_set_name(int64 set_id, const td::string &name);
|
||||
@ -234,10 +234,10 @@ class Client : public WebhookActor::Callback {
|
||||
class TdOnResolveBotUsernameCallback;
|
||||
|
||||
template <class OnSuccess>
|
||||
void check_user(int32 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||
void check_user(int64 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||
|
||||
template <class OnSuccess>
|
||||
void check_user_no_fail(int32 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||
void check_user_no_fail(int64 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||
|
||||
template <class OnSuccess>
|
||||
static void check_user_read_access(const UserInfo *user_info, PromisedQueryPtr query, OnSuccess on_success);
|
||||
@ -271,7 +271,7 @@ class Client : public WebhookActor::Callback {
|
||||
PromisedQueryPtr query, OnSuccess on_success);
|
||||
|
||||
template <class OnSuccess>
|
||||
void get_chat_member(int64 chat_id, int32 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||
void get_chat_member(int64 chat_id, int64 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||
|
||||
void send_request(object_ptr<td_api::Function> &&f, std::unique_ptr<TdQueryCallback> handler);
|
||||
void do_send_request(object_ptr<td_api::Function> &&f, std::unique_ptr<TdQueryCallback> handler);
|
||||
@ -337,10 +337,10 @@ class Client : public WebhookActor::Callback {
|
||||
struct BotCommandScope {
|
||||
object_ptr<td_api::BotCommandScope> scope_;
|
||||
td::string chat_id_;
|
||||
td::int32 user_id_ = 0;
|
||||
td::int64 user_id_ = 0;
|
||||
|
||||
explicit BotCommandScope(object_ptr<td_api::BotCommandScope> scope, td::string chat_id = td::string(),
|
||||
td::int32 user_id = 0)
|
||||
td::int64 user_id = 0)
|
||||
: scope_(std::move(scope)), chat_id_(std::move(chat_id)), user_id_(user_id) {
|
||||
}
|
||||
};
|
||||
@ -421,7 +421,7 @@ class Client : public WebhookActor::Callback {
|
||||
|
||||
static td::Result<Slice> get_inline_message_id(const Query *query, Slice field_name = Slice("inline_message_id"));
|
||||
|
||||
static td::Result<int32> get_user_id(const Query *query, Slice field_name = Slice("user_id"));
|
||||
static td::Result<int64> get_user_id(const Query *query, Slice field_name = Slice("user_id"));
|
||||
|
||||
int64 extract_yet_unsent_message_query_id(int64 chat_id, int64 message_id, bool *is_reply_to_message_deleted);
|
||||
|
||||
@ -535,7 +535,7 @@ class Client : public WebhookActor::Callback {
|
||||
void fix_inline_query_results_bot_user_ids(td::vector<object_ptr<td_api::InputInlineQueryResult>> &results) const;
|
||||
|
||||
void resolve_bot_usernames(PromisedQueryPtr query, td::Promise<PromisedQueryPtr> on_success);
|
||||
void on_resolve_bot_username(const td::string &username, int32 user_id);
|
||||
void on_resolve_bot_username(const td::string &username, int64 user_id);
|
||||
|
||||
void abort_long_poll(bool from_set_webhook);
|
||||
|
||||
@ -576,9 +576,9 @@ class Client : public WebhookActor::Callback {
|
||||
bool can_read_all_group_messages = false;
|
||||
bool is_inline_bot = false;
|
||||
};
|
||||
static void add_user(std::unordered_map<int32, UserInfo> &users, object_ptr<td_api::user> &&user);
|
||||
void set_user_bio(int32 user_id, td::string &&bio);
|
||||
const UserInfo *get_user_info(int32 user_id) const;
|
||||
static void add_user(std::unordered_map<int64, UserInfo> &users, object_ptr<td_api::user> &&user);
|
||||
void set_user_bio(int64 user_id, td::string &&bio);
|
||||
const UserInfo *get_user_info(int64 user_id) const;
|
||||
|
||||
struct GroupInfo {
|
||||
td::string description;
|
||||
@ -587,12 +587,12 @@ class Client : public WebhookActor::Callback {
|
||||
bool left = false;
|
||||
bool kicked = false;
|
||||
bool is_active = false;
|
||||
int32 upgraded_to_supergroup_id = 0;
|
||||
int64 upgraded_to_supergroup_id = 0;
|
||||
};
|
||||
static void add_group(std::unordered_map<int32, GroupInfo> &groups, object_ptr<td_api::basicGroup> &&group);
|
||||
void set_group_description(int32 group_id, td::string &&descripton);
|
||||
void set_group_invite_link(int32 group_id, td::string &&invite_link);
|
||||
const GroupInfo *get_group_info(int32 group_id) const;
|
||||
static void add_group(std::unordered_map<int64, GroupInfo> &groups, object_ptr<td_api::basicGroup> &&group);
|
||||
void set_group_description(int64 group_id, td::string &&descripton);
|
||||
void set_group_invite_link(int64 group_id, td::string &&invite_link);
|
||||
const GroupInfo *get_group_info(int64 group_id) const;
|
||||
|
||||
struct SupergroupInfo {
|
||||
td::string username;
|
||||
@ -608,16 +608,16 @@ class Client : public WebhookActor::Callback {
|
||||
bool can_set_sticker_set = false;
|
||||
bool has_location = false;
|
||||
};
|
||||
static void add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergroups,
|
||||
static void add_supergroup(std::unordered_map<int64, SupergroupInfo> &supergroups,
|
||||
object_ptr<td_api::supergroup> &&supergroup);
|
||||
void set_supergroup_description(int32 supergroup_id, td::string &&descripton);
|
||||
void set_supergroup_invite_link(int32 supergroup_id, td::string &&invite_link);
|
||||
void set_supergroup_sticker_set_id(int32 supergroup_id, int64 sticker_set_id);
|
||||
void set_supergroup_can_set_sticker_set(int32 supergroup_id, bool can_set_sticker_set);
|
||||
void set_supergroup_slow_mode_delay(int32 supergroup_id, int32 slow_mode_delay);
|
||||
void set_supergroup_linked_chat_id(int32 supergroup_id, int64 linked_chat_id);
|
||||
void set_supergroup_location(int32 supergroup_id, object_ptr<td_api::chatLocation> location);
|
||||
const SupergroupInfo *get_supergroup_info(int32 supergroup_id) const;
|
||||
void set_supergroup_description(int64 supergroup_id, td::string &&descripton);
|
||||
void set_supergroup_invite_link(int64 supergroup_id, td::string &&invite_link);
|
||||
void set_supergroup_sticker_set_id(int64 supergroup_id, int64 sticker_set_id);
|
||||
void set_supergroup_can_set_sticker_set(int64 supergroup_id, bool can_set_sticker_set);
|
||||
void set_supergroup_slow_mode_delay(int64 supergroup_id, int32 slow_mode_delay);
|
||||
void set_supergroup_linked_chat_id(int64 supergroup_id, int64 linked_chat_id);
|
||||
void set_supergroup_location(int64 supergroup_id, object_ptr<td_api::chatLocation> location);
|
||||
const SupergroupInfo *get_supergroup_info(int64 supergroup_id) const;
|
||||
|
||||
struct ChatInfo {
|
||||
enum class Type { Private, Group, Supergroup, Unknown };
|
||||
@ -627,9 +627,9 @@ class Client : public WebhookActor::Callback {
|
||||
object_ptr<td_api::chatPhotoInfo> photo;
|
||||
object_ptr<td_api::chatPermissions> permissions;
|
||||
union {
|
||||
int32 user_id;
|
||||
int32 group_id;
|
||||
int32 supergroup_id;
|
||||
int64 user_id;
|
||||
int64 group_id;
|
||||
int64 supergroup_id;
|
||||
};
|
||||
};
|
||||
ChatInfo *add_chat(int64 chat_id);
|
||||
@ -647,13 +647,13 @@ class Client : public WebhookActor::Callback {
|
||||
mutable const MessageInfo *lru_prev = nullptr;
|
||||
|
||||
int64 id = 0;
|
||||
int32 sender_user_id = 0;
|
||||
int64 sender_user_id = 0;
|
||||
int64 sender_chat_id = 0;
|
||||
int64 chat_id = 0;
|
||||
int32 date = 0;
|
||||
int32 edit_date = 0;
|
||||
int64 initial_chat_id = 0;
|
||||
int32 initial_sender_user_id = 0;
|
||||
int64 initial_sender_user_id = 0;
|
||||
int64 initial_sender_chat_id = 0;
|
||||
int32 initial_send_date = 0;
|
||||
int64 initial_message_id = 0;
|
||||
@ -662,7 +662,7 @@ class Client : public WebhookActor::Callback {
|
||||
td::string author_signature;
|
||||
int64 reply_to_message_id = 0;
|
||||
int64 media_album_id = 0;
|
||||
int32 via_bot_user_id = 0;
|
||||
int64 via_bot_user_id = 0;
|
||||
object_ptr<td_api::MessageContent> content;
|
||||
object_ptr<td_api::ReplyMarkup> reply_markup;
|
||||
|
||||
@ -690,7 +690,7 @@ class Client : public WebhookActor::Callback {
|
||||
|
||||
Slice get_sticker_set_name(int64 sticker_set_id) const;
|
||||
|
||||
int32 choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const;
|
||||
int64 choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const;
|
||||
|
||||
bool need_skip_update_message(int64 chat_id, const object_ptr<td_api::message> &message, bool is_edited) const;
|
||||
|
||||
@ -748,23 +748,23 @@ class Client : public WebhookActor::Callback {
|
||||
|
||||
static int32 as_client_message_id(int64 message_id);
|
||||
|
||||
static int64 get_supergroup_chat_id(int32 supergroup_id);
|
||||
static int64 get_supergroup_chat_id(int64 supergroup_id);
|
||||
|
||||
static int64 get_basic_group_chat_id(int32 basic_group_id);
|
||||
static int64 get_basic_group_chat_id(int64 basic_group_id);
|
||||
|
||||
void add_update_poll(object_ptr<td_api::updatePoll> &&update);
|
||||
|
||||
void add_update_poll_answer(object_ptr<td_api::updatePollAnswer> &&update);
|
||||
|
||||
void add_new_inline_query(int64 inline_query_id, int32 sender_user_id, object_ptr<td_api::location> location,
|
||||
void add_new_inline_query(int64 inline_query_id, int64 sender_user_id, object_ptr<td_api::location> location,
|
||||
object_ptr<td_api::ChatType> chat_type, const td::string &query, const td::string &offset);
|
||||
|
||||
void add_new_chosen_inline_result(int32 sender_user_id, object_ptr<td_api::location> location,
|
||||
void add_new_chosen_inline_result(int64 sender_user_id, object_ptr<td_api::location> location,
|
||||
const td::string &query, const td::string &result_id,
|
||||
const td::string &inline_message_id);
|
||||
|
||||
void add_new_callback_query(object_ptr<td_api::updateNewCallbackQuery> &&query);
|
||||
void process_new_callback_query_queue(int32 user_id, int state);
|
||||
void process_new_callback_query_queue(int64 user_id, int state);
|
||||
|
||||
void add_new_inline_callback_query(object_ptr<td_api::updateNewInlineCallbackQuery> &&query);
|
||||
|
||||
@ -842,19 +842,19 @@ class Client : public WebhookActor::Callback {
|
||||
int64 tqueue_id_;
|
||||
double start_time_ = 0;
|
||||
|
||||
int32 my_id_ = -1;
|
||||
int64 my_id_ = -1;
|
||||
int32 authorization_date_ = -1;
|
||||
|
||||
int32 group_anonymous_bot_user_id_ = 0;
|
||||
int32 service_notifications_user_id_ = 0;
|
||||
int64 group_anonymous_bot_user_id_ = 0;
|
||||
int64 service_notifications_user_id_ = 0;
|
||||
|
||||
static std::unordered_map<td::string, Status (Client::*)(PromisedQueryPtr &query)> methods_;
|
||||
|
||||
MessageInfo messages_lru_root_;
|
||||
std::unordered_map<FullMessageId, std::unique_ptr<MessageInfo>, FullMessageIdHash> messages_; // message cache
|
||||
std::unordered_map<int32, UserInfo> users_; // user info cache
|
||||
std::unordered_map<int32, GroupInfo> groups_; // group info cache
|
||||
std::unordered_map<int32, SupergroupInfo> supergroups_; // supergroup info cache
|
||||
std::unordered_map<int64, UserInfo> users_; // user info cache
|
||||
std::unordered_map<int64, GroupInfo> groups_; // group info cache
|
||||
std::unordered_map<int64, SupergroupInfo> supergroups_; // supergroup info cache
|
||||
std::unordered_map<int64, ChatInfo> chats_; // chat info cache
|
||||
|
||||
std::unordered_map<FullMessageId, std::unordered_set<int64>, FullMessageIdHash>
|
||||
@ -877,7 +877,7 @@ class Client : public WebhookActor::Callback {
|
||||
struct PendingSendMessageQuery {
|
||||
PromisedQueryPtr query;
|
||||
bool is_multisend = false;
|
||||
int32 awaited_messages = 0;
|
||||
int32 awaited_message_count = 0;
|
||||
td::vector<td::string> messages;
|
||||
object_ptr<td_api::error> error;
|
||||
};
|
||||
@ -903,14 +903,14 @@ class Client : public WebhookActor::Callback {
|
||||
std::queue<object_ptr<td_api::updateNewCallbackQuery>> queue_;
|
||||
bool has_active_request_ = false;
|
||||
};
|
||||
std::unordered_map<int32, NewCallbackQueryQueue> new_callback_query_queues_; // sender_user_id -> queue
|
||||
std::unordered_map<int64, NewCallbackQueryQueue> new_callback_query_queues_; // sender_user_id -> queue
|
||||
|
||||
std::unordered_map<int64, td::string> sticker_set_names_;
|
||||
|
||||
int32 cur_temp_bot_user_id_ = 1;
|
||||
std::unordered_map<td::string, int32> bot_user_ids_;
|
||||
int64 cur_temp_bot_user_id_ = 1;
|
||||
std::unordered_map<td::string, int64> bot_user_ids_;
|
||||
std::unordered_set<td::string> unresolved_bot_usernames_;
|
||||
std::unordered_map<int32, int32> temp_to_real_bot_user_id_;
|
||||
std::unordered_map<int64, int64> temp_to_real_bot_user_id_;
|
||||
std::unordered_map<td::string, td::vector<int64>> awaiting_bot_resolve_queries_;
|
||||
|
||||
struct PendingBotResolveQuery {
|
||||
|
Loading…
Reference in New Issue
Block a user