mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-25 04:05:52 +01:00
Add update 'chat_member'.
This commit is contained in:
parent
8323701b27
commit
418946b0e1
@ -2266,6 +2266,29 @@ class Client::JsonChatMembers : public Jsonable {
|
|||||||
const Client *client_;
|
const Client *client_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonChatMemberUpdated : public Jsonable {
|
||||||
|
public:
|
||||||
|
JsonChatMemberUpdated(const td_api::updateChatMember *update, const Client *client)
|
||||||
|
: update_(update), client_(client) {
|
||||||
|
}
|
||||||
|
void store(JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("chat", JsonChat(update_->chat_id_, false, client_));
|
||||||
|
object("actor", JsonUser(update_->actor_user_id_, client_));
|
||||||
|
object("date", update_->date_);
|
||||||
|
auto chat_type = client_->get_chat_type(update_->chat_id_);
|
||||||
|
object("old_chat_member", JsonChatMember(update_->old_chat_member_.get(), chat_type, client_));
|
||||||
|
object("new_chat_member", JsonChatMember(update_->new_chat_member_.get(), chat_type, client_));
|
||||||
|
if (update_->invite_link_ != nullptr) {
|
||||||
|
object("invite_link", JsonChatInviteLink(update_->invite_link_.get(), client_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::updateChatMember *update_;
|
||||||
|
const Client *client_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::JsonGameHighScore : public Jsonable {
|
class Client::JsonGameHighScore : public Jsonable {
|
||||||
public:
|
public:
|
||||||
JsonGameHighScore(const td_api::gameHighScore *score, const Client *client) : score_(score), client_(client) {
|
JsonGameHighScore(const td_api::gameHighScore *score, const Client *client) : score_(score), client_(client) {
|
||||||
@ -4313,6 +4336,9 @@ void Client::on_update(object_ptr<td_api::Object> result) {
|
|||||||
case td_api::updateNewCustomQuery::ID:
|
case td_api::updateNewCustomQuery::ID:
|
||||||
add_new_custom_query(move_object_as<td_api::updateNewCustomQuery>(result));
|
add_new_custom_query(move_object_as<td_api::updateNewCustomQuery>(result));
|
||||||
break;
|
break;
|
||||||
|
case td_api::updateChatMember::ID:
|
||||||
|
add_update_chat_member(move_object_as<td_api::updateChatMember>(result));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// we are not interested in this updates
|
// we are not interested in this updates
|
||||||
break;
|
break;
|
||||||
@ -8227,6 +8253,8 @@ Client::Slice Client::get_update_type_name(UpdateType update_type) {
|
|||||||
return Slice("poll");
|
return Slice("poll");
|
||||||
case UpdateType::PollAnswer:
|
case UpdateType::PollAnswer:
|
||||||
return Slice("poll_answer");
|
return Slice("poll_answer");
|
||||||
|
case UpdateType::ChatMember:
|
||||||
|
return Slice("chat_member");
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return Slice();
|
return Slice();
|
||||||
@ -8498,6 +8526,15 @@ void Client::add_new_custom_query(object_ptr<td_api::updateNewCustomQuery> &&que
|
|||||||
add_update(UpdateType::CustomQuery, JsonCustomJson(query->data_), timeout, 0);
|
add_update(UpdateType::CustomQuery, JsonCustomJson(query->data_), timeout, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::add_update_chat_member(object_ptr<td_api::updateChatMember> &&update) {
|
||||||
|
CHECK(update != nullptr);
|
||||||
|
auto left_time = update->date_ + 86400 - get_unix_time();
|
||||||
|
if (left_time > 0) {
|
||||||
|
auto webhook_queue_id = update->chat_id_ + (static_cast<int64>(5) << 33);
|
||||||
|
add_update(UpdateType::ChatMember, JsonChatMemberUpdated(update.get(), this), left_time, webhook_queue_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
td::int32 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const {
|
td::int32 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const {
|
||||||
CHECK(message_add_members != nullptr);
|
CHECK(message_add_members != nullptr);
|
||||||
for (auto &member_user_id : message_add_members->member_user_ids_) {
|
for (auto &member_user_id : message_add_members->member_user_ids_) {
|
||||||
|
@ -136,6 +136,7 @@ class Client : public WebhookActor::Callback {
|
|||||||
class JsonChatPhotos;
|
class JsonChatPhotos;
|
||||||
class JsonChatMember;
|
class JsonChatMember;
|
||||||
class JsonChatMembers;
|
class JsonChatMembers;
|
||||||
|
class JsonChatMemberUpdated;
|
||||||
class JsonGameHighScore;
|
class JsonGameHighScore;
|
||||||
class JsonAddress;
|
class JsonAddress;
|
||||||
class JsonOrderInfo;
|
class JsonOrderInfo;
|
||||||
@ -750,6 +751,8 @@ class Client : public WebhookActor::Callback {
|
|||||||
|
|
||||||
void add_new_custom_query(object_ptr<td_api::updateNewCustomQuery> &&query);
|
void add_new_custom_query(object_ptr<td_api::updateNewCustomQuery> &&query);
|
||||||
|
|
||||||
|
void add_update_chat_member(object_ptr<td_api::updateChatMember> &&update);
|
||||||
|
|
||||||
// append only before Size
|
// append only before Size
|
||||||
enum class UpdateType : int32 {
|
enum class UpdateType : int32 {
|
||||||
Message,
|
Message,
|
||||||
@ -765,6 +768,7 @@ class Client : public WebhookActor::Callback {
|
|||||||
PreCheckoutQuery,
|
PreCheckoutQuery,
|
||||||
Poll,
|
Poll,
|
||||||
PollAnswer,
|
PollAnswer,
|
||||||
|
ChatMember,
|
||||||
Size
|
Size
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -792,8 +796,8 @@ class Client : public WebhookActor::Callback {
|
|||||||
|
|
||||||
bool have_message_access(int64 chat_id) const;
|
bool have_message_access(int64 chat_id) const;
|
||||||
|
|
||||||
// by default all 13 update types up to PollAnswer are allowed
|
// by default all 14 update types up to ChatMember are allowed
|
||||||
static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES = ((1 << 13) - 1);
|
static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES = ((1 << 14) - 1);
|
||||||
|
|
||||||
object_ptr<td_api::AuthorizationState> authorization_state_;
|
object_ptr<td_api::AuthorizationState> authorization_state_;
|
||||||
bool was_authorized_ = false;
|
bool was_authorized_ = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user