
    YPij                     V   d Z ddlZddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZ ddlmZmZmZ ddlmZ erddlm Z   G d de      Z! G d de      Z" G d de      Z# G d de      Z$ G d de      Z% G d de      Z& G d de      Z'y)z;This module contains the Telegram Business related classes.    N)Sequence)TYPE_CHECKINGOptionalUnion)ZoneInfo)Chat)Location)Sticker)TelegramObject)User)de_json_optionalde_list_optionalparse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestampget_zone_info)JSONDict)Botc            !            e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddddee   dee   dee   dee   d	ee   d
ee   dee   dee   dee   dee   dee   dee   dee   dee   dee   f fdZ xZ	S )BusinessBotRightsaW  
    This object represents the rights of a business bot.

    Objects of this class are comparable in terms of equality.
    Two objects of this class are considered equal, if all their attributes are equal.

    .. versionadded:: 22.1

    Args:
        can_reply (:obj:`bool`, optional): True, if the bot can send and edit messages in the
            private chats that had incoming messages in the last 24 hours.
        can_read_messages (:obj:`bool`, optional): True, if the bot can mark incoming private
            messages as read.
        can_delete_sent_messages (:obj:`bool`, optional): True, if the bot can delete messages
            sent by the bot.
        can_delete_all_messages (:obj:`bool`, optional): True, if the bot can delete all private
            messages in managed chats.
        can_edit_name (:obj:`bool`, optional): True, if the bot can edit the first and last name
            of the business account.
        can_edit_bio (:obj:`bool`, optional): True, if the bot can edit the bio of the
            business account.
        can_edit_profile_photo (:obj:`bool`, optional): True, if the bot can edit the profile
            photo of the business account.
        can_edit_username (:obj:`bool`, optional): True, if the bot can edit the username of the
            business account.
        can_change_gift_settings (:obj:`bool`, optional): True, if the bot can change the privacy
            settings pertaining to gifts for the business account.
        can_view_gifts_and_stars (:obj:`bool`, optional): True, if the bot can view gifts and the
            amount of Telegram Stars owned by the business account.
        can_convert_gifts_to_stars (:obj:`bool`, optional): True, if the bot can convert regular
            gifts owned by the business account to Telegram Stars.
        can_transfer_and_upgrade_gifts (:obj:`bool`, optional): True, if the bot can transfer and
            upgrade gifts owned by the business account.
        can_transfer_stars (:obj:`bool`, optional): True, if the bot can transfer Telegram Stars
            received by the business account to its own account, or use them to upgrade and
            transfer gifts.
        can_manage_stories (:obj:`bool`, optional): True, if the bot can post, edit and delete
            stories on behalf of the business account.

    Attributes:
        can_reply (:obj:`bool`): Optional. True, if the bot can send and edit messages in the
            private chats that had incoming messages in the last 24 hours.
        can_read_messages (:obj:`bool`): Optional. True, if the bot can mark incoming private
            messages as read.
        can_delete_sent_messages (:obj:`bool`): Optional. True, if the bot can delete messages
            sent by the bot.
        can_delete_all_messages (:obj:`bool`): Optional. True, if the bot can delete all private
            messages in managed chats.
        can_edit_name (:obj:`bool`): Optional. True, if the bot can edit the first and last name
            of the business account.
        can_edit_bio (:obj:`bool`): Optional. True, if the bot can edit the bio of the
            business account.
        can_edit_profile_photo (:obj:`bool`): Optional. True, if the bot can edit the profile
            photo of the business account.
        can_edit_username (:obj:`bool`): Optional. True, if the bot can edit the username of the
            business account.
        can_change_gift_settings (:obj:`bool`): Optional. True, if the bot can change the privacy
            settings pertaining to gifts for the business account.
        can_view_gifts_and_stars (:obj:`bool`): Optional. True, if the bot can view gifts and the
            amount of Telegram Stars owned by the business account.
        can_convert_gifts_to_stars (:obj:`bool`): Optional. True, if the bot can convert regular
            gifts owned by the business account to Telegram Stars.
        can_transfer_and_upgrade_gifts (:obj:`bool`): Optional. True, if the bot can transfer and
            upgrade gifts owned by the business account.
        can_transfer_stars (:obj:`bool`): Optional. True, if the bot can transfer Telegram Stars
            received by the business account to its own account, or use them to upgrade and
            transfer gifts.
        can_manage_stories (:obj:`bool`): Optional. True, if the bot can post, edit and delete
            stories on behalf of the business account.
    )can_change_gift_settingscan_convert_gifts_to_starscan_delete_all_messagescan_delete_sent_messagescan_edit_biocan_edit_namecan_edit_profile_photocan_edit_usernamecan_manage_storiescan_read_messages	can_replycan_transfer_and_upgrade_giftscan_transfer_starscan_view_gifts_and_starsN
