wpyrogram
Advanced tools
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from pyrogram import raw | ||
| from .auto_name import AutoName | ||
| class PrivacyKey(AutoName): | ||
| """Privacy key enumeration used in :meth:`~pyrogram.Client.set_privacy`.""" | ||
| ABOUT = raw.types.InputPrivacyKeyAbout | ||
| "Whether people can see your bio" | ||
| ADDED_BY_PHONE = raw.types.InputPrivacyKeyAddedByPhone | ||
| "Whether people can add you to their contact list by your phone number" | ||
| BIRTHDAY = raw.types.InputPrivacyKeyBirthday | ||
| "Whether the user can see our birthday." | ||
| CHAT_INVITE = raw.types.InputPrivacyKeyChatInvite | ||
| "Whether people will be able to invite you to chats" | ||
| FORWARDS = raw.types.InputPrivacyKeyForwards | ||
| "Whether messages forwarded from you will be anonymous" | ||
| PHONE_CALL = raw.types.InputPrivacyKeyPhoneCall | ||
| "Whether you will accept phone calls" | ||
| PHONE_NUMBER = raw.types.InputPrivacyKeyPhoneNumber | ||
| "Whether people will be able to see your phone number" | ||
| PHONE_P2P = raw.types.InputPrivacyKeyPhoneP2P | ||
| "Whether to allow P2P communication during VoIP calls" | ||
| PROFILE_PHOTO = raw.types.InputPrivacyKeyProfilePhoto | ||
| "Whether people will be able to see your profile picture" | ||
| STATUS = raw.types.InputPrivacyKeyStatusTimestamp | ||
| "Whether people will be able to see our exact last online timestamp." | ||
| VOICE_MESSAGES = raw.types.InputPrivacyKeyVoiceMessages | ||
| "Whether people can send you voice messages or round videos (Premium users only)." |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from .get_account_ttl import GetAccountTTL | ||
| from .get_privacy import GetPrivacy | ||
| from .set_account_ttl import SetAccountTTL | ||
| from .set_privacy import SetPrivacy | ||
| class Account( | ||
| GetAccountTTL, | ||
| GetPrivacy, | ||
| SetAccountTTL, | ||
| SetPrivacy | ||
| ): | ||
| pass |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| class GetAccountTTL: | ||
| async def get_account_ttl( | ||
| self: "pyrogram.Client", | ||
| ): | ||
| """Get days to live of account. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Returns: | ||
| ``int``: Time to live in days of the current account. | ||
| Example: | ||
| .. code-block:: python | ||
| # Get ttl in days | ||
| await app.get_account_ttl() | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.account.GetAccountTTL() | ||
| ) | ||
| return r.days |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw, types, enums | ||
| class GetPrivacy: | ||
| async def get_privacy( | ||
| self: "pyrogram.Client", | ||
| key: "enums.PrivacyKey" | ||
| ): | ||
| """Get account privacy rules. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| key (:obj:`~pyrogram.enums.PrivacyKey`): | ||
| Privacy key. | ||
| Returns: | ||
| List of :obj:`~pyrogram.types.PrivacyRule`: On success, the list of privacy rules is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| from pyrogram import enums | ||
| await app.get_privacy(enums.PrivacyKey.PHONE_NUMBER) | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.account.GetPrivacy( | ||
| key=key.value() | ||
| ) | ||
| ) | ||
| users = {i.id: i for i in r.users} | ||
| chats = {i.id: i for i in r.chats} | ||
| return types.List(types.PrivacyRule._parse(self, rule, users, chats) for rule in r.rules) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| class SetAccountTTL: | ||
| async def set_account_ttl( | ||
| self: "pyrogram.Client", | ||
| days: int | ||
| ): | ||
| """Set days to live of account. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| days (``int``): | ||
| Time to live in days. | ||
| Returns: | ||
| ``bool``: On success, True is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| # Set ttl in days | ||
| await app.set_account_ttl(365) | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.account.SetAccountTTL( | ||
| ttl=raw.types.AccountDaysTTL(days=days) | ||
| ) | ||
| ) | ||
| return r |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import List, Union | ||
| import pyrogram | ||
| from pyrogram import raw, types, enums | ||
| class SetPrivacy: | ||
| async def set_privacy( | ||
| self: "pyrogram.Client", | ||
| key: "enums.PrivacyKey", | ||
| rules: List[Union[ | ||
| "types.InputPrivacyRuleAllowAll", | ||
| "types.InputPrivacyRuleAllowContacts", | ||
| "types.InputPrivacyRuleAllowPremium", | ||
| "types.InputPrivacyRuleAllowUsers", | ||
| "types.InputPrivacyRuleAllowChats", | ||
| "types.InputPrivacyRuleDisallowAll", | ||
| "types.InputPrivacyRuleDisallowContacts", | ||
| "types.InputPrivacyRuleDisallowUsers", | ||
| "types.InputPrivacyRuleDisallowChats", | ||
| ]], | ||
| ): | ||
| """Set account privacy rules. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| key (:obj:`~pyrogram.enums.PrivacyKey`): | ||
| Privacy key. | ||
| rules (Iterable of :obj:`~pyrogram.types.InputPrivacyRule`): | ||
| List of privacy rules. | ||
| Returns: | ||
| List of :obj:`~pyrogram.types.PrivacyRule`: On success, the list of privacy rules is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| from pyrogram import enums, types | ||
| # Prevent everyone from seeing your phone number | ||
| await app.set_privacy(enums.PrivacyKey.PHONE_NUMBER, [types.InputPrivacyRuleDisallowAll()]) | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.account.SetPrivacy( | ||
| key=key.value(), | ||
| rules=[await rule.write(self) for rule in rules] | ||
| ) | ||
| ) | ||
| users = {i.id: i for i in r.users} | ||
| chats = {i.id: i for i in r.chats} | ||
| return types.List(types.PrivacyRule._parse(self, rule, users, chats) for rule in r.rules) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw, types | ||
| class GetActiveSessions: | ||
| async def get_active_sessions( | ||
| self: "pyrogram.Client" | ||
| ) -> "types.ActiveSessions": | ||
| """Returns all active sessions of the current user. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Returns: | ||
| :obj:`~pyrogram.types.ActiveSessions`: On success, all the active sessions of the current user is returned. | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.account.GetAuthorizations() | ||
| ) | ||
| return types.ActiveSessions._parse(r) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| class ResetSession: | ||
| async def reset_session( | ||
| self: "pyrogram.Client", | ||
| id: int | ||
| ) -> bool: | ||
| """Log out an active authorized session by its hash. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Returns: | ||
| ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned. | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.account.ResetAuthorization(hash=id) | ||
| ) | ||
| return r |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| class ResetSessions: | ||
| async def reset_sessions( | ||
| self: "pyrogram.Client" | ||
| ) -> bool: | ||
| """Terminates all user's authorized sessions except for the current one. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Returns: | ||
| ``bool``: On success, in case the sessions is destroyed, True is returned. Otherwise, False is returned. | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.auth.ResetAuthorizations() | ||
| ) | ||
| return r |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import Union | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| class RefundStarPayment: | ||
| async def refund_star_payment( | ||
| self: "pyrogram.Client", | ||
| user_id: Union[int, str], | ||
| telegram_payment_charge_id: str | ||
| ) -> bool: | ||
| """Refunds a successful payment in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| .. include:: /_includes/usable-by/bots.rst | ||
| Parameters: | ||
| user_id (``int`` | ``str``): | ||
| Unique identifier (int) or username (str) of the target user, whose payment will be refunded. | ||
| telegram_payment_charge_id (``str``): | ||
| Telegram payment identifier. | ||
| Returns: | ||
| ``bool``: True on success | ||
| """ | ||
| r = await self.invoke( | ||
| raw.functions.payments.RefundStarsCharge( | ||
| user_id=await self.resolve_peer(user_id), | ||
| charge_id=telegram_payment_charge_id | ||
| ) | ||
| ) | ||
| return bool(r) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import logging | ||
| from typing import List, Optional, Union | ||
| import pyrogram | ||
| from pyrogram import enums, raw, utils, types | ||
| log = logging.getLogger(__name__) | ||
| class SendInvoice: | ||
| async def send_invoice( | ||
| self: "pyrogram.Client", | ||
| chat_id: Union[int, str], | ||
| title: str, | ||
| description: str, | ||
| payload: Union[str, bytes], | ||
| currency: str, | ||
| prices: List["types.LabeledPrice"], | ||
| message_thread_id: Optional[int] = None, | ||
| provider_token: Optional[str] = None, | ||
| max_tip_amount: Optional[int] = None, | ||
| suggested_tip_amounts: Optional[List[int]] = None, | ||
| start_parameter: Optional[str] = None, | ||
| provider_data: Optional[str] = None, | ||
| photo_url: Optional[str] = None, | ||
| photo_size: Optional[int] = None, | ||
| photo_width: Optional[int] = None, | ||
| photo_height: Optional[int] = None, | ||
| need_name: Optional[bool] = None, | ||
| need_phone_number: Optional[bool] = None, | ||
| need_email: Optional[bool] = None, | ||
| need_shipping_address: Optional[bool] = None, | ||
| send_phone_number_to_provider: Optional[bool] = None, | ||
| send_email_to_provider: Optional[bool] = None, | ||
| is_flexible: Optional[bool] = None, | ||
| disable_notification: Optional[bool] = None, | ||
| protect_content: Optional[bool] = None, | ||
| message_effect_id: Optional[int] = None, | ||
| reply_to_message_id: Optional[int] = None, | ||
| reply_markup: Optional[Union[ | ||
| "types.InlineKeyboardMarkup", | ||
| "types.ReplyKeyboardMarkup", | ||
| "types.ReplyKeyboardRemove", | ||
| "types.ForceReply" | ||
| ]] = None, | ||
| caption: str = "", | ||
| parse_mode: Optional["enums.ParseMode"] = None, | ||
| caption_entities: Optional[List["types.MessageEntity"]] = None | ||
| ) -> "types.Message": | ||
| """Use this method to send invoices. | ||
| .. include:: /_includes/usable-by/bots.rst | ||
| Parameters: | ||
| chat_id (``int`` | ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| title (``str``): | ||
| Product name, 1-32 characters. | ||
| description (``str``): | ||
| Product description, 1-255 characters | ||
| payload (``str`` | ``bytes``): | ||
| Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. | ||
| currency (``str``): | ||
| Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass ``XTR`` for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| prices (List of :obj:`~pyrogram.types.LabeledPrice`): | ||
| Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| message_thread_id (``int``, *optional*): | ||
| If the message is in a thread, ID of the original message. | ||
| reply_to_message_id (``int``, *optional*): | ||
| If the message is a reply, ID of the original message. | ||
| provider_token (``str``, *optional*): | ||
| Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| max_tip_amount (``int``, *optional*): | ||
| The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of ``US$ 1.45`` pass ``max_tip_amount = 145``. See the exp parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| suggested_tip_amounts (List of ``int``, *optional*): | ||
| An array of suggested amounts of tips in the smallest units of the currency (integer, **not** float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed ``max_tip_amount``. | ||
| start_parameter (``str``, *optional*): | ||
| Unique deep-linking parameter. If left empty, **forwarded copies** of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter. | ||
| provider_data (``str``, *optional*): | ||
| JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. | ||
| photo_url (``str``, *optional*): | ||
| URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. | ||
| photo_size (``int``, *optional*): | ||
| Photo size in bytes | ||
| photo_width (``int``, *optional*): | ||
| Photo width | ||
| photo_height (``int``, *optional*): | ||
| Photo height | ||
| need_name (``bool``, *optional*): | ||
| Pass True if you require the user's full name to complete the order. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| need_phone_number (``bool``, *optional*): | ||
| Pass True if you require the user's phone number to complete the order. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| need_email (``bool``, *optional*): | ||
| Pass True if you require the user's email address to complete the order. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| need_shipping_address (``bool``, *optional*): | ||
| Pass True if you require the user's shipping address to complete the order. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| send_phone_number_to_provider (``bool``, *optional*): | ||
| Pass True if the user's phone number should be sent to the provider. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| send_email_to_provider (``bool``, *optional*): | ||
| Pass True if the user's email address should be sent to the provider. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| is_flexible (``bool``, *optional*): | ||
| Pass True if the final price depends on the shipping method. Ignored for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| disable_notification (``bool``, *optional*): | ||
| Sends the message silently. | ||
| Users will receive a notification with no sound. | ||
| protect_content (``bool``, *optional*): | ||
| Protects the contents of the sent message from forwarding and saving. | ||
| message_effect_id (``int`` ``64-bit``, *optional*): | ||
| Unique identifier of the message effect to be added to the message; for private chats only. | ||
| reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*): | ||
| Additional interface options. An object for an inline keyboard, custom reply keyboard, | ||
| instructions to remove reply keyboard or to force a reply from the user. | ||
| caption (``str``, *optional*): | ||
| Document caption, 0-1024 characters. | ||
| parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*): | ||
| By default, texts are parsed using both Markdown and HTML styles. | ||
| You can combine both syntaxes together. | ||
| caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): | ||
| List of special entities that appear in the caption, which can be specified instead of *parse_mode*. | ||
| Returns: | ||
| :obj:`~pyrogram.types.Message`: On success, the sent invoice message is returned. | ||
| """ | ||
| media = raw.types.InputMediaInvoice( | ||
| title=title, | ||
| description=description, | ||
| photo=raw.types.InputWebDocument( | ||
| url=photo_url, | ||
| mime_type="image/jpg", | ||
| size=photo_size, | ||
| attributes=[ | ||
| raw.types.DocumentAttributeImageSize( | ||
| w=photo_width, | ||
| h=photo_height | ||
| ) | ||
| ] | ||
| ) if photo_url else None, | ||
| invoice=raw.types.Invoice( | ||
| currency=currency, | ||
| prices=[i.write() for i in prices], | ||
| test=self.test_mode, | ||
| name_requested=need_name, | ||
| phone_requested=need_phone_number, | ||
| email_requested=need_email, | ||
| shipping_address_requested=need_shipping_address, | ||
| flexible=is_flexible, | ||
| phone_to_provider=send_phone_number_to_provider, | ||
| email_to_provider=send_email_to_provider, | ||
| max_tip_amount=max_tip_amount, | ||
| suggested_tip_amounts=suggested_tip_amounts | ||
| ), | ||
| payload=payload.encode() if isinstance(payload, str) else payload, | ||
| provider=provider_token, | ||
| provider_data=raw.types.DataJSON( | ||
| data=provider_data if provider_data else "{}" | ||
| ), | ||
| start_param=start_parameter | ||
| ) | ||
| rpc = raw.functions.messages.SendMedia( | ||
| peer=await self.resolve_peer(chat_id), | ||
| media=media, | ||
| silent=disable_notification or None, | ||
| reply_to=utils.get_reply_to( | ||
| reply_to_message_id=reply_to_message_id, | ||
| message_thread_id=message_thread_id | ||
| ), | ||
| random_id=self.rnd_id(), | ||
| noforwards=protect_content, | ||
| reply_markup=await reply_markup.write(self) if reply_markup else None, | ||
| effect=message_effect_id, | ||
| **await utils.parse_text_entities(self, caption, parse_mode, caption_entities) | ||
| ) | ||
| r = await self.invoke(rpc) | ||
| for i in r.updates: | ||
| if isinstance(i, (raw.types.UpdateNewMessage, | ||
| raw.types.UpdateNewChannelMessage, | ||
| raw.types.UpdateNewScheduledMessage, | ||
| raw.types.UpdateBotNewBusinessMessage)): | ||
| return await types.Message._parse( | ||
| self, i.message, | ||
| {i.id: i for i in r.users}, | ||
| {i.id: i for i in r.chats}, | ||
| is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage), | ||
| business_connection_id=getattr(i, "connection_id", None) | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from pyrogram import types | ||
| class SearchContacts: | ||
| async def search_contacts( | ||
| self: "pyrogram.Client", | ||
| query: str, | ||
| limit: int = 0 | ||
| ): | ||
| """Returns users or channels found by name substring and auxiliary data. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| query (``str``): | ||
| Target substring. | ||
| limit (``int``, *optional*): | ||
| Maximum number of users to be returned. | ||
| Returns: | ||
| :obj:`~pyrogram.types.FoundContacts`: On success, a list of chats is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| await app.search_contacts("pyrogram") | ||
| """ | ||
| total = limit or (1 << 31) - 1 | ||
| limit = min(100, total) | ||
| r = await self.invoke( | ||
| raw.functions.contacts.Search( | ||
| q=query, | ||
| limit=limit | ||
| ) | ||
| ) | ||
| return types.FoundContacts._parse(self, r) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from datetime import datetime | ||
| import logging | ||
| from typing import Union | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from pyrogram import utils | ||
| log = logging.getLogger(__name__) | ||
| class DeleteChatHistory: | ||
| async def delete_chat_history( | ||
| self: "pyrogram.Client", | ||
| chat_id: Union[int, str], | ||
| max_id: int = 0, | ||
| revoke: bool = None, | ||
| just_clear = None, | ||
| min_date: datetime = None, | ||
| max_date: datetime = None, | ||
| ) -> int: | ||
| """Delete the history of a chat. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| chat_id (``int`` | ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| max_id (``int``, *optional*): | ||
| Maximum ID of message to delete. | ||
| revoke (``bool``, *optional*): | ||
| Deletes messages history for everyone. | ||
| Required ``True`` if using in channel. | ||
| just_clear (``bool``, *optional*): | ||
| If True, clear history for the current user, without actually removing chat. | ||
| For private and simple group chats only. | ||
| min_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Delete all messages newer than this time. | ||
| For private and simple group chats only. | ||
| max_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Delete all messages older than this time. | ||
| For private and simple group chats only. | ||
| Returns: | ||
| ``int``: Amount of affected messages | ||
| Example: | ||
| .. code-block:: python | ||
| # Delete all messages in channel | ||
| await app.delete_chat_history(chat_id, revoke=True) | ||
| """ | ||
| peer = await self.resolve_peer(chat_id) | ||
| if isinstance(peer, raw.types.InputPeerChannel): | ||
| r = await self.invoke( | ||
| raw.functions.channels.DeleteHistory( | ||
| channel=raw.types.InputChannel( | ||
| channel_id=peer.channel_id, | ||
| access_hash=peer.access_hash | ||
| ), | ||
| max_id=max_id, | ||
| for_everyone=revoke | ||
| ) | ||
| ) | ||
| else: | ||
| r = await self.invoke( | ||
| raw.functions.messages.DeleteHistory( | ||
| peer=peer, | ||
| max_id=max_id, | ||
| just_clear=just_clear, | ||
| revoke=revoke, | ||
| min_date=utils.datetime_to_timestamp(min_date), | ||
| max_date=utils.datetime_to_timestamp(max_date) | ||
| ) | ||
| ) | ||
| return len(r.updates[0].messages) if isinstance(peer, raw.types.InputPeerChannel) else r.pts_count |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import logging | ||
| import os | ||
| from datetime import datetime | ||
| from typing import Union, List, Optional | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from pyrogram import types | ||
| from pyrogram import utils | ||
| from pyrogram import enums | ||
| from pyrogram.file_id import FileType | ||
| log = logging.getLogger(__name__) | ||
| class SendPaidMedia: | ||
| # TODO: Add progress parameter | ||
| async def send_paid_media( | ||
| self: "pyrogram.Client", | ||
| chat_id: Union[int, str], | ||
| stars_amount: int, | ||
| media: List[Union[ | ||
| "types.InputMediaPhoto", | ||
| "types.InputMediaVideo", | ||
| ]], | ||
| caption: str = "", | ||
| parse_mode: Optional["enums.ParseMode"] = None, | ||
| caption_entities: List["types.MessageEntity"] = None, | ||
| disable_notification: bool = None, | ||
| reply_to_message_id: int = None, | ||
| quote_text: str = None, | ||
| quote_entities: List["types.MessageEntity"] = None, | ||
| quote_offset: int = None, | ||
| schedule_date: datetime = None, | ||
| protect_content: bool = None, | ||
| show_above_text: bool = None | ||
| ) -> List["types.Message"]: | ||
| """Send a group or one paid photo/video. | ||
| .. include:: /_includes/usable-by/users-bots.rst | ||
| Parameters: | ||
| chat_id (``int`` | ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| For your personal cloud (Saved Messages) you can simply use "me" or "self". | ||
| For a contact that exists in your Telegram address book you can use his phone number (str). | ||
| stars_amount (``int``): | ||
| The number of Telegram Stars that must be paid to buy access to the media. | ||
| media (List of :obj:`~pyrogram.types.InputMediaPhoto`, :obj:`~pyrogram.types.InputMediaVideo`): | ||
| A list describing photos and videos to be sent, must include 1–10 items. | ||
| caption (``str``, *optional*): | ||
| Media caption, 0-1024 characters after entities parsing. | ||
| parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*): | ||
| By default, texts are parsed using both Markdown and HTML styles. | ||
| You can combine both syntaxes together. | ||
| disable_notification (``bool``, *optional*): | ||
| Sends the message silently. | ||
| Users will receive a notification with no sound. | ||
| reply_to_message_id (``int``, *optional*): | ||
| If the message is a reply, ID of the original message. | ||
| quote_text (``str``, *optional*): | ||
| Text of the quote to be sent. | ||
| parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*): | ||
| By default, texts are parsed using both Markdown and HTML styles. | ||
| You can combine both syntaxes together. | ||
| quote_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*): | ||
| List of special entities that appear in quote text, which can be specified instead of *parse_mode*. | ||
| quote_offset (``int``, *optional*): | ||
| Offset for quote in original message. | ||
| schedule_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Date when the message will be automatically sent. | ||
| protect_content (``bool``, *optional*): | ||
| Protects the contents of the sent message from forwarding and saving. | ||
| show_above_text (``bool``, *optional*): | ||
| If True, link preview will be shown above the message text. | ||
| Otherwise, the link preview will be shown below the message text. | ||
| Returns: | ||
| :obj:`~pyrogram.types.Message`: On success, the sent message is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| from pyrogram.types import InputMediaPhoto, InputMediaVideo | ||
| await app.send_paid_media( | ||
| chat_id, | ||
| stars_amount=50, | ||
| caption="Look at this!", | ||
| media=[ | ||
| InputMediaPhoto("photo1.jpg"), | ||
| InputMediaPhoto("photo2.jpg"), | ||
| InputMediaVideo("video.mp4") | ||
| ] | ||
| ) | ||
| """ | ||
| multi_media = [] | ||
| for i in media: | ||
| if isinstance(i, types.InputMediaPhoto): | ||
| if isinstance(i.media, str): | ||
| if os.path.isfile(i.media): | ||
| media = await self.invoke( | ||
| raw.functions.messages.UploadMedia( | ||
| peer=await self.resolve_peer(chat_id), | ||
| media=raw.types.InputMediaUploadedPhoto( | ||
| file=await self.save_file(i.media), | ||
| spoiler=i.has_spoiler | ||
| ), | ||
| ) | ||
| ) | ||
| media = raw.types.InputMediaPhoto( | ||
| id=raw.types.InputPhoto( | ||
| id=media.photo.id, | ||
| access_hash=media.photo.access_hash, | ||
| file_reference=media.photo.file_reference | ||
| ), | ||
| spoiler=i.has_spoiler | ||
| ) | ||
| else: | ||
| media = utils.get_input_media_from_file_id(i.media, FileType.PHOTO, has_spoiler=i.has_spoiler) | ||
| else: | ||
| media = await self.invoke( | ||
| raw.functions.messages.UploadMedia( | ||
| peer=await self.resolve_peer(chat_id), | ||
| media=raw.types.InputMediaUploadedPhoto( | ||
| file=await self.save_file(i.media), | ||
| spoiler=i.has_spoiler | ||
| ), | ||
| ) | ||
| ) | ||
| media = raw.types.InputMediaPhoto( | ||
| id=raw.types.InputPhoto( | ||
| id=media.photo.id, | ||
| access_hash=media.photo.access_hash, | ||
| file_reference=media.photo.file_reference | ||
| ), | ||
| spoiler=i.has_spoiler | ||
| ) | ||
| elif isinstance(i, types.InputMediaVideo): | ||
| if isinstance(i.media, str): | ||
| if os.path.isfile(i.media): | ||
| media = await self.invoke( | ||
| raw.functions.messages.UploadMedia( | ||
| peer=await self.resolve_peer(chat_id), | ||
| media=raw.types.InputMediaUploadedDocument( | ||
| file=await self.save_file(i.media), | ||
| thumb=await self.save_file(i.thumb), | ||
| spoiler=i.has_spoiler, | ||
| mime_type=self.guess_mime_type(i.media) or "video/mp4", | ||
| nosound_video=True, | ||
| attributes=[ | ||
| raw.types.DocumentAttributeVideo( | ||
| supports_streaming=i.supports_streaming or None, | ||
| duration=i.duration, | ||
| w=i.width, | ||
| h=i.height | ||
| ), | ||
| raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)) | ||
| ] | ||
| ), | ||
| ) | ||
| ) | ||
| media = raw.types.InputMediaDocument( | ||
| id=raw.types.InputDocument( | ||
| id=media.document.id, | ||
| access_hash=media.document.access_hash, | ||
| file_reference=media.document.file_reference | ||
| ), | ||
| spoiler=i.has_spoiler | ||
| ) | ||
| else: | ||
| media = utils.get_input_media_from_file_id(i.media, FileType.VIDEO, has_spoiler=i.has_spoiler) | ||
| else: | ||
| media = await self.invoke( | ||
| raw.functions.messages.UploadMedia( | ||
| peer=await self.resolve_peer(chat_id), | ||
| media=raw.types.InputMediaUploadedDocument( | ||
| file=await self.save_file(i.media), | ||
| thumb=await self.save_file(i.thumb), | ||
| spoiler=i.has_spoiler, | ||
| mime_type=self.guess_mime_type(getattr(i.media, "name", "video.mp4")) or "video/mp4", | ||
| nosound_video=True, | ||
| attributes=[ | ||
| raw.types.DocumentAttributeVideo( | ||
| supports_streaming=i.supports_streaming or None, | ||
| duration=i.duration, | ||
| w=i.width, | ||
| h=i.height | ||
| ), | ||
| raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "video.mp4")) | ||
| ] | ||
| ), | ||
| ) | ||
| ) | ||
| media = raw.types.InputMediaDocument( | ||
| id=raw.types.InputDocument( | ||
| id=media.document.id, | ||
| access_hash=media.document.access_hash, | ||
| file_reference=media.document.file_reference | ||
| ), | ||
| spoiler=i.has_spoiler | ||
| ) | ||
| else: | ||
| raise ValueError(f"{i.__class__.__name__} is not a supported type for send_paid_media") | ||
| multi_media.append(media) | ||
| quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values() | ||
| r = await self.invoke( | ||
| raw.functions.messages.SendMedia( | ||
| peer=await self.resolve_peer(chat_id), | ||
| media=raw.types.InputMediaPaidMedia( | ||
| stars_amount=stars_amount, | ||
| extended_media=multi_media | ||
| ), | ||
| silent=disable_notification or None, | ||
| reply_to=utils.get_reply_to( | ||
| reply_to_message_id=reply_to_message_id, | ||
| quote_text=quote_text, | ||
| quote_entities=quote_entities, | ||
| quote_offset=quote_offset, | ||
| ), | ||
| random_id=self.rnd_id(), | ||
| schedule_date=utils.datetime_to_timestamp(schedule_date), | ||
| noforwards=protect_content, | ||
| invert_media=show_above_text, | ||
| **await utils.parse_text_entities(self, caption, parse_mode, caption_entities) | ||
| ), | ||
| sleep_threshold=60, | ||
| ) | ||
| return await utils.parse_messages( | ||
| self, | ||
| raw.types.messages.Messages( | ||
| messages=[m.message for m in filter( | ||
| lambda u: isinstance(u, (raw.types.UpdateNewMessage, | ||
| raw.types.UpdateNewChannelMessage, | ||
| raw.types.UpdateNewScheduledMessage, | ||
| raw.types.UpdateBotNewBusinessMessage)), | ||
| r.updates | ||
| )], | ||
| users=r.users, | ||
| chats=r.chats | ||
| ), | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import re | ||
| from typing import Union | ||
| import pyrogram | ||
| from pyrogram import raw, types | ||
| class GetPaymentForm: | ||
| async def get_payment_form( | ||
| self: "pyrogram.Client", | ||
| chat_id: Union[int, str], | ||
| message_id: Union[int, str], | ||
| ) -> "types.PaymentForm": | ||
| """Get information about a invoice or paid media. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| chat_id (``int`` | ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| Unique identifier for the target chat in form of a *t.me/joinchat/* link, identifier (int) or username | ||
| of the target channel/supergroup (in the format @username). | ||
| message_id (``int`` | ``str``): | ||
| Pass a message identifier or to get the invoice from message. | ||
| Pass a invoice link in form of a *t.me/$...* link or slug itself to get the payment form from link. | ||
| Returns: | ||
| :obj:`~pyrogram.types.PaymentForm`: On success, a payment form is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| # get payment form from message | ||
| app.get_payment_form(chat_id, 123) | ||
| # get payment form from link | ||
| app.get_payment_form(chat_id, "https://t.me/$xvbzUtt5sUlJCAAATqZrWRy9Yzk") | ||
| """ | ||
| invoice = None | ||
| if isinstance(message_id, int): | ||
| invoice = raw.types.InputInvoiceMessage( | ||
| peer=await self.resolve_peer(chat_id), | ||
| msg_id=message_id | ||
| ) | ||
| elif isinstance(message_id, str): | ||
| match = re.match(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/\$)([\w-]+)$", message_id) | ||
| if match: | ||
| slug = match.group(1) | ||
| else: | ||
| slug = message_id | ||
| invoice = raw.types.InputInvoiceSlug( | ||
| slug=slug | ||
| ) | ||
| r = await self.invoke( | ||
| raw.functions.payments.GetPaymentForm( | ||
| invoice=invoice | ||
| ) | ||
| ) | ||
| return types.PaymentForm._parse(self, r) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import re | ||
| from typing import Union | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| class SendPaymentForm: | ||
| async def send_payment_form( | ||
| self: "pyrogram.Client", | ||
| chat_id: Union[int, str], | ||
| message_id: Union[int, str], | ||
| ) -> bool: | ||
| """Pay an invoice. | ||
| .. note:: | ||
| For now only stars invoices are supported. | ||
| .. include:: /_includes/usable-by/users.rst | ||
| Parameters: | ||
| chat_id (``int`` | ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| Unique identifier for the target chat in form of a *t.me/joinchat/* link, identifier (int) or username | ||
| of the target channel/supergroup (in the format @username). | ||
| message_id (``int`` | ``str``): | ||
| Pass a message identifier or to get the invoice from message. | ||
| Pass a invoice link in form of a *t.me/$...* link or slug itself to get the payment form from link. | ||
| Returns: | ||
| ``bool``: On success, True is returned. | ||
| Example: | ||
| .. code-block:: python | ||
| # Pay invoice from message | ||
| app.send_payment_form(chat_id, 123) | ||
| # Pay invoice form from link | ||
| # Chat id can be None | ||
| app.send_payment_form(chat_id, "https://t.me/$xvbzUtt5sUlJCAAATqZrWRy9Yzk") | ||
| """ | ||
| invoice = None | ||
| if isinstance(message_id, int): | ||
| invoice = raw.types.InputInvoiceMessage( | ||
| peer=await self.resolve_peer(chat_id), | ||
| msg_id=message_id | ||
| ) | ||
| elif isinstance(message_id, str): | ||
| match = re.match(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/\$)([\w-]+)$", message_id) | ||
| if match: | ||
| slug = match.group(1) | ||
| else: | ||
| slug = message_id | ||
| invoice = raw.types.InputInvoiceSlug( | ||
| slug=slug | ||
| ) | ||
| form = await self.get_payment_form(chat_id=chat_id, message_id=message_id) | ||
| # if form.invoice.currency == "XTR": | ||
| await self.invoke( | ||
| raw.functions.payments.SendStarsForm( | ||
| form_id=form.id, | ||
| invoice=invoice | ||
| ) | ||
| ) | ||
| # TODO: Add support for regular invoices (credentials) | ||
| # else: | ||
| # r = await self.invoke( | ||
| # raw.functions.payments.SendPaymentForm( | ||
| # form_id=form.id, | ||
| # invoice=invoice, | ||
| # credentials=raw.types.InputPaymentCredentials(data=raw.types.DataJSON(data={})) | ||
| # ) | ||
| # ) | ||
| return True |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from datetime import datetime | ||
| from pyrogram import raw, utils | ||
| from ..object import Object | ||
| class ActiveSession(Object): | ||
| """Contains information about one session in a Telegram application used by the current user. Sessions must be shown to the user in the returned order. | ||
| Parameters: | ||
| id (``int``): | ||
| Session identifier. | ||
| device_model (``str``): | ||
| Model of the device the application has been run or is running on, as provided by the application. | ||
| platform (``str``): | ||
| Operating system the application has been run or is running on, as provided by the application. | ||
| system_version (``str``): | ||
| Version of the operating system the application has been run or is running on, as provided by the application. | ||
| api_id (``int``): | ||
| Telegram API identifier, as provided by the application. | ||
| application_name (``str``): | ||
| Name of the application, as provided by the application. | ||
| application_version (``str``): | ||
| The version of the application, as provided by the application. | ||
| log_in_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Point in time (Unix timestamp) when the user has logged in. | ||
| last_active_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Point in time (Unix timestamp) when the session was last used. | ||
| ip_address (``str``): | ||
| IP address from which the session was created, in human-readable format. | ||
| location (``str``): | ||
| A human-readable description of the location from which the session was created, based on the IP address. | ||
| country (``str``): | ||
| Country determined from IP. | ||
| region (``str``): | ||
| Region determined from IP. | ||
| is_current (``bool``): | ||
| True, if this session is the current session. | ||
| is_password_pending (``bool``): | ||
| True, if a 2-step verification password is needed to complete authorization of the session. | ||
| is_unconfirmed (``bool``): | ||
| True, if the session wasn't confirmed from another session. | ||
| can_accept_secret_chats (``bool``): | ||
| True, if incoming secret chats can be accepted by the session. | ||
| can_accept_calls (``bool``): | ||
| True, if incoming calls can be accepted by the session. | ||
| is_official_application (``bool``): | ||
| True, if the application is an official application or uses the api_id of an official application. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| id: int = None, | ||
| device_model: str = None, | ||
| platform: str = None, | ||
| system_version: str = None, | ||
| api_id: int = None, | ||
| application_name: str = None, | ||
| application_version: str = None, | ||
| log_in_date: datetime = None, | ||
| last_active_date: datetime = None, | ||
| ip_address: str = None, | ||
| location: str = None, | ||
| country: str = None, | ||
| region: str = None, | ||
| is_current: bool = None, | ||
| is_password_pending: bool = None, | ||
| is_unconfirmed: bool = None, | ||
| can_accept_secret_chats: bool = None, | ||
| can_accept_calls: bool = None, | ||
| is_official_application: bool = None | ||
| ): | ||
| super().__init__() | ||
| self.id = id | ||
| self.device_model = device_model | ||
| self.platform = platform | ||
| self.system_version = system_version | ||
| self.api_id = api_id | ||
| self.application_name = application_name | ||
| self.application_version = application_version | ||
| self.log_in_date = log_in_date | ||
| self.last_active_date = last_active_date | ||
| self.ip_address = ip_address | ||
| self.location = location | ||
| self.country = country | ||
| self.region = region | ||
| self.is_current = is_current | ||
| self.is_password_pending = is_password_pending | ||
| self.is_unconfirmed = is_unconfirmed | ||
| self.can_accept_secret_chats = can_accept_secret_chats | ||
| self.can_accept_calls = can_accept_calls | ||
| self.is_official_application = is_official_application | ||
| @staticmethod | ||
| def _parse(session: "raw.types.Authorization") -> "ActiveSession": | ||
| return ActiveSession( | ||
| id=session.hash, | ||
| device_model=session.device_model, | ||
| platform=session.platform, | ||
| system_version=session.system_version, | ||
| api_id=session.api_id, | ||
| application_name=session.app_name, | ||
| application_version=session.app_version, | ||
| log_in_date=utils.timestamp_to_datetime(session.date_created), | ||
| last_active_date=utils.timestamp_to_datetime(session.date_active), | ||
| ip_address=session.ip, | ||
| location=session.region, | ||
| country=session.country, | ||
| region=session.region, | ||
| is_current=getattr(session, "current", None), | ||
| is_password_pending=getattr(session, "password_pending", None), | ||
| is_unconfirmed=getattr(session, "unconfirmed", None), | ||
| can_accept_secret_chats=not getattr(session, "encrypted_requests_disabled", False), | ||
| can_accept_calls=not getattr(session, "call_requests_disabled", False), | ||
| is_official_application=getattr(session, "official_app", None) | ||
| ) | ||
| async def reset(self): | ||
| """Bound method *reset* of :obj:`~pyrogram.types.ActiveSession`. | ||
| Use as a shortcut for: | ||
| .. code-block:: python | ||
| await client.reset_session(123456789) | ||
| Example: | ||
| .. code-block:: python | ||
| await session.reset() | ||
| Returns: | ||
| True on success. | ||
| Raises: | ||
| RPCError: In case of a Telegram RPC error. | ||
| """ | ||
| return await self._client.reset_session(self.id) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import List | ||
| from pyrogram import raw, types | ||
| from ..object import Object | ||
| class ActiveSessions(Object): | ||
| """Contains a list of currently active sessions | ||
| Parameters: | ||
| inactive_session_ttl_days (``int``): | ||
| Number of days of inactivity before sessions will automatically be terminated; 1-366 days. | ||
| active_sessions (List of :obj:`~pyrogram.types.ActiveSession`): | ||
| List of sessions. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| inactive_session_ttl_days: int = None, | ||
| active_sessions: List["types.ActiveSession"] = None | ||
| ): | ||
| super().__init__() | ||
| self.inactive_session_ttl_days = inactive_session_ttl_days | ||
| self.active_sessions = active_sessions | ||
| @staticmethod | ||
| def _parse(authorizations: "raw.types.account.Authorizations") -> "ActiveSessions": | ||
| return ActiveSessions( | ||
| inactive_session_ttl_days=authorizations.authorization_ttl_days, | ||
| active_sessions=types.List([ | ||
| types.ActiveSession._parse(active) | ||
| for active in authorizations.authorizations | ||
| ]) | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from pyrogram import raw | ||
| from ..object import Object | ||
| class LabeledPrice(Object): | ||
| """This object represents a portion of the price for goods or services. | ||
| Parameters: | ||
| label (``str``): | ||
| Portion label. | ||
| amount (``int``): | ||
| Price of the product in the smallest units of the currency (integer, **not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``. See the __exp__ parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). | ||
| """ | ||
| def __init__( | ||
| self, | ||
| label: str, | ||
| amount: int | ||
| ): | ||
| super().__init__() | ||
| self.label = label | ||
| self.amount = amount | ||
| @staticmethod | ||
| def _parse(labeled_price: "raw.types.LabeledPrice") -> "LabeledPrice": | ||
| if isinstance(labeled_price, raw.types.LabeledPrice): | ||
| return LabeledPrice( | ||
| label=labeled_price.label, | ||
| amount=labeled_price.amount | ||
| ) | ||
| def write(self): | ||
| return raw.types.LabeledPrice( | ||
| label=self.label, | ||
| amount=self.amount | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import Optional | ||
| from pyrogram import types | ||
| from ..object import Object | ||
| class OrderInfo(Object): | ||
| """This object represents information about an order. | ||
| Parameters: | ||
| name (``str``, *optional*): | ||
| User name. | ||
| phone_number (``str``, *optional*): | ||
| User's phone number. | ||
| email (``str``, *optional*): | ||
| User email. | ||
| shipping_address (:obj:`~pyrogram.types.ShippingAddress`, *optional*): | ||
| User shipping address. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| name: Optional[str] = None, | ||
| phone_number: Optional[str] = None, | ||
| email: Optional[str] = None, | ||
| shipping_address: Optional["types.ShippingAddress"] = None | ||
| ): | ||
| super().__init__() | ||
| self.name = name | ||
| self.phone_number = phone_number | ||
| self.email = email | ||
| self.shipping_address = shipping_address |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| from .input_privacy_rule_allow_all import InputPrivacyRuleAllowAll | ||
| from .input_privacy_rule_allow_chats import InputPrivacyRuleAllowChats | ||
| from .input_privacy_rule_allow_contacts import InputPrivacyRuleAllowContacts | ||
| from .input_privacy_rule_allow_premium import InputPrivacyRuleAllowPremium | ||
| from .input_privacy_rule_allow_users import InputPrivacyRuleAllowUsers | ||
| from .input_privacy_rule_disallow_all import InputPrivacyRuleDisallowAll | ||
| from .input_privacy_rule_disallow_chats import InputPrivacyRuleDisallowChats | ||
| from .input_privacy_rule_disallow_contacts import InputPrivacyRuleDisallowContacts | ||
| from .input_privacy_rule_disallow_users import InputPrivacyRuleDisallowUsers | ||
| __all__ = [ | ||
| "InputPrivacyRule", | ||
| "InputPrivacyRuleAllowAll", | ||
| "InputPrivacyRuleAllowChats", | ||
| "InputPrivacyRuleAllowContacts", | ||
| "InputPrivacyRuleAllowPremium", | ||
| "InputPrivacyRuleAllowUsers", | ||
| "InputPrivacyRuleDisallowAll", | ||
| "InputPrivacyRuleDisallowChats", | ||
| "InputPrivacyRuleDisallowContacts", | ||
| "InputPrivacyRuleDisallowUsers" | ||
| ] |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleAllowAll(InputPrivacyRule): | ||
| """Allow all users.""" | ||
| def __init__( | ||
| self, | ||
| ): | ||
| super().__init__() | ||
| async def write(self, client: "pyrogram.Client"): | ||
| return raw.types.InputPrivacyValueAllowAll() |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import asyncio | ||
| from typing import Union, Iterable | ||
| import pyrogram | ||
| from pyrogram import raw, utils | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleAllowChats(InputPrivacyRule): | ||
| """Allow only participants of certain chats. | ||
| Parameters: | ||
| chat_ids (``int`` | ``str`` | Iterable of ``int`` or ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| chat_ids: Union[int, str, Iterable[Union[int, str]]], | ||
| ): | ||
| super().__init__() | ||
| self.chat_ids = chat_ids | ||
| async def write(self, client: "pyrogram.Client"): | ||
| chats = list(self.chat_ids) if not isinstance(self.chat_ids, (int, str)) else [self.chat_ids] | ||
| chats = await asyncio.gather(*[client.resolve_peer(i) for i in chats]) | ||
| return raw.types.InputPrivacyValueAllowChatParticipants( | ||
| chats=[utils.get_peer_id(i) for i in chats] | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleAllowContacts(InputPrivacyRule): | ||
| """Allow contacts only.""" | ||
| def __init__( | ||
| self, | ||
| ): | ||
| super().__init__() | ||
| async def write(self, client: "pyrogram.Client"): | ||
| return raw.types.InputPrivacyValueAllowContacts() |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleAllowPremium(InputPrivacyRule): | ||
| """Allow only users with a Premium subscription, currently only usable for :obj:`~pyrogram.enums.PrivacyKey.CHAT_INVITE`.""" | ||
| def __init__( | ||
| self, | ||
| ): | ||
| super().__init__() | ||
| async def write(self, client: "pyrogram.Client"): | ||
| return raw.types.InputPrivacyValueAllowPremium() |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import asyncio | ||
| from typing import Union, Iterable | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleAllowUsers(InputPrivacyRule): | ||
| """Allow only participants of certain users. | ||
| Parameters: | ||
| chat_ids (``int`` | ``str`` | Iterable of ``int`` or ``str``, *optional*): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| chat_ids: Union[int, str, Iterable[Union[int, str]]], | ||
| ): | ||
| super().__init__() | ||
| self.chat_ids = chat_ids | ||
| async def write(self, client: "pyrogram.Client"): | ||
| users = list(self.chat_ids) if not isinstance(self.chat_ids, (int, str)) else [self.chat_ids] | ||
| users = await asyncio.gather(*[client.resolve_peer(i) for i in users]) | ||
| return raw.types.InputPrivacyValueAllowUsers(users=users) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleDisallowAll(InputPrivacyRule): | ||
| """Disallow all users.""" | ||
| def __init__( | ||
| self, | ||
| ): | ||
| super().__init__() | ||
| async def write(self, client: "pyrogram.Client"): | ||
| return raw.types.InputPrivacyValueDisallowAll() |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import asyncio | ||
| from typing import Union, Iterable | ||
| import pyrogram | ||
| from pyrogram import raw, utils | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleDisallowChats(InputPrivacyRule): | ||
| """Disallow only participants of certain chats. | ||
| Parameters: | ||
| chat_ids (``int`` | ``str`` | Iterable of ``int`` or ``str``): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| chat_ids: Union[int, str, Iterable[Union[int, str]]], | ||
| ): | ||
| super().__init__() | ||
| self.chat_ids = chat_ids | ||
| async def write(self, client: "pyrogram.Client"): | ||
| chats = list(self.chat_ids) if not isinstance(self.chat_ids, (int, str)) else [self.chat_ids] | ||
| chats = await asyncio.gather(*[client.resolve_peer(i) for i in chats]) | ||
| return raw.types.InputPrivacyValueDisallowChatParticipants( | ||
| chats=[utils.get_peer_id(i) for i in chats] | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleDisallowContacts(InputPrivacyRule): | ||
| """Disallow contacts only.""" | ||
| def __init__( | ||
| self, | ||
| ): | ||
| super().__init__() | ||
| async def write(self, client: "pyrogram.Client"): | ||
| return raw.types.InputPrivacyValueDisallowContacts() |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import asyncio | ||
| from typing import Union, Iterable | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from .input_privacy_rule import InputPrivacyRule | ||
| class InputPrivacyRuleDisallowUsers(InputPrivacyRule): | ||
| """Disallow only participants of certain users. | ||
| Parameters: | ||
| chat_ids (``int`` | ``str`` | Iterable of ``int`` or ``str``, *optional*): | ||
| Unique identifier (int) or username (str) of the target chat. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| chat_ids: Union[int, str, Iterable[Union[int, str]]], | ||
| ): | ||
| super().__init__() | ||
| self.chat_ids = chat_ids | ||
| async def write(self, client: "pyrogram.Client"): | ||
| users = list(self.chat_ids) if not isinstance(self.chat_ids, (int, str)) else [self.chat_ids] | ||
| users = await asyncio.gather(*[client.resolve_peer(i) for i in users]) | ||
| return raw.types.InputPrivacyValueDisallowUsers(users=users) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| import pyrogram | ||
| from ..object import Object | ||
| class InputPrivacyRule(Object): | ||
| """Content of a privacy rule. | ||
| It should be one of: | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleAllowAll` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleAllowContacts` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleAllowPremium` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleAllowUsers` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleAllowChats` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleDisallowAll` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleDisallowContacts` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleDisallowUsers` | ||
| - :obj:`~pyrogram.types.InputPrivacyRuleDisallowChats` | ||
| """ | ||
| def __init__(self): | ||
| super().__init__() | ||
| async def write(self, client: "pyrogram.Client"): | ||
| raise NotImplementedError |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import List, Union | ||
| import pyrogram | ||
| from pyrogram import raw, types | ||
| from ..object import Object | ||
| class PaidMediaInfo(Object): | ||
| """Describes the paid media added to a message. | ||
| Parameters: | ||
| stars_amount (``int``): | ||
| The number of Telegram Stars that must be paid to buy access to the media. | ||
| media (List of :obj:`~pyrogram.types.Photo` | :obj:`~pyrogram.types.Video` | :obj:`~pyrogram.types.PaidMediaPreview`): | ||
| Information about the paid media. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| stars_amount: str, | ||
| media: List[Union["types.Photo", "types.Video", "types.PaidMediaPreview"]] | ||
| ): | ||
| super().__init__() | ||
| self.stars_amount = stars_amount | ||
| self.media = media | ||
| @staticmethod | ||
| def _parse( | ||
| client: "pyrogram.Client", | ||
| message_paid_media: "raw.types.MessageMediaPaidMedia" | ||
| ) -> "PaidMediaInfo": | ||
| medias = [] | ||
| for extended_media in message_paid_media.extended_media: | ||
| if isinstance(extended_media, raw.types.MessageExtendedMediaPreview): | ||
| thumbnail = None | ||
| if isinstance(getattr(extended_media, "thumb", None), raw.types.PhotoStrippedSize): | ||
| thumbnail = types.StrippedThumbnail._parse(client, extended_media.thumb) | ||
| medias.append( | ||
| types.PaidMediaPreview( | ||
| width=getattr(extended_media, "w", None), | ||
| height=getattr(extended_media, "h", None), | ||
| duration=getattr(extended_media, "video_duration", None), | ||
| thumbnail=thumbnail, | ||
| ) | ||
| ) | ||
| elif isinstance(extended_media, raw.types.MessageExtendedMedia): | ||
| media = extended_media.media | ||
| if isinstance(media, raw.types.MessageMediaPhoto): | ||
| medias.append(types.Photo._parse(client, media.photo, media.ttl_seconds)) | ||
| elif isinstance(media, raw.types.MessageMediaDocument): | ||
| doc = media.document | ||
| attributes = {type(i): i for i in doc.attributes} | ||
| file_name = getattr( | ||
| attributes.get( | ||
| raw.types.DocumentAttributeFilename, None | ||
| ), "file_name", None | ||
| ) | ||
| video_attributes = attributes[raw.types.DocumentAttributeVideo] | ||
| medias.append(types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds)) | ||
| return PaidMediaInfo( | ||
| stars_amount=message_paid_media.stars_amount, | ||
| media=types.List(medias) | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from pyrogram import types | ||
| from ..object import Object | ||
| class PaidMediaPreview(Object): | ||
| """The paid media isn't available before the payment. | ||
| Parameters: | ||
| width (``int``, *optional*): | ||
| Media width as defined by the sender. | ||
| height (``int``, *optional*): | ||
| Media height as defined by the sender. | ||
| duration (``int``, *optional*): | ||
| Duration of the media in seconds as defined by the sender. | ||
| thumbnail (:obj:`~pyrogram.types.StrippedThumbnail`, *optional*): | ||
| Media thumbnail. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| width: int = None, | ||
| height: int = None, | ||
| duration: int = None, | ||
| thumbnail: "types.StrippedThumbnail" = None | ||
| ): | ||
| super().__init__() | ||
| self.width = width | ||
| self.height = height | ||
| self.duration = duration | ||
| self.thumbnail = thumbnail |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import Optional | ||
| import pyrogram | ||
| from pyrogram import types, raw | ||
| from ..object import Object | ||
| class PaymentForm(Object): | ||
| """This object contains basic information about an payment form. | ||
| Parameters: | ||
| id (``int``): | ||
| Form id. | ||
| bot (``str``): | ||
| Bot. | ||
| title (``str``): | ||
| Form title. | ||
| description (``str``): | ||
| Form description. | ||
| invoice (``str``): | ||
| Invoice. | ||
| provider (``str``, *optional*): | ||
| Payment provider. | ||
| url (``str``, *optional*): | ||
| Payment form URL. | ||
| can_save_credentials (``str``, *optional*): | ||
| Whether the user can choose to save credentials. | ||
| is_password_missing (``str``, *optional*): | ||
| Indicates that the user can save payment credentials, | ||
| but only after setting up a 2FA password | ||
| (currently the account doesn't have a 2FA password). | ||
| native_provider (``str``, *optional*): | ||
| Payment provider name. | ||
| raw (:obj:`~raw.base.payments.PaymentForm`, *optional*): | ||
| The raw object, as received from the Telegram API. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| client: "pyrogram.Client" = None, | ||
| id: int, | ||
| bot: "types.User", | ||
| title: str, | ||
| description: str, | ||
| invoice: "types.Invoice", | ||
| provider: Optional["types.User"] = None, | ||
| url: Optional[str] = None, | ||
| can_save_credentials: Optional[bool] = None, | ||
| is_password_missing: Optional[bool] = None, | ||
| native_provider: Optional[str] = None, | ||
| raw: "raw.base.payments.PaymentForm" = None, | ||
| # TODO: Add support for other params: | ||
| # native_params | ||
| # additional_params | ||
| # saved_info | ||
| # saved_credentials | ||
| ): | ||
| super().__init__(client) | ||
| self.id = id | ||
| self.bot = bot | ||
| self.title = title | ||
| self.description = description | ||
| self.invoice = invoice | ||
| self.provider = provider | ||
| self.url = url | ||
| self.can_save_credentials = can_save_credentials | ||
| self.is_password_missing = is_password_missing | ||
| self.native_provider = native_provider | ||
| self.raw = raw | ||
| @staticmethod | ||
| def _parse(client, payment_form: "raw.base.payments.PaymentForm") -> "PaymentForm": | ||
| users = {i.id: i for i in payment_form.users} | ||
| return PaymentForm( | ||
| id=payment_form.form_id, | ||
| bot=types.User._parse(client, users.get(payment_form.bot_id)), | ||
| title=payment_form.title, | ||
| description=payment_form.description, | ||
| invoice=types.Invoice._parse(client, payment_form.invoice), | ||
| provider=types.User._parse(client, users.get(getattr(payment_form, "provider_id", None))), | ||
| url=getattr(payment_form, "url", None), | ||
| can_save_credentials=getattr(payment_form, "can_save_credentials", None), | ||
| is_password_missing=getattr(payment_form, "password_missing", None), | ||
| native_provider=getattr(payment_form, "native_provider", None), | ||
| raw=payment_form | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import Union, Optional | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from pyrogram import types | ||
| from ..object import Object | ||
| class SuccessfulPayment(Object): | ||
| """A service message about a new successful payment. | ||
| Parameters: | ||
| currency (``str``): | ||
| Three-letter ISO 4217 `currency <https://core.telegram.org/bots/payments#supported-currencies>`_ code, or ``XTR`` for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| total_amount (``int``): | ||
| Total price in the smallest units of the currency (integer, **not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``. See the __exp__ parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). | ||
| invoice_payload (``str``, *optional*): | ||
| Bot specified invoice payload. Only available to the bot that received the payment. | ||
| telegram_payment_charge_id (``str``, *optional*): | ||
| Telegram payment identifier. Only available to the bot that received the payment. | ||
| provider_payment_charge_id (``str``, *optional*): | ||
| Provider payment identifier. Only available to the bot that received the payment. | ||
| shipping_option_id (``str``, *optional*): | ||
| Identifier of the shipping option chosen by the user. Only available to the bot that received the payment. | ||
| payment_info (:obj:`~pyrogram.types.PaymentInfo`, *optional*): | ||
| Payment information provided by the user. Only available to the bot that received the payment. | ||
| is_recurring (``bool``, *optional*): | ||
| True, if this is a recurring payment. | ||
| is_first_recurring (``bool``, *optional*): | ||
| True, if this is the first recurring payment. | ||
| invoice_slug (``str``, *optional*): | ||
| Name of the invoice. | ||
| """ | ||
| def __init__( | ||
| self, *, | ||
| currency: str, | ||
| total_amount: str, | ||
| invoice_payload: str, | ||
| telegram_payment_charge_id: str, | ||
| provider_payment_charge_id: str, | ||
| shipping_option_id: Optional[str] = None, | ||
| order_info: Optional["types.OrderInfo"] = None, | ||
| is_recurring: Optional[bool] = None, | ||
| is_first_recurring: Optional[bool] = None, | ||
| invoice_slug: Optional[str] = None | ||
| ): | ||
| super().__init__() | ||
| self.currency = currency | ||
| self.total_amount = total_amount | ||
| self.invoice_payload = invoice_payload | ||
| self.telegram_payment_charge_id = telegram_payment_charge_id | ||
| self.provider_payment_charge_id = provider_payment_charge_id | ||
| self.shipping_option_id = shipping_option_id | ||
| self.order_info = order_info | ||
| self.is_recurring = is_recurring | ||
| self.is_first_recurring = is_first_recurring | ||
| self.invoice_slug = invoice_slug | ||
| @staticmethod | ||
| def _parse( | ||
| client: "pyrogram.Client", | ||
| successful_payment: Union[ | ||
| "raw.types.MessageActionPaymentSent", | ||
| "raw.types.MessageActionPaymentSentMe" | ||
| ]) -> "SuccessfulPayment": | ||
| invoice_payload = None | ||
| telegram_payment_charge_id = None | ||
| provider_payment_charge_id = None | ||
| shipping_option_id = None | ||
| order_info = None | ||
| if isinstance(successful_payment, raw.types.MessageActionPaymentSentMe): | ||
| # Try to decode invoice payload into string. If that fails, fallback to bytes instead of decoding by | ||
| # ignoring/replacing errors, this way, button clicks will still work. | ||
| try: | ||
| invoice_payload = successful_payment.payload.decode() | ||
| except (UnicodeDecodeError, AttributeError): | ||
| invoice_payload = successful_payment.payload | ||
| telegram_payment_charge_id = successful_payment.charge.id | ||
| provider_payment_charge_id = successful_payment.charge.provider_charge_id | ||
| shipping_option_id = getattr(successful_payment, "shipping_option_id") | ||
| if successful_payment.info: | ||
| payment_info = successful_payment.info | ||
| order_info = types.OrderInfo( | ||
| name=getattr(payment_info, "name", None), | ||
| phone_number=getattr(payment_info, "phone", None), | ||
| email=getattr(payment_info, "email", None), | ||
| shipping_address=types.ShippingAddress( | ||
| country_code=successful_payment.info.shipping_address.country_iso2, | ||
| state=successful_payment.info.shipping_address.state, | ||
| city=successful_payment.info.shipping_address.city, | ||
| street_line1=successful_payment.info.shipping_address.street_line1, | ||
| street_line2=successful_payment.info.shipping_address.street_line2, | ||
| post_code=successful_payment.info.shipping_address.post_code | ||
| ) | ||
| ) | ||
| return SuccessfulPayment( | ||
| currency=successful_payment.currency, | ||
| total_amount=successful_payment.total_amount, | ||
| invoice_payload=invoice_payload, | ||
| telegram_payment_charge_id=telegram_payment_charge_id, | ||
| provider_payment_charge_id=provider_payment_charge_id, | ||
| shipping_option_id=shipping_option_id, | ||
| order_info=order_info, | ||
| is_recurring=getattr(successful_payment, "recurring_used", None), | ||
| is_first_recurring=getattr(successful_payment, "recurring_init", None), | ||
| invoice_slug=getattr(successful_payment, "invoice_slug", None), | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import Optional | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from pyrogram import utils | ||
| from pyrogram import types | ||
| from ..object import Object | ||
| class FoundContacts(Object): | ||
| """Chats found by name substring and auxiliary data. | ||
| Parameters: | ||
| my_results (List of :obj:`~pyrogram.types.Chat`, *optional*): | ||
| Personalized results. | ||
| global_results (List of :obj:`~pyrogram.types.Chat`, *optional*): | ||
| List of found chats in global search. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| client: "pyrogram.Client" = None, | ||
| my_results: Optional["types.Chat"] = None, | ||
| global_results: Optional["types.Chat"] = None | ||
| ): | ||
| super().__init__(client) | ||
| self.my_results = my_results | ||
| self.global_results = global_results | ||
| @staticmethod | ||
| def _parse(client, found: "raw.types.contacts.Found") -> "FoundContacts": | ||
| users = {u.id: u for u in found.users} | ||
| chats = {c.id: c for c in found.chats} | ||
| my_results = [] | ||
| global_results = [] | ||
| for result in found.my_results: | ||
| peer_id = utils.get_raw_peer_id(result) | ||
| peer = users.get(peer_id) or chats.get(peer_id) | ||
| my_results.append(types.Chat._parse_chat(client, peer)) | ||
| for result in found.results: | ||
| peer_id = utils.get_raw_peer_id(result) | ||
| peer = users.get(peer_id) or chats.get(peer_id) | ||
| global_results.append(types.Chat._parse_chat(client, peer)) | ||
| return FoundContacts( | ||
| my_results=types.List(my_results) or None, | ||
| global_results=types.List(global_results) or None, | ||
| client=client | ||
| ) |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import List, Optional | ||
| from pyrogram import raw, types | ||
| from ..object import Object | ||
| class PrivacyRule(Object): | ||
| """A privacy rule. | ||
| Parameters: | ||
| allow_all (``bool``, *optional*): | ||
| Allow all users. | ||
| allow_chats (``bool``, *optional*): | ||
| Allow only participants of certain chats. | ||
| allow_contacts (``bool``, *optional*): | ||
| Allow contacts only | ||
| allow_premium (``bool``, *optional*): | ||
| Allow only users with a Premium subscription, currently only usable for :obj:`~pyrogram.enums.PrivacyKey.CHAT_INVITE`. | ||
| allow_users (``bool``, *optional*): | ||
| Allow only participants of certain users. | ||
| users (List of :obj:`~pyrogram.types.User`, *optional*): | ||
| List of users. | ||
| chats (List of :obj:`~pyrogram.types.Chat`, *optional*): | ||
| List of chats. | ||
| """ | ||
| def __init__( | ||
| self, *, | ||
| allow_all: Optional[bool] = None, | ||
| allow_chats: Optional[bool] = None, | ||
| allow_contacts: Optional[bool] = None, | ||
| allow_premium: Optional[bool] = None, | ||
| allow_users: Optional[bool] = None, | ||
| users: Optional[List["types.User"]] = None, | ||
| chats: Optional[List["types.Chat"]] = None | ||
| ): | ||
| super().__init__(None) | ||
| self.allow_all = allow_all | ||
| self.allow_chats = allow_chats | ||
| self.allow_contacts = allow_contacts | ||
| self.allow_premium = allow_premium | ||
| self.allow_users = allow_users | ||
| self.users = users | ||
| self.chats = chats | ||
| @staticmethod | ||
| def _parse(client, rule: "raw.base.PrivacyRule", users, chats) -> "PrivacyRule": | ||
| parsed_users = None | ||
| parsed_chats = None | ||
| if isinstance(rule, (raw.types.PrivacyValueAllowUsers, raw.types.PrivacyValueDisallowUsers)): | ||
| parsed_users = types.List(types.User._parse(client, users.get(i)) for i in rule.users) | ||
| if isinstance(rule, (raw.types.PrivacyValueAllowChatParticipants, raw.types.PrivacyValueDisallowChatParticipants)): | ||
| parsed_chats = types.List(types.Chat._parse_chat(client, chats.get(i)) for i in rule.chats) | ||
| return PrivacyRule( | ||
| allow_all=True if isinstance(rule, raw.types.PrivacyValueAllowAll) else False if isinstance(rule, raw.types.PrivacyValueDisallowAll) else None, | ||
| allow_chats=True if isinstance(rule, raw.types.PrivacyValueAllowChatParticipants) else False if isinstance(rule, raw.types.PrivacyValueDisallowChatParticipants) else None, | ||
| allow_contacts=True if isinstance(rule, raw.types.PrivacyValueAllowContacts) else False if isinstance(rule, raw.types.PrivacyValueDisallowContacts) else None, | ||
| allow_premium=True if isinstance(rule, raw.types.PrivacyValueAllowPremium) else None, | ||
| allow_users=True if isinstance(rule, raw.types.PrivacyValueAllowUsers) else False if isinstance(rule, raw.types.PrivacyValueDisallowUsers) else None, | ||
| users=parsed_users or None, | ||
| chats=parsed_chats or None | ||
| ) |
@@ -207,2 +207,4 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| update_color | ||
| delete_chat_history | ||
| send_paid_media | ||
| """, | ||
@@ -278,2 +280,3 @@ chats=""" | ||
| set_profile_photo | ||
| set_personal_channel | ||
| delete_profile_photos | ||
@@ -290,3 +293,2 @@ set_username | ||
| update_birthday | ||
| update_personal_channel | ||
| """, | ||
@@ -320,2 +322,3 @@ invite_links=""" | ||
| get_contacts_count | ||
| search_contacts | ||
| """, | ||
@@ -325,2 +328,4 @@ payments=""" | ||
| check_gift_code | ||
| get_payment_form | ||
| send_payment_form | ||
| """, | ||
@@ -341,2 +346,3 @@ phone=""" | ||
| send_inline_bot_result | ||
| send_invoice | ||
| answer_callback_query | ||
@@ -379,2 +385,5 @@ answer_inline_query | ||
| log_out | ||
| get_active_sessions | ||
| reset_session | ||
| reset_sessions | ||
| """, | ||
@@ -412,2 +421,9 @@ advanced=""" | ||
| get_boosts_status | ||
| """, | ||
| account=""" | ||
| Account | ||
| get_account_ttl | ||
| set_account_ttl | ||
| set_privacy | ||
| get_privacy | ||
| """ | ||
@@ -465,3 +481,2 @@ ) | ||
| Chat | ||
| ChatPreview | ||
| ChatPhoto | ||
@@ -484,2 +499,4 @@ ChatMember | ||
| ChatColor | ||
| FoundContacts | ||
| PrivacyRule | ||
| """, | ||
@@ -525,2 +542,5 @@ messages_media=""" | ||
| SuccessfulPayment | ||
| PaidMediaInfo | ||
| PaidMediaPreview | ||
| PaymentForm | ||
| """, | ||
@@ -550,3 +570,3 @@ bot_keyboards=""" | ||
| RequestPollInfo | ||
| PaymentInfo | ||
| OrderInfo | ||
| PreCheckoutQuery | ||
@@ -607,4 +627,18 @@ ShippingAddress | ||
| Authorization | ||
| ActiveSession | ||
| ActiveSessions | ||
| SentCode | ||
| TermsOfService | ||
| """, | ||
| input_privacy_rule=""" | ||
| InputPrivacyRule | ||
| InputPrivacyRuleAllowAll | ||
| InputPrivacyRuleAllowContacts | ||
| InputPrivacyRuleAllowPremium | ||
| InputPrivacyRuleAllowUsers | ||
| InputPrivacyRuleAllowChats | ||
| InputPrivacyRuleDisallowAll | ||
| InputPrivacyRuleDisallowContacts | ||
| InputPrivacyRuleDisallowUsers | ||
| InputPrivacyRuleDisallowChats | ||
| """ | ||
@@ -680,2 +714,3 @@ ) | ||
| Message.view | ||
| Message.pay | ||
| """, | ||
@@ -768,2 +803,6 @@ chat=""" | ||
| Folder.export_link | ||
| """, | ||
| active_session=""" | ||
| ActiveSession | ||
| ActiveSession.reset | ||
| """ | ||
@@ -770,0 +809,0 @@ ) |
@@ -5,2 +5,3 @@ id message | ||
| ACCESS_TOKEN_INVALID The bot access token is invalid | ||
| ADDRESS_INVALID The specified geopoint address is invalid. | ||
| ADMINS_TOO_MUCH The chat has too many administrators | ||
@@ -10,2 +11,3 @@ ADMIN_ID_INVALID The specified admin ID is invalid | ||
| ADMIN_RANK_INVALID The custom administrator title is invalid or too long | ||
| ADMIN_RIGHTS_EMPTY The chatAdminRights constructor passed in keyboardButtonRequestPeer.peer_type.user_admin_rights has no rights set (i.e. flags is 0). | ||
| ALBUM_PHOTOS_TOO_MANY Too many photos were included in the album | ||
@@ -25,8 +27,14 @@ API_ID_INVALID The api_id/api_hash combination is invalid | ||
| AUTOARCHIVE_NOT_AVAILABLE This feature is not yet enabled for your account due to it not receiving too many private messages from strangers | ||
| BALANCE_TOO_LOW Your stars balance too low | ||
| BANK_CARD_NUMBER_INVALID The credit card number is invalid | ||
| BANNED_RIGHTS_INVALID You provided a set of restrictions that is invalid | ||
| BASE_PORT_LOC_INVALID The base port location is invalid | ||
| BIRTHDAY_INVALID The age should be less than 150 year old in Telegram | ||
| BOOSTS_EMPTY Boosts empty | ||
| BOOSTS_REQUIRED Boosts required | ||
| BOOST_NOT_MODIFIED You're already [boosting](https://core.telegram.org/api/boost) the specified channel. | ||
| BOOST_PEER_INVALID The specified `boost_peer` is invalid. | ||
| BOTS_TOO_MUCH The chat has too many bots | ||
| BOT_APP_INVALID The specified bot app is invalid. | ||
| BOT_APP_SHORTNAME_INVALID The specified bot app short name is invalid. | ||
| BOT_CHANNELS_NA Bots can't edit admin privileges | ||
@@ -47,2 +55,3 @@ BOT_COMMAND_DESCRIPTION_INVALID The command description was empty, too long or had invalid characters | ||
| BOT_SCORE_NOT_MODIFIED The bot score was not modified | ||
| BOT_WEBVIEW_DISABLED A webview cannot be opened in the specified conditions: emitted for example if `from_bot_menu` or `url` are set and `peer` is not the chat with the bot. | ||
| BROADCAST_CALLS_DISABLED Broadcast calls disabled | ||
@@ -53,8 +62,11 @@ BROADCAST_ID_INVALID The channel is invalid | ||
| BUTTON_DATA_INVALID The button callback data is invalid or too large | ||
| BUTTON_ID_INVALID The button_id parameter is invalid | ||
| BUTTON_TEXT_INVALID The specified button text is invalid | ||
| BUTTON_TYPE_INVALID The type of one of the buttons you provided is invalid | ||
| BUTTON_URL_INVALID The button url is invalid | ||
| BUTTON_USER_INVALID The user_id passed to inputKeyboardButtonUserProfile is invalid | ||
| BUTTON_USER_PRIVACY_RESTRICTED The privacy settings of the user specified in a keyboard button do not allow creating such button | ||
| CALL_ALREADY_ACCEPTED The call is already accepted | ||
| CALL_ALREADY_DECLINED The call is already declined | ||
| CALL_OCCUPY_FAILED The call failed because the user is already making another call. | ||
| CALL_PEER_INVALID The provided call peer object is invalid | ||
@@ -69,2 +81,3 @@ CALL_PROTOCOL_FLAGS_INVALID Call protocol flags invalid | ||
| CHANNEL_FORUM_MISSING The channel forum is missing | ||
| CHANNEL_ID_INVALID The specified supergroup ID is invalid. | ||
| CHANNEL_INVALID The channel parameter is invalid | ||
@@ -75,2 +88,6 @@ CHANNEL_PARICIPANT_MISSING The current user is not in the channel | ||
| CHANNEL_TOO_LARGE The channel is too large | ||
| CHARGE_ALREADY_REFUNDED The charge id was already used for a refund. | ||
| CHARGE_NOT_FOUND The charge id was not found. | ||
| CHATLISTS_TOO_MUCH You have too much chatlists on your account | ||
| CHATLIST_EXCLUDE_INVALID The specified `exclude_peers` are invalid. | ||
| CHAT_ABOUT_NOT_MODIFIED The chat about text was not modified because you tried to edit it using the same content | ||
@@ -87,2 +104,3 @@ CHAT_ABOUT_TOO_LONG The chat about text is too long | ||
| CHAT_NOT_MODIFIED The chat settings (title, permissions, photo, etc..) were not modified because you tried to edit them using the same content | ||
| CHAT_PUBLIC_REQUIRED You can only enable join requests in public groups. | ||
| CHAT_RESTRICTED The chat is restricted and cannot be used | ||
@@ -107,2 +125,3 @@ CHAT_REVOKE_DATE_UNSUPPORTED `min_date` and `max_date` are not available for using with non-user peers | ||
| CONTACT_ID_INVALID The provided contact id is invalid | ||
| CONTACT_MISSING The specified user is not a contact. | ||
| CONTACT_NAME_EMPTY The provided contact name is empty | ||
@@ -112,2 +131,3 @@ CONTACT_REQ_MISSING Missing contact request | ||
| CURRENCY_TOTAL_AMOUNT_INVALID The total amount of all prices is invalid | ||
| CUSTOM_REACTIONS_TOO_MANY Too many custom reactions were specified. | ||
| DATA_INVALID The encrypted data is invalid | ||
@@ -123,2 +143,3 @@ DATA_JSON_INVALID The provided JSON data is invalid | ||
| EMAIL_NOT_ALLOWED This email is not allowed | ||
| EMAIL_NOT_SETUP In order to change the login email with emailVerifyPurposeLoginChange, an existing login email must already be set using emailVerifyPurposeLoginSetup. | ||
| EMAIL_UNCONFIRMED Email unconfirmed | ||
@@ -128,2 +149,3 @@ EMAIL_UNCONFIRMED_X The provided email isn't confirmed, {value} is the length of the verification code that was just sent to the email | ||
| EMOJI_INVALID The specified theme emoji is valid | ||
| EMOJI_MARKUP_INVALID The specified `video_emoji_markup` was invalid. | ||
| EMOJI_NOT_MODIFIED The theme wasn't changed | ||
@@ -145,2 +167,5 @@ EMOTICON_EMPTY The emoticon parameter is empty | ||
| EXPORT_CARD_INVALID The provided card is invalid | ||
| EXTENDED_MEDIA_AMOUNT_INVALID The maximum amount of `star_count` should be less than the `stars_paid_post_amount_max` [client configuration parameters](/api/config). | ||
| EXTENDED_MEDIA_PEER_INVALID The specified chat type is invalid. | ||
| EXTENDED_MEDIA_TYPE_INVALID The specified extended media type is unsupported. | ||
| EXTERNAL_URL_INVALID The external media URL is invalid | ||
@@ -166,2 +191,3 @@ FIELD_NAME_EMPTY The field with the name FIELD_NAME is missing | ||
| FILE_TITLE_EMPTY An empty file title was specified | ||
| FILE_TOKEN_INVALID The specified file token is invalid. | ||
| FILTER_ID_INVALID The specified filter ID is invalid | ||
@@ -174,2 +200,4 @@ FILTER_INCLUDE_EMPTY The filter include is empty | ||
| FOLDER_ID_INVALID The folder id is invalid | ||
| FORM_ID_EXPIRED The specified id has expired. | ||
| FORUM_ENABLED You can't execute the specified action because the group is a [forum](https://core.telegram.org/api/forum), disable forum functionality to continue. | ||
| FRESH_CHANGE_ADMINS_FORBIDDEN You can't change administrator settings in this chat because your session was logged-in recently | ||
@@ -179,4 +207,6 @@ FROM_MESSAGE_BOT_DISABLED Bots can't use fromMessage min constructors | ||
| GAME_BOT_INVALID You cannot send that game with the current bot | ||
| GENERAL_MODIFY_ICON_FORBIDDEN You can't modify the icon of the "General" topic. | ||
| GEO_POINT_INVALID Invalid geo point provided | ||
| GIFT_SLUG_EXPIRED The gift slug is expired | ||
| GIFT_SLUG_INVALID The specified slug is invalid. | ||
| GIF_CONTENT_TYPE_INVALID GIF content-type invalid | ||
@@ -188,2 +218,3 @@ GIF_ID_INVALID The provided gif/animation id is invalid | ||
| GROUPCALL_ALREADY_DISCARDED The group call was already discarded | ||
| GROUPCALL_FORBIDDEN The group call has already ended. | ||
| GROUPCALL_INVALID The specified group call is invalid | ||
@@ -201,3 +232,5 @@ GROUPCALL_JOIN_MISSING You haven't joined this group call | ||
| IMPORT_ID_INVALID The import id is invalid | ||
| IMPORT_TOKEN_INVALID The specified token is invalid. | ||
| INLINE_RESULT_EXPIRED The inline bot query expired | ||
| INPUT_CHATLIST_INVALID The specified folder is invalid. | ||
| INPUT_CONSTRUCTOR_INVALID The provided constructor is invalid | ||
@@ -211,3 +244,5 @@ INPUT_FETCH_ERROR An error occurred while deserializing TL parameters | ||
| INPUT_TEXT_EMPTY The specified text is empty | ||
| INPUT_TEXT_TOO_LONG The specified text is too long. | ||
| INPUT_USER_DEACTIVATED The target user has been deleted/deactivated | ||
| INVITES_TOO_MUCH The maximum number of per-folder invites specified by the `chatlist_invites_limit_default`/`chatlist_invites_limit_premium` [client configuration parameters »](/api/config#chatlist-invites-limit-default) was reached. | ||
| INVITE_FORBIDDEN_WITH_JOINAS If the user has anonymously joined a group call as a channel, they can't invite other users to the group call because that would cause deanonymization, because the invite would be sent using the original user ID, not the anonymized channel ID | ||
@@ -242,3 +277,5 @@ INVITE_HASH_EMPTY The invite hash is empty | ||
| MEDIA_TTL_INVALID The media ttl is invalid | ||
| MEDIA_TYPE_INVALID The specified media type cannot be used in stories. | ||
| MEDIA_VIDEO_STORY_MISSING The media does not have a photo or a video | ||
| MEGAGROUP_GEO_REQUIRED This method can only be invoked on a geogroup. | ||
| MEGAGROUP_ID_INVALID The supergroup is invalid | ||
@@ -265,2 +302,3 @@ MEGAGROUP_PREHISTORY_HIDDEN The action failed because the supergroup has the pre-history hidden | ||
| NEXT_OFFSET_INVALID The next offset value is invalid | ||
| NOGENERAL_HIDE_FORBIDDEN The hidden parameter is only valid for the General topic message_thread_id=1 | ||
| OFFSET_INVALID The offset parameter is invalid | ||
@@ -270,2 +308,3 @@ OFFSET_PEER_ID_INVALID The provided offset peer is invalid | ||
| OPTION_INVALID The option specified is invalid and does not exist in the target poll | ||
| ORDER_INVALID The specified username order is invalid. | ||
| PACK_SHORT_NAME_INVALID Invalid sticker pack name. It must begin with a letter, can't contain consecutive underscores and must end in '_by_<bot username>'. | ||
@@ -281,2 +320,3 @@ PACK_SHORT_NAME_OCCUPIED A sticker pack with this name already exists | ||
| PASSWORD_MISSING The account is missing the two-step verification password | ||
| PASSWORD_RECOVERY_EXPIRED The recovery code has expired. | ||
| PASSWORD_RECOVERY_NA The password recovery e-mail is not available | ||
@@ -286,2 +326,3 @@ PASSWORD_REQUIRED The two-step verification password is required for this method | ||
| PAYMENT_PROVIDER_INVALID The payment provider was not recognised or its token was invalid | ||
| PEERS_LIST_EMPTY The specified list of peers is empty. | ||
| PEER_FLOOD The method can't be used because your account is currently limited | ||
@@ -320,2 +361,3 @@ PEER_HISTORY_EMPTY Peer history empty | ||
| PIN_RESTRICTED You can't pin messages in private chats with other people | ||
| PLATFORM_INVALID The provided platform is invalid. Allowed values are "android", "ios", "wp", "bb", "desktop", "web", "ubp", "other". | ||
| POLL_ANSWERS_INVALID The poll answers are invalid | ||
@@ -329,5 +371,7 @@ POLL_ANSWER_INVALID One of the poll answers is not acceptable | ||
| PREMIUM_ACCOUNT_REQUIRED The method requires a premium user account | ||
| PREMIUM_GIFTCODE_WAS_REFUNDED This gift code can't be redeemed because the giveaway organizer requested a refund | ||
| PRIVACY_KEY_INVALID The privacy key is invalid | ||
| PRIVACY_TOO_LONG Your privacy exception list has exceeded the maximum capacity | ||
| PRIVACY_VALUE_INVALID The privacy value is invalid | ||
| PUBLIC_BROADCAST_EXPECTED A public channel was expected, but something else was provided | ||
| PUBLIC_KEY_REQUIRED A public key is required | ||
@@ -356,2 +400,4 @@ QUERY_ID_EMPTY The query ID is empty | ||
| REPLY_MESSAGE_ID_INVALID The reply message id is invalid | ||
| REPLY_TO_INVALID The specified `reply_to` field is invalid. | ||
| REPLY_TO_USER_INVALID The replied-to user is invalid. | ||
| RESET_REQUEST_MISSING No password reset is in progress | ||
@@ -366,2 +412,3 @@ RESULTS_TOO_MUCH The result contains too many items | ||
| RSA_DECRYPT_FAILED Internal RSA decryption failed | ||
| SAVED_DIALOGS_UNSUPPORTED You cannot use this method | ||
| SCHEDULE_BOT_NOT_ALLOWED Bots are not allowed to schedule messages | ||
@@ -385,3 +432,5 @@ SCHEDULE_DATE_INVALID Invalid schedule date provided | ||
| SHORT_NAME_OCCUPIED The specified short name is already in use | ||
| SLOTS_EMPTY The specified slot list is empty. | ||
| SLOWMODE_MULTI_MSGS_DISABLED Slowmode is enabled, you cannot forward multiple messages to this group | ||
| SLUG_INVALID The specified invoice slug is invalid. | ||
| SMS_CODE_CREATE_FAILED An error occurred while creating the SMS code | ||
@@ -410,11 +459,19 @@ SRP_ID_INVALID Invalid SRP ID provided | ||
| STICKER_THUMB_PNG_NOPNG A png sticker thumbnail file was expected, but something else was provided | ||
| STICKER_THUMB_TGS_NOTGS Incorrect stickerset TGS thumb file provided. | ||
| STICKER_VIDEO_BIG The specified video sticker is too big | ||
| STICKER_VIDEO_NODOC You must send the video sticker as a document | ||
| STICKER_VIDEO_NOWEBM A webm video file was expected, but something else was provided | ||
| STORAGE_KEY_REQUIRED A cloud storage key is required. | ||
| STORIES_NEVER_CREATED You have never created any stories | ||
| STORIES_TOO_MUCH Too many stories in the current account | ||
| STORY_ID_EMPTY You specified no story IDs. | ||
| STORY_ID_INVALID The specified story ID is invalid. | ||
| STORY_NOT_MODIFIED The new story information you passed is equal to the previous story information, thus it wasn't modified. | ||
| STORY_PERIOD_INVALID The story period is invalid | ||
| STORY_SEND_FLOOD_MONTHLY_X You've hit the monthly story limit as specified by the [`stories_sent_monthly_limit_*` client configuration parameters](https://core.telegram.org/api/config#stories-sent-monthly-limit-default): wait for the specified number of seconds before posting a new story. | ||
| STORY_SEND_FLOOD_WEEKLY_X You've hit the weekly story limit as specified by the [`stories_sent_weekly_limit_*` client configuration parameters](https://core.telegram.org/api/config#stories-sent-weekly-limit-default): wait for the specified number of seconds before posting a new story. | ||
| SWITCH_PM_TEXT_EMPTY The switch_pm.text field was empty | ||
| TAKEOUT_INVALID The takeout id is invalid | ||
| TAKEOUT_REQUIRED The method must be invoked inside a takeout session | ||
| TASK_ALREADY_EXISTS An email reset was already requested. | ||
| TEMP_AUTH_KEY_ALREADY_BOUND The passed temporary key is already bound to another perm_auth_key_id | ||
@@ -430,7 +487,14 @@ TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty | ||
| TMP_PASSWORD_INVALID The temporary password is invalid | ||
| TOKEN_EMPTY The specified token is empty. | ||
| TOKEN_INVALID The provided token is invalid | ||
| TOKEN_SECRET_INVALID The specified token secret is invalid | ||
| TOKEN_TYPE_INVALID The specified token type is invalid. | ||
| TOPICS_EMPTY You specified no topic IDs. | ||
| TOPIC_CLOSED The topic was closed | ||
| TOPIC_CLOSE_SEPARATELY The `close` flag cannot be provided together with any of the other flags. | ||
| TOPIC_DELETED The topic was deleted | ||
| TOPIC_HIDE_SEPARATELY The `hide` flag cannot be provided together with any of the other flags. | ||
| TOPIC_ID_INVALID The provided topic ID is invalid | ||
| TOPIC_NOT_MODIFIED The topic was not modified | ||
| TOPIC_TITLE_EMPTY The specified topic title is empty. | ||
| TO_LANG_INVALID The specified destination language is invalid | ||
@@ -447,2 +511,3 @@ TRANSCRIPTION_FAILED Telegram is having internal problems. Please try again later to transcribe the audio. | ||
| USAGE_LIMIT_INVALID The usage limit is invalid | ||
| USERNAMES_ACTIVE_TOO_MUCH The maximum number of active usernames was reached. | ||
| USERNAME_INVALID The username is invalid | ||
@@ -475,2 +540,3 @@ USERNAME_NOT_MODIFIED The username was not modified because you tried to edit it using the same one | ||
| USER_VOLUME_INVALID The specified user volume is invalid | ||
| VENUE_ID_INVALID The specified venue ID is invalid. | ||
| VIDEO_CONTENT_TYPE_INVALID The video content type is invalid (i.e.: not streamable) | ||
@@ -484,2 +550,3 @@ VIDEO_FILE_INVALID The video file is invalid | ||
| WALLPAPER_MIME_INVALID The wallpaper mime type is invalid | ||
| WALLPAPER_NOT_FOUND The specified wallpaper could not be found. | ||
| WC_CONVERT_URL_INVALID WC convert URL invalid | ||
@@ -486,0 +553,0 @@ WEBDOCUMENT_INVALID The web document is invalid |
| id message | ||
| ANONYMOUS_REACTIONS_DISABLED Sorry, anonymous administrators cannot leave reactions or participate in polls. | ||
| BROADCAST_FORBIDDEN The request can't be used in channels | ||
@@ -9,2 +10,3 @@ CHANNEL_PUBLIC_GROUP_NA The channel/supergroup is not available | ||
| CHAT_SEND_AUDIOS_FORBIDDEN You can't send audio messages in this chat | ||
| CHAT_SEND_DOCS_FORBIDDEN You can't send documents in this chat. | ||
| CHAT_SEND_GAME_FORBIDDEN You can't send a game to this chat | ||
@@ -17,2 +19,3 @@ CHAT_SEND_GIFS_FORBIDDEN You can't send animations in this chat | ||
| CHAT_SEND_POLL_FORBIDDEN You can't send polls in this chat | ||
| CHAT_SEND_ROUNDVIDEOS_FORBIDDEN You cannot send video notes in this chat | ||
| CHAT_SEND_STICKERS_FORBIDDEN You can't send stickers in this chat | ||
@@ -46,2 +49,3 @@ CHAT_SEND_VIDEOS_FORBIDDEN You can't send videos in this chat | ||
| USER_PRIVACY_RESTRICTED The user's privacy settings is preventing you to perform this action | ||
| USER_RESTRICTED You are limited/restricted. You can't perform this action | ||
| USER_RESTRICTED You are limited/restricted. You can't perform this action | ||
| VOICE_MESSAGES_FORBIDDEN This user's privacy settings forbid you from sending voice messages. |
| id message | ||
| AUTH_KEY_DUPLICATED The same authorization key (session file) was used in more than one place simultaneously. You must delete your session file and log in again with your phone number or bot token | ||
| BANNED_RIGHTS_INVALID You provided some invalid flags in the banned rights. | ||
| BOT_PRECHECKOUT_FAILED Bot precheckout is failed | ||
| CALL_PROTOCOL_COMPAT_LAYER_INVALID The other side of the call does not support any of the VoIP protocols supported by the local client, as specified by the `protocol.layer` and `protocol.library_versions` fields. | ||
| CHANNEL_PRIVATE The channel/supergroup is not accessible | ||
@@ -12,2 +15,3 @@ CHANNEL_TOO_LARGE Сhannel is too large to be deleted. Contact support for removal | ||
| INVITE_HASH_EXPIRED The chat the user tried to join has expired and is not valid anymore | ||
| PAYMENT_UNSUPPORTED A detailed description of the error will be received separately as described [here »](https://core.telegram.org/api/errors#406-not-acceptable). | ||
| PHONE_NUMBER_INVALID The phone number is invalid | ||
@@ -17,8 +21,11 @@ PHONE_PASSWORD_FLOOD You have tried to log-in too many times | ||
| PREVIOUS_CHAT_IMPORT_ACTIVE_WAIT_XMIN Similar to a flood wait, must wait {value} minutes | ||
| PRIVACY_PREMIUM_REQUIRED You need a [Telegram Premium subscription](https://core.telegram.org/api/premium) to send a message to this user. | ||
| SEND_CODE_UNAVAILABLE Returned when all available options for this type of number were already used (e.g. flash-call, then SMS, then this error might be returned to trigger a second resend) | ||
| STICKERSET_INVALID The sticker set is invalid | ||
| STICKERSET_OWNER_ANONYMOUS This sticker set can't be used as the group's sticker set because it was created by one of its anonymous admins | ||
| TOPIC_CLOSED This topic was closed, you can't send messages to it anymore. | ||
| TOPIC_DELETED The specified topic was deleted. | ||
| UPDATE_APP_TO_LOGIN Update app to login | ||
| USERPIC_PRIVACY_REQUIRED You need to disable privacy settings for your profile picture in order to make your geolocation public | ||
| USERPIC_UPLOAD_REQUIRED You must have a profile picture to publish your geolocation | ||
| USER_RESTRICTED You are limited/restricted. You can't perform this action | ||
| USER_RESTRICTED You are limited/restricted. You can't perform this action |
@@ -5,3 +5,5 @@ id message | ||
| CALL_OCCUPY_FAILED The call failed because the user is already making another call | ||
| CDN_UPLOAD_TIMEOUT A server-side timeout occurred while reuploading the file to the CDN DC. | ||
| CHAT_ID_GENERATE_FAILED Failure while generating the chat ID due to Telegram having internal problems. Please try again later | ||
| CHAT_INVALID Invalid chat. | ||
| CHAT_OCCUPY_LOC_FAILED An internal error occurred while creating the chat | ||
@@ -26,2 +28,3 @@ CHAT_OCCUPY_USERNAME_FAILED Failure to occupy chat username due to Telegram having internal problems. Please try again later | ||
| MSG_RANGE_UNSYNC Message range unsynchronized due to Telegram having internal problems. Please try again later | ||
| MSG_WAIT_FAILED A waiting call returned an error. | ||
| MT_SEND_QUEUE_TOO_LONG The MTProto send queue has grown too much due to Telegram having internal problems. Please try again later | ||
@@ -41,4 +44,7 @@ NEED_CHAT_INVALID The provided chat is invalid | ||
| RPC_MCGET_FAIL Telegram is having internal problems. Please try again later | ||
| RPC_SEND_FAIL Telegram is having internal problems. Please try again later | ||
| SEND_MEDIA_INVALID The specified media is invalid. | ||
| SIGN_IN_FAILED Failure while signing in due to Telegram having internal problems. Please try again later | ||
| STORAGE_CHECK_FAILED Server storage check failed due to Telegram having internal problems. Please try again later | ||
| STORAGE_CHOOSE_VOLUME_FAILED Storage choose volume failed due to Telegram having internal problems. Please try again later | ||
| STORE_INVALID_SCALAR_TYPE Telegram is having internal problems. Please try again later | ||
@@ -45,0 +51,0 @@ TIMEOUT A timeout occurred while fetching data from the worker |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: WPyrogram | ||
| Version: 2.0.147 | ||
| Version: 2.0.148 | ||
| Summary: Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots - Woto's experimental fork | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/ALiwoto/WPyrogram |
@@ -19,3 +19,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| __version__ = "2.0.147" | ||
| __version__ = "2.0.148" | ||
| __license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)" | ||
@@ -22,0 +22,0 @@ __copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>" |
@@ -19,2 +19,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .account import Account | ||
| from .advanced import Advanced | ||
@@ -39,2 +40,3 @@ from .auth import Auth | ||
| class Methods( | ||
| Account, | ||
| Advanced, | ||
@@ -41,0 +43,0 @@ Auth, |
@@ -23,2 +23,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .disconnect import Disconnect | ||
| from .get_active_sessions import GetActiveSessions | ||
| from .get_password_hint import GetPasswordHint | ||
@@ -29,2 +30,4 @@ from .initialize import Initialize | ||
| from .resend_code import ResendCode | ||
| from .reset_session import ResetSession | ||
| from .reset_sessions import ResetSessions | ||
| from .send_code import SendCode | ||
@@ -43,2 +46,3 @@ from .send_recovery_code import SendRecoveryCode | ||
| Disconnect, | ||
| GetActiveSessions, | ||
| GetPasswordHint, | ||
@@ -49,2 +53,4 @@ Initialize, | ||
| ResendCode, | ||
| ResetSession, | ||
| ResetSessions, | ||
| SendCode, | ||
@@ -51,0 +57,0 @@ SendRecoveryCode, |
@@ -29,5 +29,7 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .get_inline_bot_results import GetInlineBotResults | ||
| from .refund_star_payment import RefundStarPayment | ||
| from .request_callback_answer import RequestCallbackAnswer | ||
| from .send_game import SendGame | ||
| from .send_inline_bot_result import SendInlineBotResult | ||
| from .send_invoice import SendInvoice | ||
| from .set_bot_commands import SetBotCommands | ||
@@ -43,4 +45,6 @@ from .set_bot_default_privileges import SetBotDefaultPrivileges | ||
| GetInlineBotResults, | ||
| RefundStarPayment, | ||
| RequestCallbackAnswer, | ||
| SendInlineBotResult, | ||
| SendInvoice, | ||
| SendGame, | ||
@@ -47,0 +51,0 @@ SetGameScore, |
@@ -19,2 +19,4 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from typing import Optional | ||
| import pyrogram | ||
@@ -28,4 +30,4 @@ from pyrogram import raw | ||
| pre_checkout_query_id: str, | ||
| success: bool = None, | ||
| error: str = None | ||
| ok: Optional[bool] = None, | ||
| error_message: Optional[str] = None | ||
| ): | ||
@@ -40,7 +42,7 @@ """Send answers to pre-checkout queries. | ||
| success (``bool``, *optional*): | ||
| ok (``bool``, *optional*): | ||
| Set this flag if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. | ||
| Otherwise do not set it, and set the error field, instead. | ||
| error (``str``, *optional*): | ||
| error_message (``str``, *optional*): | ||
| Error message in human readable form that explains the reason for failure to proceed with the checkout. | ||
@@ -56,6 +58,6 @@ Required if ``success`` isn't set. | ||
| # Proceed with the order | ||
| await app.answer_pre_checkout_query(query_id, success=True) | ||
| await app.answer_pre_checkout_query(query_id, ok=True) | ||
| # Answer with error message | ||
| await app.answer_pre_checkout_query(query_id, error=error) | ||
| await app.answer_pre_checkout_query(query_id, ok=False, error_message="Out of stock") | ||
| """ | ||
@@ -65,5 +67,5 @@ return await self.invoke( | ||
| query_id=int(pre_checkout_query_id), | ||
| success=success or None, | ||
| error=error or None | ||
| success=ok, | ||
| error=error_message | ||
| ) | ||
| ) |
@@ -24,2 +24,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .import_contacts import ImportContacts | ||
| from .search_contacts import SearchContacts | ||
@@ -32,4 +33,5 @@ | ||
| GetContactsCount, | ||
| AddContact | ||
| AddContact, | ||
| SearchContacts | ||
| ): | ||
| pass |
@@ -21,2 +21,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .copy_message import CopyMessage | ||
| from .delete_chat_history import DeleteChatHistory | ||
| from .delete_messages import DeleteMessages | ||
@@ -64,2 +65,3 @@ from .download_media import DownloadMedia | ||
| from .send_message import SendMessage | ||
| from .send_paid_media import SendPaidMedia | ||
| from .send_photo import SendPhoto | ||
@@ -101,2 +103,3 @@ from .send_poll import SendPoll | ||
| SendMessage, | ||
| SendPaidMedia, | ||
| SendPhoto, | ||
@@ -130,2 +133,3 @@ SendSticker, | ||
| CopyMessage, | ||
| DeleteChatHistory, | ||
| CopyMediaGroup, | ||
@@ -132,0 +136,0 @@ SearchMessagesCount, |
@@ -27,2 +27,5 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| async def get_session(client: "pyrogram.Client", dc_id: int) -> Session: | ||
| if dc_id == await client.storage.dc_id(): | ||
| return client.session | ||
| async with client.media_sessions_lock: | ||
@@ -29,0 +32,0 @@ if client.media_sessions.get(dc_id): |
@@ -20,2 +20,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from typing import Union, List, AsyncGenerator, Optional | ||
| from datetime import datetime | ||
@@ -33,3 +34,8 @@ import pyrogram | ||
| offset: int = 0, | ||
| offset_id: int = 0, | ||
| min_date: datetime = utils.zero_datetime(), | ||
| max_date: datetime = utils.zero_datetime(), | ||
| limit: int = 100, | ||
| min_id: int = 0, | ||
| max_id: int = 0, | ||
| from_user: Union[int, str] = None | ||
@@ -42,9 +48,9 @@ ) -> List["types.Message"]: | ||
| filter=filter.value(), | ||
| min_date=0, | ||
| max_date=0, | ||
| offset_id=0, | ||
| min_date=utils.datetime_to_timestamp(min_date), | ||
| max_date= utils.datetime_to_timestamp(max_date), | ||
| offset_id=offset_id, | ||
| add_offset=offset, | ||
| limit=limit, | ||
| min_id=0, | ||
| max_id=0, | ||
| min_id=min_id, | ||
| max_id=max_id, | ||
| from_id=( | ||
@@ -70,2 +76,7 @@ await client.resolve_peer(from_user) | ||
| offset: int = 0, | ||
| offset_id: int = 0, | ||
| min_date: datetime = utils.zero_datetime(), | ||
| max_date: datetime = utils.zero_datetime(), | ||
| min_id: int = 0, | ||
| max_id: int = 0, | ||
| filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY, | ||
@@ -97,2 +108,17 @@ limit: int = 0, | ||
| offset_id (``int``, *optional*): | ||
| Identifier of the first message to be returned. | ||
| min_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Pass a date as offset to retrieve only older messages starting from that date. | ||
| max_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Pass a date as offset to retrieve only newer messages starting from that date. | ||
| min_id (``int``, *optional*): | ||
| If a positive value was provided, the method will return only messages with IDs more than min_id. | ||
| max_id (``int``, *optional*): | ||
| If a positive value was provided, the method will return only messages with IDs less than max_id. | ||
| filter (:obj:`~pyrogram.enums.MessagesFilter`, *optional*): | ||
@@ -141,2 +167,7 @@ Pass a filter in order to search for specific kind of messages only. | ||
| offset=offset, | ||
| offset_id=offset_id, | ||
| min_date=min_date, | ||
| max_date=max_date, | ||
| min_id=min_id, | ||
| max_id=max_id, | ||
| limit=limit, | ||
@@ -143,0 +174,0 @@ from_user=from_user |
@@ -216,3 +216,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| mime_type=self.guess_mime_type(i.media) or "video/mp4", | ||
| nosound_video=i.no_sound, | ||
| nosound_video=True, # no-sounds videos cannot be sent in a media group | ||
| attributes=[ | ||
@@ -271,3 +271,3 @@ raw.types.DocumentAttributeVideo( | ||
| mime_type=self.guess_mime_type(getattr(i.media, "name", "video.mp4")) or "video/mp4", | ||
| nosound_video=i.no_sound, | ||
| nosound_video=True, # no-sounds videos cannot be sent in a media group | ||
| attributes=[ | ||
@@ -274,0 +274,0 @@ raw.types.DocumentAttributeVideo( |
@@ -60,3 +60,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| protect_content: bool = None, | ||
| no_sound: bool = None, | ||
| no_sound: bool = True, | ||
| business_connection_id: str = None, | ||
@@ -63,0 +63,0 @@ reply_markup: Union[ |
@@ -20,6 +20,10 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .check_giftcode import CheckGiftCode | ||
| from .get_payment_form import GetPaymentForm | ||
| from .send_payment_form import SendPaymentForm | ||
| class Payments( | ||
| CheckGiftCode | ||
| CheckGiftCode, | ||
| GetPaymentForm, | ||
| SendPaymentForm | ||
| ): | ||
| pass |
@@ -24,2 +24,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .input_message_content import * | ||
| from .input_privacy_rule import * | ||
| from .list import List | ||
@@ -26,0 +27,0 @@ from .messages_and_media import * |
@@ -19,5 +19,12 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .active_session import ActiveSession | ||
| from .active_sessions import ActiveSessions | ||
| from .sent_code import SentCode | ||
| from .terms_of_service import TermsOfService | ||
| __all__ = ["TermsOfService", "SentCode"] | ||
| __all__ = [ | ||
| "ActiveSession", | ||
| "ActiveSessions", | ||
| "SentCode", | ||
| "TermsOfService", | ||
| ] |
@@ -35,2 +35,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .keyboard_button import KeyboardButton | ||
| from .labeled_price import LabeledPrice | ||
| from .login_url import LoginUrl | ||
@@ -41,3 +42,3 @@ from .menu_button import MenuButton | ||
| from .menu_button_web_app import MenuButtonWebApp | ||
| from .payment_info import PaymentInfo | ||
| from .order_info import OrderInfo | ||
| from .pre_checkout_query import PreCheckoutQuery | ||
@@ -48,8 +49,7 @@ from .reply_keyboard_markup import ReplyKeyboardMarkup | ||
| from .request_chat_info import RequestChatInfo | ||
| from .request_poll_info import RequestPollInfo | ||
| from .request_user_info import RequestUserInfo | ||
| from .request_poll_info import RequestPollInfo | ||
| from .requested_chats import RequestedChats | ||
| from .sent_web_app_message import SentWebAppMessage | ||
| from .shipping_address import ShippingAddress | ||
| from .successful_payment import SuccessfulPayment | ||
| from .web_app_info import WebAppInfo | ||
@@ -72,2 +72,3 @@ | ||
| "RequestedChats", | ||
| "LabeledPrice", | ||
| "LoginUrl", | ||
@@ -87,8 +88,7 @@ "BotCommand", | ||
| "MenuButtonWebApp", | ||
| "OrderInfo", | ||
| "PreCheckoutQuery", | ||
| "MenuButtonDefault", | ||
| "SentWebAppMessage", | ||
| "ShippingAddress", | ||
| "PaymentInfo", | ||
| "PreCheckoutQuery", | ||
| "SuccessfulPayment" | ||
| "ShippingAddress" | ||
| ] |
@@ -46,3 +46,3 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| request_peer (:obj:`~pyrogram.types.RequestPeerTypeChannelInfo` | :obj:`~pyrogram.types.RequestPeerTypeChatInfo` | :obj:`~pyrogram.types.RequestPeerTypeUserInfo`, *optional*): | ||
| request_peer (:obj:`~pyrogram.types.RequestChannelInfo` | :obj:`~pyrogram.types.RequestChatInfo` | :obj:`~pyrogram.types.RequestUserInfo`, *optional*): | ||
| If specified, the requested peer will be sent when the button is pressed. | ||
@@ -49,0 +49,0 @@ |
@@ -19,14 +19,12 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from typing import Union, List, Match, Optional | ||
| from typing import Union, Optional | ||
| import pyrogram | ||
| from pyrogram import raw, enums | ||
| from pyrogram import types | ||
| from pyrogram import types, raw | ||
| from ..object import Object | ||
| from ..update import Update | ||
| from ... import utils | ||
| class PreCheckoutQuery(Object, Update): | ||
| """An incoming pre-checkout query from a buy button in an inline keyboard. | ||
| """This object contains information about an incoming pre-checkout query. | ||
@@ -41,8 +39,8 @@ Parameters: | ||
| currency (``str``): | ||
| Three-letter ISO 4217 currency code. | ||
| Three-letter ISO 4217 `currency <https://core.telegram.org/bots/payments#supported-currencies>`_ code, or ``XTR`` for payments in `Telegram Stars <https://t.me/BotNews/90>`_. | ||
| total_amount (``int``): | ||
| Total price in the smallest units of the currency. | ||
| Total price in the smallest units of the currency (integer, **not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``. See the __exp__ parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). | ||
| payload (``str``): | ||
| invoice_payload (``str``): | ||
| Bot specified invoice payload. | ||
@@ -53,3 +51,3 @@ | ||
| payment_info (:obj:`~pyrogram.types.PaymentInfo`, *optional*): | ||
| order_info (:obj:`~pyrogram.types.OrderInfo`, *optional*): | ||
| Payment information provided by the user. | ||
@@ -66,5 +64,5 @@ """ | ||
| total_amount: int, | ||
| payload: str, | ||
| shipping_option_id: str = None, | ||
| payment_info: "types.PaymentInfo" = None | ||
| invoice_payload: str, | ||
| shipping_option_id: Optional[str] = None, | ||
| order_info: Optional["types.OrderInfo"] = None | ||
| ): | ||
@@ -77,14 +75,18 @@ super().__init__(client) | ||
| self.total_amount = total_amount | ||
| self.payload = payload | ||
| self.invoice_payload = invoice_payload | ||
| self.shipping_option_id = shipping_option_id | ||
| self.payment_info = payment_info | ||
| self.order_info = order_info | ||
| @staticmethod | ||
| async def _parse(client: "pyrogram.Client", pre_checkout_query, users) -> "PreCheckoutQuery": | ||
| async def _parse( | ||
| client: "pyrogram.Client", | ||
| pre_checkout_query: "raw.types.UpdateBotPrecheckoutQuery", | ||
| users: dict | ||
| ) -> "PreCheckoutQuery": | ||
| # Try to decode pre-checkout query payload into string. If that fails, fallback to bytes instead of decoding by | ||
| # ignoring/replacing errors, this way, button clicks will still work. | ||
| try: | ||
| payload = pre_checkout_query.payload.decode() | ||
| invoice_payload = pre_checkout_query.payload.decode() | ||
| except (UnicodeDecodeError, AttributeError): | ||
| payload = pre_checkout_query.payload | ||
| invoice_payload = pre_checkout_query.payload | ||
@@ -96,5 +98,5 @@ return PreCheckoutQuery( | ||
| total_amount=pre_checkout_query.total_amount, | ||
| payload=payload, | ||
| invoice_payload=invoice_payload, | ||
| shipping_option_id=pre_checkout_query.shipping_option_id, | ||
| payment_info=types.PaymentInfo( | ||
| order_info=types.OrderInfo( | ||
| name=pre_checkout_query.info.name, | ||
@@ -115,3 +117,3 @@ phone_number=pre_checkout_query.info.phone, | ||
| async def answer(self, success: bool = None, error: str = None): | ||
| async def answer(self, ok: bool = None, error_message: str = None): | ||
| """Bound method *answer* of :obj:`~pyrogram.types.PreCheckoutQuery`. | ||
@@ -125,3 +127,3 @@ | ||
| pre_checkout_query.id, | ||
| success=True | ||
| ok=True | ||
| ) | ||
@@ -132,17 +134,18 @@ | ||
| await pre_checkout_query.answer(success=True) | ||
| await pre_checkout_query.answer(ok=True) | ||
| Parameters: | ||
| success (``bool`` *optional*): | ||
| If true, an alert will be shown by the client instead of a notification at the top of the chat screen. | ||
| Defaults to False. | ||
| ok (``bool`` *optional*): | ||
| Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. | ||
| error (``bool`` *optional*): | ||
| If true, an alert will be shown by the client instead of a notification at the top of the chat screen. | ||
| Defaults to False. | ||
| error_message (``str`` *optional*): | ||
| Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. | ||
| Returns: | ||
| ``bool``: True, on success. | ||
| """ | ||
| return await self._client.answer_pre_checkout_query( | ||
| pre_checkout_query_id=self.id, | ||
| success=success, | ||
| error=error | ||
| ok=ok, | ||
| error_message=error_message | ||
| ) |
@@ -26,37 +26,39 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| Parameters: | ||
| country_code (``str``): | ||
| Two-letter `ISO 3166-1 alpha-2 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`_ country code. | ||
| state (``str``): | ||
| State, if applicable. | ||
| city (``str``): | ||
| City. | ||
| street_line1 (``str``): | ||
| First line for the address. | ||
| street_line1 (``str``): | ||
| street_line2 (``str``): | ||
| Second line for the address. | ||
| city (``str``): | ||
| City for the address. | ||
| state (``str``): | ||
| State for the address, if applicable. | ||
| post_code (``str``): | ||
| Post code for the address. | ||
| Address post code. | ||
| country_code (``str``): | ||
| Two-letter ISO 3166-1 alpha-2 country code. | ||
| """ | ||
| def __init__( | ||
| self, *, | ||
| self, | ||
| *, | ||
| country_code: str, | ||
| state: str, | ||
| city: str, | ||
| street_line1: str, | ||
| street_line2: str, | ||
| city: str, | ||
| state: str, | ||
| post_code: str, | ||
| country_code: str | ||
| post_code: str | ||
| ): | ||
| super().__init__() | ||
| self.country_code = country_code | ||
| self.state = state | ||
| self.city = city | ||
| self.street_line1 = street_line1 | ||
| self.street_line2 = street_line2 | ||
| self.city = city | ||
| self.state = state | ||
| self.post_code = post_code | ||
| self.country_code = country_code |
@@ -45,2 +45,5 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .my_boost import MyBoost | ||
| from .paid_media_info import PaidMediaInfo | ||
| from .paid_media_preview import PaidMediaPreview | ||
| from .payment_form import PaymentForm | ||
| from .photo import Photo | ||
@@ -53,2 +56,3 @@ from .poll import Poll | ||
| from .stripped_thumbnail import StrippedThumbnail | ||
| from .successful_payment import SuccessfulPayment | ||
| from .thumbnail import Thumbnail | ||
@@ -89,2 +93,5 @@ from .venue import Venue | ||
| "MyBoost", | ||
| "PaidMediaInfo", | ||
| "PaidMediaPreview", | ||
| "PaymentForm", | ||
| "Photo", | ||
@@ -97,2 +104,3 @@ "Poll", | ||
| "StrippedThumbnail", | ||
| "SuccessfulPayment", | ||
| "Thumbnail", | ||
@@ -99,0 +107,0 @@ "Venue", |
@@ -19,5 +19,6 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from typing import Optional | ||
| from typing import Optional, List, Union | ||
| from pyrogram import raw | ||
| import pyrogram | ||
| from pyrogram import raw, types | ||
| from ..object import Object | ||
@@ -30,22 +31,62 @@ | ||
| Parameters: | ||
| title (``str``): | ||
| currency (``str``): | ||
| Three-letter ISO 4217 `currency <https://core.telegram.org/bots/payments#supported-currencies>`_ code. | ||
| is_test (``bool``): | ||
| True, if the invoice is a test invoice. | ||
| title (``str``, *optional*): | ||
| Product name. | ||
| description (``str``): | ||
| description (``str``, *optional*): | ||
| Product description. | ||
| start_parameter (``str``): | ||
| total_amount (``int``, *optional*): | ||
| Total price in the smallest units of the currency (integer, **not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``. See the exp parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). | ||
| start_parameter (``str``, *optional*): | ||
| Unique bot deep-linking parameter that can be used to generate this invoice. | ||
| currency (``str``): | ||
| Three-letter ISO 4217 `currency <https://core.telegram.org/bots/payments#supported-currencies>`_ code. | ||
| prices (List of :obj:`~pyrogram.types.LabeledPrice`, *optional*): | ||
| Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). | ||
| total_amount (``int``): | ||
| Total price in the smallest units of the currency (integer, **not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``. See the exp parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). | ||
| is_name_requested (``bool``, *optional*): | ||
| True, if the name should be specified. | ||
| is_phone_requested (``bool``, *optional*): | ||
| True, if the phone should be specified. | ||
| is_email_requested (``bool``, *optional*): | ||
| True, if the email address should be specified. | ||
| is_shipping_address_requested (``bool``, *optional*): | ||
| True, if the shipping address should be specified. | ||
| is_test (``bool``, *optional*): | ||
| True, if the invoice is a test invoice. | ||
| is_flexible (``bool``, *optional*): | ||
| True, if the final price depends on the shipping method. | ||
| is_phone_to_provider (``bool``, *optional*): | ||
| True, if user's phone should be sent to provider. | ||
| is_email_to_provider (``bool``, *optional*): | ||
| True, if user's email address should be sent to provider. | ||
| is_recurring (``bool``, *optional*): | ||
| Whether this is a recurring payment. | ||
| max_tip_amount (``int``, *optional*): | ||
| The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). | ||
| For example, for a price of US$ 1.45 pass amount = 145. | ||
| See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). | ||
| suggested_tip_amounts (List of ``int``, *optional*): | ||
| A vector of suggested amounts of tips in the smallest units of the currency (integer, not float/double). | ||
| At most 4 suggested tip amounts can be specified. | ||
| The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. | ||
| terms_url (``str``, *optional*): | ||
| Terms of service URL. | ||
| raw (:obj:`~raw.base.payments.MessageMediaInvoice` | :obj:`~raw.base.Invoice`, *optional*): | ||
| The raw object, as received from the Telegram API. | ||
| """ | ||
@@ -57,32 +98,68 @@ | ||
| client: "pyrogram.Client" = None, | ||
| title: str, | ||
| description: str, | ||
| currency: str, | ||
| total_amount: int, | ||
| is_test: bool, | ||
| title: Optional[str] = None, | ||
| description: Optional[str] = None, | ||
| total_amount: Optional[int] = None, | ||
| start_parameter: Optional[str] = None, | ||
| prices: Optional[List["types.LabeledPrice"]] = None, | ||
| is_name_requested: Optional[bool] = None, | ||
| is_phone_requested: Optional[bool] = None, | ||
| is_email_requested: Optional[bool] = None, | ||
| is_shipping_address_requested: Optional[bool] = None, | ||
| is_test: Optional[bool] = None | ||
| is_flexible: Optional[bool] = None, | ||
| is_phone_to_provider: Optional[bool] = None, | ||
| is_email_to_provider: Optional[bool] = None, | ||
| is_recurring: Optional[bool] = None, | ||
| max_tip_amount: Optional[int] = None, | ||
| suggested_tip_amounts: Optional[List[int]] = None, | ||
| terms_url: Optional[str] = None, | ||
| raw: Union["raw.types.MessageMediaInvoice", "raw.types.Invoice"] = None | ||
| ): | ||
| super().__init__(client) | ||
| self.currency = currency | ||
| self.is_test = is_test | ||
| self.title = title | ||
| self.description = description | ||
| self.total_amount = total_amount | ||
| self.start_parameter = start_parameter | ||
| self.prices = prices | ||
| self.is_name_requested = is_name_requested | ||
| self.is_phone_requested = is_phone_requested | ||
| self.is_email_requested = is_email_requested | ||
| self.is_shipping_address_requested = is_shipping_address_requested | ||
| self.currency = currency | ||
| self.start_parameter = start_parameter | ||
| self.total_amount = total_amount | ||
| self.is_test = is_test | ||
| self.is_flexible = is_flexible | ||
| self.is_phone_to_provider = is_phone_to_provider | ||
| self.is_email_to_provider = is_email_to_provider | ||
| self.is_recurring = is_recurring | ||
| self.max_tip_amount = max_tip_amount | ||
| self.suggested_tip_amounts = suggested_tip_amounts | ||
| self.terms_url = terms_url | ||
| self.raw = raw | ||
| @staticmethod | ||
| def _parse(client, invoice: "raw.types.MessageMediaInvoice") -> "Invoice": | ||
| def _parse(client, invoice: Union["raw.types.MessageMediaInvoice", "raw.types.Invoice"]) -> "Invoice": | ||
| return Invoice( | ||
| title=invoice.title, | ||
| description=invoice.description, | ||
| currency=invoice.currency, | ||
| total_amount=invoice.total_amount, | ||
| start_parameter=invoice.start_param or None, | ||
| is_test=invoice.test, | ||
| title=getattr(invoice, "title", None), | ||
| description=getattr(invoice, "description", None), | ||
| total_amount=getattr(invoice, "total_amount", None), | ||
| start_parameter=getattr(invoice, "start_param", None) or None, | ||
| prices=types.List(types.LabeledPrice._parse(lp) for lp in invoice.prices) if getattr(invoice, "prices", None) else None, | ||
| is_name_requested=getattr(invoice, "name_requested", None), | ||
| is_phone_requested=getattr(invoice, "phone_requested", None), | ||
| is_email_requested=getattr(invoice, "email_requested", None), | ||
| is_shipping_address_requested=getattr(invoice, "shipping_address_requested", None), | ||
| is_test=getattr(invoice, "test", None), | ||
| is_flexible=getattr(invoice, "flexible", None), | ||
| is_phone_to_provider=getattr(invoice, "phone_to_provider", None), | ||
| is_email_to_provider=getattr(invoice, "email_to_provider", None), | ||
| is_recurring=getattr(invoice, "recurring", None), | ||
| max_tip_amount=getattr(invoice, "max_tip_amount", None), | ||
| suggested_tip_amounts=getattr(invoice, "suggested_tip_amounts", None) or None, | ||
| terms_url=getattr(invoice, "terms_url", None), | ||
| raw=invoice, | ||
| client=client | ||
| # TODO: Add photo and extended media | ||
| ) |
@@ -38,3 +38,2 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| from .chat_photo import ChatPhoto | ||
| from .chat_preview import ChatPreview | ||
| from .chat_privileges import ChatPrivileges | ||
@@ -45,4 +44,6 @@ from .chat_reactions import ChatReactions | ||
| from .folder import Folder | ||
| from .found_contacts import FoundContacts | ||
| from .group_call_member import GroupCallMember | ||
| from .invite_link_importer import InviteLinkImporter | ||
| from .privacy_rule import PrivacyRule | ||
| from .restriction import Restriction | ||
@@ -68,3 +69,2 @@ from .user import User | ||
| "ChatPhoto", | ||
| "ChatPreview", | ||
| "Dialog", | ||
@@ -78,2 +78,3 @@ "User", | ||
| "InviteLinkImporter", | ||
| "PrivacyRule", | ||
| "ChatAdminWithInviteLinks", | ||
@@ -91,4 +92,5 @@ "ChatColor", | ||
| "Folder", | ||
| "FoundContacts", | ||
| "GroupCallMember", | ||
| "ChatReactions" | ||
| ] |
@@ -33,6 +33,6 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| Parameters: | ||
| id (``int``): | ||
| id (``int``, *optional*): | ||
| Unique identifier for this chat. | ||
| type (:obj:`~pyrogram.enums.ChatType`): | ||
| type (:obj:`~pyrogram.enums.ChatType`, *optional*): | ||
| Type of chat. | ||
@@ -80,2 +80,17 @@ | ||
| is_preview (``bool``, *optional*): | ||
| True, if this chat is a preview. | ||
| is_banned (``bool``, *optional*): | ||
| True, if you are banned in this chat. | ||
| is_call_active (``bool``, *optional*): | ||
| True, if a group call is currently active. | ||
| is_call_not_empty (``bool``, *optional*): | ||
| True, if there's anyone in the group call. | ||
| is_public (``bool``, *optional*): | ||
| True, if this chat is public. | ||
| title (``str``, *optional*): | ||
@@ -96,5 +111,2 @@ Title, for supergroups, channels and basic group chats. | ||
| full_name (``str``, *property*): | ||
| Full name of the other party in a private chat, for private chats and bots. | ||
| photo (:obj:`~pyrogram.types.ChatPhoto`, *optional*): | ||
@@ -129,2 +141,8 @@ Chat photo. Suitable for downloads only. | ||
| has_visible_history (``bool``, *optional*): | ||
| True, if new chat members will have access to old messages; available only to chat administrators. | ||
| has_aggressive_anti_spam_enabled (``bool``, *optional*): | ||
| True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. | ||
| invite_link (``str``, *optional*): | ||
@@ -142,2 +160,5 @@ Chat invite link, for groups, supergroups and channels. | ||
| custom_emoji_sticker_set_name (``str``, *optional*): | ||
| For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. | ||
| can_set_sticker_set (``bool``, *optional*): | ||
@@ -147,2 +168,8 @@ True, if the group sticker set can be changed by you. | ||
| can_send_paid_media (``bool``, *optional*): | ||
| True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. | ||
| members (List of :obj:`~pyrogram.types.User`, *optional*): | ||
| A few of the participants that are in the group. | ||
| members_count (``int``, *optional*): | ||
@@ -201,4 +228,31 @@ Chat members count, for groups, supergroups and channels only. | ||
| message_auto_delete_time (``int``, *optional*): | ||
| The time after which all messages sent to the chat will be automatically deleted; in seconds. | ||
| unrestrict_boost_count (``int``, *optional*): | ||
| For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. | ||
| slow_mode_delay (``int``, *optional*): | ||
| For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. | ||
| slowmode_next_send_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Indicates when the user will be allowed to send another message in the chat. For supergroups only. | ||
| join_by_request (``bool``, *optional*): | ||
| True, if all users directly joining the supergroup need to be approved by supergroup administrators. | ||
| join_requests_count (``int``, *optional*): | ||
| Number of users who requested to join the chat. | ||
| banned_until_date (:py:obj:`~datetime.datetime`, *optional*): | ||
| Date when the user will be unbanned. | ||
| reactions_limit (``int``, *optional*): | ||
| This flag may be used to impose a custom limit of unique reactions (i.e. a customizable version of appConfig.reactions_uniq_max). | ||
| raw (:obj:`~pyrogram.raw.base.Chat` | :obj:`~pyrogram.raw.base.User` | :obj:`~pyrogram.raw.base.ChatFull` | :obj:`~pyrogram.raw.base.UserFull`, *optional*): | ||
| The raw chat or user object, as received from the Telegram API. | ||
| full_name (``str``, *property*): | ||
| Full name of the other party in a private chat, for private chats and bots. | ||
| """ | ||
@@ -210,4 +264,4 @@ | ||
| client: "pyrogram.Client" = None, | ||
| id: int, | ||
| type: "enums.ChatType", | ||
| id: int = None, | ||
| type: "enums.ChatType" = None, | ||
| is_forum: bool = None, | ||
@@ -226,2 +280,7 @@ is_verified: bool = None, | ||
| is_business_bot: bool = None, | ||
| is_preview: bool = None, | ||
| is_banned: bool = None, | ||
| is_call_active: bool = None, | ||
| is_call_not_empty: bool = None, | ||
| is_public: bool = None, | ||
| title: str = None, | ||
@@ -240,6 +299,11 @@ username: str = None, | ||
| has_protected_content: bool = None, | ||
| has_visible_history: bool = None, | ||
| has_aggressive_anti_spam_enabled: bool = None, | ||
| invite_link: str = None, | ||
| pinned_message=None, | ||
| sticker_set_name: str = None, | ||
| custom_emoji_sticker_set_name = None, | ||
| can_set_sticker_set: bool = None, | ||
| can_send_paid_media: bool = None, | ||
| members: List["types.User"] = None, | ||
| members_count: int = None, | ||
@@ -260,2 +324,10 @@ restrictions: List["types.Restriction"] = None, | ||
| birthday: "types.Birthday" = None, | ||
| message_auto_delete_time = None, | ||
| unrestrict_boost_count = None, | ||
| slow_mode_delay = None, | ||
| slowmode_next_send_date: datetime = None, | ||
| join_by_request: bool = None, | ||
| join_requests_count: int = None, | ||
| banned_until_date: datetime = None, | ||
| reactions_limit: int = None, | ||
| raw: Union["raw.base.Chat", "raw.base.User", "raw.base.ChatFull", "raw.base.UserFull"] = None | ||
@@ -280,2 +352,7 @@ ): | ||
| self.is_business_bot = is_business_bot | ||
| self.is_preview = is_preview | ||
| self.is_banned = is_banned | ||
| self.is_call_active = is_call_active | ||
| self.is_call_not_empty = is_call_not_empty | ||
| self.is_public = is_public | ||
| self.title = title | ||
@@ -294,6 +371,11 @@ self.username = username | ||
| self.has_protected_content = has_protected_content | ||
| self.has_visible_history = has_visible_history | ||
| self.has_aggressive_anti_spam_enabled = has_aggressive_anti_spam_enabled | ||
| self.invite_link = invite_link | ||
| self.pinned_message = pinned_message | ||
| self.sticker_set_name = sticker_set_name | ||
| self.custom_emoji_sticker_set_name = custom_emoji_sticker_set_name | ||
| self.can_set_sticker_set = can_set_sticker_set | ||
| self.can_send_paid_media = can_send_paid_media | ||
| self.members = members | ||
| self.members_count = members_count | ||
@@ -314,2 +396,10 @@ self.restrictions = restrictions | ||
| self.birthday = birthday | ||
| self.message_auto_delete_time = message_auto_delete_time | ||
| self.unrestrict_boost_count = unrestrict_boost_count | ||
| self.slow_mode_delay = slow_mode_delay | ||
| self.slowmode_next_send_date = slowmode_next_send_date | ||
| self.join_by_request = join_by_request | ||
| self.join_requests_count = join_requests_count | ||
| self.banned_until_date = banned_until_date | ||
| self.reactions_limit = reactions_limit | ||
| self.raw = raw | ||
@@ -351,2 +441,12 @@ | ||
| if isinstance(chat, raw.types.ChatForbidden): | ||
| return Chat( | ||
| id=peer_id, | ||
| type=enums.ChatType.GROUP, | ||
| title=chat.title, | ||
| is_banned=True, | ||
| raw=chat, | ||
| client=client | ||
| ) | ||
| return Chat( | ||
@@ -359,2 +459,4 @@ id=peer_id, | ||
| is_deactivated=getattr(chat, "deactivated", None), | ||
| is_call_active=getattr(chat, "call_active", None), | ||
| is_call_not_empty=getattr(chat, "call_not_empty", None), | ||
| usernames=types.List([types.Username._parse(r) for r in usernames]) or None, | ||
@@ -377,2 +479,13 @@ photo=types.ChatPhoto._parse(client, getattr(chat, "photo", None), peer_id, 0), | ||
| if isinstance(channel, raw.types.ChannelForbidden): | ||
| return Chat( | ||
| id=peer_id, | ||
| type=enums.ChatType.SUPERGROUP if getattr(channel, "megagroup", None) else enums.ChatType.CHANNEL, | ||
| title=channel.title, | ||
| is_banned=True, | ||
| banned_until_date=utils.timestamp_to_datetime(getattr(channel, "until_date", None)), | ||
| raw=channel, | ||
| client=client, | ||
| ) | ||
| return Chat( | ||
@@ -390,2 +503,4 @@ id=peer_id, | ||
| is_stories_unavailable=getattr(channel, "stories_unavailable", None), | ||
| is_call_active=getattr(channel, "call_active", None), | ||
| is_call_not_empty=getattr(channel, "call_not_empty", None), | ||
| title=channel.title, | ||
@@ -480,3 +595,3 @@ username=getattr(channel, "username", None), | ||
| else: | ||
| full_chat = chat_full.full_chat | ||
| full_chat: Union["raw.types.ChatFull", "raw.types.ChannelFull"] = chat_full.full_chat | ||
| chat_raw = chats[full_chat.id] | ||
@@ -497,4 +612,11 @@ | ||
| parsed_chat.sticker_set_name = getattr(full_chat.stickerset, "short_name", None) | ||
| parsed_chat.custom_emoji_sticker_set_name = getattr(full_chat.emojiset, "short_name", None) | ||
| parsed_chat.is_members_hidden = full_chat.participants_hidden | ||
| parsed_chat.folder_id = getattr(full_chat, "folder_id", None) | ||
| parsed_chat.has_visible_history = not getattr(full_chat, "hidden_prehistory", False) | ||
| parsed_chat.has_aggressive_anti_spam_enabled = getattr(full_chat, "antispam", False) | ||
| parsed_chat.slow_mode_delay = getattr(full_chat, "slowmode_seconds", None) | ||
| parsed_chat.slowmode_next_send_date = utils.timestamp_to_datetime( | ||
| getattr(full_chat, "slowmode_next_send_date", None) | ||
| ) | ||
| parsed_chat.can_send_paid_media = getattr(full_chat, "paid_media_allowed", None) | ||
@@ -540,2 +662,8 @@ linked_chat_raw = chats.get(full_chat.linked_chat_id, None) | ||
| parsed_chat.available_reactions = types.ChatReactions._parse(client, full_chat.available_reactions) | ||
| parsed_chat.folder_id = getattr(full_chat, "folder_id", None) | ||
| parsed_chat.message_auto_delete_time = getattr(full_chat, "ttl_period", None) | ||
| parsed_chat.unrestrict_boost_count = getattr(full_chat, "boosts_unrestrict", None) | ||
| parsed_chat.join_requests_count = getattr(full_chat, "requests_pending", None) | ||
| parsed_chat.reactions_limit = getattr(full_chat, "reactions_limit", None) | ||
| parsed_chat.raw = full_chat | ||
@@ -554,2 +682,29 @@ | ||
| @staticmethod | ||
| def _parse_preview(client, chat_invite: "raw.types.ChatInvite") -> "Chat": | ||
| return Chat( | ||
| type=( | ||
| enums.ChatType.SUPERGROUP if getattr(chat_invite, "megagroup", None) else | ||
| enums.ChatType.CHANNEL if getattr(chat_invite, "broadcast", None) else | ||
| enums.ChatType.GROUP | ||
| ), | ||
| is_verified=getattr(chat_invite, "verified", None), | ||
| is_scam=getattr(chat_invite, "scam", None), | ||
| is_fake=getattr(chat_invite, "fake", None), | ||
| is_public=getattr(chat_invite, "public", None), | ||
| is_preview=True, | ||
| title=chat_invite.title, | ||
| photo=types.Photo._parse(client, chat_invite.photo), | ||
| members_count=chat_invite.participants_count, | ||
| members=[ | ||
| types.User._parse(client, user) | ||
| for user in getattr(chat_invite, "participants", []) | ||
| ] or None, | ||
| description=getattr(chat_invite, "about", None), | ||
| join_by_request=getattr(chat_invite, "request_needed", None), | ||
| profile_color=types.ChatColor._parse(getattr(chat_invite, "color", None)), | ||
| raw=chat_invite, | ||
| client=client | ||
| ) | ||
| @property | ||
@@ -556,0 +711,0 @@ def full_name(self) -> str: |
@@ -42,2 +42,5 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| unread_reactions_count (``int``): | ||
| Amount of unread messages containing a reaction in this dialog. | ||
| unread_mark (``bool``): | ||
@@ -48,2 +51,11 @@ True, if the dialog has the unread mark set. | ||
| True, if the dialog is pinned. | ||
| folder_id (``int``, *optional*): | ||
| Unique identifier (int) of the folder. | ||
| ttl_period (``int``, *optional*) | ||
| Time-to-live of all messages sent in this dialog (in seconds). | ||
| raw (:obj:`~pyrogram.raw.types.Dialog`, *optional*): | ||
| The raw object, as received from the Telegram API. | ||
| """ | ||
@@ -59,4 +71,8 @@ | ||
| unread_mentions_count: int, | ||
| unread_reactions_count: int, | ||
| unread_mark: bool, | ||
| is_pinned: bool | ||
| is_pinned: bool, | ||
| folder_id: int = None, | ||
| ttl_period: int = None, | ||
| raw: "raw.types.Dialog" = None | ||
| ): | ||
@@ -69,4 +85,8 @@ super().__init__(client) | ||
| self.unread_mentions_count = unread_mentions_count | ||
| self.unread_reactions_count = unread_reactions_count | ||
| self.unread_mark = unread_mark | ||
| self.is_pinned = is_pinned | ||
| self.folder_id = folder_id | ||
| self.ttl_period = ttl_period | ||
| self.raw = raw | ||
@@ -80,5 +100,9 @@ @staticmethod | ||
| unread_mentions_count=dialog.unread_mentions_count, | ||
| unread_reactions_count=dialog.unread_reactions_count, | ||
| unread_mark=dialog.unread_mark, | ||
| is_pinned=dialog.pinned, | ||
| folder_id=getattr(dialog, "folder_id", None), | ||
| ttl_period=getattr(dialog, "ttl_period", None), | ||
| raw=dialog, | ||
| client=client | ||
| ) |
@@ -176,4 +176,40 @@ # Pyrogram - Telegram MTProto API Client Library for Python | ||
| added_to_attachment_menu (``bool``, *optional*): | ||
| True, if this user added the bot to the attachment menu. | ||
| active_users_count (``int``, *optional*): | ||
| The number of recently (monthly) active users of the bot. | ||
| inline_need_location (``bool``, *optional*): | ||
| True, if the bot supports inline `user location <https://core.telegram.org/bots/inline#location-based-results>`_ requests. Returned only in get_me. | ||
| inline_query_placeholder (``str``, *optional*): | ||
| Placeholder for inline queries (displayed on the application input field). | ||
| can_be_edited (``bool``, *optional*): | ||
| True, if the current user can edit this bot's profile picture. | ||
| can_be_added_to_attachment_menu (``bool``, *optional*): | ||
| True, if the bot can be added to attachment or side menu. | ||
| can_join_groups (``bool``, *optional*): | ||
| True, if the bot can be invited to groups. Returned only in get_me. | ||
| can_read_all_group_messages (``bool``, *optional*): | ||
| True, if privacy mode is disabled for the bot. Returned only in get_me. | ||
| has_main_web_app (``bool``, *optional*): | ||
| True, if the bot has a main Web App. Returned only in get_me. | ||
| raw (:obj:`~pyrogram.raw.base.User` | :obj:`~pyrogram.raw.base.UserStatus`, *optional*): | ||
| The raw user or user status object, as received from the Telegram API. | ||
| mention (``str``, *property*): | ||
| Generate a text mention for this user. | ||
| You can use ``user.mention()`` to mention the user using their first name (styled using html), or | ||
| ``user.mention("another name")`` for a custom name. To choose a different style | ||
| ("html" or "md"/"markdown") use ``user.mention(style="md")``. | ||
| full_name (``str``, *property*): | ||
| Full name of the other party in a private chat, for private chats and bots. | ||
| """ | ||
@@ -217,2 +253,11 @@ | ||
| profile_color: "types.ChatColor" = None, | ||
| added_to_attachment_menu: bool = None, | ||
| active_users_count: int = None, | ||
| inline_need_location: bool = None, | ||
| inline_query_placeholder: str = None, | ||
| can_be_edited: bool = None, | ||
| can_be_added_to_attachment_menu: bool = None, | ||
| can_join_groups: bool = None, | ||
| can_read_all_group_messages: bool = None, | ||
| has_main_web_app: bool = None, | ||
| raw: Union["raw.base.User", "raw.base.UserStatus"] = None | ||
@@ -254,2 +299,11 @@ ): | ||
| self.profile_color = profile_color | ||
| self.added_to_attachment_menu = added_to_attachment_menu | ||
| self.active_users_count = active_users_count | ||
| self.inline_need_location = inline_need_location | ||
| self.inline_query_placeholder = inline_query_placeholder | ||
| self.can_be_edited = can_be_edited | ||
| self.can_be_added_to_attachment_menu = can_be_added_to_attachment_menu | ||
| self.can_join_groups = can_join_groups | ||
| self.can_read_all_group_messages = can_read_all_group_messages | ||
| self.has_main_web_app = has_main_web_app | ||
| self.raw = raw | ||
@@ -305,2 +359,11 @@ | ||
| profile_color=types.ChatColor._parse_profile_color(getattr(user, "profile_color", None)), | ||
| added_to_attachment_menu=getattr(user, "attach_menu_enabled", None), | ||
| active_users_count=getattr(user, "bot_active_users", None), | ||
| inline_need_location=getattr(user, "bot_inline_geo", None), | ||
| inline_query_placeholder=getattr(user, "bot_inline_placeholder", None), | ||
| can_be_edited=getattr(user, "bot_can_edit", None), | ||
| can_be_added_to_attachment_menu=getattr(user, "bot_attach_menu", None), | ||
| can_join_groups=getattr(user, "bot_nochats", None), | ||
| can_read_all_group_messages=getattr(user, "bot_chat_history", None), | ||
| has_main_web_app=getattr(user, "bot_has_main_app", None), | ||
| raw=user, | ||
@@ -307,0 +370,0 @@ client=client |
| Metadata-Version: 2.1 | ||
| Name: WPyrogram | ||
| Version: 2.0.147 | ||
| Version: 2.0.148 | ||
| Summary: Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots - Woto's experimental fork | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/ALiwoto/WPyrogram |
@@ -81,2 +81,3 @@ COPYING | ||
| pyrogram/enums/poll_type.py | ||
| pyrogram/enums/privacy_key.py | ||
| pyrogram/enums/profile_color.py | ||
@@ -109,2 +110,7 @@ pyrogram/enums/reply_color.py | ||
| pyrogram/methods/__init__.py | ||
| pyrogram/methods/account/__init__.py | ||
| pyrogram/methods/account/get_account_ttl.py | ||
| pyrogram/methods/account/get_privacy.py | ||
| pyrogram/methods/account/set_account_ttl.py | ||
| pyrogram/methods/account/set_privacy.py | ||
| pyrogram/methods/advanced/__init__.py | ||
@@ -119,2 +125,3 @@ pyrogram/methods/advanced/invoke.py | ||
| pyrogram/methods/auth/disconnect.py | ||
| pyrogram/methods/auth/get_active_sessions.py | ||
| pyrogram/methods/auth/get_password_hint.py | ||
@@ -125,2 +132,4 @@ pyrogram/methods/auth/initialize.py | ||
| pyrogram/methods/auth/resend_code.py | ||
| pyrogram/methods/auth/reset_session.py | ||
| pyrogram/methods/auth/reset_sessions.py | ||
| pyrogram/methods/auth/send_code.py | ||
@@ -143,5 +152,7 @@ pyrogram/methods/auth/send_recovery_code.py | ||
| pyrogram/methods/bots/get_inline_bot_results.py | ||
| pyrogram/methods/bots/refund_star_payment.py | ||
| pyrogram/methods/bots/request_callback_answer.py | ||
| pyrogram/methods/bots/send_game.py | ||
| pyrogram/methods/bots/send_inline_bot_result.py | ||
| pyrogram/methods/bots/send_invoice.py | ||
| pyrogram/methods/bots/set_bot_commands.py | ||
@@ -219,2 +230,3 @@ pyrogram/methods/bots/set_bot_default_privileges.py | ||
| pyrogram/methods/contacts/import_contacts.py | ||
| pyrogram/methods/contacts/search_contacts.py | ||
| pyrogram/methods/decorators/__init__.py | ||
@@ -257,2 +269,3 @@ pyrogram/methods/decorators/on_callback_query.py | ||
| pyrogram/methods/messages/copy_message.py | ||
| pyrogram/methods/messages/delete_chat_history.py | ||
| pyrogram/methods/messages/delete_messages.py | ||
@@ -303,2 +316,3 @@ pyrogram/methods/messages/download_media.py | ||
| pyrogram/methods/messages/send_message.py | ||
| pyrogram/methods/messages/send_paid_media.py | ||
| pyrogram/methods/messages/send_photo.py | ||
@@ -326,2 +340,4 @@ pyrogram/methods/messages/send_poll.py | ||
| pyrogram/methods/payments/check_giftcode.py | ||
| pyrogram/methods/payments/get_payment_form.py | ||
| pyrogram/methods/payments/send_payment_form.py | ||
| pyrogram/methods/phone/__init__.py | ||
@@ -424,2 +440,4 @@ pyrogram/methods/phone/get_call_members.py | ||
| pyrogram/types/authorization/__init__.py | ||
| pyrogram/types/authorization/active_session.py | ||
| pyrogram/types/authorization/active_sessions.py | ||
| pyrogram/types/authorization/sent_code.py | ||
@@ -444,2 +462,3 @@ pyrogram/types/authorization/terms_of_service.py | ||
| pyrogram/types/bots_and_keyboards/keyboard_button.py | ||
| pyrogram/types/bots_and_keyboards/labeled_price.py | ||
| pyrogram/types/bots_and_keyboards/login_url.py | ||
@@ -450,3 +469,3 @@ pyrogram/types/bots_and_keyboards/menu_button.py | ||
| pyrogram/types/bots_and_keyboards/menu_button_web_app.py | ||
| pyrogram/types/bots_and_keyboards/payment_info.py | ||
| pyrogram/types/bots_and_keyboards/order_info.py | ||
| pyrogram/types/bots_and_keyboards/pre_checkout_query.py | ||
@@ -498,2 +517,13 @@ pyrogram/types/bots_and_keyboards/reply_keyboard_markup.py | ||
| pyrogram/types/input_message_content/input_text_message_content.py | ||
| pyrogram/types/input_privacy_rule/__init__.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_allow_all.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_allow_chats.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_allow_contacts.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_allow_premium.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_allow_users.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_all.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_chats.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_contacts.py | ||
| pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_users.py | ||
| pyrogram/types/messages_and_media/__init__.py | ||
@@ -538,3 +568,6 @@ pyrogram/types/messages_and_media/animation.py | ||
| pyrogram/types/messages_and_media/next_code_type.py | ||
| pyrogram/types/messages_and_media/paid_media_info.py | ||
| pyrogram/types/messages_and_media/paid_media_preview.py | ||
| pyrogram/types/messages_and_media/parse_mode.py | ||
| pyrogram/types/messages_and_media/payment_form.py | ||
| pyrogram/types/messages_and_media/photo.py | ||
@@ -549,2 +582,3 @@ pyrogram/types/messages_and_media/poll.py | ||
| pyrogram/types/messages_and_media/stripped_thumbnail.py | ||
| pyrogram/types/messages_and_media/successful_payment.py | ||
| pyrogram/types/messages_and_media/thumbnail.py | ||
@@ -579,3 +613,2 @@ pyrogram/types/messages_and_media/user_status.py | ||
| pyrogram/types/user_and_chats/chat_photo.py | ||
| pyrogram/types/user_and_chats/chat_preview.py | ||
| pyrogram/types/user_and_chats/chat_privileges.py | ||
@@ -586,4 +619,6 @@ pyrogram/types/user_and_chats/chat_reactions.py | ||
| pyrogram/types/user_and_chats/folder.py | ||
| pyrogram/types/user_and_chats/found_contacts.py | ||
| pyrogram/types/user_and_chats/group_call_member.py | ||
| pyrogram/types/user_and_chats/invite_link_importer.py | ||
| pyrogram/types/user_and_chats/privacy_rule.py | ||
| pyrogram/types/user_and_chats/restriction.py | ||
@@ -590,0 +625,0 @@ pyrogram/types/user_and_chats/user.py |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from ..object import Object | ||
| from pyrogram import types | ||
| class PaymentInfo(Object): | ||
| """Contains information about a payment. | ||
| Parameters: | ||
| name (``str``, *optional*): | ||
| User's name. | ||
| phone_number (``str``, *optional*): | ||
| User's phone number. | ||
| email (``str``, *optional*): | ||
| User's email. | ||
| shipping_address (:obj:`~pyrogram.types.ShippingAddress`, *optional*): | ||
| User's shipping address. | ||
| """ | ||
| def __init__( | ||
| self, *, | ||
| name: str = None, | ||
| phone_number: str = None, | ||
| email: str = None, | ||
| shipping_address: "types.ShippingAddress" = None | ||
| ): | ||
| super().__init__() | ||
| self.name = name | ||
| self.phone_number = phone_number | ||
| self.email = email | ||
| self.shipping_address = shipping_address |
| # Pyrogram - Telegram MTProto API Client Library for Python | ||
| # Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
| # | ||
| # This file is part of Pyrogram. | ||
| # | ||
| # Pyrogram is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser General Public License as published | ||
| # by the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Pyrogram is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. | ||
| from typing import List | ||
| import pyrogram | ||
| from pyrogram import raw | ||
| from pyrogram import types | ||
| from ..object import Object | ||
| class ChatPreview(Object): | ||
| """A chat preview. | ||
| Parameters: | ||
| title (``str``): | ||
| Title of the chat. | ||
| type (``str``): | ||
| Type of chat, can be either, "group", "supergroup" or "channel". | ||
| members_count (``int``): | ||
| Chat members count. | ||
| photo (:obj:`~pyrogram.types.Photo`, *optional*): | ||
| Chat photo. | ||
| members (List of :obj:`~pyrogram.types.User`, *optional*): | ||
| Preview of some of the chat members. | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| client: "pyrogram.Client" = None, | ||
| title: str, | ||
| type: str, | ||
| members_count: int, | ||
| photo: "types.Photo" = None, | ||
| members: List["types.User"] = None | ||
| ): | ||
| super().__init__(client) | ||
| self.title = title | ||
| self.type = type | ||
| self.members_count = members_count | ||
| self.photo = photo | ||
| self.members = members | ||
| @staticmethod | ||
| def _parse(client, chat_invite: "raw.types.ChatInvite") -> "ChatPreview": | ||
| return ChatPreview( | ||
| title=chat_invite.title, | ||
| type=("group" if not chat_invite.channel else | ||
| "channel" if chat_invite.broadcast else | ||
| "supergroup"), | ||
| members_count=chat_invite.participants_count, | ||
| photo=types.Photo._parse(client, chat_invite.photo), | ||
| members=[types.User._parse(client, user) for user in chat_invite.participants] or None, | ||
| client=client | ||
| ) | ||
| # TODO: Maybe just merge this object into Chat itself by adding the "members" field. | ||
| # get_chat can be used as well instead of get_chat_preview |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
2957177
4.8%622
5.96%57354
4.63%