Add td_api::businessGreetingMessageSettings.
This commit is contained in:
parent
bdb3088a0c
commit
3d43bbb80d
|
@ -301,6 +301,7 @@ set(TDLIB_SOURCE
|
||||||
td/telegram/BotCommandScope.cpp
|
td/telegram/BotCommandScope.cpp
|
||||||
td/telegram/BotInfoManager.cpp
|
td/telegram/BotInfoManager.cpp
|
||||||
td/telegram/BotMenuButton.cpp
|
td/telegram/BotMenuButton.cpp
|
||||||
|
td/telegram/BusinessGreetingMessage.cpp
|
||||||
td/telegram/BusinessRecipients.cpp
|
td/telegram/BusinessRecipients.cpp
|
||||||
td/telegram/BusinessWorkHours.cpp
|
td/telegram/BusinessWorkHours.cpp
|
||||||
td/telegram/CallActor.cpp
|
td/telegram/CallActor.cpp
|
||||||
|
@ -581,6 +582,7 @@ set(TDLIB_SOURCE
|
||||||
td/telegram/BotCommandScope.h
|
td/telegram/BotCommandScope.h
|
||||||
td/telegram/BotInfoManager.h
|
td/telegram/BotInfoManager.h
|
||||||
td/telegram/BotMenuButton.h
|
td/telegram/BotMenuButton.h
|
||||||
|
td/telegram/BusinessGreetingMessage.h
|
||||||
td/telegram/BusinessRecipients.h
|
td/telegram/BusinessRecipients.h
|
||||||
td/telegram/BusinessWorkHours.h
|
td/telegram/BusinessWorkHours.h
|
||||||
td/telegram/CallActor.h
|
td/telegram/CallActor.h
|
||||||
|
@ -881,6 +883,7 @@ set(TDLIB_SOURCE
|
||||||
td/telegram/AuthManager.hpp
|
td/telegram/AuthManager.hpp
|
||||||
td/telegram/BackgroundInfo.hpp
|
td/telegram/BackgroundInfo.hpp
|
||||||
td/telegram/BackgroundType.hpp
|
td/telegram/BackgroundType.hpp
|
||||||
|
td/telegram/BusinessGreetingMessage.hpp
|
||||||
td/telegram/BusinessRecipients.hpp
|
td/telegram/BusinessRecipients.hpp
|
||||||
td/telegram/BusinessWorkHours.hpp
|
td/telegram/BusinessWorkHours.hpp
|
||||||
td/telegram/ChatReactions.hpp
|
td/telegram/ChatReactions.hpp
|
||||||
|
|
|
@ -309,6 +309,7 @@ function split_file($file, $chunks, $undo) {
|
||||||
'BotMenuButton|[a-z_]*_menu_button' => 'BotMenuButton',
|
'BotMenuButton|[a-z_]*_menu_button' => 'BotMenuButton',
|
||||||
'boost_manager[_(-](?![.]get[(][)])|BoostManager' => 'BoostManager',
|
'boost_manager[_(-](?![.]get[(][)])|BoostManager' => 'BoostManager',
|
||||||
'bot_info_manager[_(-](?![.]get[(][)])|BotInfoManager' => 'BotInfoManager',
|
'bot_info_manager[_(-](?![.]get[(][)])|BotInfoManager' => 'BotInfoManager',
|
||||||
|
'BusinessGreetingMessage' => 'BusinessGreetingMessage',
|
||||||
'BusinessRecipients' => 'BusinessRecipients',
|
'BusinessRecipients' => 'BusinessRecipients',
|
||||||
'BusinessWorkHours' => 'BusinessWorkHours',
|
'BusinessWorkHours' => 'BusinessWorkHours',
|
||||||
'callback_queries_manager[_(-](?![.]get[(][)])|CallbackQueriesManager' => 'CallbackQueriesManager',
|
'callback_queries_manager[_(-](?![.]get[(][)])|CallbackQueriesManager' => 'CallbackQueriesManager',
|
||||||
|
|
|
@ -588,6 +588,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
|
//@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;
|
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 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
|
||||||
|
//@inactivity_days The number of days after which a chat will be considered as inactive; currently, must be on of 7, 14, 21, or 28
|
||||||
|
businessGreetingMessageSettings shortcut_id:int32 recipients:businessRecipients inactivity_days:int32 = BusinessGreetingMessageSettings;
|
||||||
|
|
||||||
//@description Describes an interval of time when the business is open
|
//@description Describes an interval of time when the business is open
|
||||||
//@start_minute The first minute of the interval since start of the week; 0-7*24*60
|
//@start_minute The first minute of the interval since start of the week; 0-7*24*60
|
||||||
//@end_minute The first minute after the end of the interval since start of the week; 1-8*24*60
|
//@end_minute The first minute after the end of the interval since start of the week; 1-8*24*60
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
//
|
||||||
|
// 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/BusinessGreetingMessage.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"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
BusinessGreetingMessage::BusinessGreetingMessage(
|
||||||
|
telegram_api::object_ptr<telegram_api::businessGreetingMessage> greeting_message)
|
||||||
|
: shortcut_id_(greeting_message->shortcut_id_)
|
||||||
|
, recipients_(std::move(greeting_message->recipients_))
|
||||||
|
, inactivity_days_(clamp(greeting_message->no_activity_days_ / 7 * 7, 7, 28)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
BusinessGreetingMessage::BusinessGreetingMessage(
|
||||||
|
td_api::object_ptr<td_api::businessGreetingMessageSettings> greeting_message) {
|
||||||
|
if (greeting_message == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto inactivity_days = greeting_message->inactivity_days_;
|
||||||
|
if (inactivity_days < 7 || inactivity_days > 28 || inactivity_days % 7 != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shortcut_id_ = QuickReplyShortcutId(greeting_message->shortcut_id_);
|
||||||
|
recipients_ = BusinessRecipients(std::move(greeting_message->recipients_));
|
||||||
|
inactivity_days_ = inactivity_days;
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::businessGreetingMessageSettings>
|
||||||
|
BusinessGreetingMessage::get_business_greeting_message_settings_object(Td *td) const {
|
||||||
|
if (!is_valid()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::businessGreetingMessageSettings>(
|
||||||
|
shortcut_id_.get(), recipients_.get_business_recipients_object(td), inactivity_days_);
|
||||||
|
}
|
||||||
|
|
||||||
|
telegram_api::object_ptr<telegram_api::inputBusinessGreetingMessage>
|
||||||
|
BusinessGreetingMessage::get_input_business_greeting_message(Td *td) const {
|
||||||
|
return telegram_api::make_object<telegram_api::inputBusinessGreetingMessage>(
|
||||||
|
shortcut_id_.get(), recipients_.get_input_business_recipients(td), inactivity_days_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const BusinessGreetingMessage &lhs, const BusinessGreetingMessage &rhs) {
|
||||||
|
return lhs.shortcut_id_ == rhs.shortcut_id_ && lhs.recipients_ == rhs.recipients_ &&
|
||||||
|
lhs.inactivity_days_ == rhs.inactivity_days_;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessGreetingMessage &greeting_message) {
|
||||||
|
return string_builder << "greeting message " << greeting_message.shortcut_id_ << ' ' << greeting_message.recipients_
|
||||||
|
<< " after " << greeting_message.inactivity_days_ << " inactivity days";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
|
@ -0,0 +1,63 @@
|
||||||
|
//
|
||||||
|
// 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/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 BusinessGreetingMessage {
|
||||||
|
public:
|
||||||
|
BusinessGreetingMessage() = default;
|
||||||
|
|
||||||
|
explicit BusinessGreetingMessage(telegram_api::object_ptr<telegram_api::businessGreetingMessage> greeting_message);
|
||||||
|
|
||||||
|
explicit BusinessGreetingMessage(td_api::object_ptr<td_api::businessGreetingMessageSettings> greeting_message);
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::businessGreetingMessageSettings> get_business_greeting_message_settings_object(
|
||||||
|
Td *td) const;
|
||||||
|
|
||||||
|
telegram_api::object_ptr<telegram_api::inputBusinessGreetingMessage> get_input_business_greeting_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_;
|
||||||
|
int32 inactivity_days_ = 0;
|
||||||
|
|
||||||
|
friend bool operator==(const BusinessGreetingMessage &lhs, const BusinessGreetingMessage &rhs);
|
||||||
|
|
||||||
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessGreetingMessage &greeting_message);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const BusinessGreetingMessage &lhs, const BusinessGreetingMessage &rhs);
|
||||||
|
|
||||||
|
inline bool operator!=(const BusinessGreetingMessage &lhs, const BusinessGreetingMessage &rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessGreetingMessage &greeting_message);
|
||||||
|
|
||||||
|
} // namespace td
|
|
@ -0,0 +1,35 @@
|
||||||
|
//
|
||||||
|
// 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/BusinessGreetingMessage.h"
|
||||||
|
#include "td/telegram/BusinessRecipients.hpp"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/tl_helpers.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void BusinessGreetingMessage::store(StorerT &storer) const {
|
||||||
|
BEGIN_STORE_FLAGS();
|
||||||
|
END_STORE_FLAGS();
|
||||||
|
td::store(shortcut_id_, storer);
|
||||||
|
td::store(recipients_, storer);
|
||||||
|
td::store(inactivity_days_, storer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void BusinessGreetingMessage::parse(ParserT &parser) {
|
||||||
|
BEGIN_PARSE_FLAGS();
|
||||||
|
END_PARSE_FLAGS();
|
||||||
|
td::parse(shortcut_id_, parser);
|
||||||
|
td::parse(recipients_, parser);
|
||||||
|
td::parse(inactivity_days_, parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
|
@ -19,6 +19,8 @@ class Td;
|
||||||
|
|
||||||
class BusinessRecipients {
|
class BusinessRecipients {
|
||||||
public:
|
public:
|
||||||
|
BusinessRecipients() = default;
|
||||||
|
|
||||||
explicit BusinessRecipients(telegram_api::object_ptr<telegram_api::businessRecipients> recipients);
|
explicit BusinessRecipients(telegram_api::object_ptr<telegram_api::businessRecipients> recipients);
|
||||||
|
|
||||||
explicit BusinessRecipients(td_api::object_ptr<td_api::businessRecipients> recipients);
|
explicit BusinessRecipients(td_api::object_ptr<td_api::businessRecipients> recipients);
|
||||||
|
|
Loading…
Reference in New Issue