api_kwargsr!   r    r   r   r   r   r   r   r   r$   r   r"   r#   r   r&   c                L   t         |   |       || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        || _        || _        || _        | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  f| _        | j#                          y Nr%   )super__init__r!   r    r   r   r   r   r   r   r   r$   r   r"   r#   r   	_id_attrs_freeze)selfr!   r    r   r   r   r   r   r   r   r$   r   r"   r#   r   r&   	__class__s                   H/root/twitch_bot/venv/lib/python3.12/site-packages/telegram/_business.pyr*   zBusinessBotRights.__init__   s   & 	J/)21B8P%7N$-:,86L#1B8P%8P%:T'>\+2D2D NN""))((''""))))++//####
" 	    )NNNNNNNNNNNNNN)
__name__
__module____qualname____doc__	__slots__r   boolr   r*   __classcell__r.   s   @r/   r   r   0   s"   ENI& %),03726(,'+15,03737599=-1-14" *.#4D>4 $D>4 #+4.	4
 "*$4  ~4 tn4 !)4 $D>4 #+4.4 #+4.4 %-TN4 )14 %TN4 %TN4" X&#4 4r0   r   c                        e Zd ZdZdZ	 ddddeddded	ej                  d
e	de
e   de
e   f fdZeddede
d   dd f fd       Z xZS )BusinessConnectiona  
    Describes the connection of the bot with a business account.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal if their :attr:`id`, :attr:`user`, :attr:`user_chat_id`, :attr:`date`,
    :attr:`rights`, and :attr:`is_enabled` are equal.

    .. versionadded:: 21.1
    .. versionchanged:: 22.1
        Equality comparison now considers :attr:`rights` instead of ``can_reply``.

    .. versionremoved:: 22.3
       Removed argument and attribute ``can_reply`` deprecated  by API 9.0.

    Args:
        id (:obj:`str`): Unique identifier of the business connection.
        user (:class:`telegram.User`): Business account user that created the business connection.
        user_chat_id (:obj:`int`): Identifier of a private chat with the user who created the
            business connection.
        date (:obj:`datetime.datetime`): Date the connection was established in Unix time.
        is_enabled (:obj:`bool`): True, if the connection is active.
        rights (:class:`BusinessBotRights`, optional): Rights of the business bot.

            .. versionadded:: 22.1

    Attributes:
        id (:obj:`str`): Unique identifier of the business connection.
        user (:class:`telegram.User`): Business account user that created the business connection.
        user_chat_id (:obj:`int`): Identifier of a private chat with the user who created the
            business connection.
        date (:obj:`datetime.datetime`): Date the connection was established in Unix time.
        is_enabled (:obj:`bool`): True, if the connection is active.
        rights (:class:`BusinessBotRights`): Optional. Rights of the business bot.

            .. versionadded:: 22.1
    )dateid
is_enabledrightsuseruser_chat_idNr%   r<   r?   r   r@   r;   r=   r>   r&   c                ,   t         |   |       || _        || _        || _        || _        || _        || _        | j                  | j                  | j                  | j
                  | j                  | j                  f| _        | j                          y r(   )
