L iAdZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZmZmZdd lmZmZdd lmZmZdd lmZdd lmZerdd lmZmZGdde ZGdde Z Gdde Z!Gdde Z"y)z?This module contains an objects related to Telegram checklists.N)Sequence) TYPE_CHECKINGOptional) MessageEntity)TelegramObject)User)de_json_optionalde_list_optionalparse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)parse_message_entitiesparse_message_entity)JSONDict) ZERO_DATE)BotMessageceZdZdZdZ ddddededeee dee d ee jd ee f fd Zedd e d edddffd Zde defdZddeeedee effdZxZS) ChecklistTaska Describes a task in a checklist. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`id` is equal. .. versionadded:: 22.3 Args: id (:obj:`int`): Unique identifier of the task. text (:obj:`str`): Text of the task. text_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities that appear in the task text. completed_by_user (:class:`telegram.User`, optional): User that completed the task; omitted if the task wasn't completed completion_date (:class:`datetime.datetime`, optional): Point in time when the task was completed; :attr:`~telegram.constants.ZERO_DATE` if the task wasn't completed |datetime_localization| Attributes: id (:obj:`int`): Unique identifier of the task. text (:obj:`str`): Text of the task. text_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. Special entities that appear in the task text. completed_by_user (:class:`telegram.User`): Optional. User that completed the task; omitted if the task wasn't completed completion_date (:class:`datetime.datetime`): Optional. Point in time when the task was completed; :attr:`~telegram.constants.ZERO_DATE` if the task wasn't completed |datetime_localization| )completed_by_usercompletion_dateidtext text_entitiesN api_kwargsrrrrrrct||||_||_t ||_||_||_|jf|_|jyNr) super__init__rrr rrr _id_attrs_freeze)selfrrrrrr __class__s Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/_checklists.pyr zChecklistTask.__init__RsV J/ 8J=8Y1B7F'' databotrreturncJ|j|}t|}|jdx}dk(r t|d<nt |||d<t |jdt ||d<t|jdt||d<t|)||S),See :meth:`telegram.TelegramObject.de_json`.rr)tzinforrr'r() _parse_datar getrr r rr rrde_json)clsr'r( loc_tzinfodater$s r%r0zChecklistTask.de_jsongst$2#6 HH./ /DA 5&/D" #&4T*&MD" #$4TXX>Q5RTXZ]$^ ! 0/1JM[^ __wDc22r&entityc.t|j|S)aReturns the text in :attr:`text` from a given :class:`telegram.MessageEntity` of :attr:`text_entities`. Note: This method is present because Telegram calculates the offset and length in UTF-16 codepoint pairs, which some versions of Python don't handle automatically. (That is, you can't just slice ``ChecklistTask.text`` with the offset and length.) Args: entity (:class:`telegram.MessageEntity`): The entity to extract the text from. It must be an entity that belongs to :attr:`text_entities`. Returns: :obj:`str`: The text of the given entity. )rrr#r4s r% parse_entityzChecklistTask.parse_entityys $DIIv66r&typescDt|j|j|S)a Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`. It contains entities from this checklist task filtered by their ``type`` attribute as the key, and the text that each entity belongs to as the value of the :obj:`dict`. Note: This method should always be used instead of the :attr:`text_entities` attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. See :attr:`parse_entity` for more info. Args: types (list[:obj:`str`], optional): List of ``MessageEntity`` types as strings. If the ``type`` attribute of an entity is contained in this list, it will be returned. Defaults to :attr:`telegram.MessageEntity.ALL_TYPES`. Returns: dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints. )rrrr#r8s r%parse_entitieszChecklistTask.parse_entitiess(&dii1C1CUKKr&NNNN)__name__ __module__ __qualname____doc__ __slots__intstrrrrrdtmdatetimerr classmethodr0r7listdictr; __classcell__r$s@r%rr&s!FI<@,026 *.   78  $D>  "#,,/ X&*383(5/3_33"7=7S7$LHT#Y$7L4 WZHZC[Lr&rceZdZdZdZ ddddedeedeee dee d ee d ee f fd Z e dd e d edddffd Zde defdZddeeedee effdZxZS) Checklista Describes a checklist. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if all their :attr:`tasks` are equal. .. versionadded:: 22.3 Args: title (:obj:`str`): Title of the checklist. title_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities that appear in the checklist title. tasks (Sequence[:class:`telegram.ChecklistTask`]): List of tasks in the checklist. others_can_add_tasks (:obj:`bool`, optional): :obj:`True` if users other than the creator of the list can add tasks to the list others_can_mark_tasks_as_done (:obj:`bool`, optional): :obj:`True` if users other than the creator of the list can mark tasks as done or not done Attributes: title (:obj:`str`): Title of the checklist. title_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. Special entities that appear in the checklist title. tasks (Tuple[:class:`telegram.ChecklistTask`]): List of tasks in the checklist. others_can_add_tasks (:obj:`bool`): Optional. :obj:`True` if users other than the creator of the list can add tasks to the list others_can_mark_tasks_as_done (:obj:`bool`): Optional. :obj:`True` if users other than the creator of the list can mark tasks as done or not done )others_can_add_tasksothers_can_mark_tasks_as_donetaskstitletitle_entitiesNrrQrPrRrNrOrct||||_t||_t||_||_||_|j f|_|jyr) rr rQr rRrPrNrOr!r")r#rQrPrRrNrOrr$s r%r zChecklist.__init__s[ J/ 9KN9[0B50I 4H!=Z*** r&r'r(rr)c|j|}t|jdt||d<t|jdt||d<t |||S)r+rRrPr-)r.r r/rrrr0)r1r'r(r$s r%r0zChecklist.de_jsons`t$!1$((;K2Lm]`!a ('):M3OW wDc22r&r4c.t|j|S)aReturns the text in :attr:`title` from a given :class:`telegram.MessageEntity` of :attr:`title_entities`. Note: This method is present because Telegram calculates the offset and length in UTF-16 codepoint pairs, which some versions of Python don't handle automatically. (That is, you can't just slice :attr:`title` with the offset and length.) Args: entity (:class:`telegram.MessageEntity`): The entity to extract the text from. It must be an entity that belongs to :attr:`title_entities`. Returns: :obj:`str`: The text of the given entity. )rrQr6s r%r7zChecklist.parse_entitys $DJJ77r&r8cDt|j|j|S)a  Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`. It contains entities from this checklist's title filtered by their ``type`` attribute as the key, and the text that each entity belongs to as the value of the :obj:`dict`. Note: This method should always be used instead of the :attr:`title_entities` attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. See :attr:`parse_entity` for more info. Args: types (list[:obj:`str`], optional): List of ``MessageEntity`` types as strings. If the ``type`` attribute of an entity is contained in this list, it will be returned. Defaults to :attr:`telegram.MessageEntity.ALL_TYPES`. Returns: dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints. )rrQrRr:s r%r;zChecklist.parse_entitiess(&djj$2E2EuMMr&r<r=)r>r?r@rArBrDrrrrboolrr rGr0r7rHrIr;rJrKs@r%rMrMs:I=A/38< *. &!-!89  'tn  (0~ X&*383(5/3[338=8S8$NHT#Y$7N4 WZHZC[Nr&rMc eZdZdZdZ ddddeddeeedeeed eeffd Z e dd ed ed ddffd Z xZ S)ChecklistTasksDonea Describes a service message about checklist tasks marked as done or not done. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`marked_as_done_task_ids` and :attr:`marked_as_not_done_task_ids` are equal. .. versionadded:: 22.3 Args: checklist_message (:class:`telegram.Message`, optional): Message containing the checklist whose tasks were marked as done or not done. Note that the ~:class:`telegram.Message` object in this field will not contain the :attr:`~telegram.Message.reply_to_message` field even if it itself is a reply. marked_as_done_task_ids (Sequence[:obj:`int`], optional): Identifiers of the tasks that were marked as done marked_as_not_done_task_ids (Sequence[:obj:`int`], optional): Identifiers of the tasks that were marked as not done Attributes: checklist_message (:class:`telegram.Message`): Optional. Message containing the checklist whose tasks were marked as done or not done. Note that the ~:class:`telegram.Message` object in this field will not contain the :attr:`~telegram.Message.reply_to_message` field even if it itself is a reply. marked_as_done_task_ids (Tuple[:obj:`int`]): Optional. Identifiers of the tasks that were marked as done marked_as_not_done_task_ids (Tuple[:obj:`int`]): Optional. Identifiers of the tasks that were marked as not done )checklist_messagemarked_as_done_task_idsmarked_as_not_done_task_idsNrrZrr[r\rct||||_t||_t||_|j|j f|_|jyr)rr rZr r[r\r!r")r#rZr[r\rr$s r%r zChecklistTasksDone.__init__5s^ J/4E8JKb8c$Q5RT[]`$a !wDc22r&r<r=) r>r?r@rArBrrrCrr rGr0rJrKs@r%rYrYs<I26;??C  *. #I."*(3-!8&.hsm%<  X& & 38 3(5/ 3EY 3 3r&rYc zeZdZdZdZ ddddeededdeeffd Z e dd ed ed d dffd Z xZ S)ChecklistTasksAddedaX Describes a service message about tasks added to a checklist. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`tasks` are equal. .. versionadded:: 22.3 Args: checklist_message (:class:`telegram.Message`, optional): Message containing the checklist to which tasks were added. Note that the ~:class:`telegram.Message` object in this field will not contain the :attr:`~telegram.Message.reply_to_message` field even if it itself is a reply. tasks (Sequence[:class:`telegram.ChecklistTask`]): List of tasks added to the checklist Attributes: checklist_message (:class:`telegram.Message`): Optional. Message containing the checklist to which tasks were added. Note that the ~:class:`telegram.Message` object in this field will not contain the :attr:`~telegram.Message.reply_to_message` field even if it itself is a reply. tasks (Tuple[:class:`telegram.ChecklistTask`]): List of tasks added to the checklist )rZrPNrrPrZrrct||||_t||_|jf|_|j yr)rr rZr rPr!r")r#rPrZrr$s r%r zChecklistTasksAdded.__init__os? J/4E0B50I ** r&r'r(rr)c|j|}ddlm}t|j d|||d<t j |j dg||d<t|!||S)r+rr_rZrPr-) r.r`rr r/rde_listrr0ras r%r0zChecklistTasksAdded.de_json~slt$ %$4TXX>Q5RT[]`$a !%--dhhw.CSIW wDc22r&r=) r>r?r@rArBrrrrr rGr0rJrKs@r%rcrcUs|./I 26  *.  & $I.  X&  38 3(5/ 3EZ 3 3r&rc)#rArFrEcollections.abcrtypingrrtelegram._messageentityrtelegram._telegramobjectrtelegram._userrtelegram._utils.argumentparsingr r r telegram._utils.datetimer r telegram._utils.entitiesrrtelegram._utils.typesrtelegram.constantsrr`rrrrMrYrcr&r%rrsr&F$*13bbQQ*(%yLNyLxkNkN\B3B3J43.43r&