blob: 934b4acdfd8bf16568395fe6a7a3dbf66e7da2e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/BotAccessSettings.h"
#include "td/telegram/Td.h"
#include "td/telegram/UserManager.h"
#include "td/utils/logging.h"
namespace td {
BotAccessSettings::BotAccessSettings(Td *td, telegram_api::object_ptr<telegram_api::bots_accessSettings> &&settings) {
CHECK(settings != nullptr);
is_restricted_ = settings->restricted_;
if (is_restricted_) {
for (auto &user : settings->add_users_) {
auto user_id = td->user_manager_->on_get_user(std::move(user), "BotAccessSettings");
if (user_id.is_valid()) {
added_user_ids_.push_back(user_id);
}
}
} else if (!settings->add_users_.empty()) {
LOG(ERROR) << "Receive added users in a non-restricted bot";
}
}
BotAccessSettings::BotAccessSettings(td_api::object_ptr<td_api::botAccessSettings> &&settings) {
if (settings != nullptr) {
is_restricted_ = settings->is_restricted_;
for (auto added_user_id : settings->added_user_ids_) {
UserId user_id(added_user_id);
if (user_id.is_valid()) {
added_user_ids_.push_back(user_id);
}
}
}
}
td_api::object_ptr<td_api::botAccessSettings> BotAccessSettings::get_bot_access_settings_object(Td *td) const {
return td_api::make_object<td_api::botAccessSettings>(
is_restricted_, td->user_manager_->get_user_ids_object(added_user_ids_, "botAccessSettings"));
}
} // namespace td
|