Add td_api::businessAwayMessageSettings.

This commit is contained in:
levlam 2024-02-26 20:27:17 +03:00
parent 4c469a3f2c
commit 5bde9c6fb6
6 changed files with 169 additions and 0 deletions

View File

@ -301,6 +301,7 @@ set(TDLIB_SOURCE
td/telegram/BotCommandScope.cpp
td/telegram/BotInfoManager.cpp
td/telegram/BotMenuButton.cpp
td/telegram/BusinessAwayMessage.cpp
td/telegram/BusinessAwayMessageSchedule.cpp
td/telegram/BusinessGreetingMessage.cpp
td/telegram/BusinessRecipients.cpp
@ -583,6 +584,7 @@ set(TDLIB_SOURCE
td/telegram/BotCommandScope.h
td/telegram/BotInfoManager.h
td/telegram/BotMenuButton.h
td/telegram/BusinessAwayMessage.h
td/telegram/BusinessAwayMessageSchedule.h
td/telegram/BusinessGreetingMessage.h
td/telegram/BusinessRecipients.h
@ -885,6 +887,7 @@ set(TDLIB_SOURCE
td/telegram/AuthManager.hpp
td/telegram/BackgroundInfo.hpp
td/telegram/BackgroundType.hpp
td/telegram/BusinessAwayMessage.hpp
td/telegram/BusinessAwayMessageSchedule.hpp
td/telegram/BusinessGreetingMessage.hpp
td/telegram/BusinessRecipients.hpp

View File

@ -309,6 +309,7 @@ function split_file($file, $chunks, $undo) {
'BotMenuButton|[a-z_]*_menu_button' => 'BotMenuButton',
'boost_manager[_(-](?![.]get[(][)])|BoostManager' => 'BoostManager',
'bot_info_manager[_(-](?![.]get[(][)])|BotInfoManager' => 'BotInfoManager',
'BusinessAwayMessage' => 'BusinessAwayMessage',
'BusinessGreetingMessage' => 'BusinessGreetingMessage',
'BusinessRecipients' => 'BusinessRecipients',
'BusinessWorkHours' => 'BusinessWorkHours',

View File

@ -602,6 +602,12 @@ businessLocation location:location address:string = BusinessLocation;
//@exclude_selected If true, then all private chats except the selected are chosen. Otherwise, only the selected chats are chosen
businessRecipients chat_ids:vector<int53> select_existing_chats:Bool select_new_chats:Bool select_contacts:Bool select_non_contacts:Bool exclude_selected:Bool = BusinessRecipients;
//@description Describes settings for messages that are automatically sent by a Telegram Business account when it is away
//@shortcut_id Unique quick reply shortcut identifier for the away messages
//@recipients Chosen recipients of the away messages
//@schedule Settings used to check whether the current user is away
businessAwayMessageSettings shortcut_id:int32 recipients:businessRecipients schedule:BusinessAwayMessageSchedule = BusinessAwayMessageSettings;
//@description Describes settings for greeting messages that are automatically sent by a Telegram Business account as response to incoming messages in an inactive private chat
//@shortcut_id Unique quick reply shortcut identifier for the greeting messages
//@recipients Chosen recipients of the greeting messages

View File

@ -0,0 +1,61 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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/BusinessAwayMessage.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Td.h"
#include "td/utils/algorithm.h"
#include "td/utils/misc.h"
namespace td {
BusinessAwayMessage::BusinessAwayMessage(telegram_api::object_ptr<telegram_api::businessAwayMessage> away_message)
: shortcut_id_(away_message->shortcut_id_)
, recipients_(std::move(away_message->recipients_))
, schedule_(std::move(away_message->schedule_)) {
}
BusinessAwayMessage::BusinessAwayMessage(td_api::object_ptr<td_api::businessAwayMessageSettings> away_message) {
if (away_message == nullptr) {
return;
}
shortcut_id_ = QuickReplyShortcutId(away_message->shortcut_id_);
recipients_ = BusinessRecipients(std::move(away_message->recipients_));
schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_));
}
td_api::object_ptr<td_api::businessAwayMessageSettings> BusinessAwayMessage::get_business_away_message_settings_object(
Td *td) const {
if (!is_valid()) {
return nullptr;
}
return td_api::make_object<td_api::businessAwayMessageSettings>(
shortcut_id_.get(), recipients_.get_business_recipients_object(td),
schedule_.get_business_away_message_schedule_object());
}
telegram_api::object_ptr<telegram_api::inputBusinessAwayMessage> BusinessAwayMessage::get_input_business_away_message(
Td *td) const {
int32 flags = 0;
return telegram_api::make_object<telegram_api::inputBusinessAwayMessage>(
flags, false /*ignored*/, shortcut_id_.get(), schedule_.get_input_business_away_message_schedule(),
recipients_.get_input_business_recipients(td));
}
bool operator==(const BusinessAwayMessage &lhs, const BusinessAwayMessage &rhs) {
return lhs.shortcut_id_ == rhs.shortcut_id_ && lhs.recipients_ == rhs.recipients_ && lhs.schedule_ == rhs.schedule_;
}
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessage &away_message) {
return string_builder << "away message " << away_message.shortcut_id_ << ' ' << away_message.recipients_ << ' '
<< away_message.schedule_;
}
} // namespace td

View File

@ -0,0 +1,62 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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/BusinessAwayMessageSchedule.h"
#include "td/telegram/BusinessRecipients.h"
#include "td/telegram/QuickReplyShortcutId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
namespace td {
class Td;
class BusinessAwayMessage {
public:
BusinessAwayMessage() = default;
explicit BusinessAwayMessage(telegram_api::object_ptr<telegram_api::businessAwayMessage> away_message);
explicit BusinessAwayMessage(td_api::object_ptr<td_api::businessAwayMessageSettings> away_message);
td_api::object_ptr<td_api::businessAwayMessageSettings> get_business_away_message_settings_object(Td *td) const;
telegram_api::object_ptr<telegram_api::inputBusinessAwayMessage> get_input_business_away_message(Td *td) const;
bool is_valid() const {
return shortcut_id_.is_server();
}
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
private:
QuickReplyShortcutId shortcut_id_;
BusinessRecipients recipients_;
BusinessAwayMessageSchedule schedule_;
friend bool operator==(const BusinessAwayMessage &lhs, const BusinessAwayMessage &rhs);
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessage &away_message);
};
bool operator==(const BusinessAwayMessage &lhs, const BusinessAwayMessage &rhs);
inline bool operator!=(const BusinessAwayMessage &lhs, const BusinessAwayMessage &rhs) {
return !(lhs == rhs);
}
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessage &away_message);
} // namespace td

View File

@ -0,0 +1,36 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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/BusinessAwayMessage.h"
#include "td/telegram/BusinessAwayMessageSchedule.hpp"
#include "td/telegram/BusinessRecipients.hpp"
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void BusinessAwayMessage::store(StorerT &storer) const {
BEGIN_STORE_FLAGS();
END_STORE_FLAGS();
td::store(shortcut_id_, storer);
td::store(recipients_, storer);
td::store(schedule_, storer);
}
template <class ParserT>
void BusinessAwayMessage::parse(ParserT &parser) {
BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS();
td::parse(shortcut_id_, parser);
td::parse(recipients_, parser);
td::parse(schedule_, parser);
}
} // namespace td