r)   r*   r<   r?   r@   r;   r=   r>   r+   r,   )	r-   r<   r?   r@   r;   r=   r>   r&   r.   s	           r/   r*   zBusinessConnection.__init__   s     	J/	!-"&	 *39 GGIIIIKKOO
 	r0   databotr   returnc                 (   | j                  |      }t        |      }t        |j                  d      |      |d<   t	        |j                  d      t
        |      |d<   t	        |j                  d      t        |      |d<   t        | !  ||      S ),See :meth:`telegram.TelegramObject.de_json`.r;   tzinfor?   r>   rB   rC   )	_parse_datar   r   getr   r   r   r)   de_json)clsrB   rC   
loc_tzinfor.   s       r/   rL   zBusinessConnection.de_json  s     t$ 2#6
%dhhv&6zJV'(8$DV)$((8*<>OQTUXwDc22r0   N)r1   r2   r3   r4   r5   strintdtmdatetimer6   r   r   r   r*   classmethodrL   r7   r8   s   @r/   r:   r:      s    #JI  /3 *.  	
 ll  *+ X&< 38 3(5/ 3EY 3 3r0   r:   c            
       t     e Zd ZdZdZdddededee   de	e
   f fd	Zedd
e
de	d   dd f fd       Z xZS )BusinessMessagesDeleteda  
    This object is received when messages are deleted from a connected business account.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal if their :attr:`business_connection_id`, :attr:`message_ids`, and
    :attr:`chat` are equal.

    .. versionadded:: 21.1

    Args:
        business_connection_id (:obj:`str`): Unique identifier of the business connection.
        chat (:class:`telegram.Chat`): Information about a chat in the business account. The bot
            may not have access to the chat or the corresponding user.
        message_ids (Sequence[:obj:`int`]): A list of identifiers of the deleted messages in the
            chat of the business account.

    Attributes:
        business_connection_id (:obj:`str`): Unique identifier of the business connection.
        chat (:class:`telegram.Chat`): Information about a chat in the business account. The bot
            may not have access to the chat or the corresponding user.
        message_ids (tuple[:obj:`int`]): A list of identifiers of the deleted messages in the
            chat of the business account.
    )business_connection_idchatmessage_idsNr%   rW   rX   rY   r&   c                    t         |   |       || _        || _        t	        |      | _        | j                  | j                  | j
                  f| _        | j                          y r(   )r)   r*   rW   rX   r   rY   r+   r,   )r-   rW   rX   rY   r&   r.   s        r/   r*   z BusinessMessagesDeleted.__init__;  s`     	J/+A#	,>{,K ''II
 	r0   rB   rC   r   rD   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )rF   rX   rI   )rJ   r   rK   r   r)   rL   rM   rB   rC   r.   s      r/   rL   zBusinessMessagesDeleted.de_jsonP  sA     t$'(8$DVwDc22r0   rO   )r1   r2   r3   r4   r5   rP   r   r   rQ   r   r   r*   rT   rL   r7   r8   s   @r/   rV   rV     sv    0I *. #  c]	 X&* 38 3(5/ 3E^ 3 3r0   rV   c                        e Zd ZdZdZ	 	 	 ddddee   dee   dee   dee   f fd	Z	e
dd
eded   dd f fd       Z xZS )BusinessIntroa3  
    This object contains information about the start page settings of a Telegram Business account.

    Objects of this class are comparable in terms of equality.
    Two objects of this class are considered equal, if their
    :attr:`title`, :attr:`message` and :attr:`sticker` are equal.

    .. versionadded:: 21.1

    Args:
        title (:obj:`str`, optional): Title text of the business intro.
        message (:obj:`str`, optional): Message text of the business intro.
        sticker (:class:`telegram.Sticker`, optional): Sticker of the business intro.

    Attributes:
        title (:obj:`str`): Optional. Title text of the business intro.
        message (:obj:`str`): Optional. Message text of the business intro.
        sticker (:class:`telegram.Sticker`): Optional. Sticker of the business intro.
    )messagestickertitleNr%   ra   r_   r`   r&   c                    t         |   |       || _        || _        || _        | j                  | j                  | j                  f| _        | j                          y r(   )r)   r*   ra   r_   r`   r+   r,   )r-   ra   r_   r`   r&   r.   s        r/   r*   zBusinessIntro.__init__u  sM     	J/$)
