mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-11-23 20:26:50 +01:00
commit
86f99faee3
19
README.md
19
README.md
@ -71,6 +71,15 @@ The maximum number of messages to be deleted in a single batch is determined by
|
|||||||
- `end` Last message id to delete
|
- `end` Last message id to delete
|
||||||
##### Returns `true`
|
##### Returns `true`
|
||||||
|
|
||||||
|
#### Command `ping`
|
||||||
|
Send an MTProto ping message to the telegram servers.
|
||||||
|
Useful to detect the delay of the bot api server.
|
||||||
|
|
||||||
|
##### Parameters
|
||||||
|
No parameters
|
||||||
|
##### Returns `string`
|
||||||
|
Ping delay in seconds represented as string.
|
||||||
|
|
||||||
<!--TODO:
|
<!--TODO:
|
||||||
#### Command `togglegroupinvites`
|
#### Command `togglegroupinvites`
|
||||||
(todo)
|
(todo)
|
||||||
@ -103,6 +112,16 @@ The `ChatMember` object now has two new fields:
|
|||||||
- `joined_date`: integer, unix timestamp, when has the user joined
|
- `joined_date`: integer, unix timestamp, when has the user joined
|
||||||
- `inviter`: `User`, the inviter
|
- `inviter`: `User`, the inviter
|
||||||
|
|
||||||
|
#### Object `Chat`
|
||||||
|
The `Chat` object now has two new fields:
|
||||||
|
- `is_verified`: bool, optional, default false. Is the chat verified by Telegram, clients show a verified batch
|
||||||
|
- `is_scam`: bool, optional, default false. Is the chat reported for scam, clients show a warning to the user
|
||||||
|
|
||||||
|
#### Object `User`
|
||||||
|
The `User` object now has two new fields:
|
||||||
|
- `is_verified`: bool, optional, default false. Is the user verified by Telegram, clients show a verified batch
|
||||||
|
- `is_scam`: bool, optional, default false. Is the user reported for scam, clients show a warning to the user
|
||||||
|
|
||||||
In addition, the member list now shows the full bot list (previously only the bot that executed the query was shown)
|
In addition, the member list now shows the full bot list (previously only the bot that executed the query was shown)
|
||||||
|
|
||||||
<a name="installation"></a>
|
<a name="installation"></a>
|
||||||
|
@ -256,6 +256,8 @@ bool Client::init_methods() {
|
|||||||
methods_.emplace("getparticipants", &Client::process_get_participants_query);
|
methods_.emplace("getparticipants", &Client::process_get_participants_query);
|
||||||
methods_.emplace("deletemessages", &Client::process_delete_messages_query);
|
methods_.emplace("deletemessages", &Client::process_delete_messages_query);
|
||||||
methods_.emplace("togglegroupinvites", &Client::process_toggle_group_invites_query);
|
methods_.emplace("togglegroupinvites", &Client::process_toggle_group_invites_query);
|
||||||
|
methods_.emplace("ping", &Client::process_ping_query);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -329,6 +331,12 @@ class Client::JsonUser : public Jsonable {
|
|||||||
if (user_info != nullptr && !user_info->language_code.empty()) {
|
if (user_info != nullptr && !user_info->language_code.empty()) {
|
||||||
object("language_code", user_info->language_code);
|
object("language_code", user_info->language_code);
|
||||||
}
|
}
|
||||||
|
if (user_info != nullptr && user_info->is_verified) {
|
||||||
|
object("is_verified", td::JsonBool(user_info->is_verified));
|
||||||
|
}
|
||||||
|
if (user_info != nullptr && user_info->is_scam) {
|
||||||
|
object("is_scam", td::JsonBool(user_info->is_scam));
|
||||||
|
}
|
||||||
if (is_bot && full_bot_info_) {
|
if (is_bot && full_bot_info_) {
|
||||||
object("can_join_groups", td::JsonBool(user_info->can_join_groups));
|
object("can_join_groups", td::JsonBool(user_info->can_join_groups));
|
||||||
object("can_read_all_group_messages", td::JsonBool(user_info->can_read_all_group_messages));
|
object("can_read_all_group_messages", td::JsonBool(user_info->can_read_all_group_messages));
|
||||||
@ -582,6 +590,12 @@ class Client::JsonChat : public Jsonable {
|
|||||||
object("username", user_info->username);
|
object("username", user_info->username);
|
||||||
}
|
}
|
||||||
object("type", "private");
|
object("type", "private");
|
||||||
|
if (user_info->is_verified) {
|
||||||
|
object("is_verified", td::JsonBool(user_info->is_verified));
|
||||||
|
}
|
||||||
|
if (user_info->is_scam) {
|
||||||
|
object("is_scam", td::JsonBool(user_info->is_scam));
|
||||||
|
}
|
||||||
if (is_full_) {
|
if (is_full_) {
|
||||||
if (!user_info->bio.empty()) {
|
if (!user_info->bio.empty()) {
|
||||||
object("bio", user_info->bio);
|
object("bio", user_info->bio);
|
||||||
@ -627,6 +641,12 @@ class Client::JsonChat : public Jsonable {
|
|||||||
} else {
|
} else {
|
||||||
object("type", "channel");
|
object("type", "channel");
|
||||||
}
|
}
|
||||||
|
if (supergroup_info->is_verified) {
|
||||||
|
object("is_verified", td::JsonBool(supergroup_info->is_verified));
|
||||||
|
}
|
||||||
|
if (supergroup_info->is_scam) {
|
||||||
|
object("is_scam", td::JsonBool(supergroup_info->is_scam));
|
||||||
|
}
|
||||||
if (is_full_) {
|
if (is_full_) {
|
||||||
if (!supergroup_info->description.empty()) {
|
if (!supergroup_info->description.empty()) {
|
||||||
object("description", supergroup_info->description);
|
object("description", supergroup_info->description);
|
||||||
@ -3213,6 +3233,30 @@ class Client::TdOnSendCustomRequestCallback : public TdQueryCallback {
|
|||||||
PromisedQueryPtr query_;
|
PromisedQueryPtr query_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//start custom callbacks impl
|
||||||
|
|
||||||
|
class Client::TdOnPingCallback : public TdQueryCallback {
|
||||||
|
public:
|
||||||
|
TdOnPingCallback(PromisedQueryPtr query)
|
||||||
|
: query_(std::move(query)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(object_ptr<td_api::Object> result) override {
|
||||||
|
if (result->get_id() == td_api::error::ID) {
|
||||||
|
return fail_query_with_error(std::move(query_), move_object_as<td_api::error>(result), "Server not available");
|
||||||
|
}
|
||||||
|
CHECK(result->get_id() == 959899022); // id for return type `seconds`
|
||||||
|
|
||||||
|
auto seconds_ = move_object_as<td_api::seconds>(result);
|
||||||
|
answer_query(td::VirtuallyJsonableString(std::to_string(seconds_->seconds_)), std::move(query_));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PromisedQueryPtr query_;
|
||||||
|
};
|
||||||
|
|
||||||
|
//end custom callbacks impl
|
||||||
|
|
||||||
void Client::close() {
|
void Client::close() {
|
||||||
need_close_ = true;
|
need_close_ = true;
|
||||||
if (td_client_.empty()) {
|
if (td_client_.empty()) {
|
||||||
@ -7500,6 +7544,12 @@ td::Status Client::process_toggle_group_invites_query(PromisedQueryPtr &query) {
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::Status Client::process_ping_query(PromisedQueryPtr &query) {
|
||||||
|
send_request(make_object<td_api::pingProxy>(),
|
||||||
|
std::make_unique<TdOnPingCallback>(std::move(query)));
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
//end custom methods impl
|
//end custom methods impl
|
||||||
|
|
||||||
void Client::do_get_file(object_ptr<td_api::file> file, PromisedQueryPtr query) {
|
void Client::do_get_file(object_ptr<td_api::file> file, PromisedQueryPtr query) {
|
||||||
@ -7934,6 +7984,8 @@ void Client::add_user(std::unordered_map<int32, UserInfo> &users, object_ptr<td_
|
|||||||
user_info->last_name = user->last_name_;
|
user_info->last_name = user->last_name_;
|
||||||
user_info->username = user->username_;
|
user_info->username = user->username_;
|
||||||
user_info->language_code = user->language_code_;
|
user_info->language_code = user->language_code_;
|
||||||
|
user_info->is_verified = user->is_verified_;
|
||||||
|
user_info->is_scam = user->is_scam_;
|
||||||
|
|
||||||
user_info->have_access = user->have_access_;
|
user_info->have_access = user->have_access_;
|
||||||
|
|
||||||
@ -8003,6 +8055,8 @@ void Client::add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergrou
|
|||||||
supergroup_info->status = std::move(supergroup->status_);
|
supergroup_info->status = std::move(supergroup->status_);
|
||||||
supergroup_info->is_supergroup = !supergroup->is_channel_;
|
supergroup_info->is_supergroup = !supergroup->is_channel_;
|
||||||
supergroup_info->has_location = supergroup->has_location_;
|
supergroup_info->has_location = supergroup->has_location_;
|
||||||
|
supergroup_info->is_verified = supergroup->is_verified_;
|
||||||
|
supergroup_info->is_scam = supergroup->is_scam_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::set_supergroup_description(int32 supergroup_id, td::string &&descripton) {
|
void Client::set_supergroup_description(int32 supergroup_id, td::string &&descripton) {
|
||||||
|
@ -178,6 +178,10 @@ class Client : public WebhookActor::Callback {
|
|||||||
class TdOnCancelDownloadFileCallback;
|
class TdOnCancelDownloadFileCallback;
|
||||||
class TdOnSendCustomRequestCallback;
|
class TdOnSendCustomRequestCallback;
|
||||||
|
|
||||||
|
//start custom callbacks
|
||||||
|
class TdOnPingCallback;
|
||||||
|
//end custom callbacks
|
||||||
|
|
||||||
void on_get_reply_message(int64 chat_id, object_ptr<td_api::message> reply_to_message);
|
void on_get_reply_message(int64 chat_id, object_ptr<td_api::message> reply_to_message);
|
||||||
|
|
||||||
void on_get_edited_message(object_ptr<td_api::message> edited_message);
|
void on_get_edited_message(object_ptr<td_api::message> edited_message);
|
||||||
@ -492,6 +496,7 @@ class Client : public WebhookActor::Callback {
|
|||||||
Status process_get_participants_query(PromisedQueryPtr &query);
|
Status process_get_participants_query(PromisedQueryPtr &query);
|
||||||
Status process_delete_messages_query(PromisedQueryPtr &query);
|
Status process_delete_messages_query(PromisedQueryPtr &query);
|
||||||
Status process_toggle_group_invites_query(PromisedQueryPtr &query);
|
Status process_toggle_group_invites_query(PromisedQueryPtr &query);
|
||||||
|
Status process_ping_query(PromisedQueryPtr &query);
|
||||||
|
|
||||||
|
|
||||||
void webhook_verified(td::string cached_ip_address) override;
|
void webhook_verified(td::string cached_ip_address) override;
|
||||||
@ -556,6 +561,8 @@ class Client : public WebhookActor::Callback {
|
|||||||
|
|
||||||
td::string bio;
|
td::string bio;
|
||||||
|
|
||||||
|
bool is_verified = false;
|
||||||
|
bool is_scam = false;
|
||||||
bool have_access = false;
|
bool have_access = false;
|
||||||
bool can_join_groups = false;
|
bool can_join_groups = false;
|
||||||
bool can_read_all_group_messages = false;
|
bool can_read_all_group_messages = false;
|
||||||
@ -592,6 +599,8 @@ class Client : public WebhookActor::Callback {
|
|||||||
bool is_supergroup = false;
|
bool is_supergroup = false;
|
||||||
bool can_set_sticker_set = false;
|
bool can_set_sticker_set = false;
|
||||||
bool has_location = false;
|
bool has_location = false;
|
||||||
|
bool is_verified = false;
|
||||||
|
bool is_scam = false;
|
||||||
};
|
};
|
||||||
static void add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergroups,
|
static void add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergroups,
|
||||||
object_ptr<td_api::supergroup> &&supergroup);
|
object_ptr<td_api::supergroup> &&supergroup);
|
||||||
|
Loading…
Reference in New Issue
Block a user