/* 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; BusinessRecipients recipients; bool repliesAllowed = false; friend inline bool operator==( const ChatbotsSettings &, const ChatbotsSettings &) = default; }; class Chatbots final { public: explicit Chatbots(not_null owner); ~Chatbots(); void preload(); [[nodiscard]] bool loaded() const; [[nodiscard]] const ChatbotsSettings ¤t() const; [[nodiscard]] rpl::producer changes() const; [[nodiscard]] rpl::producer value() const; void save( ChatbotsSettings settings, Fn done, Fn fail); void togglePaused(not_null peer, bool paused); void removeFrom(not_null peer); private: enum class SentRequestType { Pause, Unpause, Remove, }; struct SentRequest { SentRequestType type = SentRequestType::Pause; mtpRequestId requestId = 0; }; void reload(); const not_null _owner; rpl::variable _settings; mtpRequestId _requestId = 0; bool _loaded = false; base::flat_map, SentRequest> _sentRequests; }; } // namespace Data