Add td_api::storyArea.
This commit is contained in:
parent
92f69a228d
commit
6deae588bf
@ -386,6 +386,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/Location.cpp
|
td/telegram/Location.cpp
|
||||||
td/telegram/logevent/LogEventHelper.cpp
|
td/telegram/logevent/LogEventHelper.cpp
|
||||||
td/telegram/Logging.cpp
|
td/telegram/Logging.cpp
|
||||||
|
td/telegram/MediaArea.cpp
|
||||||
td/telegram/MediaAreaCoordinates.cpp
|
td/telegram/MediaAreaCoordinates.cpp
|
||||||
td/telegram/MessageContent.cpp
|
td/telegram/MessageContent.cpp
|
||||||
td/telegram/MessageContentType.cpp
|
td/telegram/MessageContentType.cpp
|
||||||
@ -660,6 +661,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/logevent/LogEventHelper.h
|
td/telegram/logevent/LogEventHelper.h
|
||||||
td/telegram/logevent/SecretChatEvent.h
|
td/telegram/logevent/SecretChatEvent.h
|
||||||
td/telegram/Logging.h
|
td/telegram/Logging.h
|
||||||
|
td/telegram/MediaArea.h
|
||||||
td/telegram/MediaAreaCoordinates.h
|
td/telegram/MediaAreaCoordinates.h
|
||||||
td/telegram/MessageContent.h
|
td/telegram/MessageContent.h
|
||||||
td/telegram/MessageContentType.h
|
td/telegram/MessageContentType.h
|
||||||
@ -834,6 +836,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/Game.hpp
|
td/telegram/Game.hpp
|
||||||
td/telegram/InputInvoice.hpp
|
td/telegram/InputInvoice.hpp
|
||||||
td/telegram/InputMessageText.hpp
|
td/telegram/InputMessageText.hpp
|
||||||
|
td/telegram/MediaArea.hpp
|
||||||
td/telegram/MediaAreaCoordinates.hpp
|
td/telegram/MediaAreaCoordinates.hpp
|
||||||
td/telegram/MessageEntity.hpp
|
td/telegram/MessageEntity.hpp
|
||||||
td/telegram/MessageExtendedMedia.hpp
|
td/telegram/MessageExtendedMedia.hpp
|
||||||
|
@ -4907,7 +4907,7 @@ messageLink link:string is_public:Bool = MessageLink;
|
|||||||
messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:message media_timestamp:int32 for_album:Bool = MessageLinkInfo;
|
messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:message media_timestamp:int32 for_album:Bool = MessageLinkInfo;
|
||||||
|
|
||||||
|
|
||||||
//@description Describes a clickable rectangle area on a story media
|
//@description Describes position of a clickable rectangle area on a story media
|
||||||
//@x_percentage The abscissa of the rectangle's center, as a percentage of the media width
|
//@x_percentage The abscissa of the rectangle's center, as a percentage of the media width
|
||||||
//@y_percentage The ordinate of the rectangle's center, as a percentage of the media height
|
//@y_percentage The ordinate of the rectangle's center, as a percentage of the media height
|
||||||
//@width_percentage The width of the rectangle, as a percentage of the media width
|
//@width_percentage The width of the rectangle, as a percentage of the media width
|
||||||
@ -4916,6 +4916,19 @@ messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:mes
|
|||||||
storyAreaPosition x_percentage:double y_percentage:double width_percentage:double height_percentage:double rotation_angle:double = StoryAreaPosition;
|
storyAreaPosition x_percentage:double y_percentage:double width_percentage:double height_percentage:double rotation_angle:double = StoryAreaPosition;
|
||||||
|
|
||||||
|
|
||||||
|
//@class StoryAreaType @description Describes type of a clickable rectangle area on a story media
|
||||||
|
|
||||||
|
//@description An area pointing to a location @location The location
|
||||||
|
storyAreaTypeLocation location:location = StoryAreaType;
|
||||||
|
|
||||||
|
//@description An area pointing to a venue @venue Information about the venue
|
||||||
|
storyAreaTypeVenue venue:venue = StoryAreaType;
|
||||||
|
|
||||||
|
|
||||||
|
//@description Describes a clickable rectangle area on a story media @position Position of the area @type Type of the area
|
||||||
|
storyArea position:storyAreaPosition type:StoryAreaType = StoryArea;
|
||||||
|
|
||||||
|
|
||||||
//@description Describes a video file sent in a story
|
//@description Describes a video file sent in a story
|
||||||
//@duration Duration of the video, in seconds
|
//@duration Duration of the video, in seconds
|
||||||
//@width Video width
|
//@width Video width
|
||||||
|
75
td/telegram/MediaArea.cpp
Normal file
75
td/telegram/MediaArea.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// 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/MediaArea.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
MediaArea::MediaArea(Td *td, telegram_api::object_ptr<telegram_api::MediaArea> &&media_area_ptr) {
|
||||||
|
CHECK(media_area_ptr != nullptr);
|
||||||
|
switch (media_area_ptr->get_id()) {
|
||||||
|
case telegram_api::mediaAreaGeoPoint::ID: {
|
||||||
|
auto area = telegram_api::move_object_as<telegram_api::mediaAreaGeoPoint>(media_area_ptr);
|
||||||
|
coordinates_ = MediaAreaCoordinates(area->coordinates_);
|
||||||
|
location_ = Location(td, area->geo_);
|
||||||
|
if (coordinates_.is_valid() && !location_.empty()) {
|
||||||
|
type_ = Type::Location;
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive " << to_string(area);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case telegram_api::mediaAreaVenue::ID: {
|
||||||
|
auto area = telegram_api::move_object_as<telegram_api::mediaAreaVenue>(media_area_ptr);
|
||||||
|
coordinates_ = MediaAreaCoordinates(area->coordinates_);
|
||||||
|
venue_ = Venue(td, area->geo_, std::move(area->title_), std::move(area->address_), std::move(area->provider_),
|
||||||
|
std::move(area->venue_id_), std::move(area->venue_type_));
|
||||||
|
if (coordinates_.is_valid() && !venue_.empty()) {
|
||||||
|
type_ = Type::Venue;
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive " << to_string(area);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case telegram_api::inputMediaAreaVenue::ID:
|
||||||
|
LOG(ERROR) << "Receive " << to_string(media_area_ptr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::storyArea> MediaArea::get_story_area_object() const {
|
||||||
|
CHECK(is_valid());
|
||||||
|
td_api::object_ptr<td_api::StoryAreaType> type;
|
||||||
|
switch (type_) {
|
||||||
|
case Type::Location:
|
||||||
|
type = td_api::make_object<td_api::storyAreaTypeLocation>(location_.get_location_object());
|
||||||
|
break;
|
||||||
|
case Type::Venue:
|
||||||
|
type = td_api::make_object<td_api::storyAreaTypeVenue>(venue_.get_venue_object());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::storyArea>(coordinates_.get_story_area_position_object(), std::move(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const MediaArea &lhs, const MediaArea &rhs) {
|
||||||
|
return lhs.type_ == rhs.type_ && lhs.coordinates_ == rhs.coordinates_ && lhs.location_ == rhs.location_ &&
|
||||||
|
lhs.venue_ == rhs.venue_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const MediaArea &lhs, const MediaArea &rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const MediaArea &media_area) {
|
||||||
|
return string_builder << "StoryArea[" << media_area.coordinates_ << ": " << media_area.location_ << '/'
|
||||||
|
<< media_area.venue_ << ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
57
td/telegram/MediaArea.h
Normal file
57
td/telegram/MediaArea.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// 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/Location.h"
|
||||||
|
#include "td/telegram/MediaAreaCoordinates.h"
|
||||||
|
#include "td/telegram/td_api.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
#include "td/telegram/Venue.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/StringBuilder.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
class Td;
|
||||||
|
|
||||||
|
class MediaArea {
|
||||||
|
enum class Type : int32 { None, Location, Venue };
|
||||||
|
Type type_ = Type::None;
|
||||||
|
MediaAreaCoordinates coordinates_;
|
||||||
|
Location location_;
|
||||||
|
Venue venue_;
|
||||||
|
|
||||||
|
friend bool operator==(const MediaArea &lhs, const MediaArea &rhs);
|
||||||
|
friend bool operator!=(const MediaArea &lhs, const MediaArea &rhs);
|
||||||
|
|
||||||
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const MediaArea &media_area);
|
||||||
|
|
||||||
|
public:
|
||||||
|
MediaArea() = default;
|
||||||
|
|
||||||
|
MediaArea(Td *td, telegram_api::object_ptr<telegram_api::MediaArea> &&media_area_ptr);
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::storyArea> get_story_area_object() const;
|
||||||
|
|
||||||
|
bool is_valid() const {
|
||||||
|
return type_ != Type::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const;
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const MediaArea &lhs, const MediaArea &rhs);
|
||||||
|
bool operator!=(const MediaArea &lhs, const MediaArea &rhs);
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const MediaArea &media_area);
|
||||||
|
|
||||||
|
} // namespace td
|
54
td/telegram/MediaArea.hpp
Normal file
54
td/telegram/MediaArea.hpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// 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/MediaArea.h"
|
||||||
|
#include "td/telegram/MediaAreaCoordinates.hpp"
|
||||||
|
|
||||||
|
#include "td/utils/tl_helpers.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void MediaArea::store(StorerT &storer) const {
|
||||||
|
using td::store;
|
||||||
|
BEGIN_STORE_FLAGS();
|
||||||
|
END_STORE_FLAGS();
|
||||||
|
store(type_, storer);
|
||||||
|
store(coordinates_, storer);
|
||||||
|
switch (type_) {
|
||||||
|
case Type::Location:
|
||||||
|
store(location_, storer);
|
||||||
|
break;
|
||||||
|
case Type::Venue:
|
||||||
|
store(venue_, storer);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void MediaArea::parse(ParserT &parser) {
|
||||||
|
using td::parse;
|
||||||
|
BEGIN_PARSE_FLAGS();
|
||||||
|
END_PARSE_FLAGS();
|
||||||
|
parse(type_, parser);
|
||||||
|
parse(coordinates_, parser);
|
||||||
|
switch (type_) {
|
||||||
|
case Type::Location:
|
||||||
|
parse(location_, parser);
|
||||||
|
break;
|
||||||
|
case Type::Venue:
|
||||||
|
parse(venue_, parser);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
parser.set_error("Load invalid area type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
Loading…
Reference in New Issue
Block a user