aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/BusinessBotManageBar.h
blob: d45b747a041f1afe51b72707a3f57a3a29c0f88c (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// 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)
//
#pragma once

#include "td/telegram/DialogId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/UserId.h"

#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"

namespace td {

class Dependencies;
class Td;

class BusinessBotManageBar {
  UserId business_bot_user_id_;
  string business_bot_manage_url_;
  bool is_business_bot_paused_ = false;
  bool can_business_bot_reply_ = false;

  friend bool operator==(const BusinessBotManageBar &lhs, const BusinessBotManageBar &rhs);

 public:
  static unique_ptr<BusinessBotManageBar> create(bool is_business_bot_paused, bool can_business_bot_reply,
                                                 UserId business_bot_user_id, string business_bot_manage_url);

  bool is_empty() const;

  void fix(DialogId dialog_id);

  td_api::object_ptr<td_api::businessBotManageBar> get_business_bot_manage_bar_object(Td *td) const;

  bool on_user_deleted();

  bool set_business_bot_is_paused(bool is_paused);

  void add_dependencies(Dependencies &dependencies) const;

  template <class StorerT>
  void store(StorerT &storer) const {
    bool has_business_bot_user_id = business_bot_user_id_.is_valid();
    bool has_business_bot_manage_url = !business_bot_manage_url_.empty();
    BEGIN_STORE_FLAGS();
    STORE_FLAG(is_business_bot_paused_);
    STORE_FLAG(can_business_bot_reply_);
    STORE_FLAG(has_business_bot_user_id);
    STORE_FLAG(has_business_bot_manage_url);
    END_STORE_FLAGS();
    if (has_business_bot_user_id) {
      td::store(business_bot_user_id_, storer);
    }
    if (has_business_bot_manage_url) {
      td::store(business_bot_manage_url_, storer);
    }
  }

  template <class ParserT>
  void parse(ParserT &parser) {
    bool has_business_bot_user_id;
    bool has_business_bot_manage_url;
    BEGIN_PARSE_FLAGS();
    PARSE_FLAG(is_business_bot_paused_);
    PARSE_FLAG(can_business_bot_reply_);
    PARSE_FLAG(has_business_bot_user_id);
    PARSE_FLAG(has_business_bot_manage_url);
    END_PARSE_FLAGS();
    if (has_business_bot_user_id) {
      td::parse(business_bot_user_id_, parser);
    }
    if (has_business_bot_manage_url) {
      td::parse(business_bot_manage_url_, parser);
    }
  }
};

bool operator==(const BusinessBotManageBar &lhs, const BusinessBotManageBar &rhs);

bool operator!=(const BusinessBotManageBar &lhs, const BusinessBotManageBar &rhs);

}  // namespace td