diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7e724d13a..9f57ce87e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -578,8 +578,8 @@ 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 always +businessAwayMessageScheduleAlways = BusinessAwayMessageSchedule; //@description Send away messages outside of the business opening hours businessAwayMessageScheduleOutsideOfOpeningHours = BusinessAwayMessageSchedule; @@ -606,7 +606,8 @@ businessRecipients chat_ids:vector select_existing_chats:Bool select_new_ //@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; +//@offline_only True, if the messages must not be sent if the account was online in the last 10 minutes +businessAwayMessageSettings shortcut_id:int32 recipients:businessRecipients schedule:BusinessAwayMessageSchedule offline_only:Bool = 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 diff --git a/td/telegram/BusinessAwayMessage.cpp b/td/telegram/BusinessAwayMessage.cpp index 8dddc3c40..273aafb85 100644 --- a/td/telegram/BusinessAwayMessage.cpp +++ b/td/telegram/BusinessAwayMessage.cpp @@ -23,6 +23,7 @@ BusinessAwayMessage::BusinessAwayMessage(telegram_api::object_ptrshortcut_id_); recipients_ = BusinessRecipients(std::move(away_message->recipients_)); schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_)); + offline_only_ = away_message->offline_only_; } BusinessAwayMessage::BusinessAwayMessage(td_api::object_ptr away_message) { @@ -32,6 +33,7 @@ BusinessAwayMessage::BusinessAwayMessage(td_api::object_ptrshortcut_id_); recipients_ = BusinessRecipients(std::move(away_message->recipients_)); schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_)); + offline_only_ = away_message->offline_only_; } td_api::object_ptr BusinessAwayMessage::get_business_away_message_settings_object( @@ -41,24 +43,28 @@ td_api::object_ptr BusinessAwayMessage::get } return td_api::make_object( shortcut_id_.get(), recipients_.get_business_recipients_object(td), - schedule_.get_business_away_message_schedule_object()); + schedule_.get_business_away_message_schedule_object(), offline_only_); } telegram_api::object_ptr BusinessAwayMessage::get_input_business_away_message( Td *td) const { int32 flags = 0; + if (offline_only_) { + flags |= telegram_api::inputBusinessAwayMessage::OFFLINE_ONLY_MASK; + } return telegram_api::make_object( 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_; + return lhs.shortcut_id_ == rhs.shortcut_id_ && lhs.recipients_ == rhs.recipients_ && lhs.schedule_ == rhs.schedule_ && + lhs.offline_only_ == rhs.offline_only_; } StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessage &away_message) { return string_builder << "away message " << away_message.shortcut_id_ << ' ' << away_message.recipients_ << ' ' - << away_message.schedule_; + << away_message.schedule_ << (away_message.offline_only_ ? " only offline" : ""); } } // namespace td diff --git a/td/telegram/BusinessAwayMessage.h b/td/telegram/BusinessAwayMessage.h index 5591fcf9f..8f9fde6fd 100644 --- a/td/telegram/BusinessAwayMessage.h +++ b/td/telegram/BusinessAwayMessage.h @@ -49,6 +49,7 @@ class BusinessAwayMessage { QuickReplyShortcutId shortcut_id_; BusinessRecipients recipients_; BusinessAwayMessageSchedule schedule_; + bool offline_only_ = false; friend bool operator==(const BusinessAwayMessage &lhs, const BusinessAwayMessage &rhs); diff --git a/td/telegram/BusinessAwayMessage.hpp b/td/telegram/BusinessAwayMessage.hpp index b1cc70fa2..602c5cb89 100644 --- a/td/telegram/BusinessAwayMessage.hpp +++ b/td/telegram/BusinessAwayMessage.hpp @@ -18,6 +18,7 @@ namespace td { template void BusinessAwayMessage::store(StorerT &storer) const { BEGIN_STORE_FLAGS(); + STORE_FLAG(offline_only_); END_STORE_FLAGS(); td::store(shortcut_id_, storer); td::store(recipients_, storer); @@ -27,6 +28,7 @@ void BusinessAwayMessage::store(StorerT &storer) const { template void BusinessAwayMessage::parse(ParserT &parser) { BEGIN_PARSE_FLAGS(); + PARSE_FLAG(offline_only_); END_PARSE_FLAGS(); td::parse(shortcut_id_, parser); td::parse(recipients_, parser); diff --git a/td/telegram/BusinessAwayMessageSchedule.cpp b/td/telegram/BusinessAwayMessageSchedule.cpp index 6cc6ce574..8bc7139b5 100644 --- a/td/telegram/BusinessAwayMessageSchedule.cpp +++ b/td/telegram/BusinessAwayMessageSchedule.cpp @@ -13,7 +13,7 @@ BusinessAwayMessageSchedule::BusinessAwayMessageSchedule( CHECK(schedule != nullptr); switch (schedule->get_id()) { case telegram_api::businessAwayMessageScheduleAlways::ID: - type_ = Type::Offline; + type_ = Type::Always; break; case telegram_api::businessAwayMessageScheduleOutsideWorkHours::ID: type_ = Type::OutsideOfWorkHours; @@ -36,8 +36,8 @@ BusinessAwayMessageSchedule::BusinessAwayMessageSchedule( return; } switch (schedule->get_id()) { - case td_api::businessAwayMessageScheduleOffline::ID: - type_ = Type::Offline; + case td_api::businessAwayMessageScheduleAlways::ID: + type_ = Type::Always; break; case td_api::businessAwayMessageScheduleOutsideOfOpeningHours::ID: type_ = Type::OutsideOfWorkHours; @@ -57,8 +57,8 @@ BusinessAwayMessageSchedule::BusinessAwayMessageSchedule( td_api::object_ptr BusinessAwayMessageSchedule::get_business_away_message_schedule_object() const { switch (type_) { - case Type::Offline: - return td_api::make_object(); + case Type::Always: + return td_api::make_object(); case Type::OutsideOfWorkHours: return td_api::make_object(); case Type::Custom: @@ -72,7 +72,7 @@ BusinessAwayMessageSchedule::get_business_away_message_schedule_object() const { telegram_api::object_ptr BusinessAwayMessageSchedule::get_input_business_away_message_schedule() const { switch (type_) { - case Type::Offline: + case Type::Always: return telegram_api::make_object(); case Type::OutsideOfWorkHours: return telegram_api::make_object(); @@ -90,10 +90,10 @@ bool operator==(const BusinessAwayMessageSchedule &lhs, const BusinessAwayMessag StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessageSchedule &schedule) { switch (schedule.type_) { - case BusinessAwayMessageSchedule::Type::Offline: - return string_builder << "sent offline"; + case BusinessAwayMessageSchedule::Type::Always: + return string_builder << "sent always"; case BusinessAwayMessageSchedule::Type::OutsideOfWorkHours: - return string_builder << "sent outside of work hours"; + return string_builder << "sent outside of opening hours"; case BusinessAwayMessageSchedule::Type::Custom: return string_builder << "sent from " << schedule.start_date_ << " to " << schedule.end_date_; default: diff --git a/td/telegram/BusinessAwayMessageSchedule.h b/td/telegram/BusinessAwayMessageSchedule.h index 74f2c732b..c76ff9b16 100644 --- a/td/telegram/BusinessAwayMessageSchedule.h +++ b/td/telegram/BusinessAwayMessageSchedule.h @@ -33,8 +33,8 @@ class BusinessAwayMessageSchedule { void parse(ParserT &parser); private: - enum class Type : int32 { Offline, OutsideOfWorkHours, Custom }; - Type type_ = Type::Offline; + enum class Type : int32 { Always, OutsideOfWorkHours, Custom }; + Type type_ = Type::Always; int32 start_date_ = 0; int32 end_date_ = 0; diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index e9d5d0714..5d634df89 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -5984,7 +5984,7 @@ class CliClient final : public Actor { rand_bool(), rand_bool(), rand_bool()), inactivity_days))); } - } else if (op == "sbams") { + } else if (op == "sbams" || op == "sbamso") { ShortcutId shortcut_id; string chat_ids; string schedule; @@ -5993,9 +5993,9 @@ class CliClient final : public Actor { send_request(td_api::make_object(nullptr)); } else { td_api::object_ptr schedule_object; - if (schedule[0] == 'o') { - schedule_object = td_api::make_object(); - } else if (schedule[0] == 'h') { + if (schedule[0] == 'a') { + schedule_object = td_api::make_object(); + } else if (schedule[0] == 'o') { schedule_object = td_api::make_object(); } else { auto start_date = to_integer(schedule); @@ -6007,7 +6007,7 @@ class CliClient final : public Actor { shortcut_id, td_api::make_object(as_chat_ids(chat_ids), rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool()), - std::move(schedule_object)))); + std::move(schedule_object), op == "sbamso"))); } } else if (op == "sco") { SearchQuery query;