@@ -11866,3 +11866,308 @@ def convert_input_story(self):
1186611866 return self.to_json(), {self._video_name: self.video}
1186711867
1186811868
11869+ class StoryAreaPosition(JsonSerializable):
11870+ """
11871+ Describes the position of a clickable area within a story.
11872+
11873+ Telegram documentation: https://core.telegram.org/bots/api#storyareaposition
11874+
11875+ :param x_percentage: The abscissa of the area's center, as a percentage of the media width
11876+ :type x_percentage: :obj:`float`
11877+
11878+ :param y_percentage: The ordinate of the area's center, as a percentage of the media height
11879+ :type y_percentage: :obj:`float`
11880+
11881+ :param width_percentage: The width of the area's rectangle, as a percentage of the media width
11882+ :type width_percentage: :obj:`float`
11883+
11884+ :param height_percentage: The height of the area's rectangle, as a percentage of the media height
11885+ :type height_percentage: :obj:`float`
11886+
11887+ :param rotation_angle: The clockwise rotation angle of the rectangle, in degrees; 0-360
11888+ :type rotation_angle: :obj:`float`
11889+
11890+ :param corner_radius_percentage: The radius of the rectangle corner rounding, as a percentage of the media width
11891+ :type corner_radius_percentage: :obj:`float`
11892+
11893+ :return: Instance of the class
11894+ :rtype: :class:`StoryAreaPosition`
11895+ """
11896+ def __init__(self, x_percentage: float, y_percentage: float, width_percentage: float,
11897+ height_percentage: float, rotation_angle: float, corner_radius_percentage: float, **kwargs):
11898+ self.x_percentage: float = x_percentage
11899+ self.y_percentage: float = y_percentage
11900+ self.width_percentage: float = width_percentage
11901+ self.height_percentage: float = height_percentage
11902+ self.rotation_angle: float = rotation_angle
11903+ self.corner_radius_percentage: float = corner_radius_percentage
11904+ def to_json(self):
11905+ return json.dumps(self.to_dict())
11906+ def to_dict(self):
11907+ data = {
11908+ 'x_percentage': self.x_percentage,
11909+ 'y_percentage': self.y_percentage,
11910+ 'width_percentage': self.width_percentage,
11911+ 'height_percentage': self.height_percentage,
11912+ 'rotation_angle': self.rotation_angle,
11913+ 'corner_radius_percentage': self.corner_radius_percentage
11914+ }
11915+ return data
11916+
11917+
11918+ class LocationAddress(JsonSerializable):
11919+ """
11920+ Describes the physical address of a location.
11921+
11922+ Telegram documentation: https://core.telegram.org/bots/api#locationaddress
11923+
11924+ :param country_code: The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located
11925+ :type country_code: :obj:`str`
11926+
11927+ :param state: Optional. State of the location
11928+ :type state: :obj:`str`
11929+
11930+ :param city: Optional. City of the location
11931+ :type city: :obj:`str`
11932+
11933+ :param street: Optional. Street address of the location
11934+ :type street: :obj:`str`
11935+
11936+ :return: Instance of the class
11937+ :rtype: :class:`LocationAddress`
11938+ """
11939+ def __init__(self, country_code: str, state: Optional[str] = None, city: Optional[str] = None,
11940+ street: Optional[str] = None, **kwargs):
11941+ self.country_code: str = country_code
11942+ self.state: Optional[str] = state
11943+ self.city: Optional[str] = city
11944+ self.street: Optional[str] = street
11945+ def to_json(self):
11946+ return json.dumps(self.to_dict())
11947+ def to_dict(self):
11948+ data = {
11949+ 'country_code': self.country_code
11950+ }
11951+ if self.state is not None:
11952+ data['state'] = self.state
11953+ if self.city is not None:
11954+ data['city'] = self.city
11955+ if self.street is not None:
11956+ data['street'] = self.street
11957+ return data
11958+
11959+ class StoryAreaType(JsonSerializable):
11960+ """
11961+ Describes the type of a clickable area on a story. Currently, it can be one of
11962+ StoryAreaTypeLocation
11963+ StoryAreaTypeSuggestedReaction
11964+ StoryAreaTypeLink
11965+ StoryAreaTypeWeather
11966+ StoryAreaTypeUniqueGift
11967+
11968+ Telegram documentation: https://core.telegram.org/bots/api#storyarea
11969+
11970+ :return: Instance of the class
11971+ :rtype: :class:`StoryArea`
11972+ """
11973+
11974+
11975+ class StoryAreaTypeLocation(StoryAreaType):
11976+ """
11977+ Describes a story area pointing to a location. Currently, a story can have up to 10 location areas.
11978+
11979+ Telegram documentation: https://core.telegram.org/bots/api#storyareatypelocation
11980+
11981+ :param type: Type of the area, always “location”
11982+ :type type: :obj:`str`
11983+
11984+ :param latitude: Location latitude in degrees
11985+ :type latitude: :obj:`float`
11986+
11987+ :param longitude: Location longitude in degrees
11988+ :type longitude: :obj:`float`
11989+
11990+ :param address: Location address
11991+ :type address: :class:`LocationAddress`
11992+
11993+ :return: Instance of the class
11994+ :rtype: :class:`StoryAreaTypeLocation`
11995+ """
11996+ def __init__(self,latitude: float, longitude: float, address: LocationAddress, **kwargs):
11997+ self.type: str = "location"
11998+ self.latitude: float = latitude
11999+ self.longitude: float = longitude
12000+ self.address: LocationAddress = address
12001+ def to_json(self):
12002+ return json.dumps(self.to_dict())
12003+ def to_dict(self):
12004+ data = {
12005+ 'type': self.type,
12006+ 'latitude': self.latitude,
12007+ 'longitude': self.longitude,
12008+ 'address': self.address.to_json()
12009+ }
12010+ return data
12011+
12012+
12013+ class StoryAreaTypeSuggestedReaction(StoryAreaType):
12014+ """
12015+ Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas.
12016+
12017+ Telegram documentation: https://core.telegram.org/bots/api#storyareatypesuggestedreaction
12018+
12019+ :param type: Type of the area, always “suggested_reaction”
12020+ :type type: :obj:`str`
12021+
12022+ :param reaction_type: Type of the reaction
12023+ :type reaction_type: :class:`ReactionType`
12024+
12025+ :param is_dark: Optional. Pass True if the reaction area has a dark background
12026+ :type is_dark: :obj:`bool`
12027+
12028+ :param is_flipped: Optional. Pass True if reaction area corner is flipped
12029+ :type is_flipped: :obj:`bool`
12030+
12031+ :return: Instance of the class
12032+ :rtype: :class:`StoryAreaTypeSuggestedReaction`
12033+ """
12034+ def __init__(self, reaction_type: ReactionType, is_dark: Optional[bool] = None, is_flipped: Optional[bool] = None, **kwargs):
12035+ self.type: str = "suggested_reaction"
12036+ self.reaction_type: ReactionType = reaction_type
12037+ self.is_dark: Optional[bool] = is_dark
12038+ self.is_flipped: Optional[bool] = is_flipped
12039+ def to_json(self):
12040+ return json.dumps(self.to_dict())
12041+ def to_dict(self):
12042+ data = {
12043+ 'type': self.type,
12044+ 'reaction_type': self.reaction_type.to_json()
12045+ }
12046+ if self.is_dark is not None:
12047+ data['is_dark'] = self.is_dark
12048+ if self.is_flipped is not None:
12049+ data['is_flipped'] = self.is_flipped
12050+ return data
12051+
12052+ class StoryAreaTypeLink(StoryAreaType):
12053+ """
12054+ Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas.
12055+
12056+ Telegram documentation: https://core.telegram.org/bots/api#storyareatypelink
12057+
12058+ :param type: Type of the area, always “link”
12059+ :type type: :obj:`str`
12060+
12061+ :param url: HTTP or tg:// URL to be opened when the area is clicked
12062+ :type url: :obj:`str`
12063+
12064+ :return: Instance of the class
12065+ :rtype: :class:`StoryAreaTypeLink`
12066+ """
12067+ def __init__(self, url: str, **kwargs):
12068+ self.type: str = "link"
12069+ self.url: str = url
12070+ def to_json(self):
12071+ return json.dumps(self.to_dict())
12072+ def to_dict(self):
12073+ data = {
12074+ 'type': self.type,
12075+ 'url': self.url
12076+ }
12077+ return data
12078+
12079+ class StoryAreaTypeWeather(StoryAreaType):
12080+ """
12081+ Describes a story area containing weather information. Currently, a story can have up to 3 weather areas.
12082+
12083+ Telegram documentation: https://core.telegram.org/bots/api#storyareatypeweather
12084+
12085+ :param type: Type of the area, always “weather”
12086+ :type type: :obj:`str`
12087+
12088+ :param temperature: Temperature, in degree Celsius
12089+ :type temperature: :obj:`float`
12090+
12091+ :param emoji: Emoji representing the weather
12092+ :type emoji: :obj:`str`
12093+
12094+ :param background_color: A color of the area background in the ARGB format
12095+ :type background_color: :obj:`int`
12096+
12097+ :return: Instance of the class
12098+ :rtype: :class:`StoryAreaTypeWeather`
12099+ """
12100+ def __init__(self, temperature: float, emoji: str, background_color: int, **kwargs):
12101+ self.type: str = "weather"
12102+ self.temperature: float = temperature
12103+ self.emoji: str = emoji
12104+ self.background_color: int = background_color
12105+ def to_json(self):
12106+ return json.dumps(self.to_dict())
12107+ def to_dict(self):
12108+ data = {
12109+ 'type': self.type,
12110+ 'temperature': self.temperature,
12111+ 'emoji': self.emoji,
12112+ 'background_color': self.background_color
12113+ }
12114+ return data
12115+
12116+ class StoryAreaTypeUniqueGift(StoryAreaType):
12117+ """
12118+ Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area.
12119+
12120+ Telegram documentation: https://core.telegram.org/bots/api#storyareatypeuniquegift
12121+
12122+ :param type: Type of the area, always “unique_gift”
12123+ :type type: :obj:`str`
12124+
12125+ :param name: Unique name of the gift
12126+ :type name: :obj:`str`
12127+
12128+ :return: Instance of the class
12129+ :rtype: :class:`StoryAreaTypeUniqueGift`
12130+ """
12131+ def __init__(self, name: str, **kwargs):
12132+ self.type: str = "unique_gift"
12133+ self.name: str = name
12134+ def to_json(self):
12135+ return json.dumps(self.to_dict())
12136+ def to_dict(self):
12137+ data = {
12138+ 'type': self.type,
12139+ 'name': self.name
12140+ }
12141+
12142+ return data
12143+
12144+
12145+ class StoryArea(JsonSerializable):
12146+ """
12147+ Describes a clickable area on a story media.
12148+
12149+ Telegram documentation: https://core.telegram.org/bots/api#storyarea
12150+
12151+ :param position: Position of the area
12152+ :type position: :class:`StoryAreaPosition`
12153+
12154+ :param type: Type of the area
12155+ :type type: :class:`StoryAreaType`
12156+
12157+ :return: Instance of the class
12158+ :rtype: :class:`StoryArea`
12159+ """
12160+ def __init__(self, position: StoryAreaPosition, type: StoryAreaType, **kwargs):
12161+ self.position: StoryAreaPosition = position
12162+ self.type: StoryAreaType = type
12163+ def to_json(self):
12164+ return json.dumps(self.to_dict())
12165+ def to_dict(self):
12166+ data = {
12167+ 'position': self.position.to_json(),
12168+ 'type': self.type.to_json()
12169+ }
12170+ return data
12171+
12172+
12173+
0 commit comments