2024-02-20 12:02:02 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "data/business/data_business_common.h"
|
|
|
|
|
|
|
|
class UserData;
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class Session;
|
|
|
|
|
|
|
|
struct ChatbotsSettings {
|
|
|
|
UserData *bot = nullptr;
|
2024-02-20 15:06:01 +00:00
|
|
|
BusinessRecipients recipients;
|
2024-02-20 12:02:02 +00:00
|
|
|
bool repliesAllowed = false;
|
2024-03-05 16:52:14 +00:00
|
|
|
|
|
|
|
friend inline bool operator==(
|
|
|
|
const ChatbotsSettings &,
|
|
|
|
const ChatbotsSettings &) = default;
|
2024-02-20 12:02:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Chatbots final {
|
|
|
|
public:
|
2024-03-05 16:52:14 +00:00
|
|
|
explicit Chatbots(not_null<Session*> owner);
|
2024-02-20 12:02:02 +00:00
|
|
|
~Chatbots();
|
|
|
|
|
2024-03-05 16:52:14 +00:00
|
|
|
void preload();
|
2024-03-08 08:28:53 +00:00
|
|
|
[[nodiscard]] bool loaded() const;
|
2024-02-20 12:02:02 +00:00
|
|
|
[[nodiscard]] const ChatbotsSettings ¤t() const;
|
|
|
|
[[nodiscard]] rpl::producer<ChatbotsSettings> changes() const;
|
|
|
|
[[nodiscard]] rpl::producer<ChatbotsSettings> value() const;
|
|
|
|
|
2024-03-05 16:52:14 +00:00
|
|
|
void save(
|
|
|
|
ChatbotsSettings settings,
|
|
|
|
Fn<void()> done,
|
|
|
|
Fn<void(QString)> fail);
|
2024-02-20 12:02:02 +00:00
|
|
|
|
2024-03-18 11:02:12 +00:00
|
|
|
void togglePaused(not_null<PeerData*> peer, bool paused);
|
|
|
|
void removeFrom(not_null<PeerData*> peer);
|
|
|
|
|
2024-02-20 12:02:02 +00:00
|
|
|
private:
|
2024-03-18 11:02:12 +00:00
|
|
|
enum class SentRequestType {
|
|
|
|
Pause,
|
|
|
|
Unpause,
|
|
|
|
Remove,
|
|
|
|
};
|
|
|
|
struct SentRequest {
|
|
|
|
SentRequestType type = SentRequestType::Pause;
|
|
|
|
mtpRequestId requestId = 0;
|
|
|
|
};
|
|
|
|
|
2024-03-20 12:58:52 +00:00
|
|
|
void reload();
|
|
|
|
|
2024-03-05 16:52:14 +00:00
|
|
|
const not_null<Session*> _owner;
|
2024-02-20 12:02:02 +00:00
|
|
|
|
|
|
|
rpl::variable<ChatbotsSettings> _settings;
|
2024-03-05 16:52:14 +00:00
|
|
|
mtpRequestId _requestId = 0;
|
|
|
|
bool _loaded = false;
|
2024-02-20 12:02:02 +00:00
|
|
|
|
2024-03-18 11:02:12 +00:00
|
|
|
base::flat_map<not_null<PeerData*>, SentRequest> _sentRequests;
|
|
|
|
|
2024-02-20 12:02:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|