Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added is_verified and is_scam #5

Merged
merged 4 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ The `ChatMember` object now has two new fields:
- `joined_date`: integer, unix timestamp, when has the user joined
- `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)

<a name="installation"></a>
Expand Down
22 changes: 22 additions & 0 deletions telegram-bot-api/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ class Client::JsonUser : public Jsonable {
if (user_info != nullptr && !user_info->language_code.empty()) {
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_) {
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));
Expand Down Expand Up @@ -582,6 +588,12 @@ class Client::JsonChat : public Jsonable {
object("username", user_info->username);
}
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 (!user_info->bio.empty()) {
object("bio", user_info->bio);
Expand Down Expand Up @@ -627,6 +639,12 @@ class Client::JsonChat : public Jsonable {
} else {
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 (!supergroup_info->description.empty()) {
object("description", supergroup_info->description);
Expand Down Expand Up @@ -7934,6 +7952,8 @@ void Client::add_user(std::unordered_map<int32, UserInfo> &users, object_ptr<td_
user_info->last_name = user->last_name_;
user_info->username = user->username_;
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_;

Expand Down Expand Up @@ -8003,6 +8023,8 @@ void Client::add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergrou
supergroup_info->status = std::move(supergroup->status_);
supergroup_info->is_supergroup = !supergroup->is_channel_;
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) {
Expand Down
4 changes: 4 additions & 0 deletions telegram-bot-api/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ class Client : public WebhookActor::Callback {

td::string bio;

bool is_verified = false;
bool is_scam = false;
bool have_access = false;
bool can_join_groups = false;
bool can_read_all_group_messages = false;
Expand Down Expand Up @@ -592,6 +594,8 @@ class Client : public WebhookActor::Callback {
bool is_supergroup = false;
bool can_set_sticker_set = false;
bool has_location = false;
bool is_verified = false;
bool is_scam = false;
};
static void add_supergroup(std::unordered_map<int32, SupergroupInfo> &supergroups,
object_ptr<td_api::supergroup> &&supergroup);
Expand Down