Add td_api::BusinessAwayMessageSchedule.
This commit is contained in:
parent
3d43bbb80d
commit
4c469a3f2c
|
@ -301,6 +301,7 @@ set(TDLIB_SOURCE
|
|||
td/telegram/BotCommandScope.cpp
|
||||
td/telegram/BotInfoManager.cpp
|
||||
td/telegram/BotMenuButton.cpp
|
||||
td/telegram/BusinessAwayMessageSchedule.cpp
|
||||
td/telegram/BusinessGreetingMessage.cpp
|
||||
td/telegram/BusinessRecipients.cpp
|
||||
td/telegram/BusinessWorkHours.cpp
|
||||
|
@ -582,6 +583,7 @@ set(TDLIB_SOURCE
|
|||
td/telegram/BotCommandScope.h
|
||||
td/telegram/BotInfoManager.h
|
||||
td/telegram/BotMenuButton.h
|
||||
td/telegram/BusinessAwayMessageSchedule.h
|
||||
td/telegram/BusinessGreetingMessage.h
|
||||
td/telegram/BusinessRecipients.h
|
||||
td/telegram/BusinessWorkHours.h
|
||||
|
@ -883,6 +885,7 @@ set(TDLIB_SOURCE
|
|||
td/telegram/AuthManager.hpp
|
||||
td/telegram/BackgroundInfo.hpp
|
||||
td/telegram/BackgroundType.hpp
|
||||
td/telegram/BusinessAwayMessageSchedule.hpp
|
||||
td/telegram/BusinessGreetingMessage.hpp
|
||||
td/telegram/BusinessRecipients.hpp
|
||||
td/telegram/BusinessWorkHours.hpp
|
||||
|
|
|
@ -576,6 +576,20 @@ botMenuButton text:string url:string = BotMenuButton;
|
|||
chatLocation location:location address:string = ChatLocation;
|
||||
|
||||
|
||||
//@class BusinessAwayMessageSchedule @description Describes conditions for sending of away messages by a Telegram Business account
|
||||
|
||||
//@description Send away messages if the account was online more than 10 minutes
|
||||
businessAwayMessageScheduleOffline = BusinessAwayMessageSchedule;
|
||||
|
||||
//@description Send away messages outside of the business work hours
|
||||
businessAwayMessageScheduleOutsideOfWorkHours = BusinessAwayMessageSchedule;
|
||||
|
||||
//@description Send away messages only in the specified time span
|
||||
//@start_date Point in time (Unix timestamp) when the away messages will start to be sent
|
||||
//@end_date Point in time (Unix timestamp) when the away messages will stop to be sent
|
||||
businessAwayMessageScheduleCustom start_date:int32 end_date:int32 = BusinessAwayMessageSchedule;
|
||||
|
||||
|
||||
//@description Represents a location of a business @location The location; may be null if not specified @address Location address; 1-96 characters
|
||||
businessLocation location:location address:string = BusinessLocation;
|
||||
|
||||
|
|
105
td/telegram/BusinessAwayMessageSchedule.cpp
Normal file
105
td/telegram/BusinessAwayMessageSchedule.cpp
Normal file
|
@ -0,0 +1,105 @@
|
|||
//
|
||||
// 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/BusinessAwayMessageSchedule.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
BusinessAwayMessageSchedule::BusinessAwayMessageSchedule(
|
||||
telegram_api::object_ptr<telegram_api::BusinessAwayMessageSchedule> schedule) {
|
||||
CHECK(schedule != nullptr);
|
||||
switch (schedule->get_id()) {
|
||||
case telegram_api::businessAwayMessageScheduleAlways::ID:
|
||||
type_ = Type::Offline;
|
||||
break;
|
||||
case telegram_api::businessAwayMessageScheduleOutsideWorkHours::ID:
|
||||
type_ = Type::OutsideOfWorkHours;
|
||||
break;
|
||||
case telegram_api::businessAwayMessageScheduleCustom::ID: {
|
||||
auto custom_schedule = telegram_api::move_object_as<telegram_api::businessAwayMessageScheduleCustom>(schedule);
|
||||
type_ = Type::Custom;
|
||||
start_date_ = custom_schedule->start_date_;
|
||||
end_date_ = custom_schedule->end_date_;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
BusinessAwayMessageSchedule::BusinessAwayMessageSchedule(
|
||||
td_api::object_ptr<td_api::BusinessAwayMessageSchedule> schedule) {
|
||||
if (schedule == nullptr) {
|
||||
return;
|
||||
}
|
||||
switch (schedule->get_id()) {
|
||||
case td_api::businessAwayMessageScheduleOffline::ID:
|
||||
type_ = Type::Offline;
|
||||
break;
|
||||
case td_api::businessAwayMessageScheduleOutsideOfWorkHours::ID:
|
||||
type_ = Type::OutsideOfWorkHours;
|
||||
break;
|
||||
case td_api::businessAwayMessageScheduleCustom::ID: {
|
||||
auto custom_schedule = td_api::move_object_as<td_api::businessAwayMessageScheduleCustom>(schedule);
|
||||
type_ = Type::Custom;
|
||||
start_date_ = custom_schedule->start_date_;
|
||||
end_date_ = custom_schedule->end_date_;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::BusinessAwayMessageSchedule>
|
||||
BusinessAwayMessageSchedule::get_business_away_message_schedule_object() const {
|
||||
switch (type_) {
|
||||
case Type::Offline:
|
||||
return td_api::make_object<td_api::businessAwayMessageScheduleOffline>();
|
||||
case Type::OutsideOfWorkHours:
|
||||
return td_api::make_object<td_api::businessAwayMessageScheduleOutsideOfWorkHours>();
|
||||
case Type::Custom:
|
||||
return td_api::make_object<td_api::businessAwayMessageScheduleCustom>(start_date_, end_date_);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::BusinessAwayMessageSchedule>
|
||||
BusinessAwayMessageSchedule::get_input_business_away_message_schedule() const {
|
||||
switch (type_) {
|
||||
case Type::Offline:
|
||||
return telegram_api::make_object<telegram_api::businessAwayMessageScheduleAlways>();
|
||||
case Type::OutsideOfWorkHours:
|
||||
return telegram_api::make_object<telegram_api::businessAwayMessageScheduleOutsideWorkHours>();
|
||||
case Type::Custom:
|
||||
return telegram_api::make_object<telegram_api::businessAwayMessageScheduleCustom>(start_date_, end_date_);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const BusinessAwayMessageSchedule &lhs, const BusinessAwayMessageSchedule &rhs) {
|
||||
return lhs.type_ == rhs.type_ && lhs.start_date_ == rhs.start_date_ && lhs.end_date_ == rhs.end_date_;
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessageSchedule &schedule) {
|
||||
switch (schedule.type_) {
|
||||
case BusinessAwayMessageSchedule::Type::Offline:
|
||||
return string_builder << "sent offline";
|
||||
case BusinessAwayMessageSchedule::Type::OutsideOfWorkHours:
|
||||
return string_builder << "sent outside of work hours";
|
||||
case BusinessAwayMessageSchedule::Type::Custom:
|
||||
return string_builder << "sent from " << schedule.start_date_ << " to " << schedule.end_date_;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return string_builder;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
54
td/telegram/BusinessAwayMessageSchedule.h
Normal file
54
td/telegram/BusinessAwayMessageSchedule.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// 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/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class BusinessAwayMessageSchedule {
|
||||
public:
|
||||
BusinessAwayMessageSchedule() = default;
|
||||
|
||||
explicit BusinessAwayMessageSchedule(telegram_api::object_ptr<telegram_api::BusinessAwayMessageSchedule> schedule);
|
||||
|
||||
explicit BusinessAwayMessageSchedule(td_api::object_ptr<td_api::BusinessAwayMessageSchedule> schedule);
|
||||
|
||||
td_api::object_ptr<td_api::BusinessAwayMessageSchedule> get_business_away_message_schedule_object() const;
|
||||
|
||||
telegram_api::object_ptr<telegram_api::BusinessAwayMessageSchedule> get_input_business_away_message_schedule() const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser);
|
||||
|
||||
private:
|
||||
enum class Type : int32 { Offline, OutsideOfWorkHours, Custom };
|
||||
Type type_ = Type::Offline;
|
||||
int32 start_date_ = 0;
|
||||
int32 end_date_ = 0;
|
||||
|
||||
friend bool operator==(const BusinessAwayMessageSchedule &lhs, const BusinessAwayMessageSchedule &rhs);
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessageSchedule &schedule);
|
||||
};
|
||||
|
||||
bool operator==(const BusinessAwayMessageSchedule &lhs, const BusinessAwayMessageSchedule &rhs);
|
||||
|
||||
inline bool operator!=(const BusinessAwayMessageSchedule &lhs, const BusinessAwayMessageSchedule &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessageSchedule &schedule);
|
||||
|
||||
} // namespace td
|
50
td/telegram/BusinessAwayMessageSchedule.hpp
Normal file
50
td/telegram/BusinessAwayMessageSchedule.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
//
|
||||
// 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/utils/common.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void BusinessAwayMessageSchedule::store(StorerT &storer) const {
|
||||
bool has_start_date = start_date_ != 0;
|
||||
bool has_end_date = end_date_ != 0;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_start_date);
|
||||
STORE_FLAG(has_end_date);
|
||||
END_STORE_FLAGS();
|
||||
td::store(type_, storer);
|
||||
if (has_start_date) {
|
||||
td::store(start_date, storer);
|
||||
}
|
||||
if (has_end_date) {
|
||||
td::store(end_date, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void BusinessAwayMessageSchedule::parse(ParserT &parser) {
|
||||
bool has_start_date;
|
||||
bool has_end_date;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_start_date);
|
||||
PARSE_FLAG(has_end_date);
|
||||
END_PARSE_FLAGS();
|
||||
td::parse(type_, parser);
|
||||
if (has_start_date) {
|
||||
td::parse(start_date, parser);
|
||||
}
|
||||
if (has_end_date) {
|
||||
td::parse(end_date, parser);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
|
@ -12,6 +12,7 @@
|
|||
#include "td/telegram/Td.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void BusinessRecipients::store(StorerT &storer) const {
|
|||
|
||||
template <class ParserT>
|
||||
void BusinessRecipients::parse(ParserT &parser) {
|
||||
bool has_user_ids = !user_ids_.empty();
|
||||
bool has_user_ids;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(existing_chats_);
|
||||
PARSE_FLAG(new_chats_);
|
||||
|
|
Loading…
Reference in New Issue
Block a user