&-*1**dllDLLAr0   rB   rC   r   rD   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )rF   r`   rI   )rJ   r   rK   r
   r)   rL   r\   s      r/   rL   zBusinessIntro.de_json  sA     t$*488I+>MYwDc22r0   )NNNrO   )r1   r2   r3   r4   r5   r   rP   r
   r   r*   rT   rL   r7   r8   s   @r/   r^   r^   Z  s    (I  $!%%)	 *.} # '"	 X&" 38 3(5/ 3_ 3 3r0   r^   c            	       t     e Zd ZdZdZ	 ddddedee   dee   f fdZ	e
dd	ed
ed   dd f fd       Z xZS )BusinessLocationaD  
    This object contains information about the location of a Telegram Business account.

    Objects of this class are comparable in terms of equality.
    Two objects of this class are considered equal, if their
    :attr:`address` is equal.

    .. versionadded:: 21.1

    Args:
        address (:obj:`str`): Address of the business.
        location (:class:`telegram.Location`, optional): Location of the business.

    Attributes:
        address (:obj:`str`): Address of the business.
        location (:class:`telegram.Location`): Optional. Location of the business.
    )addresslocationNr%   rf   rg   r&   c                    t         |   |       || _        || _        | j                  f| _        | j                          y r(   )r)   r*   rf   rg   r+   r,   )r-   rf   rg   r&   r.   s       r/   r*   zBusinessLocation.__init__  s9     	J/#,4,,r0   rB   rC   r   rD   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )rF   rg   rI   )rJ   r   rK   r	   r)   rL   r\   s      r/   rL   zBusinessLocation.de_json  sB     t$+DHHZ,@(CPZwDc22r0   rO   )r1   r2   r3   r4   r5   rP   r   r	   r   r*   rT   rL   r7   r8   s   @r/   re   re     sw    $I (,
 *. 8$
 X& 38 3(5/ 3EW 3 3r0   re   c                        e Zd ZdZdZdddededee   f fdZd	ed
e	eeef   fdZ
ed
e	eeef   fd       Zed
e	eeef   fd       Z xZS )BusinessOpeningHoursIntervala|  
    This object describes an interval of time during which a business is open.

    Objects of this class are comparable in terms of equality.
    Two objects of this class are considered equal, if their
    :attr:`opening_minute` and :attr:`closing_minute` are equal.

    .. versionadded:: 21.1

    Examples:
        A day has (24 * 60 =) 1440 minutes, a week has (7 * 1440 =) 10080 minutes.
        Starting the minute's sequence from Monday, example values of
        :attr:`opening_minute`, :attr:`closing_minute` will map to the following day times:

        * Monday - 8am to 8:30pm:
            - ``opening_minute = 480`` :guilabel:`8 * 60`
            - ``closing_minute = 1230`` :guilabel:`20 * 60 + 30`
        * Tuesday - 24 hours:
            - ``opening_minute = 1440`` :guilabel:`24 * 60`
            - ``closing_minute = 2879`` :guilabel:`2 * 24 * 60 - 1`
        * Sunday - 12am - 11:58pm:
            - ``opening_minute = 8640`` :guilabel:`6 * 24 * 60`
            - ``closing_minute = 10078`` :guilabel:`7 * 24 * 60 - 2`

    Args:
        opening_minute (:obj:`int`): The minute's sequence number in a week, starting on Monday,
            marking the start of the time interval during which the business is open;
            0 - 7 * 24 * 60.
        closing_minute (:obj:`int`): The minute's
            sequence number in a week, starting on Monday, marking the end of the time interval
            during which the business is open; 0 - 8 * 24 * 60

    Attributes:
        opening_minute (:obj:`int`): The minute's sequence number in a week, starting on Monday,
            marking the start of the time interval during which the business is open;
            0 - 7 * 24 * 60.
        closing_minute (:obj:`int`): The minute's
            sequence number in a week, starting on Monday, marking the end of the time interval
            during which the business is open; 0 - 8 * 24 * 60
    )_closing_time_opening_timeclosing_minuteopening_minuteNr%   ro   rn   r&   c                    t         |   |       || _        || _        d | _        d | _        | j                  | j                  f| _        | j                          y r(   )r)   r*   ro   rn   rm   rl   r+   r,   )r-   ro   rn   r&   r.   s       r/   r*   z%BusinessOpeningHoursInterval.__init__  sV     	J/#1#1=A=A--t/B/BCr0   minuterD   c                 *    |dz  |dz  dz  |dz  dz  fS )N  <    )r-   rq   s     r/   _parse_minutez*BusinessOpeningHoursInterval._parse_minute  s%    $ 3Vd]R5GHHr0   c                 r    | j                    | j                  | j                        | _         | j                   S )aW  Convenience attribute. A :obj:`tuple` parsed from :attr:`opening_minute`. It contains
        the `weekday`, `hour` and `minute` in the same ranges as :attr:`datetime.datetime.weekday`,
        :attr:`datetime.datetime.hour` and :attr:`datetime.datetime.minute`

        Returns:
            tuple[:obj:`int`, :obj:`int`, :obj:`int`]:
        )rm   rv   ro   r-   s    r/   opening_timez)BusinessOpeningHoursInterval.opening_time  5     %!%!3!3D4G4G!HD!!!r0   c                 r    | j                    | j                  | j                        | _         | j                   S )aW  Convenience attribute. A :obj:`tuple` parsed from :attr:`closing_minute`. It contains
        the `weekday`, `hour` and `minute` in the same ranges as :attr:`datetime.datetime.weekday`,
        :attr:`datetime.datetime.hour` and :attr:`datetime.datetime.minute`

        Returns:
            tuple[:obj:`int`, :obj:`int`, :obj:`int`]:
        )rl   rv   rn   rx   s    r/   closing_timez)BusinessOpeningHoursInterval.closing_time  rz   r0   )r1   r2   r3   r4   r5   rQ   r   r   r*   tuplerv   propertyry   r|   r7   r8   s   @r/   rk   rk     s    'R WI *. 
 X&$IC IE#sC-,@ I 
"eCcM2 
" 
" 
"eCcM2 
" 
"r0   rk   c            
       2    e Zd ZdZdZdddedee   dee	   f fdZ
ed	efd
       Z	 ddej                  deej"                  edf   d	eeej&                  ej&                  f   df   fdZdej&                  d	efdZedde	ded   d	d f fd       Z xZS )BusinessOpeningHoursaS  
    This object describes the opening hours of a business.

    Objects of this class are comparable in terms of equality.
    Two objects of this class are considered equal, if their
    :attr:`time_zone_name` and :attr:`opening_hours` are equal.

    .. versionadded:: 21.1

    Args:
        time_zone_name (:obj:`str`): Unique name of the time zone for which the opening
            hours are defined.
        opening_hours (Sequence[:class:`telegram.BusinessOpeningHoursInterval`]): List of
            time intervals describing business opening hours.

    Attributes:
        time_zone_name (:obj:`str`): Unique name of the time zone for which the opening
            hours are defined.
        opening_hours (Sequence[:class:`telegram.BusinessOpeningHoursInterval`]): List of
            time intervals describing business opening hours.
    )_cached_zone_infoopening_hourstime_zone_nameNr%   r   r   r&   c                    t         |   |       || _        t        |      | _        d | _        | j                  | j                  f| _        | j                          y r(   )r)   r*   r   r   r   r   r+   r,   )r-   r   r   r&   r.   s       r/   r*   zBusinessOpeningHours.__init__6  sY     	J/#1EWF
 6:--t/A/ABr0   rD   c                 f    | j                   t        | j                        | _         | j                   S rO   )r   r   r   rx   s    r/   
_zone_infozBusinessOpeningHours._zone_infoI  s-    !!)%243F3F%GD"%%%r0   r;   	time_zone.c           	         |j                         }g }t        |t              rt        |      }n|| j                  }n|}| j
                  D ]  }|j                  }|j                  }|d   |k7  r$t        j                  |j                  |j                  |j                  |d   |d   | j                        j                  |      }	t        j                  |j                  |j                  |j                  |d   |d   | j                        j                  |      }
|j                  |	|
f        t        t!        |d             S )a  Returns the opening hours intervals for a specific day as datetime objects.

        .. versionadded:: 22.5

        Args:
            date (:obj:`datetime.date`): The date to get opening hours for.
            time_zone (:obj:`datetime.tzinfo` | :obj:`str`, optional): Timezone to use for the
                returned datetime objects. If not specified, then :attr:`time_zone_name` be used.

        Returns:
            tuple[tuple[:obj:`datetime.datetime`, :obj:`datetime.datetime`], ...]:
            A tuple of datetime pairs representing opening and closing times for the specified day.
            Each pair consists of ``(opening_time, closing_time)``.
            Returns an empty tuple if there are no opening hours for the given day.
        r         )yearmonthdayhourrq   rH   c                     | d   S )Nr   ru   )xs    r/   <lambda>z@BusinessOpeningHours.get_opening_hours_for_day.<locals>.<lambda>  s
    qt r0   )key)weekday
isinstancerP   r   r   r   ry   r|   rR   rS   r   r   r   
astimezoneappendr}   sorted)r-   r;   r   week_dayres	tz_targetintervalint_open	int_closeresult_int_openresult_int_closes              r/   get_opening_hours_for_dayz.BusinessOpeningHours.get_opening_hours_for_dayO  s1   & <<>i%$1)$<II!I** 	<H,,H --I{h& "llYYjjHHa[{ j#   #||YYjjHHq\ |  j#  JJ)9:;;	<@ VC^455r0   rS   c                 R   |j                   |j                  | j                        n|j                  | j                        }|j	                         dz  |j
                  dz  z   |j                  z   }| j                  D ]%  }|j                  |cxk  r|j                  k  s# y ' y)a  Check if the business is open at the specified datetime.

        .. versionadded:: 22.5

        Args:
            datetime (:obj:`datetime.datetime`): The datetime to check.
                If the object is timezone-naive, it is assumed to be in the
                timezone specified by :attr:`time_zone_name`.

        Returns:
            :obj:`bool`: True if the business is open at the specified time, False otherwise.
        rG   rs   rt   TF)
rH   replacer   r   r   r   rq   r   ro   rn   )r-   rS   datetime_in_native_tzminute_of_weekr   s        r/   is_openzBusinessOpeningHours.is_open  s     9A8OHDOO4U]
*T__
% 	 "))+d2#((2-.#**+ 	 ** 	H&&.R8;R;RR S	 r0   rB   rC   r   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )rF   r   rI   )rJ   r   rK   rk   r)   rL   r\   s      r/   rL   zBusinessOpeningHours.de_json  sH     t$ 0HH_%'CS!
_ wDc22r0   rO   )r1   r2   r3   r4   r5   rP   r   rk   r   r   r*   r~   r   r   rR   r;   r   rH   r}   rS   r   r6   r   rT   rL   r7   r8   s   @r/   r   r     s    , II *.   <=
 X&& &H & & IM<6HH<6).szz3/D)E<6	uS\\3<</0#5	6<6|  : 38 3(5/ 3E[ 3 3r0   r   )(r4   rS   rR   collections.abcr   typingr   r   r   zoneinfor   telegram._chatr   telegram._files.locationr	   telegram._files.stickerr
   telegram._telegramobjectr   telegram._userr   telegram._utils.argumentparsingr   r   r   telegram._utils.datetimer   r   r   telegram._utils.typesr   telegramr   r   r:   rV   r^   re   rk   r   ru   r0   r/   <module>r      s   ( B  $ 1 1   - + 3  
 
 +M M`Y3 Y3x;3n ;3|33N 33l.3~ .3bY"> Y"xV3> V3r0   