mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-29 13:45:49 +01:00
Add "business_connection" updates.
This commit is contained in:
parent
de02ab0a00
commit
393b6c00fb
@ -3576,6 +3576,26 @@ class Client::JsonMessageReactionCountUpdated final : public td::Jsonable {
|
|||||||
const Client *client_;
|
const Client *client_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonBusinessConnection final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
JsonBusinessConnection(const td_api::businessConnection *connection, const Client *client)
|
||||||
|
: connection_(connection), client_(client) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("id", connection_->id_);
|
||||||
|
object("user", JsonUser(connection_->user_id_, client_));
|
||||||
|
object("user_chat_id", connection_->user_chat_id_);
|
||||||
|
object("date", connection_->date_);
|
||||||
|
object("can_reply", td::JsonBool(connection_->can_reply_));
|
||||||
|
object("is_enabled", td::JsonBool(connection_->is_enabled_));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::businessConnection *connection_;
|
||||||
|
const Client *client_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::JsonUpdateTypes final : public td::Jsonable {
|
class Client::JsonUpdateTypes final : public td::Jsonable {
|
||||||
public:
|
public:
|
||||||
explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) {
|
explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) {
|
||||||
@ -6330,6 +6350,9 @@ void Client::on_update(object_ptr<td_api::Object> result) {
|
|||||||
case td_api::updateMessageReactions::ID:
|
case td_api::updateMessageReactions::ID:
|
||||||
add_update_message_reaction_count(move_object_as<td_api::updateMessageReactions>(result));
|
add_update_message_reaction_count(move_object_as<td_api::updateMessageReactions>(result));
|
||||||
break;
|
break;
|
||||||
|
case td_api::updateBusinessConnection::ID:
|
||||||
|
add_update_business_connection(move_object_as<td_api::updateBusinessConnection>(result));
|
||||||
|
break;
|
||||||
case td_api::updateConnectionState::ID: {
|
case td_api::updateConnectionState::ID: {
|
||||||
auto update = move_object_as<td_api::updateConnectionState>(result);
|
auto update = move_object_as<td_api::updateConnectionState>(result);
|
||||||
if (update->state_->get_id() == td_api::connectionStateReady::ID) {
|
if (update->state_->get_id() == td_api::connectionStateReady::ID) {
|
||||||
@ -11967,6 +11990,8 @@ td::Slice Client::get_update_type_name(UpdateType update_type) {
|
|||||||
return td::Slice("message_reaction");
|
return td::Slice("message_reaction");
|
||||||
case UpdateType::MessageReactionCount:
|
case UpdateType::MessageReactionCount:
|
||||||
return td::Slice("message_reaction_count");
|
return td::Slice("message_reaction_count");
|
||||||
|
case UpdateType::BusinessConnection:
|
||||||
|
return td::Slice("business_connection");
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return td::Slice();
|
return td::Slice();
|
||||||
@ -12317,6 +12342,20 @@ void Client::add_update_message_reaction_count(object_ptr<td_api::updateMessageR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::add_update_business_connection(object_ptr<td_api::updateBusinessConnection> &&update) {
|
||||||
|
CHECK(update != nullptr);
|
||||||
|
auto connection = std::move(update->connection_);
|
||||||
|
auto left_time = connection->date_ + 86400 - get_unix_time();
|
||||||
|
if (left_time > 0) {
|
||||||
|
auto webhook_queue_id = connection->user_id_ + (static_cast<int64>(10) << 33);
|
||||||
|
add_update(UpdateType::BusinessConnection, JsonBusinessConnection(connection.get(), this), left_time,
|
||||||
|
webhook_queue_id);
|
||||||
|
} else {
|
||||||
|
LOG(DEBUG) << "Skip updateBusinessConnection with date " << connection->date_ << ", because current date is "
|
||||||
|
<< get_unix_time();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
td::int64 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);
|
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_) {
|
||||||
|
@ -163,6 +163,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonGameHighScore;
|
class JsonGameHighScore;
|
||||||
class JsonMessageReactionUpdated;
|
class JsonMessageReactionUpdated;
|
||||||
class JsonMessageReactionCountUpdated;
|
class JsonMessageReactionCountUpdated;
|
||||||
|
class JsonBusinessConnection;
|
||||||
class JsonAddress;
|
class JsonAddress;
|
||||||
class JsonOrderInfo;
|
class JsonOrderInfo;
|
||||||
class JsonStory;
|
class JsonStory;
|
||||||
@ -1017,6 +1018,8 @@ class Client final : public WebhookActor::Callback {
|
|||||||
|
|
||||||
void add_update_message_reaction_count(object_ptr<td_api::updateMessageReactions> &&update);
|
void add_update_message_reaction_count(object_ptr<td_api::updateMessageReactions> &&update);
|
||||||
|
|
||||||
|
void add_update_business_connection(object_ptr<td_api::updateBusinessConnection> &&update);
|
||||||
|
|
||||||
// append only before Size
|
// append only before Size
|
||||||
enum class UpdateType : int32 {
|
enum class UpdateType : int32 {
|
||||||
Message,
|
Message,
|
||||||
@ -1039,6 +1042,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
ChatBoostRemoved,
|
ChatBoostRemoved,
|
||||||
MessageReaction,
|
MessageReaction,
|
||||||
MessageReactionCount,
|
MessageReactionCount,
|
||||||
|
BusinessConnection,
|
||||||
Size
|
Size
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user