├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml └── workflows │ ├── github_release.yml │ ├── pypi_release.yml │ └── python.yml ├── .gitignore ├── COPYING ├── COPYING.lesser ├── MANIFEST.in ├── Makefile ├── NOTICE ├── README.md ├── compiler ├── __init__.py ├── api │ ├── __init__.py │ ├── compiler.py │ ├── source │ │ ├── auth_key.tl │ │ ├── main_api.tl │ │ └── sys_msgs.tl │ └── template │ │ ├── combinator.txt │ │ └── type.txt ├── docs │ ├── __init__.py │ ├── compiler.py │ └── template │ │ ├── bound-methods.rst │ │ ├── enums.rst │ │ ├── methods.rst │ │ ├── page.txt │ │ ├── toctree.txt │ │ └── types.rst └── errors │ ├── __init__.py │ ├── compiler.py │ ├── sort.py │ ├── source │ ├── 303_SEE_OTHER.tsv │ ├── 400_BAD_REQUEST.tsv │ ├── 401_UNAUTHORIZED.tsv │ ├── 403_FORBIDDEN.tsv │ ├── 406_NOT_ACCEPTABLE.tsv │ ├── 420_FLOOD.tsv │ ├── 500_INTERNAL_SERVER_ERROR.tsv │ └── 503_SERVICE_UNAVAILABLE.tsv │ └── template │ ├── class.txt │ └── sub_class.txt ├── hatch_build.py ├── pyproject.toml ├── pyrogram ├── __init__.py ├── client.py ├── connection │ ├── __init__.py │ ├── connection.py │ └── transport │ │ ├── __init__.py │ │ └── tcp │ │ ├── __init__.py │ │ ├── tcp.py │ │ ├── tcp_abridged.py │ │ ├── tcp_abridged_o.py │ │ ├── tcp_full.py │ │ ├── tcp_intermediate.py │ │ └── tcp_intermediate_o.py ├── crypto │ ├── __init__.py │ ├── aes.py │ ├── mtproto.py │ ├── prime.py │ └── rsa.py ├── dispatcher.py ├── enums │ ├── __init__.py │ ├── auto_name.py │ ├── business_schedule.py │ ├── chat_action.py │ ├── chat_event_action.py │ ├── chat_join_type.py │ ├── chat_member_status.py │ ├── chat_members_filter.py │ ├── chat_type.py │ ├── client_platform.py │ ├── folder_color.py │ ├── gift_attribute_type.py │ ├── gift_for_resale_order.py │ ├── media_area_type.py │ ├── message_entity_type.py │ ├── message_media_type.py │ ├── message_origin_type.py │ ├── message_service_type.py │ ├── messages_filter.py │ ├── next_code_type.py │ ├── paid_reaction_privacy.py │ ├── parse_mode.py │ ├── phone_call_discard_reason.py │ ├── poll_type.py │ ├── privacy_key.py │ ├── privacy_rule_type.py │ ├── profile_color.py │ ├── reply_color.py │ ├── sent_code_type.py │ ├── stories_privacy_rules.py │ └── user_status.py ├── errors │ ├── __init__.py │ └── rpc_error.py ├── file_id.py ├── filters.py ├── handlers │ ├── __init__.py │ ├── business_connection_handler.py │ ├── business_message_handler.py │ ├── callback_query_handler.py │ ├── chat_boost_handler.py │ ├── chat_join_request_handler.py │ ├── chat_member_updated_handler.py │ ├── chosen_inline_result_handler.py │ ├── connect_handler.py │ ├── deleted_business_messages_handler.py │ ├── deleted_messages_handler.py │ ├── disconnect_handler.py │ ├── edited_business_message_handler.py │ ├── edited_message_handler.py │ ├── handler.py │ ├── inline_query_handler.py │ ├── message_handler.py │ ├── message_reaction_count_handler.py │ ├── message_reaction_handler.py │ ├── poll_handler.py │ ├── pre_checkout_query_handler.py │ ├── purchased_paid_media_handler.py │ ├── raw_update_handler.py │ ├── shipping_query_handler.py │ ├── start_handler.py │ ├── stop_handler.py │ ├── story_handler.py │ └── user_status_handler.py ├── methods │ ├── __init__.py │ ├── account │ │ ├── __init__.py │ │ ├── get_account_ttl.py │ │ ├── get_global_privacy_settings.py │ │ ├── get_privacy.py │ │ ├── set_account_ttl.py │ │ ├── set_global_privacy_settings.py │ │ └── set_privacy.py │ ├── advanced │ │ ├── __init__.py │ │ ├── invoke.py │ │ ├── resolve_peer.py │ │ └── save_file.py │ ├── auth │ │ ├── __init__.py │ │ ├── accept_terms_of_service.py │ │ ├── check_password.py │ │ ├── connect.py │ │ ├── disconnect.py │ │ ├── get_active_sessions.py │ │ ├── get_password_hint.py │ │ ├── initialize.py │ │ ├── log_out.py │ │ ├── recover_password.py │ │ ├── resend_code.py │ │ ├── reset_session.py │ │ ├── reset_sessions.py │ │ ├── send_code.py │ │ ├── send_recovery_code.py │ │ ├── sign_in.py │ │ ├── sign_in_bot.py │ │ ├── sign_up.py │ │ └── terminate.py │ ├── bots │ │ ├── __init__.py │ │ ├── answer_callback_query.py │ │ ├── answer_inline_query.py │ │ ├── answer_pre_checkout_query.py │ │ ├── answer_shipping_query.py │ │ ├── answer_web_app_query.py │ │ ├── create_invoice_link.py │ │ ├── delete_bot_commands.py │ │ ├── get_bot_commands.py │ │ ├── get_bot_default_privileges.py │ │ ├── get_bot_info_description.py │ │ ├── get_bot_info_short_description.py │ │ ├── get_bot_name.py │ │ ├── get_chat_menu_button.py │ │ ├── get_game_high_scores.py │ │ ├── get_inline_bot_results.py │ │ ├── get_owned_bots.py │ │ ├── refund_star_payment.py │ │ ├── request_callback_answer.py │ │ ├── send_game.py │ │ ├── send_inline_bot_result.py │ │ ├── send_invoice.py │ │ ├── set_bot_commands.py │ │ ├── set_bot_default_privileges.py │ │ ├── set_bot_info_description.py │ │ ├── set_bot_info_short_description.py │ │ ├── set_bot_name.py │ │ ├── set_chat_menu_button.py │ │ └── set_game_score.py │ ├── business │ │ ├── __init__.py │ │ ├── delete_business_messages.py │ │ ├── get_business_account_gifts.py │ │ ├── get_business_account_star_balance.py │ │ ├── get_business_connection.py │ │ └── transfer_business_account_stars.py │ ├── chats │ │ ├── __init__.py │ │ ├── add_chat_members.py │ │ ├── archive_chats.py │ │ ├── ban_chat_member.py │ │ ├── close_forum_topic.py │ │ ├── create_channel.py │ │ ├── create_folder.py │ │ ├── create_forum_topic.py │ │ ├── create_group.py │ │ ├── create_supergroup.py │ │ ├── delete_channel.py │ │ ├── delete_chat_photo.py │ │ ├── delete_folder.py │ │ ├── delete_forum_topic.py │ │ ├── delete_supergroup.py │ │ ├── delete_user_history.py │ │ ├── edit_folder.py │ │ ├── edit_forum_topic.py │ │ ├── export_folder_link.py │ │ ├── get_chat.py │ │ ├── get_chat_event_log.py │ │ ├── get_chat_member.py │ │ ├── get_chat_members.py │ │ ├── get_chat_members_count.py │ │ ├── get_chat_online_count.py │ │ ├── get_chat_settings.py │ │ ├── get_dialogs.py │ │ ├── get_dialogs_count.py │ │ ├── get_folders.py │ │ ├── get_forum_topics.py │ │ ├── get_forum_topics_by_id.py │ │ ├── get_personal_channels.py │ │ ├── get_send_as_chats.py │ │ ├── get_similar_channels.py │ │ ├── get_suitable_discussion_chats.py │ │ ├── join_chat.py │ │ ├── join_folder.py │ │ ├── leave_chat.py │ │ ├── leave_folder.py │ │ ├── mark_chat_unread.py │ │ ├── pin_chat_message.py │ │ ├── pin_forum_topic.py │ │ ├── promote_chat_member.py │ │ ├── reorder_folders.py │ │ ├── restrict_chat_member.py │ │ ├── set_administrator_title.py │ │ ├── set_chat_description.py │ │ ├── set_chat_discussion_group.py │ │ ├── set_chat_permissions.py │ │ ├── set_chat_photo.py │ │ ├── set_chat_protected_content.py │ │ ├── set_chat_title.py │ │ ├── set_chat_ttl.py │ │ ├── set_chat_username.py │ │ ├── set_send_as_chat.py │ │ ├── set_slow_mode.py │ │ ├── toggle_folder_tags.py │ │ ├── toggle_forum_topics.py │ │ ├── toggle_join_to_send.py │ │ ├── transfer_chat_ownership.py │ │ ├── unarchive_chats.py │ │ ├── unban_chat_member.py │ │ ├── unpin_all_chat_messages.py │ │ ├── unpin_chat_message.py │ │ ├── unpin_forum_topic.py │ │ ├── update_chat_notifications.py │ │ └── update_color.py │ ├── contacts │ │ ├── __init__.py │ │ ├── add_contact.py │ │ ├── delete_contacts.py │ │ ├── get_contacts.py │ │ ├── get_contacts_count.py │ │ ├── import_contacts.py │ │ └── search_contacts.py │ ├── decorators │ │ ├── __init__.py │ │ ├── on_business_connection.py │ │ ├── on_business_message.py │ │ ├── on_callback_query.py │ │ ├── on_chat_boost.py │ │ ├── on_chat_join_request.py │ │ ├── on_chat_member_updated.py │ │ ├── on_chosen_inline_result.py │ │ ├── on_connect.py │ │ ├── on_deleted_business_messages.py │ │ ├── on_deleted_messages.py │ │ ├── on_disconnect.py │ │ ├── on_edited_business_message.py │ │ ├── on_edited_message.py │ │ ├── on_inline_query.py │ │ ├── on_message.py │ │ ├── on_message_reaction.py │ │ ├── on_message_reaction_count.py │ │ ├── on_poll.py │ │ ├── on_pre_checkout_query.py │ │ ├── on_purchased_paid_media.py │ │ ├── on_raw_update.py │ │ ├── on_shipping_query.py │ │ ├── on_start.py │ │ ├── on_stop.py │ │ ├── on_story.py │ │ └── on_user_status.py │ ├── invite_links │ │ ├── __init__.py │ │ ├── approve_all_chat_join_requests.py │ │ ├── approve_chat_join_request.py │ │ ├── create_chat_invite_link.py │ │ ├── decline_all_chat_join_requests.py │ │ ├── decline_chat_join_request.py │ │ ├── delete_chat_admin_invite_links.py │ │ ├── delete_chat_invite_link.py │ │ ├── edit_chat_invite_link.py │ │ ├── export_chat_invite_link.py │ │ ├── get_chat_admin_invite_links.py │ │ ├── get_chat_admin_invite_links_count.py │ │ ├── get_chat_admins_with_invite_links.py │ │ ├── get_chat_invite_link.py │ │ ├── get_chat_invite_link_joiners.py │ │ ├── get_chat_invite_link_joiners_count.py │ │ ├── get_chat_join_requests.py │ │ └── revoke_chat_invite_link.py │ ├── messages │ │ ├── __init__.py │ │ ├── add_to_gifs.py │ │ ├── business_session.py │ │ ├── copy_media_group.py │ │ ├── copy_message.py │ │ ├── delete_chat_history.py │ │ ├── delete_messages.py │ │ ├── download_media.py │ │ ├── edit_inline_caption.py │ │ ├── edit_inline_media.py │ │ ├── edit_inline_reply_markup.py │ │ ├── edit_inline_text.py │ │ ├── edit_message_caption.py │ │ ├── edit_message_media.py │ │ ├── edit_message_reply_markup.py │ │ ├── edit_message_text.py │ │ ├── forward_media_group.py │ │ ├── forward_messages.py │ │ ├── get_available_effects.py │ │ ├── get_chat_history.py │ │ ├── get_chat_history_count.py │ │ ├── get_custom_emoji_stickers.py │ │ ├── get_discussion_message.py │ │ ├── get_discussion_replies.py │ │ ├── get_discussion_replies_count.py │ │ ├── get_media_group.py │ │ ├── get_messages.py │ │ ├── get_scheduled_messages.py │ │ ├── get_stickers.py │ │ ├── inline_session.py │ │ ├── read_chat_history.py │ │ ├── read_mentions.py │ │ ├── read_reactions.py │ │ ├── retract_vote.py │ │ ├── search_global.py │ │ ├── search_global_count.py │ │ ├── search_messages.py │ │ ├── search_messages_count.py │ │ ├── search_posts.py │ │ ├── search_posts_count.py │ │ ├── send_animation.py │ │ ├── send_audio.py │ │ ├── send_cached_media.py │ │ ├── send_chat_action.py │ │ ├── send_contact.py │ │ ├── send_dice.py │ │ ├── send_document.py │ │ ├── send_location.py │ │ ├── send_media_group.py │ │ ├── send_message.py │ │ ├── send_paid_media.py │ │ ├── send_paid_reaction.py │ │ ├── send_photo.py │ │ ├── send_poll.py │ │ ├── send_reaction.py │ │ ├── send_screenshot_notification.py │ │ ├── send_sticker.py │ │ ├── send_venue.py │ │ ├── send_video.py │ │ ├── send_video_note.py │ │ ├── send_voice.py │ │ ├── send_web_page.py │ │ ├── start_bot.py │ │ ├── stop_poll.py │ │ ├── stream_media.py │ │ ├── view_messages.py │ │ └── vote_poll.py │ ├── password │ │ ├── __init__.py │ │ ├── change_cloud_password.py │ │ ├── enable_cloud_password.py │ │ └── remove_cloud_password.py │ ├── payments │ │ ├── __init__.py │ │ ├── apply_gift_code.py │ │ ├── check_gift_code.py │ │ ├── convert_gift_to_stars.py │ │ ├── get_available_gifts.py │ │ ├── get_chat_gifts.py │ │ ├── get_chat_gifts_count.py │ │ ├── get_gift_upgrade_preview.py │ │ ├── get_payment_form.py │ │ ├── get_stars_balance.py │ │ ├── get_upgraded_gift.py │ │ ├── hide_gift.py │ │ ├── search_gifts_for_resale.py │ │ ├── send_gift.py │ │ ├── send_payment_form.py │ │ ├── send_resold_gift.py │ │ ├── set_gift_resale_price.py │ │ ├── set_pinned_gifts.py │ │ ├── show_gift.py │ │ ├── transfer_gift.py │ │ └── upgrade_gift.py │ ├── phone │ │ ├── __init__.py │ │ └── get_call_members.py │ ├── premium │ │ ├── __init__.py │ │ ├── apply_boost.py │ │ ├── get_boosts.py │ │ └── get_boosts_status.py │ ├── stories │ │ ├── __init__.py │ │ ├── can_post_stories.py │ │ ├── copy_story.py │ │ ├── delete_stories.py │ │ ├── edit_story_caption.py │ │ ├── edit_story_media.py │ │ ├── edit_story_privacy.py │ │ ├── enable_stealth_mode.py │ │ ├── forward_story.py │ │ ├── get_all_stories.py │ │ ├── get_archived_stories.py │ │ ├── get_chat_stories.py │ │ ├── get_pinned_stories.py │ │ ├── get_stories.py │ │ ├── get_story_views.py │ │ ├── hide_chat_stories.py │ │ ├── pin_chat_stories.py │ │ ├── read_chat_stories.py │ │ ├── send_story.py │ │ ├── show_chat_stories.py │ │ ├── unpin_chat_stories.py │ │ └── view_stories.py │ ├── users │ │ ├── __init__.py │ │ ├── block_user.py │ │ ├── check_username.py │ │ ├── delete_profile_photos.py │ │ ├── get_chat_photos.py │ │ ├── get_chat_photos_count.py │ │ ├── get_common_chats.py │ │ ├── get_default_emoji_statuses.py │ │ ├── get_me.py │ │ ├── get_users.py │ │ ├── set_emoji_status.py │ │ ├── set_personal_channel.py │ │ ├── set_profile_photo.py │ │ ├── set_username.py │ │ ├── unblock_user.py │ │ ├── update_birthday.py │ │ ├── update_profile.py │ │ └── update_status.py │ └── utilities │ │ ├── __init__.py │ │ ├── add_handler.py │ │ ├── compose.py │ │ ├── export_session_string.py │ │ ├── idle.py │ │ ├── remove_handler.py │ │ ├── restart.py │ │ ├── run.py │ │ ├── start.py │ │ ├── stop.py │ │ └── stop_transmission.py ├── mime_types.py ├── parser │ ├── __init__.py │ ├── html.py │ ├── markdown.py │ ├── parser.py │ └── utils.py ├── py.typed ├── qrlogin.py ├── raw │ ├── __init__.py │ └── core │ │ ├── __init__.py │ │ ├── future_salt.py │ │ ├── future_salts.py │ │ ├── gzip_packed.py │ │ ├── list.py │ │ ├── message.py │ │ ├── msg_container.py │ │ ├── primitives │ │ ├── __init__.py │ │ ├── bool.py │ │ ├── bytes.py │ │ ├── double.py │ │ ├── int.py │ │ ├── string.py │ │ └── vector.py │ │ └── tl_object.py ├── session │ ├── __init__.py │ ├── auth.py │ ├── internals │ │ ├── __init__.py │ │ ├── data_center.py │ │ ├── msg_factory.py │ │ ├── msg_id.py │ │ └── seq_no.py │ └── session.py ├── storage │ ├── __init__.py │ ├── file_storage.py │ ├── memory_storage.py │ ├── sqlite_storage.py │ └── storage.py ├── sync.py ├── types │ ├── __init__.py │ ├── authorization │ │ ├── __init__.py │ │ ├── active_session.py │ │ ├── active_sessions.py │ │ ├── sent_code.py │ │ └── terms_of_service.py │ ├── bots_and_keyboards │ │ ├── __init__.py │ │ ├── bot_command.py │ │ ├── bot_command_scope.py │ │ ├── bot_command_scope_all_chat_administrators.py │ │ ├── bot_command_scope_all_group_chats.py │ │ ├── bot_command_scope_all_private_chats.py │ │ ├── bot_command_scope_chat.py │ │ ├── bot_command_scope_chat_administrators.py │ │ ├── bot_command_scope_chat_member.py │ │ ├── bot_command_scope_default.py │ │ ├── callback_game.py │ │ ├── callback_query.py │ │ ├── chat_boost_updated.py │ │ ├── chat_shared.py │ │ ├── force_reply.py │ │ ├── game_high_score.py │ │ ├── inline_keyboard_button.py │ │ ├── inline_keyboard_markup.py │ │ ├── keyboard_button.py │ │ ├── keyboard_button_poll_type.py │ │ ├── keyboard_button_request_chat.py │ │ ├── keyboard_button_request_users.py │ │ ├── labeled_price.py │ │ ├── login_url.py │ │ ├── menu_button.py │ │ ├── menu_button_commands.py │ │ ├── menu_button_default.py │ │ ├── menu_button_web_app.py │ │ ├── message_reaction_count_updated.py │ │ ├── message_reaction_updated.py │ │ ├── order_info.py │ │ ├── pre_checkout_query.py │ │ ├── purchased_paid_media.py │ │ ├── reply_keyboard_markup.py │ │ ├── reply_keyboard_remove.py │ │ ├── sent_web_app_message.py │ │ ├── shipping_address.py │ │ ├── shipping_option.py │ │ ├── shipping_query.py │ │ ├── users_shared.py │ │ └── web_app_info.py │ ├── inline_mode │ │ ├── __init__.py │ │ ├── chosen_inline_result.py │ │ ├── inline_query.py │ │ ├── inline_query_result.py │ │ ├── inline_query_result_animation.py │ │ ├── inline_query_result_article.py │ │ ├── inline_query_result_audio.py │ │ ├── inline_query_result_cached_animation.py │ │ ├── inline_query_result_cached_audio.py │ │ ├── inline_query_result_cached_document.py │ │ ├── inline_query_result_cached_photo.py │ │ ├── inline_query_result_cached_sticker.py │ │ ├── inline_query_result_cached_video.py │ │ ├── inline_query_result_cached_voice.py │ │ ├── inline_query_result_contact.py │ │ ├── inline_query_result_document.py │ │ ├── inline_query_result_location.py │ │ ├── inline_query_result_photo.py │ │ ├── inline_query_result_venue.py │ │ ├── inline_query_result_video.py │ │ └── inline_query_result_voice.py │ ├── input_media │ │ ├── __init__.py │ │ ├── input_media.py │ │ ├── input_media_animation.py │ │ ├── input_media_audio.py │ │ ├── input_media_document.py │ │ ├── input_media_photo.py │ │ ├── input_media_video.py │ │ └── input_phone_contact.py │ ├── input_message_content │ │ ├── __init__.py │ │ ├── input_contact_message_content.py │ │ ├── input_invoice_message_content.py │ │ ├── input_location_message_content.py │ │ ├── input_message_content.py │ │ ├── input_text_message_content.py │ │ └── input_venue_message_content.py │ ├── input_privacy_rule │ │ ├── __init__.py │ │ ├── input_privacy_rule.py │ │ ├── input_privacy_rule_allow_all.py │ │ ├── input_privacy_rule_allow_bots.py │ │ ├── input_privacy_rule_allow_chats.py │ │ ├── input_privacy_rule_allow_close_friends.py │ │ ├── input_privacy_rule_allow_contacts.py │ │ ├── input_privacy_rule_allow_premium.py │ │ ├── input_privacy_rule_allow_users.py │ │ ├── input_privacy_rule_disallow_all.py │ │ ├── input_privacy_rule_disallow_bots.py │ │ ├── input_privacy_rule_disallow_chats.py │ │ ├── input_privacy_rule_disallow_contacts.py │ │ └── input_privacy_rule_disallow_users.py │ ├── list.py │ ├── messages_and_media │ │ ├── __init__.py │ │ ├── animation.py │ │ ├── audio.py │ │ ├── available_effect.py │ │ ├── boosts_status.py │ │ ├── business_message.py │ │ ├── chat_background.py │ │ ├── chat_boost.py │ │ ├── chat_theme.py │ │ ├── checked_gift_code.py │ │ ├── contact.py │ │ ├── contact_registered.py │ │ ├── dice.py │ │ ├── document.py │ │ ├── external_reply_info.py │ │ ├── fact_check.py │ │ ├── forum_topic.py │ │ ├── forum_topic_closed.py │ │ ├── forum_topic_created.py │ │ ├── forum_topic_edited.py │ │ ├── forum_topic_reopened.py │ │ ├── game.py │ │ ├── general_forum_topic_hidden.py │ │ ├── general_forum_topic_unhidden.py │ │ ├── gift.py │ │ ├── gift_attribute.py │ │ ├── gift_code.py │ │ ├── gift_upgrade_preview.py │ │ ├── gifted_premium.py │ │ ├── gifted_stars.py │ │ ├── giveaway.py │ │ ├── giveaway_completed.py │ │ ├── giveaway_created.py │ │ ├── giveaway_prize_stars.py │ │ ├── giveaway_winners.py │ │ ├── invoice.py │ │ ├── link_preview_options.py │ │ ├── location.py │ │ ├── media_area.py │ │ ├── message.py │ │ ├── message_entity.py │ │ ├── message_origin.py │ │ ├── message_origin_channel.py │ │ ├── message_origin_chat.py │ │ ├── message_origin_hidden_user.py │ │ ├── message_origin_import.py │ │ ├── message_origin_user.py │ │ ├── message_reactions.py │ │ ├── my_boost.py │ │ ├── paid_media_info.py │ │ ├── paid_media_preview.py │ │ ├── paid_messages_price_changed.py │ │ ├── paid_messages_refunded.py │ │ ├── payment_form.py │ │ ├── photo.py │ │ ├── poll.py │ │ ├── poll_option.py │ │ ├── proximity_alert_triggered.py │ │ ├── reaction.py │ │ ├── refunded_payment.py │ │ ├── reply_parameters.py │ │ ├── restriction_reason.py │ │ ├── screenshot_taken.py │ │ ├── sticker.py │ │ ├── story.py │ │ ├── story_view.py │ │ ├── stripped_thumbnail.py │ │ ├── successful_payment.py │ │ ├── text_quote.py │ │ ├── thumbnail.py │ │ ├── upgraded_gift_attribute_id.py │ │ ├── upgraded_gift_attribute_id_backdrop.py │ │ ├── upgraded_gift_attribute_id_model.py │ │ ├── upgraded_gift_attribute_id_symbol.py │ │ ├── venue.py │ │ ├── video.py │ │ ├── video_note.py │ │ ├── voice.py │ │ ├── web_app_data.py │ │ ├── web_page.py │ │ └── write_access_allowed.py │ ├── object.py │ ├── update.py │ └── user_and_chats │ │ ├── __init__.py │ │ ├── accepted_gift_types.py │ │ ├── birthday.py │ │ ├── bot_verification.py │ │ ├── business_bot_rights.py │ │ ├── business_connection.py │ │ ├── business_intro.py │ │ ├── business_recipients.py │ │ ├── business_weekly_open.py │ │ ├── business_working_hours.py │ │ ├── chat.py │ │ ├── chat_admin_with_invite_links.py │ │ ├── chat_color.py │ │ ├── chat_event.py │ │ ├── chat_event_filter.py │ │ ├── chat_invite_link.py │ │ ├── chat_join_request.py │ │ ├── chat_joiner.py │ │ ├── chat_member.py │ │ ├── chat_member_updated.py │ │ ├── chat_permissions.py │ │ ├── chat_photo.py │ │ ├── chat_privileges.py │ │ ├── chat_reactions.py │ │ ├── chat_settings.py │ │ ├── dialog.py │ │ ├── emoji_status.py │ │ ├── folder.py │ │ ├── found_contacts.py │ │ ├── global_privacy_settings.py │ │ ├── group_call_member.py │ │ ├── history_cleared.py │ │ ├── invite_link_importer.py │ │ ├── phone_call_ended.py │ │ ├── phone_call_started.py │ │ ├── privacy_rule.py │ │ ├── restriction.py │ │ ├── stories_stealth_mode.py │ │ ├── user.py │ │ ├── username.py │ │ ├── video_chat_ended.py │ │ ├── video_chat_members_invited.py │ │ ├── video_chat_scheduled.py │ │ └── video_chat_started.py └── utils.py └── tests ├── __init__.py ├── filters ├── __init__.py └── test_command.py ├── parser ├── __init__.py ├── test_html.py └── test_markdown.py └── test_file_id.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: delivrance 2 | liberapay: delivrance 3 | open_collective: pyrogram 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Ask Pyrogram related questions 4 | url: https://stackoverflow.com/questions/tagged/pyrogram 5 | about: This place is only for reporting issues about Pyrogram. You can ask questions at StackOverflow. 6 | - name: Join the Telegram channel 7 | url: https://t.me/pyrogram 8 | about: Join the official channel and stay tuned for news, updates and announcements. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest ideas, new features or enhancements 3 | labels: [enhancement] 4 | body: 5 | - type: checkboxes 6 | attributes: 7 | label: Checklist 8 | options: 9 | - label: I believe the idea is awesome and would benefit the framework 10 | required: true 11 | - label: I have searched in the issue tracker for similar requests, including closed ones 12 | required: true 13 | 14 | - type: textarea 15 | attributes: 16 | label: Description 17 | description: Provide a detailed description of the request 18 | placeholder: Description... 19 | validations: 20 | required: true -------------------------------------------------------------------------------- /.github/workflows/github_release.yml: -------------------------------------------------------------------------------- 1 | name: Upload release to GitHub 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | workflow_dispatch: {} 8 | 9 | permissions: write-all 10 | 11 | jobs: 12 | build-n-publish: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout source 17 | uses: actions/checkout@v4 18 | 19 | - name: Set up Python 20 | uses: actions/setup-python@v5 21 | with: 22 | python-version: "3.x" 23 | 24 | - name: Install dependencies 25 | run: | 26 | python -m pip install --upgrade pip 27 | pip install -e .[dev] 28 | 29 | - name: Build package 30 | run: hatch build 31 | 32 | - name: Get package version 33 | run: | 34 | echo "CURRENT_LIB_VERSION=v$(hatch version)" >> $GITHUB_ENV 35 | 36 | - name: Create and upload release 37 | id: upload-release-asset 38 | uses: softprops/action-gh-release@v2 39 | with: 40 | tag_name: ${{ env.CURRENT_LIB_VERSION }} 41 | name: ${{ env.CURRENT_LIB_VERSION }} 42 | generate_release_notes: true 43 | make_latest: true 44 | draft: false 45 | prerelease: false 46 | files: dist/* 47 | -------------------------------------------------------------------------------- /.github/workflows/pypi_release.yml: -------------------------------------------------------------------------------- 1 | name: Upload release to PyPI 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | workflow_dispatch: {} 8 | 9 | permissions: write-all 10 | 11 | jobs: 12 | build-n-publish: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout source 17 | uses: actions/checkout@v4 18 | 19 | - name: Set up Python 20 | uses: actions/setup-python@v5 21 | with: 22 | python-version: "3.x" 23 | 24 | - name: Install dependencies 25 | run: | 26 | python -m pip install --upgrade pip 27 | pip install -e .[dev] 28 | 29 | - name: Build package 30 | run: hatch build 31 | 32 | - name: Publish package 33 | uses: pypa/gh-action-pypi-publish@release/v1 34 | with: 35 | user: __token__ 36 | password: ${{ secrets.PYPI_API_TOKEN }} 37 | -------------------------------------------------------------------------------- /.github/workflows/python.yml: -------------------------------------------------------------------------------- 1 | name: Pyrogram 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | matrix: 11 | os: [ubuntu-latest, macos-latest] 12 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | 17 | - name: Set up Python ${{ matrix.python-version }} 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: ${{ matrix.python-version }} 21 | 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | pip install tox 26 | 27 | - name: Generate API 28 | run: | 29 | make venv 30 | make api 31 | 32 | - name: Run tests 33 | run: | 34 | tox 35 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | # Include files 2 | include README.md COPYING COPYING.lesser NOTICE requirements.txt 3 | recursive-include compiler *.py *.tl *.tsv *.txt 4 | recursive-include tests *.py 5 | 6 | # Exclude files 7 | exclude pyrogram/raw/all.py 8 | 9 | # Prune directories 10 | prune pyrogram/errors/exceptions 11 | prune pyrogram/raw/functions 12 | prune pyrogram/raw/types 13 | prune pyrogram/raw/base 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VENV := venv 2 | PYTHON := $(VENV)/bin/python 3 | TAG = v$(shell grep -E '__version__ = ".*"' pyrogram/__init__.py | cut -d\" -f2) 4 | 5 | RM := rm -rf 6 | 7 | .PHONY: venv clean-build clean-api clean-docs clean api docs build tag dtag 8 | 9 | venv: 10 | python3 -m venv $(VENV) 11 | $(PYTHON) -m pip install -U pip wheel setuptools 12 | $(PYTHON) -m pip install -U -e .[docs] 13 | @echo "Created venv with $$($(PYTHON) --version)" 14 | 15 | clean-venv: 16 | $(RM) $(VENV) 17 | @echo "Cleaned venv directory" 18 | 19 | clean-build: 20 | $(RM) *.egg-info build dist 21 | @echo "Cleaned build directory" 22 | 23 | clean-api: 24 | $(RM) pyrogram/errors/exceptions pyrogram/raw/all.py pyrogram/raw/base pyrogram/raw/functions pyrogram/raw/types 25 | @echo "Cleaned api directory" 26 | 27 | clean-docs: 28 | $(RM) docs/build docs/source/api/bound-methods docs/source/api/methods docs/source/api/types docs/source/api/enums docs/source/telegram 29 | @echo "Cleaned docs directory" 30 | 31 | clean: clean-venv clean-build clean-api clean-docs 32 | @echo "Cleaned all directories" 33 | 34 | api: 35 | cd compiler/api && ../../$(PYTHON) compiler.py 36 | cd compiler/errors && ../../$(PYTHON) compiler.py 37 | 38 | docs: 39 | cd compiler/docs && ../../$(PYTHON) compiler.py 40 | $(VENV)/bin/sphinx-build -b dirhtml "docs/source" "docs/build/html" -j auto 41 | cd docs/build/html && zip -r ../docs.zip ./ 42 | 43 | build: 44 | hatch build 45 | 46 | tag: 47 | git tag $(TAG) 48 | git push origin $(TAG) 49 | 50 | dtag: 51 | git tag -d $(TAG) 52 | git push origin -d $(TAG) 53 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Pyrogram - Telegram MTProto API Client Library for Python 2 | Copyright (C) 2017-present Dan 3 | 4 | This file is part of Pyrogram. 5 | 6 | Pyrogram is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published 8 | by the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Pyrogram is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with Pyrogram. If not, see . -------------------------------------------------------------------------------- /compiler/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | -------------------------------------------------------------------------------- /compiler/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | -------------------------------------------------------------------------------- /compiler/api/template/combinator.txt: -------------------------------------------------------------------------------- 1 | {notice} 2 | 3 | from io import BytesIO 4 | 5 | from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector 6 | from pyrogram.raw.core import TLObject 7 | from pyrogram import raw 8 | from typing import List, Optional, Any 9 | 10 | {warning} 11 | 12 | 13 | class {name}(TLObject): # type: ignore 14 | """{docstring} 15 | """ 16 | 17 | __slots__: List[str] = [{slots}] 18 | 19 | ID = {id} 20 | QUALNAME = "{qualname}" 21 | 22 | def __init__(self{arguments}) -> None: 23 | {fields} 24 | 25 | @staticmethod 26 | def read(b: BytesIO, *args: Any) -> "{name}": 27 | {read_types} 28 | return {name}({return_arguments}) 29 | 30 | def write(self, *args) -> bytes: 31 | b = BytesIO() 32 | b.write(Int(self.ID, False)) 33 | 34 | {write_types} 35 | return b.getvalue() 36 | -------------------------------------------------------------------------------- /compiler/api/template/type.txt: -------------------------------------------------------------------------------- 1 | {notice} 2 | 3 | {warning} 4 | 5 | from typing import Union 6 | from pyrogram import raw 7 | from pyrogram.raw.core import TLObject 8 | 9 | # We need to dynamically set `__doc__` due to `sphinx` 10 | {name} = Union[{types}] 11 | {name}.__doc__ = """ 12 | {docstring} 13 | """ 14 | -------------------------------------------------------------------------------- /compiler/docs/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | -------------------------------------------------------------------------------- /compiler/docs/template/enums.rst: -------------------------------------------------------------------------------- 1 | Enumerations 2 | ============ 3 | 4 | This page is about Pyrogram enumerations. 5 | Enumerations are types that hold a group of related values to be used whenever a constant value is required. 6 | They will help you deal with those values in a type-safe way and also enable code completion so that you can be sure 7 | to apply only a valid value among the expected ones. 8 | 9 | ----- 10 | 11 | .. currentmodule:: pyrogram.enums 12 | 13 | .. autosummary:: 14 | :nosignatures: 15 | 16 | {enums_hlist} 17 | 18 | .. toctree:: 19 | :hidden: 20 | 21 | {enums_toctree} 22 | -------------------------------------------------------------------------------- /compiler/docs/template/page.txt: -------------------------------------------------------------------------------- 1 | {title} 2 | {title_markup} 3 | 4 | .. {directive_type}:: {full_class_path}{directive_suffix} 5 | :{directive_option}: 6 | -------------------------------------------------------------------------------- /compiler/docs/template/toctree.txt: -------------------------------------------------------------------------------- 1 | {title} 2 | {title_markup} 3 | 4 | .. module:: {module} 5 | 6 | .. toctree:: 7 | :titlesonly: 8 | 9 | {entities} -------------------------------------------------------------------------------- /compiler/errors/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | -------------------------------------------------------------------------------- /compiler/errors/sort.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import csv 20 | from pathlib import Path 21 | 22 | for p in Path("source").glob("*.tsv"): 23 | with open(p) as f: 24 | reader = csv.reader(f, delimiter="\t") 25 | dct = {k: v for k, v in reader if k != "id"} 26 | keys = sorted(dct) 27 | 28 | with open(p, "w") as f: 29 | f.write("id\tmessage\n") 30 | 31 | for i, item in enumerate(keys, start=1): 32 | f.write(f"{item}\t{dct[item]}") 33 | 34 | if i != len(keys): 35 | f.write("\n") 36 | -------------------------------------------------------------------------------- /compiler/errors/source/303_SEE_OTHER.tsv: -------------------------------------------------------------------------------- 1 | id message 2 | FILE_MIGRATE_X The file to be accessed is currently stored in DC{value} 3 | NETWORK_MIGRATE_X The source IP address is associated with DC{value} (for registration) 4 | PHONE_MIGRATE_X The phone number a user is trying to use for authorization is associated with DC{value} 5 | STATS_MIGRATE_X The statistics of the group/channel are stored in DC{value} 6 | USER_MIGRATE_X The user whose identity is being used to execute queries is associated with DC{value} (for registration) -------------------------------------------------------------------------------- /compiler/errors/source/401_UNAUTHORIZED.tsv: -------------------------------------------------------------------------------- 1 | id message 2 | ACTIVE_USER_REQUIRED The method is only available to already activated users 3 | AUTH_KEY_INVALID The key is invalid 4 | AUTH_KEY_PERM_EMPTY The method is unavailable for temporary authorization key, not bound to permanent 5 | AUTH_KEY_UNREGISTERED The key is not registered in the system. Delete your session file and login again 6 | SESSION_EXPIRED The authorization has expired 7 | SESSION_PASSWORD_NEEDED The two-step verification is enabled and a password is required 8 | SESSION_REVOKED The authorization has been invalidated, because of the user terminating all sessions 9 | USER_DEACTIVATED The user has been deleted/deactivated 10 | USER_DEACTIVATED_BAN The user has been deleted/deactivated -------------------------------------------------------------------------------- /compiler/errors/source/420_FLOOD.tsv: -------------------------------------------------------------------------------- 1 | id message 2 | 2FA_CONFIRM_WAIT_X A wait of {value} seconds is required because this account is active and protected by a 2FA password 3 | ADDRESS_INVALID The specified geopoint address is invalid. 4 | FLOOD_PREMIUM_WAIT_X A wait of {value} seconds is required 5 | FLOOD_TEST_PHONE_WAIT_X A wait of {value} seconds is required in the test servers 6 | FLOOD_WAIT_X A wait of {value} seconds is required 7 | FROZEN_METHOD_INVALID The method can't be used by frozen account. You can appeal via @SpamBot if you believe this was a mistake. 8 | PREMIUM_SUB_ACTIVE_UNTIL_X A wait of {value} seconds is required 9 | SLOWMODE_WAIT_X A wait of {value} seconds is required to send messages in this chat 10 | STORY_SEND_FLOOD_X A wait of {value} seconds is required to continue posting stories 11 | TAKEOUT_INIT_DELAY_X You have to confirm the data export request using one of your mobile devices or wait {value} seconds -------------------------------------------------------------------------------- /compiler/errors/source/503_SERVICE_UNAVAILABLE.tsv: -------------------------------------------------------------------------------- 1 | id message 2 | ApiCallError Telegram is having internal problems. Please try again later. 3 | Timedout Telegram is having internal problems. Please try again later. 4 | Timeout Telegram is having internal problems. Please try again later. -------------------------------------------------------------------------------- /compiler/errors/template/class.txt: -------------------------------------------------------------------------------- 1 | {notice} 2 | 3 | from ..rpc_error import RPCError 4 | 5 | 6 | class {super_class}(RPCError): 7 | {docstring} 8 | CODE = {code} 9 | """``int``: RPC Error Code""" 10 | NAME = __doc__ 11 | 12 | 13 | {sub_classes} -------------------------------------------------------------------------------- /compiler/errors/template/sub_class.txt: -------------------------------------------------------------------------------- 1 | class {sub_class}({super_class}): 2 | {docstring} 3 | ID = {id} 4 | """``str``: RPC Error ID""" 5 | MESSAGE = __doc__ 6 | 7 | 8 | -------------------------------------------------------------------------------- /hatch_build.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import sys 20 | 21 | from hatchling.builders.hooks.plugin.interface import BuildHookInterface 22 | 23 | sys.path.insert(0, ".") 24 | 25 | 26 | class CustomHook(BuildHookInterface): 27 | def initialize(self, version, build_data): 28 | if self.target_name not in ["wheel", "install"]: 29 | return 30 | 31 | from compiler.api.compiler import start as compile_api 32 | from compiler.errors.compiler import start as compile_errors 33 | 34 | compile_api(format=False) 35 | compile_errors() 36 | -------------------------------------------------------------------------------- /pyrogram/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | __version__ = "2.2.4" 20 | __license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)" 21 | __copyright__ = "Copyright (C) 2017-present Dan " 22 | 23 | from concurrent.futures.thread import ThreadPoolExecutor 24 | 25 | 26 | class StopTransmission(Exception): 27 | pass 28 | 29 | 30 | class StopPropagation(StopAsyncIteration): 31 | pass 32 | 33 | 34 | class ContinuePropagation(StopAsyncIteration): 35 | pass 36 | 37 | 38 | from . import raw, types, filters, handlers, enums 39 | from .client import Client 40 | from .sync import idle, compose 41 | 42 | crypto_executor = ThreadPoolExecutor(1, thread_name_prefix="CryptoWorker") 43 | -------------------------------------------------------------------------------- /pyrogram/connection/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .connection import Connection 20 | -------------------------------------------------------------------------------- /pyrogram/connection/transport/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .tcp import * 20 | -------------------------------------------------------------------------------- /pyrogram/connection/transport/tcp/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .tcp import TCP, Proxy 20 | from .tcp_abridged import TCPAbridged 21 | from .tcp_abridged_o import TCPAbridgedO 22 | from .tcp_full import TCPFull 23 | from .tcp_intermediate import TCPIntermediate 24 | from .tcp_intermediate_o import TCPIntermediateO 25 | -------------------------------------------------------------------------------- /pyrogram/connection/transport/tcp/tcp_intermediate.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import asyncio 20 | import logging 21 | from struct import pack, unpack 22 | from typing import Optional, Tuple 23 | 24 | from .tcp import TCP, Proxy 25 | 26 | log = logging.getLogger(__name__) 27 | 28 | 29 | class TCPIntermediate(TCP): 30 | def __init__(self, ipv6: bool, proxy: Proxy, loop: Optional[asyncio.AbstractEventLoop] = None) -> None: 31 | super().__init__(ipv6, proxy, loop) 32 | 33 | async def connect(self, address: Tuple[str, int]) -> None: 34 | await super().connect(address) 35 | await super().send(b"\xee" * 4) 36 | 37 | async def send(self, data: bytes, *args) -> None: 38 | await super().send(pack(" Optional[bytes]: 41 | length = await super().recv(4) 42 | 43 | if length is None: 44 | return None 45 | 46 | return await super().recv(unpack(" 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | -------------------------------------------------------------------------------- /pyrogram/enums/auto_name.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import Enum 20 | 21 | 22 | class AutoName(Enum): 23 | def _generate_next_value_(self, *args): 24 | return self.lower() 25 | 26 | def __repr__(self): 27 | return f"pyrogram.enums.{self}" 28 | -------------------------------------------------------------------------------- /pyrogram/enums/business_schedule.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class BusinessSchedule(AutoName): 25 | """Business away enumeration used in :obj:`~pyrogram.types.BusinessMessage`.""" 26 | 27 | ALWAYS = raw.types.BusinessAwayMessageScheduleAlways 28 | "Send always" 29 | 30 | OUTSIDE_WORK_HOURS = raw.types.BusinessAwayMessageScheduleOutsideWorkHours 31 | "Outside of Business Hours" 32 | 33 | CUSTOM = raw.types.BusinessAwayMessageScheduleCustom 34 | "Custom Schedule" 35 | -------------------------------------------------------------------------------- /pyrogram/enums/chat_join_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class ChatJoinType(AutoName): 25 | """How the service message :obj:`~pyrogram.enums.MessageServiceType.NEW_CHAT_MEMBERS` was used for the member to join the chat.""" 26 | 27 | BY_ADD = auto() 28 | "A new member joined the chat via an invite link" 29 | 30 | BY_LINK = auto() 31 | "A new member joined the chat via an invite link" 32 | 33 | BY_REQUEST = auto() 34 | "A new member was accepted to the chat by an administrator" 35 | -------------------------------------------------------------------------------- /pyrogram/enums/chat_member_status.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class ChatMemberStatus(AutoName): 25 | """Chat member status enumeration used in :obj:`~pyrogram.types.ChatMember`.""" 26 | 27 | OWNER = auto() 28 | "Chat owner" 29 | 30 | ADMINISTRATOR = auto() 31 | "Chat administrator" 32 | 33 | MEMBER = auto() 34 | "Chat member" 35 | 36 | RESTRICTED = auto() 37 | "Restricted chat member" 38 | 39 | LEFT = auto() 40 | "Left chat member" 41 | 42 | BANNED = auto() 43 | "Banned chat member" 44 | -------------------------------------------------------------------------------- /pyrogram/enums/chat_members_filter.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from .auto_name import AutoName 21 | 22 | 23 | class ChatMembersFilter(AutoName): 24 | """Chat members filter enumeration used in :meth:`~pyrogram.Client.get_chat_members`""" 25 | 26 | SEARCH = raw.types.ChannelParticipantsSearch 27 | "Search for members" 28 | 29 | BANNED = raw.types.ChannelParticipantsKicked 30 | "Banned members" 31 | 32 | RESTRICTED = raw.types.ChannelParticipantsBanned 33 | "Restricted members" 34 | 35 | BOTS = raw.types.ChannelParticipantsBots 36 | "Bots" 37 | 38 | RECENT = raw.types.ChannelParticipantsRecent 39 | "Recently active members" 40 | 41 | ADMINISTRATORS = raw.types.ChannelParticipantsAdmins 42 | "Administrators" 43 | -------------------------------------------------------------------------------- /pyrogram/enums/chat_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class ChatType(AutoName): 25 | """Chat type enumeration used in :obj:`~pyrogram.types.Chat`.""" 26 | 27 | PRIVATE = auto() 28 | "Chat is a private chat with a user" 29 | 30 | BOT = auto() 31 | "Chat is a private chat with a bot" 32 | 33 | GROUP = auto() 34 | "Chat is a basic group" 35 | 36 | SUPERGROUP = auto() 37 | "Chat is a supergroup" 38 | 39 | CHANNEL = auto() 40 | "Chat is a channel" 41 | -------------------------------------------------------------------------------- /pyrogram/enums/client_platform.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class ClientPlatform(AutoName): 25 | """Valid platforms for a :obj:`~pyrogram.Client`.""" 26 | 27 | ANDROID = auto() 28 | "Android" 29 | 30 | IOS = auto() 31 | "iOS" 32 | 33 | WP = auto() 34 | "Windows Phone" 35 | 36 | BB = auto() 37 | "Blackberry" 38 | 39 | DESKTOP = auto() 40 | "Desktop" 41 | 42 | WEB = auto() 43 | "Web" 44 | 45 | UBP = auto() 46 | "Ubuntu Phone" 47 | 48 | OTHER = auto() 49 | "Other" 50 | -------------------------------------------------------------------------------- /pyrogram/enums/folder_color.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .auto_name import AutoName 20 | 21 | 22 | class FolderColor(AutoName): 23 | """Folder color enumeration used in :obj:`~pyrogram.types.Folder`.""" 24 | 25 | NO_COLOR = None 26 | "No color." 27 | 28 | RED = 0 29 | "Red color." 30 | 31 | ORANGE = 1 32 | "Orange color." 33 | 34 | VIOLET = 2 35 | "Violet color." 36 | 37 | GREEN = 3 38 | "Green color." 39 | 40 | CYAN = 4 41 | "Cyan color." 42 | 43 | BLUE = 5 44 | "Blue color." 45 | 46 | PINK = 6 47 | "Pink color." 48 | -------------------------------------------------------------------------------- /pyrogram/enums/gift_attribute_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from .auto_name import AutoName 21 | 22 | 23 | class GiftAttributeType(AutoName): 24 | """Star gift attribute type enumeration used in :obj:`~pyrogram.types.GiftAttribute`.""" 25 | 26 | MODEL = raw.types.StarGiftAttributeModel 27 | "Model attribute" 28 | 29 | SYMBOL = raw.types.StarGiftAttributePattern 30 | "Symbol attribute" 31 | 32 | BACKDROP = raw.types.StarGiftAttributeBackdrop 33 | "Backdrop attribute" 34 | 35 | ORIGINAL_DETAILS = raw.types.StarGiftAttributeOriginalDetails 36 | "Original details attribute" 37 | -------------------------------------------------------------------------------- /pyrogram/enums/gift_for_resale_order.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class GiftForResaleOrder(AutoName): 25 | """Describes order in which upgraded gifts for resale will be sorted. Used in :meth:`~pyrogram.Client.search_gifts_for_resale`.""" 26 | 27 | PRICE = auto() 28 | "The gifts will be sorted by their price from the lowest to the highest" 29 | 30 | CHANGE_DATE = auto() 31 | "The gifts will be sorted by the last date when their price was changed from the newest to the oldest" 32 | 33 | NUMBER = auto() 34 | "The gifts will be sorted by their number from the smallest to the largest" 35 | -------------------------------------------------------------------------------- /pyrogram/enums/media_area_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class MediaAreaType(AutoName): 25 | """Media area type enumeration used in :obj:`~pyrogram.types.MediaArea`.""" 26 | 27 | POST = raw.types.MediaAreaChannelPost 28 | "Channel post." 29 | 30 | LOCATION = raw.types.MediaAreaGeoPoint 31 | "Location." 32 | 33 | REACTION = raw.types.MediaAreaSuggestedReaction 34 | "Reaction." 35 | 36 | URL = raw.types.MediaAreaUrl 37 | "URL." 38 | 39 | VENUE = raw.types.MediaAreaVenue 40 | "Venue." 41 | 42 | WEATHER = raw.types.MediaAreaWeather 43 | "Weather." 44 | 45 | GIFT = raw.types.MediaAreaStarGift 46 | "Gift." 47 | -------------------------------------------------------------------------------- /pyrogram/enums/message_origin_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class MessageOriginType(AutoName): 25 | """Message origin type enumeration used in :obj:`~pyrogram.types.MessageOrigin`.""" 26 | 27 | CHANNEL = auto() 28 | "The message was originally a post in a channel" 29 | 30 | CHAT = auto() 31 | "The message was originally sent on behalf of a chat" 32 | 33 | HIDDEN_USER = auto() 34 | "The message was originally sent by a user, which is hidden by their privacy settings" 35 | 36 | IMPORT = auto() 37 | "The message was imported from a foreign chat service" 38 | 39 | 40 | USER = auto() 41 | "The message was originally sent by a known user" 42 | -------------------------------------------------------------------------------- /pyrogram/enums/next_code_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from .auto_name import AutoName 21 | 22 | 23 | class NextCodeType(AutoName): 24 | """Next code type enumeration used in :obj:`~pyrogram.types.SentCode`.""" 25 | 26 | CALL = raw.types.auth.CodeTypeCall 27 | "The code will be sent via a phone call. A synthesized voice will tell the user which verification code to input." 28 | 29 | FLASH_CALL = raw.types.auth.CodeTypeFlashCall 30 | "The code will be sent via a flash phone call, that will be closed immediately." 31 | 32 | MISSED_CALL = raw.types.auth.CodeTypeMissedCall 33 | "Missed call." 34 | 35 | SMS = raw.types.auth.CodeTypeSms 36 | "The code was sent via SMS." 37 | 38 | FRAGMENT_SMS = raw.types.auth.CodeTypeFragmentSms 39 | "The code was sent via Fragment SMS." 40 | -------------------------------------------------------------------------------- /pyrogram/enums/paid_reaction_privacy.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | from enum import auto 19 | 20 | from pyrogram import raw 21 | 22 | from .auto_name import AutoName 23 | 24 | 25 | class PaidReactionPrivacy(AutoName): 26 | """Reaction privacy type enumeration used in :meth:`~pyrogram.Client.send_paid_reaction`.""" 27 | 28 | DEFAULT = raw.types.PaidReactionPrivacyDefault 29 | "Send default reaction" 30 | 31 | ANONYMOUS = raw.types.PaidReactionPrivacyAnonymous 32 | "Send anonymous reaction" 33 | 34 | CHAT = raw.types.PaidReactionPrivacyPeer 35 | "Send reaction as specific chat. You can get all available chats in :meth:`~pyrogram.Client.get_send_as_chats`" 36 | -------------------------------------------------------------------------------- /pyrogram/enums/parse_mode.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class ParseMode(AutoName): 25 | """Parse mode enumeration used in various places to set a specific parse mode""" 26 | 27 | DEFAULT = auto() 28 | "Default mode. Markdown and HTML combined" 29 | 30 | MARKDOWN = auto() 31 | "Markdown only mode" 32 | 33 | HTML = auto() 34 | "HTML only mode" 35 | 36 | DISABLED = auto() 37 | "Disabled mode" 38 | -------------------------------------------------------------------------------- /pyrogram/enums/poll_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class PollType(AutoName): 25 | """Poll type enumeration used in :obj:`~pyrogram.types.Poll`.""" 26 | 27 | QUIZ = auto() 28 | "Quiz poll" 29 | 30 | REGULAR = auto() 31 | "Regular poll" 32 | -------------------------------------------------------------------------------- /pyrogram/enums/stories_privacy_rules.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | from .auto_name import AutoName 21 | 22 | 23 | class StoriesPrivacyRules(AutoName): 24 | """Stories privacy rules type enumeration used in :meth:`~pyrogram.Client.send_story`.""" 25 | 26 | PUBLIC = auto() 27 | "Public stories" 28 | 29 | CONTACTS = auto() 30 | "Contacts only stories" 31 | 32 | CLOSE_FRIENDS = auto() 33 | "Close friends stories" 34 | 35 | SELECTED_USERS = auto() 36 | "Selected users stories" 37 | -------------------------------------------------------------------------------- /pyrogram/enums/user_status.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from enum import auto 20 | 21 | from .auto_name import AutoName 22 | 23 | 24 | class UserStatus(AutoName): 25 | """User status enumeration used in :obj:`~pyrogram.types.User`.""" 26 | 27 | ONLINE = auto() 28 | """User is online""" 29 | 30 | OFFLINE = auto() 31 | """User is offline""" 32 | 33 | RECENTLY = auto() 34 | """User was seen recently""" 35 | 36 | LAST_WEEK = auto() 37 | """User was seen last week""" 38 | 39 | LAST_MONTH = auto() 40 | """User was seen last month""" 41 | 42 | LONG_AGO = auto() 43 | """User was seen long ago""" 44 | -------------------------------------------------------------------------------- /pyrogram/handlers/handler.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import inspect 20 | from typing import Callable 21 | 22 | import pyrogram 23 | from pyrogram.filters import Filter 24 | from pyrogram.types import Update 25 | 26 | 27 | class Handler: 28 | def __init__(self, callback: Callable, filters: Filter = None): 29 | self.callback = callback 30 | self.filters = filters 31 | 32 | async def check(self, client: "pyrogram.Client", update: Update): 33 | if callable(self.filters): 34 | if inspect.iscoroutinefunction(self.filters.__call__): 35 | return await self.filters(client, update) 36 | else: 37 | return await client.loop.run_in_executor( 38 | client.executor, 39 | self.filters, 40 | client, update 41 | ) 42 | 43 | return True 44 | -------------------------------------------------------------------------------- /pyrogram/handlers/start_handler.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Callable 20 | 21 | from .handler import Handler 22 | 23 | 24 | class StartHandler(Handler): 25 | """The Start handler class. Used to handle client start. It is intended to be used with 26 | :meth:`~pyrogram.Client.add_handler` 27 | 28 | For a nicer way to register this handler, have a look at the 29 | :meth:`~pyrogram.Client.on_start` decorator. 30 | 31 | Parameters: 32 | callback (``Callable``): 33 | Pass a function that will be called when a client starts. It takes *(client)* 34 | as positional argument (look at the section below for a detailed description). 35 | 36 | Other parameters: 37 | client (:obj:`~pyrogram.Client`): 38 | The Client itself. Useful, for example, when you want to change the proxy before a new connection 39 | is established. 40 | """ 41 | 42 | def __init__(self, callback: Callable): 43 | super().__init__(callback) 44 | -------------------------------------------------------------------------------- /pyrogram/handlers/stop_handler.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Callable 20 | 21 | from .handler import Handler 22 | 23 | 24 | class StopHandler(Handler): 25 | """The Stop handler class. Used to handle client stop. It is intended to be used with 26 | :meth:`~pyrogram.Client.add_handler` 27 | 28 | For a nicer way to register this handler, have a look at the 29 | :meth:`~pyrogram.Client.on_stop` decorator. 30 | 31 | Parameters: 32 | callback (``Callable``): 33 | Pass a function that will be called when a client stops. It takes *(client)* 34 | as positional argument (look at the section below for a detailed description). 35 | 36 | Other parameters: 37 | client (:obj:`~pyrogram.Client`): 38 | The Client itself. Useful, for example, when you want to change the proxy before a new connection 39 | is established. 40 | """ 41 | 42 | def __init__(self, callback: Callable): 43 | super().__init__(callback) 44 | -------------------------------------------------------------------------------- /pyrogram/methods/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .account import Account 20 | from .advanced import Advanced 21 | from .auth import Auth 22 | from .business import Business 23 | from .bots import Bots 24 | from .chats import Chats 25 | from .contacts import Contacts 26 | from .decorators import Decorators 27 | from .invite_links import InviteLinks 28 | from .messages import Messages 29 | from .password import Password 30 | from .payments import Payments 31 | from .phone import Phone 32 | from .premium import Premium 33 | from .users import Users 34 | from .stories import Stories 35 | from .utilities import Utilities 36 | 37 | 38 | class Methods( 39 | Account, 40 | Advanced, 41 | Auth, 42 | Business, 43 | Bots, 44 | Contacts, 45 | Password, 46 | Payments, 47 | Phone, 48 | Premium, 49 | Chats, 50 | Users, 51 | Stories, 52 | Messages, 53 | Decorators, 54 | Utilities, 55 | InviteLinks, 56 | ): 57 | pass 58 | -------------------------------------------------------------------------------- /pyrogram/methods/account/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .get_account_ttl import GetAccountTTL 20 | from .get_global_privacy_settings import GetGlobalPrivacySettings 21 | from .get_privacy import GetPrivacy 22 | from .set_account_ttl import SetAccountTTL 23 | from .set_global_privacy_settings import SetGlobalPrivacySettings 24 | from .set_privacy import SetPrivacy 25 | 26 | class Account( 27 | GetAccountTTL, 28 | GetGlobalPrivacySettings, 29 | GetPrivacy, 30 | SetAccountTTL, 31 | SetGlobalPrivacySettings, 32 | SetPrivacy 33 | ): 34 | pass 35 | -------------------------------------------------------------------------------- /pyrogram/methods/account/get_account_ttl.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class GetAccountTTL: 24 | async def get_account_ttl( 25 | self: "pyrogram.Client", 26 | ): 27 | """Get days to live of account. 28 | 29 | .. include:: /_includes/usable-by/users.rst 30 | 31 | Returns: 32 | ``int``: Time to live in days of the current account. 33 | 34 | Example: 35 | .. code-block:: python 36 | 37 | # Get ttl in days 38 | await app.get_account_ttl() 39 | """ 40 | r = await self.invoke( 41 | raw.functions.account.GetAccountTTL() 42 | ) 43 | 44 | return r.days 45 | -------------------------------------------------------------------------------- /pyrogram/methods/account/get_global_privacy_settings.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw, types 21 | 22 | 23 | class GetGlobalPrivacySettings: 24 | async def get_global_privacy_settings(self: "pyrogram.Client") -> "types.GlobalPrivacySettings": 25 | """Get account global privacy settings. 26 | 27 | .. include:: /_includes/usable-by/users.rst 28 | 29 | Returns: 30 | :obj:`~pyrogram.types.GlobalPrivacySettings`: On success, the global privacy settings is returned. 31 | 32 | Example: 33 | .. code-block:: python 34 | 35 | await app.get_global_privacy_settings() 36 | """ 37 | r = await self.invoke(raw.functions.account.GetGlobalPrivacySettings()) 38 | 39 | return types.GlobalPrivacySettings._parse(r) 40 | -------------------------------------------------------------------------------- /pyrogram/methods/advanced/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .invoke import Invoke 20 | from .resolve_peer import ResolvePeer 21 | from .save_file import SaveFile 22 | 23 | 24 | class Advanced( 25 | Invoke, 26 | ResolvePeer, 27 | SaveFile 28 | ): 29 | pass 30 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/accept_terms_of_service.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class AcceptTermsOfService: 24 | async def accept_terms_of_service( 25 | self: "pyrogram.Client", 26 | terms_of_service_id: str 27 | ) -> bool: 28 | """Accept the given terms of service. 29 | 30 | .. include:: /_includes/usable-by/users.rst 31 | 32 | Parameters: 33 | terms_of_service_id (``str``): 34 | The terms of service identifier. 35 | """ 36 | r = await self.invoke( 37 | raw.functions.help.AcceptTermsOfService( 38 | id=raw.types.DataJSON( 39 | data=terms_of_service_id 40 | ) 41 | ) 42 | ) 43 | 44 | return bool(r) 45 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/disconnect.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | 21 | 22 | class Disconnect: 23 | async def disconnect( 24 | self: "pyrogram.Client", 25 | ): 26 | """Disconnect the client from Telegram servers. 27 | 28 | Raises: 29 | ConnectionError: In case you try to disconnect an already disconnected client or in case you try to 30 | disconnect a client that needs to be terminated first. 31 | """ 32 | if not self.is_connected: 33 | raise ConnectionError("Client is already disconnected") 34 | 35 | if self.is_initialized: 36 | raise ConnectionError("Can't disconnect an initialized client") 37 | 38 | await self.session.stop() 39 | await self.storage.close() 40 | self.is_connected = False 41 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/get_active_sessions.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw, types 21 | 22 | 23 | class GetActiveSessions: 24 | async def get_active_sessions( 25 | self: "pyrogram.Client" 26 | ) -> "types.ActiveSessions": 27 | """Returns all active sessions of the current user. 28 | 29 | .. include:: /_includes/usable-by/users.rst 30 | 31 | Returns: 32 | :obj:`~pyrogram.types.ActiveSessions`: On success, all the active sessions of the current user is returned. 33 | 34 | """ 35 | r = await self.invoke( 36 | raw.functions.account.GetAuthorizations() 37 | ) 38 | 39 | return types.ActiveSessions._parse(r) 40 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/get_password_hint.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import logging 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | 24 | log = logging.getLogger(__name__) 25 | 26 | 27 | class GetPasswordHint: 28 | async def get_password_hint( 29 | self: "pyrogram.Client", 30 | ) -> str: 31 | """Get your Two-Step Verification password hint. 32 | 33 | .. include:: /_includes/usable-by/users.rst 34 | 35 | Returns: 36 | ``str``: On success, the password hint as string is returned. 37 | """ 38 | return (await self.invoke(raw.functions.account.GetPassword())).hint 39 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/log_out.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import logging 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | 24 | log = logging.getLogger(__name__) 25 | 26 | 27 | class LogOut: 28 | async def log_out( 29 | self: "pyrogram.Client", 30 | ): 31 | """Log out from Telegram and delete the *\\*.session* file. 32 | 33 | When you log out, the current client is stopped and the storage session deleted. 34 | No more API calls can be made until you start the client and re-authorize again. 35 | 36 | .. include:: /_includes/usable-by/users-bots.rst 37 | 38 | Returns: 39 | ``bool``: On success, True is returned. 40 | 41 | Example: 42 | .. code-block:: python 43 | 44 | # Log out. 45 | await app.log_out() 46 | """ 47 | await self.invoke(raw.functions.auth.LogOut()) 48 | await self.stop() 49 | await self.storage.delete() 50 | 51 | return True 52 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/reset_session.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class ResetSession: 24 | async def reset_session( 25 | self: "pyrogram.Client", 26 | id: int 27 | ) -> bool: 28 | """Log out an active authorized session by its hash. 29 | 30 | .. include:: /_includes/usable-by/users.rst 31 | 32 | Parameters: 33 | id (``int``): 34 | Session hash to reset. 35 | 36 | Returns: 37 | ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned. 38 | 39 | """ 40 | r = await self.invoke( 41 | raw.functions.account.ResetAuthorization(hash=id) 42 | ) 43 | 44 | return r 45 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/reset_sessions.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class ResetSessions: 24 | async def reset_sessions( 25 | self: "pyrogram.Client", 26 | ) -> bool: 27 | """Terminates all user's authorized sessions except for the current one. 28 | 29 | .. include:: /_includes/usable-by/users.rst 30 | 31 | Returns: 32 | ``bool``: On success, in case the sessions is destroyed, True is returned. Otherwise, False is returned. 33 | 34 | """ 35 | r = await self.invoke( 36 | raw.functions.auth.ResetAuthorizations() 37 | ) 38 | 39 | return r 40 | -------------------------------------------------------------------------------- /pyrogram/methods/auth/send_recovery_code.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import logging 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | 24 | log = logging.getLogger(__name__) 25 | 26 | 27 | class SendRecoveryCode: 28 | async def send_recovery_code( 29 | self: "pyrogram.Client", 30 | ) -> str: 31 | """Send a code to your email to recover your password. 32 | 33 | .. include:: /_includes/usable-by/users.rst 34 | 35 | Returns: 36 | ``str``: On success, the hidden email pattern is returned and a recovery code is sent to that email. 37 | 38 | Raises: 39 | BadRequest: In case no recovery email was set up. 40 | """ 41 | return (await self.invoke( 42 | raw.functions.auth.RequestPasswordRecovery() 43 | )).email_pattern 44 | -------------------------------------------------------------------------------- /pyrogram/methods/bots/get_owned_bots.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import List 20 | 21 | import pyrogram 22 | from pyrogram import raw, types 23 | 24 | 25 | class GetOwnedBots: 26 | async def get_owned_bots( 27 | self: "pyrogram.Client", 28 | ) -> List["types.User"]: 29 | """Returns the list of bots owned by the current user. 30 | 31 | .. include:: /_includes/usable-by/users.rst 32 | 33 | Returns: 34 | List of :obj:`~pyrogram.types.User`: On success. 35 | 36 | Example: 37 | .. code-block:: python 38 | 39 | bots = await app.get_owned_bots() 40 | """ 41 | 42 | bots = await self.invoke(raw.functions.bots.GetAdminedBots()) 43 | 44 | return types.List([types.User._parse(self, bot) for bot in bots]) 45 | -------------------------------------------------------------------------------- /pyrogram/methods/business/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .delete_business_messages import DeleteBusinessMessages 20 | from .get_business_account_gifts import GetBusinessAccountGifts 21 | from .get_business_account_star_balance import GetBusinessAccountStarBalance 22 | from .get_business_connection import GetBusinessConnection 23 | from .transfer_business_account_stars import TransferBusinessAccountStars 24 | 25 | 26 | class Business( 27 | DeleteBusinessMessages, 28 | GetBusinessAccountGifts, 29 | GetBusinessAccountStarBalance, 30 | GetBusinessConnection, 31 | TransferBusinessAccountStars, 32 | ): 33 | pass 34 | -------------------------------------------------------------------------------- /pyrogram/methods/chats/delete_channel.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Union 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | 24 | 25 | class DeleteChannel: 26 | async def delete_channel( 27 | self: "pyrogram.Client", 28 | chat_id: Union[int, str] 29 | ) -> bool: 30 | """Delete a channel. 31 | 32 | .. include:: /_includes/usable-by/users.rst 33 | 34 | Parameters: 35 | chat_id (``int`` | ``str``): 36 | The id of the channel to be deleted. 37 | 38 | Returns: 39 | ``bool``: On success, True is returned. 40 | 41 | Example: 42 | .. code-block:: python 43 | 44 | await app.delete_channel(channel_id) 45 | """ 46 | await self.invoke( 47 | raw.functions.channels.DeleteChannel( 48 | channel=await self.resolve_peer(chat_id) 49 | ) 50 | ) 51 | 52 | return True 53 | -------------------------------------------------------------------------------- /pyrogram/methods/chats/delete_folder.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class DeleteFolder: 24 | async def delete_folder( 25 | self: "pyrogram.Client", 26 | folder_id: int 27 | ) -> bool: 28 | """Delete a user's folder. 29 | 30 | .. include:: /_includes/usable-by/users.rst 31 | 32 | Parameters: 33 | folder_id (``int``): 34 | Unique identifier (int) of the target folder. 35 | 36 | Returns: 37 | ``bool``: True, on success. 38 | 39 | Example: 40 | .. code-block:: python 41 | 42 | # Delete folder 43 | await app.delete_folder(folder_id) 44 | """ 45 | r = await self.invoke( 46 | raw.functions.messages.UpdateDialogFilter( 47 | id=folder_id 48 | ) 49 | ) 50 | 51 | return r 52 | -------------------------------------------------------------------------------- /pyrogram/methods/chats/delete_supergroup.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Union 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | 24 | 25 | class DeleteSupergroup: 26 | async def delete_supergroup( 27 | self: "pyrogram.Client", 28 | chat_id: Union[int, str] 29 | ) -> bool: 30 | """Delete a supergroup. 31 | 32 | .. include:: /_includes/usable-by/users.rst 33 | 34 | Parameters: 35 | chat_id (``int`` | ``str``): 36 | The id of the supergroup to be deleted. 37 | 38 | Returns: 39 | ``bool``: On success, True is returned. 40 | 41 | Example: 42 | .. code-block:: python 43 | 44 | await app.delete_supergroup(supergroup_id) 45 | """ 46 | await self.invoke( 47 | raw.functions.channels.DeleteChannel( 48 | channel=await self.resolve_peer(chat_id) 49 | ) 50 | ) 51 | 52 | return True 53 | -------------------------------------------------------------------------------- /pyrogram/methods/chats/mark_chat_unread.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Union 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | 24 | 25 | class MarkChatUnread: 26 | async def mark_chat_unread( 27 | self: "pyrogram.Client", 28 | chat_id: Union[int, str], 29 | ) -> bool: 30 | """Mark a chat as unread. 31 | 32 | .. include:: /_includes/usable-by/users.rst 33 | 34 | Parameters: 35 | chat_id (``int`` | ``str``): 36 | Unique identifier (int) or username (str) of the target chat. 37 | 38 | Returns: 39 | ``bool``: On success, True is returned. 40 | """ 41 | 42 | return await self.invoke( 43 | raw.functions.messages.MarkDialogUnread( 44 | peer=await self.resolve_peer(chat_id), 45 | unread=True 46 | ) 47 | ) 48 | -------------------------------------------------------------------------------- /pyrogram/methods/chats/toggle_folder_tags.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class ToggleFolderTags: 24 | async def toggle_folder_tags( 25 | self: "pyrogram.Client", 26 | are_tags_enabled: bool 27 | ) -> bool: 28 | """Toggles whether chat folder tags are enabled. 29 | 30 | .. include:: /_includes/usable-by/users.rst 31 | 32 | Parameters: 33 | are_tags_enabled (``bool``): 34 | Pass True to enable folder tags. 35 | Pass False to disable them. 36 | 37 | Returns: 38 | ``bool``: On success, True is returned. 39 | 40 | Example: 41 | .. code-block:: python 42 | 43 | await app.toggle_folder_tags(True) 44 | """ 45 | r = await self.invoke( 46 | raw.functions.messages.ToggleDialogFilterTags( 47 | enabled=are_tags_enabled 48 | ) 49 | ) 50 | 51 | return r 52 | -------------------------------------------------------------------------------- /pyrogram/methods/contacts/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .add_contact import AddContact 20 | from .delete_contacts import DeleteContacts 21 | from .get_contacts import GetContacts 22 | from .get_contacts_count import GetContactsCount 23 | from .import_contacts import ImportContacts 24 | from .search_contacts import SearchContacts 25 | 26 | 27 | class Contacts( 28 | GetContacts, 29 | DeleteContacts, 30 | ImportContacts, 31 | GetContactsCount, 32 | AddContact, 33 | SearchContacts 34 | ): 35 | pass 36 | -------------------------------------------------------------------------------- /pyrogram/methods/contacts/get_contacts.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import logging 20 | from typing import List 21 | 22 | import pyrogram 23 | from pyrogram import raw 24 | from pyrogram import types 25 | 26 | log = logging.getLogger(__name__) 27 | 28 | 29 | class GetContacts: 30 | async def get_contacts( 31 | self: "pyrogram.Client" 32 | ) -> List["types.User"]: 33 | """Get contacts from your Telegram address book. 34 | 35 | .. include:: /_includes/usable-by/users.rst 36 | 37 | Returns: 38 | List of :obj:`~pyrogram.types.User`: On success, a list of users is returned. 39 | 40 | Example: 41 | .. code-block:: python 42 | 43 | contacts = await app.get_contacts() 44 | print(contacts) 45 | """ 46 | contacts = await self.invoke(raw.functions.contacts.GetContacts(hash=0)) 47 | return types.List(types.User._parse(self, user) for user in contacts.users) 48 | -------------------------------------------------------------------------------- /pyrogram/methods/contacts/get_contacts_count.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | 22 | 23 | class GetContactsCount: 24 | async def get_contacts_count( 25 | self: "pyrogram.Client" 26 | ) -> int: 27 | """Get the total count of contacts from your Telegram address book. 28 | 29 | .. include:: /_includes/usable-by/users.rst 30 | 31 | Returns: 32 | ``int``: On success, the contacts count is returned. 33 | 34 | Example: 35 | .. code-block:: python 36 | 37 | count = await app.get_contacts_count() 38 | print(count) 39 | """ 40 | 41 | return len((await self.invoke(raw.functions.contacts.GetContacts(hash=0))).contacts) 42 | -------------------------------------------------------------------------------- /pyrogram/methods/decorators/on_connect.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Callable, Optional 20 | 21 | import pyrogram 22 | 23 | 24 | class OnConnect: 25 | def on_connect(self: Optional["OnConnect"] = None) -> Callable: 26 | """Decorator for handling connections. 27 | 28 | This does the same thing as :meth:`~pyrogram.Client.add_handler` using the 29 | :obj:`~pyrogram.handlers.ConnectHandler`. 30 | 31 | .. include:: /_includes/usable-by/users-bots.rst 32 | """ 33 | 34 | def decorator(func: Callable) -> Callable: 35 | if isinstance(self, pyrogram.Client): 36 | self.add_handler(pyrogram.handlers.ConnectHandler(func)) 37 | else: 38 | if not hasattr(func, "handlers"): 39 | func.handlers = [] 40 | 41 | func.handlers.append((pyrogram.handlers.ConnectHandler(func), 0)) 42 | 43 | return func 44 | 45 | return decorator 46 | -------------------------------------------------------------------------------- /pyrogram/methods/decorators/on_disconnect.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Callable, Optional 20 | 21 | import pyrogram 22 | 23 | 24 | class OnDisconnect: 25 | def on_disconnect(self: Optional["OnDisconnect"] = None) -> Callable: 26 | """Decorator for handling disconnections. 27 | 28 | This does the same thing as :meth:`~pyrogram.Client.add_handler` using the 29 | :obj:`~pyrogram.handlers.DisconnectHandler`. 30 | 31 | .. include:: /_includes/usable-by/users-bots.rst 32 | """ 33 | 34 | def decorator(func: Callable) -> Callable: 35 | if isinstance(self, pyrogram.Client): 36 | self.add_handler(pyrogram.handlers.DisconnectHandler(func)) 37 | else: 38 | if not hasattr(func, "handlers"): 39 | func.handlers = [] 40 | 41 | func.handlers.append((pyrogram.handlers.DisconnectHandler(func), 0)) 42 | 43 | return func 44 | 45 | return decorator 46 | -------------------------------------------------------------------------------- /pyrogram/methods/decorators/on_start.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Callable, Optional 20 | 21 | import pyrogram 22 | 23 | 24 | class OnStart: 25 | def on_start(self: Optional["OnStart"] = None) -> Callable: 26 | """Decorator for handling client start. 27 | 28 | This does the same thing as :meth:`~pyrogram.Client.add_handler` using the 29 | :obj:`~pyrogram.handlers.StartHandler`. 30 | 31 | .. include:: /_includes/usable-by/users-bots.rst 32 | """ 33 | 34 | def decorator(func: Callable) -> Callable: 35 | if isinstance(self, pyrogram.Client): 36 | self.add_handler(pyrogram.handlers.StartHandler(func)) 37 | else: 38 | if not hasattr(func, "handlers"): 39 | func.handlers = [] 40 | 41 | func.handlers.append((pyrogram.handlers.StartHandler(func), 0)) 42 | 43 | return func 44 | 45 | return decorator 46 | -------------------------------------------------------------------------------- /pyrogram/methods/decorators/on_stop.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Callable, Optional 20 | 21 | import pyrogram 22 | 23 | 24 | class OnStop: 25 | def on_stop(self: Optional["OnStop"] = None) -> Callable: 26 | """Decorator for handling client stop. 27 | 28 | This does the same thing as :meth:`~pyrogram.Client.add_handler` using the 29 | :obj:`~pyrogram.handlers.StopHandler`. 30 | 31 | .. include:: /_includes/usable-by/users-bots.rst 32 | """ 33 | 34 | def decorator(func: Callable) -> Callable: 35 | if isinstance(self, pyrogram.Client): 36 | self.add_handler(pyrogram.handlers.StopHandler(func)) 37 | else: 38 | if not hasattr(func, "handlers"): 39 | func.handlers = [] 40 | 41 | func.handlers.append((pyrogram.handlers.StopHandler(func), 0)) 42 | 43 | return func 44 | 45 | return decorator 46 | -------------------------------------------------------------------------------- /pyrogram/methods/password/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .change_cloud_password import ChangeCloudPassword 20 | from .enable_cloud_password import EnableCloudPassword 21 | from .remove_cloud_password import RemoveCloudPassword 22 | 23 | 24 | class Password( 25 | RemoveCloudPassword, 26 | ChangeCloudPassword, 27 | EnableCloudPassword 28 | ): 29 | pass 30 | -------------------------------------------------------------------------------- /pyrogram/methods/payments/get_available_gifts.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | from typing import List 19 | 20 | import pyrogram 21 | from pyrogram import raw, types 22 | 23 | 24 | class GetAvailableGifts: 25 | async def get_available_gifts( 26 | self: "pyrogram.Client", 27 | ) -> List["types.Gift"]: 28 | """Get all available star gifts that can be sent to other users. 29 | 30 | .. include:: /_includes/usable-by/users-bots.rst 31 | 32 | Returns: 33 | List of :obj:`~pyrogram.types.Gift`: On success, a list of star gifts is returned. 34 | 35 | Example: 36 | .. code-block:: python 37 | 38 | await app.get_available_gifts() 39 | """ 40 | r = await self.invoke( 41 | raw.functions.payments.GetStarGifts(hash=0) 42 | ) 43 | 44 | return types.List([await types.Gift._parse_regular(self, gift) for gift in r.gifts]) 45 | -------------------------------------------------------------------------------- /pyrogram/methods/phone/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .get_call_members import GetCallMembers 20 | 21 | 22 | class Phone( 23 | GetCallMembers 24 | ): 25 | pass 26 | -------------------------------------------------------------------------------- /pyrogram/methods/premium/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .apply_boost import ApplyBoost 20 | from .get_boosts_status import GetBoostsStatus 21 | from .get_boosts import GetBoosts 22 | 23 | class Premium( 24 | ApplyBoost, 25 | GetBoostsStatus, 26 | GetBoosts 27 | ): 28 | pass 29 | -------------------------------------------------------------------------------- /pyrogram/methods/users/get_me.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from pyrogram import types 22 | 23 | 24 | class GetMe: 25 | async def get_me( 26 | self: "pyrogram.Client" 27 | ) -> "types.User": 28 | """Get your own user identity. 29 | 30 | .. include:: /_includes/usable-by/users-bots.rst 31 | 32 | Returns: 33 | :obj:`~pyrogram.types.User`: Information about the own logged in user/bot. 34 | 35 | Example: 36 | .. code-block:: python 37 | 38 | me = await app.get_me() 39 | print(me) 40 | """ 41 | r = await self.invoke( 42 | raw.functions.users.GetFullUser( 43 | id=raw.types.InputUserSelf() 44 | ) 45 | ) 46 | 47 | users = {u.id: u for u in r.users} 48 | 49 | return types.User._parse(self, users[r.full_user.id]) 50 | -------------------------------------------------------------------------------- /pyrogram/methods/utilities/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .add_handler import AddHandler 20 | from .export_session_string import ExportSessionString 21 | from .remove_handler import RemoveHandler 22 | from .restart import Restart 23 | from .run import Run 24 | from .start import Start 25 | from .stop import Stop 26 | from .stop_transmission import StopTransmission 27 | 28 | 29 | class Utilities( 30 | AddHandler, 31 | ExportSessionString, 32 | RemoveHandler, 33 | Restart, 34 | Run, 35 | Start, 36 | Stop, 37 | StopTransmission 38 | ): 39 | pass 40 | -------------------------------------------------------------------------------- /pyrogram/methods/utilities/export_session_string.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | 21 | 22 | class ExportSessionString: 23 | async def export_session_string( 24 | self: "pyrogram.Client" 25 | ): 26 | """Export the current authorized session as a serialized string. 27 | 28 | Session strings are useful for storing in-memory authorized sessions in a portable, serialized string. 29 | More detailed information about session strings can be found at the dedicated page of 30 | :doc:`Storage Engines <../../topics/storage-engines>`. 31 | 32 | Returns: 33 | ``str``: The session serialized into a printable, url-safe string. 34 | 35 | Example: 36 | .. code-block:: python 37 | 38 | s = await app.export_session_string() 39 | """ 40 | return await self.storage.export_session_string() 41 | -------------------------------------------------------------------------------- /pyrogram/parser/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .parser import Parser 20 | -------------------------------------------------------------------------------- /pyrogram/parser/utils.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import re 20 | from struct import unpack 21 | 22 | # SMP = Supplementary Multilingual Plane: https://en.wikipedia.org/wiki/Plane_(Unicode)#Overview 23 | SMP_RE = re.compile(r"[\U00010000-\U0010FFFF]") 24 | 25 | 26 | def add_surrogates(text: str) -> str: 27 | # Replace each SMP code point with a surrogate pair 28 | return SMP_RE.sub( 29 | lambda match: # Split SMP in two surrogates 30 | "".join(chr(i) for i in unpack(" str: 36 | # Replace each surrogate pair with a SMP code point 37 | return text.encode("utf-16", "surrogatepass").decode("utf-16") 38 | 39 | 40 | def replace_once(source: str, old: str, new: str, start: int): 41 | return source[:start] + source[start:].replace(old, new, 1) 42 | -------------------------------------------------------------------------------- /pyrogram/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurimuzonAkuma/pyrogram/4db3f39ff8779a988a39d510688553177259ed32/pyrogram/py.typed -------------------------------------------------------------------------------- /pyrogram/raw/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from importlib import import_module 20 | 21 | from . import types, functions, base, core 22 | from .all import objects 23 | 24 | for k, v in objects.items(): 25 | path, name = v.rsplit(".", 1) 26 | objects[k] = getattr(import_module(path), name) 27 | -------------------------------------------------------------------------------- /pyrogram/raw/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .future_salt import FutureSalt 20 | from .future_salts import FutureSalts 21 | from .gzip_packed import GzipPacked 22 | from .list import List 23 | from .message import Message 24 | from .msg_container import MsgContainer 25 | from .primitives.bool import Bool, BoolFalse, BoolTrue 26 | from .primitives.bytes import Bytes 27 | from .primitives.double import Double 28 | from .primitives.int import Int, Long, Int128, Int256 29 | from .primitives.string import String 30 | from .primitives.vector import Vector 31 | from .tl_object import TLObject 32 | -------------------------------------------------------------------------------- /pyrogram/raw/core/list.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import List as TList, Any 20 | 21 | from .tl_object import TLObject 22 | 23 | 24 | class List(TList[Any], TLObject): 25 | def __repr__(self) -> str: 26 | return f"pyrogram.raw.core.List([{','.join(TLObject.__repr__(i) for i in self)}])" 27 | -------------------------------------------------------------------------------- /pyrogram/raw/core/msg_container.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from io import BytesIO 20 | from typing import List, Any 21 | 22 | from .message import Message 23 | from .primitives.int import Int 24 | from .tl_object import TLObject 25 | 26 | 27 | class MsgContainer(TLObject): 28 | ID = 0x73F1F8DC 29 | 30 | __slots__ = ["messages"] 31 | 32 | QUALNAME = "MsgContainer" 33 | 34 | def __init__(self, messages: List[Message]): 35 | self.messages = messages 36 | 37 | @staticmethod 38 | def read(data: BytesIO, *args: Any) -> "MsgContainer": 39 | count = Int.read(data) 40 | return MsgContainer([Message.read(data) for _ in range(count)]) 41 | 42 | def write(self, *args: Any) -> bytes: 43 | b = BytesIO() 44 | 45 | b.write(Int(self.ID, False)) 46 | 47 | count = len(self.messages) 48 | b.write(Int(count)) 49 | 50 | for message in self.messages: 51 | b.write(message.write()) 52 | 53 | return b.getvalue() 54 | -------------------------------------------------------------------------------- /pyrogram/raw/core/primitives/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .bool import Bool, BoolFalse, BoolTrue 20 | from .bytes import Bytes 21 | from .double import Double 22 | from .int import Int, Long, Int128, Int256 23 | from .string import String 24 | from .vector import Vector 25 | -------------------------------------------------------------------------------- /pyrogram/raw/core/primitives/bool.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from io import BytesIO 20 | from typing import Any 21 | 22 | from ..tl_object import TLObject 23 | 24 | 25 | class BoolFalse(bytes, TLObject): 26 | ID = 0xBC799737 27 | value = False 28 | 29 | @classmethod 30 | def read(cls, *args: Any) -> bool: 31 | return cls.value 32 | 33 | def __new__(cls) -> bytes: # type: ignore 34 | return cls.ID.to_bytes(4, "little") 35 | 36 | 37 | class BoolTrue(BoolFalse): 38 | ID = 0x997275B5 39 | value = True 40 | 41 | 42 | class Bool(bytes, TLObject): 43 | @classmethod 44 | def read(cls, data: BytesIO, *args: Any) -> bool: 45 | return int.from_bytes(data.read(4), "little") == BoolTrue.ID 46 | 47 | def __new__(cls, value: bool) -> bytes: # type: ignore 48 | return BoolTrue() if value else BoolFalse() 49 | -------------------------------------------------------------------------------- /pyrogram/raw/core/primitives/double.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from io import BytesIO 20 | from struct import unpack, pack 21 | from typing import cast, Any 22 | 23 | from ..tl_object import TLObject 24 | 25 | 26 | class Double(bytes, TLObject): 27 | @classmethod 28 | def read(cls, data: BytesIO, *args: Any) -> float: 29 | return cast(float, unpack("d", data.read(8))[0]) 30 | 31 | def __new__(cls, value: float) -> bytes: # type: ignore 32 | return pack("d", value) 33 | -------------------------------------------------------------------------------- /pyrogram/raw/core/primitives/int.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from io import BytesIO 20 | from typing import Any 21 | 22 | from ..tl_object import TLObject 23 | 24 | 25 | class Int(bytes, TLObject): 26 | SIZE = 4 27 | 28 | @classmethod 29 | def read(cls, data: BytesIO, signed: bool = True, *args: Any) -> int: 30 | return int.from_bytes(data.read(cls.SIZE), "little", signed=signed) 31 | 32 | def __new__(cls, value: int, signed: bool = True) -> bytes: # type: ignore 33 | return value.to_bytes(cls.SIZE, "little", signed=signed) 34 | 35 | 36 | class Long(Int): 37 | SIZE = 8 38 | 39 | 40 | class Int128(Int): 41 | SIZE = 16 42 | 43 | 44 | class Int256(Int): 45 | SIZE = 32 46 | -------------------------------------------------------------------------------- /pyrogram/raw/core/primitives/string.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from io import BytesIO 20 | from typing import cast 21 | 22 | from .bytes import Bytes 23 | 24 | 25 | class String(Bytes): 26 | @classmethod 27 | def read(cls, data: BytesIO, *args) -> str: # type: ignore 28 | return cast(bytes, super(String, String).read(data)).decode(errors="replace") 29 | 30 | def __new__(cls, value: str) -> bytes: # type: ignore 31 | return super().__new__(cls, value.encode()) 32 | -------------------------------------------------------------------------------- /pyrogram/session/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .auth import Auth 20 | from .session import Session 21 | -------------------------------------------------------------------------------- /pyrogram/session/internals/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .data_center import DataCenter 20 | from .msg_factory import MsgFactory 21 | from .msg_id import MsgId 22 | -------------------------------------------------------------------------------- /pyrogram/session/internals/msg_factory.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram.raw.core import Message, MsgContainer, TLObject 20 | from pyrogram.raw.functions import Ping 21 | from pyrogram.raw.types import MsgsAck, HttpWait 22 | from .msg_id import MsgId 23 | from .seq_no import SeqNo 24 | 25 | not_content_related = (Ping, HttpWait, MsgsAck, MsgContainer) 26 | 27 | 28 | class MsgFactory: 29 | def __init__(self): 30 | self.seq_no = SeqNo() 31 | 32 | def __call__(self, body: TLObject) -> Message: 33 | return Message( 34 | body, 35 | MsgId(), 36 | self.seq_no(not isinstance(body, not_content_related)), 37 | len(body) 38 | ) 39 | -------------------------------------------------------------------------------- /pyrogram/session/internals/msg_id.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import logging 20 | import time 21 | 22 | log = logging.getLogger(__name__) 23 | 24 | 25 | class MsgId: 26 | last_time = 0 27 | offset = 0 28 | 29 | def __new__(cls) -> int: 30 | now = int(time.time()) 31 | cls.offset = (cls.offset + 4) if now == cls.last_time else 0 32 | msg_id = (now * 2 ** 32) + cls.offset 33 | cls.last_time = now 34 | 35 | return msg_id 36 | -------------------------------------------------------------------------------- /pyrogram/session/internals/seq_no.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | 20 | class SeqNo: 21 | def __init__(self): 22 | self.content_related_messages_sent = 0 23 | 24 | def __call__(self, is_content_related: bool) -> int: 25 | seq_no = (self.content_related_messages_sent * 2) + (1 if is_content_related else 0) 26 | 27 | if is_content_related: 28 | self.content_related_messages_sent += 1 29 | 30 | return seq_no 31 | -------------------------------------------------------------------------------- /pyrogram/storage/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .file_storage import FileStorage 20 | from .memory_storage import MemoryStorage 21 | from .storage import Storage 22 | -------------------------------------------------------------------------------- /pyrogram/types/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .authorization import * 20 | from .bots_and_keyboards import * 21 | from .inline_mode import * 22 | from .input_media import * 23 | from .input_message_content import * 24 | from .input_privacy_rule import * 25 | from .list import List 26 | from .messages_and_media import * 27 | from .object import Object 28 | from .update import * 29 | from .user_and_chats import * 30 | -------------------------------------------------------------------------------- /pyrogram/types/authorization/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .active_session import ActiveSession 20 | from .active_sessions import ActiveSessions 21 | from .sent_code import SentCode 22 | from .terms_of_service import TermsOfService 23 | 24 | __all__ = [ 25 | "ActiveSession", 26 | "ActiveSessions", 27 | "SentCode", 28 | "TermsOfService", 29 | ] 30 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/bot_command_scope_all_chat_administrators.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .bot_command_scope import BotCommandScope 22 | 23 | 24 | class BotCommandScopeAllChatAdministrators(BotCommandScope): 25 | """Represents the scope of bot commands, covering all group and supergroup chat administrators. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__("all_chat_administrators") 30 | 31 | async def write(self, client: "pyrogram.Client") -> "raw.base.BotCommandScope": 32 | return raw.types.BotCommandScopeChatAdmins() 33 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/bot_command_scope_all_group_chats.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .bot_command_scope import BotCommandScope 22 | 23 | 24 | class BotCommandScopeAllGroupChats(BotCommandScope): 25 | """Represents the scope of bot commands, covering all group and supergroup chats. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__("all_group_chats") 30 | 31 | async def write(self, client: "pyrogram.Client") -> "raw.base.BotCommandScope": 32 | return raw.types.BotCommandScopeChats() 33 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/bot_command_scope_all_private_chats.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .bot_command_scope import BotCommandScope 22 | 23 | 24 | class BotCommandScopeAllPrivateChats(BotCommandScope): 25 | """Represents the scope of bot commands, covering all private chats. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__("all_private_chats") 30 | 31 | async def write(self, client: "pyrogram.Client") -> "raw.base.BotCommandScope": 32 | return raw.types.BotCommandScopeUsers() 33 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/bot_command_scope_chat.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import Union 20 | 21 | import pyrogram 22 | from pyrogram import raw 23 | from .bot_command_scope import BotCommandScope 24 | 25 | 26 | class BotCommandScopeChat(BotCommandScope): 27 | """Represents the scope of bot commands, covering a specific chat. 28 | 29 | Parameters: 30 | chat_id (``int`` | ``str``): 31 | Unique identifier for the target chat or username of the target supergroup (in the format 32 | @supergroupusername). 33 | """ 34 | 35 | def __init__(self, chat_id: Union[int, str]): 36 | super().__init__("chat") 37 | 38 | self.chat_id = chat_id 39 | 40 | async def write(self, client: "pyrogram.Client") -> "raw.base.BotCommandScope": 41 | return raw.types.BotCommandScopePeer( 42 | peer=await client.resolve_peer(self.chat_id) 43 | ) 44 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/bot_command_scope_default.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .bot_command_scope import BotCommandScope 22 | 23 | 24 | class BotCommandScopeDefault(BotCommandScope): 25 | """Represents the default scope of bot commands. 26 | Default commands are used if no commands with a narrower scope are specified for the user. 27 | """ 28 | 29 | def __init__(self): 30 | super().__init__("default") 31 | 32 | async def write(self, client: "pyrogram.Client") -> "raw.base.BotCommandScope": 33 | return raw.types.BotCommandScopeDefault() 34 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/callback_game.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class CallbackGame(Object): 23 | """Placeholder, currently holds no information. 24 | 25 | Use BotFather to set up your game. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class KeyboardButtonPollType(Object): 23 | """Contains information about a poll type. 24 | 25 | Parameters: 26 | is_quiz (``bool``): 27 | If True, the requested poll will be sent as quiz. 28 | """ 29 | 30 | def __init__( 31 | self, *, 32 | is_quiz: bool = None 33 | ): 34 | super().__init__() 35 | 36 | self.is_quiz = is_quiz 37 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/menu_button.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from ..object import Object 22 | 23 | 24 | class MenuButton(Object): 25 | """Describes the bot's menu button in a private chat. 26 | 27 | It should be one of: 28 | 29 | - :obj:`~pyrogram.types.MenuButtonCommands` 30 | - :obj:`~pyrogram.types.MenuButtonWebApp` 31 | - :obj:`~pyrogram.types.MenuButtonDefault` 32 | 33 | If a menu button other than :obj:`~pyrogram.types.MenuButtonDefault` is set for a private chat, then it is applied 34 | in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot 35 | commands. 36 | """ 37 | 38 | def __init__(self, type: str): 39 | super().__init__() 40 | 41 | self.type = type 42 | 43 | async def write(self, client: "pyrogram.Client") -> "raw.base.BotMenuButton": 44 | raise NotImplementedError 45 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/menu_button_commands.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .menu_button import MenuButton 22 | 23 | 24 | class MenuButtonCommands(MenuButton): 25 | """A menu button, which opens the bot's list of commands. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__("commands") 30 | 31 | async def write(self, client: "pyrogram.Client") -> "raw.types.BotMenuButtonCommands": 32 | return raw.types.BotMenuButtonCommands() 33 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/menu_button_default.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .menu_button import MenuButton 22 | 23 | 24 | class MenuButtonDefault(MenuButton): 25 | """Describes that no specific value for the menu button was set. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__("default") 30 | 31 | async def write(self, client: "pyrogram.Client") -> "raw.types.BotMenuButtonDefault": 32 | return raw.types.BotMenuButtonDefault() 33 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/sent_web_app_message.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw, utils 20 | from ..object import Object 21 | 22 | 23 | class SentWebAppMessage(Object): 24 | """Contains information about an inline message sent by a `Web App `_ on behalf of a user. 25 | 26 | Parameters: 27 | inline_message_id (``str``): 28 | Identifier of the sent inline message. 29 | Available only if there is an inline keyboard attached to the message. 30 | """ 31 | 32 | def __init__( 33 | self, *, 34 | inline_message_id: str, 35 | ): 36 | super().__init__() 37 | 38 | self.inline_message_id = inline_message_id 39 | 40 | @staticmethod 41 | def _parse(obj: "raw.types.WebViewMessageSent"): 42 | return SentWebAppMessage(inline_message_id=utils.pack_inline_message_id(obj.msg_id)) 43 | -------------------------------------------------------------------------------- /pyrogram/types/bots_and_keyboards/web_app_info.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class WebAppInfo(Object): 23 | """Contains information about a `Web App `_. 24 | 25 | Parameters: 26 | url (``str``): 27 | An HTTPS URL of a Web App to be opened with additional data as specified in 28 | `Initializing Web Apps `_. 29 | """ 30 | 31 | def __init__( 32 | self, *, 33 | url: str, 34 | ): 35 | super().__init__() 36 | 37 | self.url = url 38 | -------------------------------------------------------------------------------- /pyrogram/types/input_media/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .input_media import InputMedia 20 | from .input_media_animation import InputMediaAnimation 21 | from .input_media_audio import InputMediaAudio 22 | from .input_media_document import InputMediaDocument 23 | from .input_media_photo import InputMediaPhoto 24 | from .input_media_video import InputMediaVideo 25 | from .input_phone_contact import InputPhoneContact 26 | 27 | __all__ = [ 28 | "InputMedia", "InputMediaAnimation", "InputMediaAudio", "InputMediaDocument", "InputMediaPhoto", "InputMediaVideo", 29 | "InputPhoneContact" 30 | ] 31 | -------------------------------------------------------------------------------- /pyrogram/types/input_media/input_media.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import List, Union, BinaryIO 20 | 21 | from ..messages_and_media import MessageEntity 22 | from ..object import Object 23 | 24 | 25 | class InputMedia(Object): 26 | """Content of a media message to be sent. 27 | 28 | It should be one of: 29 | 30 | - :obj:`~pyrogram.types.InputMediaAnimation` 31 | - :obj:`~pyrogram.types.InputMediaDocument` 32 | - :obj:`~pyrogram.types.InputMediaAudio` 33 | - :obj:`~pyrogram.types.InputMediaPhoto` 34 | - :obj:`~pyrogram.types.InputMediaVideo` 35 | """ 36 | 37 | def __init__( 38 | self, 39 | media: Union[str, BinaryIO], 40 | caption: str = "", 41 | parse_mode: str = None, 42 | caption_entities: List[MessageEntity] = None 43 | ): 44 | super().__init__() 45 | 46 | self.media = media 47 | self.caption = caption 48 | self.parse_mode = parse_mode 49 | self.caption_entities = caption_entities 50 | -------------------------------------------------------------------------------- /pyrogram/types/input_message_content/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .input_message_content import InputMessageContent 20 | from .input_contact_message_content import InputContactMessageContent 21 | from .input_invoice_message_content import InputInvoiceMessageContent 22 | from .input_location_message_content import InputLocationMessageContent 23 | from .input_text_message_content import InputTextMessageContent 24 | from .input_venue_message_content import InputVenueMessageContent 25 | 26 | __all__ = [ 27 | "InputMessageContent", 28 | "InputContactMessageContent", 29 | "InputInvoiceMessageContent", 30 | "InputLocationMessageContent", 31 | "InputTextMessageContent", 32 | "InputVenueMessageContent" 33 | ] 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_message_content/input_message_content.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | 21 | from ..object import Object 22 | 23 | 24 | class InputMessageContent(Object): 25 | """Content of a message to be sent as a result of an inline query. 26 | 27 | Pyrogram currently supports the following types: 28 | 29 | - :obj:`~pyrogram.types.InputTextMessageContent` 30 | - :obj:`~pyrogram.types.InputLocationMessageContent` 31 | - :obj:`~pyrogram.types.InputVenueMessageContent` 32 | - :obj:`~pyrogram.types.InputContactMessageContent` 33 | - :obj:`~pyrogram.types.InputInvoiceMessageContent` 34 | """ 35 | 36 | def __init__(self): 37 | super().__init__() 38 | 39 | async def write(self, client: "pyrogram.Client", reply_markup): 40 | raise NotImplementedError 41 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | 21 | from ..object import Object 22 | 23 | 24 | class InputPrivacyRule(Object): 25 | """Content of a privacy rule. 26 | 27 | It should be one of: 28 | 29 | - :obj:`~pyrogram.types.InputPrivacyRuleAllowAll` 30 | - :obj:`~pyrogram.types.InputPrivacyRuleAllowContacts` 31 | - :obj:`~pyrogram.types.InputPrivacyRuleAllowPremium` 32 | - :obj:`~pyrogram.types.InputPrivacyRuleAllowUsers` 33 | - :obj:`~pyrogram.types.InputPrivacyRuleAllowChats` 34 | - :obj:`~pyrogram.types.InputPrivacyRuleDisallowAll` 35 | - :obj:`~pyrogram.types.InputPrivacyRuleDisallowContacts` 36 | - :obj:`~pyrogram.types.InputPrivacyRuleDisallowUsers` 37 | - :obj:`~pyrogram.types.InputPrivacyRuleDisallowChats` 38 | """ 39 | 40 | def __init__(self): 41 | super().__init__() 42 | 43 | async def write(self, client: "pyrogram.Client"): 44 | raise NotImplementedError 45 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_allow_all.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleAllowAll(InputPrivacyRule): 25 | """Allow all users.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueAllowAll() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_allow_bots.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleAllowBots(InputPrivacyRule): 25 | """Allow bots and miniapps.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueAllowBots() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_allow_close_friends.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleAllowCloseFriends(InputPrivacyRule): 25 | """Allow only close friends.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueAllowCloseFriends() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_allow_contacts.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleAllowContacts(InputPrivacyRule): 25 | """Allow contacts only.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueAllowContacts() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_allow_premium.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleAllowPremium(InputPrivacyRule): 25 | """Allow only users with a Premium subscription, currently only usable for :obj:`~pyrogram.enums.PrivacyKey.CHAT_INVITE`.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueAllowPremium() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_all.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleDisallowAll(InputPrivacyRule): 25 | """Disallow all users.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueDisallowAll() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_bots.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleDisallowBots(InputPrivacyRule): 25 | """Disallow bots and miniapps.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueDisallowBots() 34 | -------------------------------------------------------------------------------- /pyrogram/types/input_privacy_rule/input_privacy_rule_disallow_contacts.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from .input_privacy_rule import InputPrivacyRule 22 | 23 | 24 | class InputPrivacyRuleDisallowContacts(InputPrivacyRule): 25 | """Disallow contacts only.""" 26 | 27 | def __init__( 28 | self, 29 | ): 30 | super().__init__() 31 | 32 | async def write(self, client: "pyrogram.Client"): 33 | return raw.types.InputPrivacyValueDisallowContacts() 34 | -------------------------------------------------------------------------------- /pyrogram/types/list.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from .object import Object 20 | 21 | 22 | class List(list): 23 | __slots__ = [] 24 | 25 | def __str__(self): 26 | # noinspection PyCallByClass 27 | return Object.__str__(self) 28 | 29 | def __repr__(self): 30 | return f"pyrogram.types.List([{','.join(Object.__repr__(i) for i in self)}])" 31 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/chat_theme.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | 21 | from ..object import Object 22 | 23 | 24 | class ChatTheme(Object): 25 | """A theme in the chat has been changed. 26 | 27 | Parameters: 28 | name (``str``): 29 | Theme name. 30 | """ 31 | 32 | def __init__(self, *, name: str): 33 | super().__init__() 34 | 35 | self.name = name 36 | 37 | @staticmethod 38 | def _parse(action: "raw.types.MessageActionSetChatTheme") -> "ChatTheme": 39 | return ChatTheme(name=action.emoticon) 40 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/contact_registered.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class ContactRegistered(Object): 23 | """A service message that a contact has registered with Telegram. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/dice.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from ..object import Object 22 | 23 | 24 | class Dice(Object): 25 | """A dice with a random value from 1 to 6 for currently supported base emoji. 26 | 27 | Parameters: 28 | emoji (``string``): 29 | Emoji on which the dice throw animation is based. 30 | 31 | value (``int``): 32 | Value of the dice, 1-6 for currently supported base emoji. 33 | """ 34 | 35 | def __init__(self, *, client: "pyrogram.Client" = None, emoji: str, value: int): 36 | super().__init__(client) 37 | 38 | self.emoji = emoji 39 | self.value = value 40 | 41 | @staticmethod 42 | def _parse(client, dice: "raw.types.MessageMediaDice") -> "Dice": 43 | return Dice( 44 | emoji=dice.emoticon, 45 | value=dice.value, 46 | client=client 47 | ) 48 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/forum_topic_closed.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class ForumTopicClosed(Object): 23 | """A service message about a forum topic closed in the chat. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/forum_topic_reopened.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class ForumTopicReopened(Object): 23 | """A service message about a forum topic reopened in the chat. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/general_forum_topic_hidden.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class GeneralForumTopicHidden(Object): 23 | """A service message about a general topic hidden in the chat. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/general_forum_topic_unhidden.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class GeneralForumTopicUnhidden(Object): 23 | """A service message about a general topic unhidden in the chat. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/paid_messages_price_changed.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | 21 | from ..object import Object 22 | 23 | 24 | class PaidMessagesPriceChanged(Object): 25 | """A price for paid messages was changed in the supergroup chat. 26 | 27 | Parameters: 28 | paid_message_star_count (``int``): 29 | The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message. 30 | """ 31 | 32 | def __init__( 33 | self, 34 | *, 35 | paid_message_star_count: int 36 | ): 37 | 38 | super().__init__() 39 | 40 | self.paid_message_star_count = paid_message_star_count 41 | 42 | @staticmethod 43 | def _parse( 44 | action: "raw.types.MessageActionPaidMessagesPrice" 45 | ) -> "PaidMessagesPriceChanged": 46 | return PaidMessagesPriceChanged( 47 | paid_message_star_count=action.stars 48 | ) 49 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/poll_option.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from ..object import Object 21 | 22 | 23 | class PollOption(Object): 24 | """Contains information about one answer option in a poll. 25 | 26 | Parameters: 27 | text (``str``): 28 | Option text, 1-100 characters. 29 | 30 | voter_count (``int``): 31 | Number of users that voted for this option. 32 | Equals to 0 until you vote. 33 | 34 | data (``bytes``): 35 | The data this poll option is holding. 36 | """ 37 | 38 | def __init__( 39 | self, 40 | *, 41 | client: "pyrogram.Client" = None, 42 | text: str, 43 | voter_count: int, 44 | data: bytes 45 | ): 46 | super().__init__(client) 47 | 48 | self.text = text 49 | self.voter_count = voter_count 50 | self.data = data 51 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/screenshot_taken.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class ScreenshotTaken(Object): 23 | """A service message that a screenshot of a message in the chat has been taken. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/stripped_thumbnail.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | from pyrogram import raw 21 | from ..object import Object 22 | 23 | 24 | class StrippedThumbnail(Object): 25 | """A stripped thumbnail 26 | 27 | Parameters: 28 | data (``bytes``): 29 | Thumbnail data 30 | """ 31 | 32 | def __init__( 33 | self, 34 | *, 35 | client: "pyrogram.Client" = None, 36 | data: bytes 37 | ): 38 | super().__init__(client) 39 | 40 | self.data = data 41 | 42 | @staticmethod 43 | def _parse(client, stripped_thumbnail: "raw.types.PhotoStrippedSize") -> "StrippedThumbnail": 44 | return StrippedThumbnail( 45 | data=stripped_thumbnail.bytes, 46 | client=client 47 | ) 48 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/upgraded_gift_attribute_id_backdrop.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | from pyrogram import raw 19 | 20 | from .upgraded_gift_attribute_id import UpgradedGiftAttributeId 21 | 22 | 23 | class UpgradedGiftAttributeIdBackdrop(UpgradedGiftAttributeId): 24 | """Identifier of a gift backdrop. 25 | 26 | Parameters: 27 | backdrop_id (``int``): 28 | Identifier of the sticker representing the backdrop. 29 | """ 30 | def __init__( 31 | self, 32 | backdrop_id: int, 33 | ): 34 | super().__init__() 35 | 36 | self.backdrop_id = backdrop_id 37 | 38 | def write(self) -> "raw.types.StarGiftAttributeIdBackdrop": 39 | return raw.types.StarGiftAttributeIdBackdrop( 40 | backdrop_id=self.backdrop_id 41 | ) 42 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/upgraded_gift_attribute_id_model.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | from pyrogram import raw 19 | 20 | from .upgraded_gift_attribute_id import UpgradedGiftAttributeId 21 | 22 | 23 | class UpgradedGiftAttributeIdModel(UpgradedGiftAttributeId): 24 | """Identifier of a gift model. 25 | 26 | Parameters: 27 | sticker_id (``int``): 28 | Identifier of the sticker representing the model. 29 | """ 30 | def __init__( 31 | self, 32 | sticker_id: int, 33 | ): 34 | super().__init__() 35 | 36 | self.sticker_id = sticker_id 37 | 38 | def write(self) -> "raw.types.StarGiftAttributeIdModel": 39 | return raw.types.StarGiftAttributeIdModel( 40 | document_id=self.sticker_id 41 | ) 42 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/upgraded_gift_attribute_id_symbol.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | from pyrogram import raw 19 | 20 | from .upgraded_gift_attribute_id import UpgradedGiftAttributeId 21 | 22 | 23 | class UpgradedGiftAttributeIdSymbol(UpgradedGiftAttributeId): 24 | """Identifier of a gift symbol. 25 | 26 | Parameters: 27 | sticker_id (``int``): 28 | Identifier of the sticker representing the symnbol. 29 | """ 30 | def __init__( 31 | self, 32 | sticker_id: int, 33 | ): 34 | super().__init__() 35 | 36 | self.sticker_id = sticker_id 37 | 38 | def write(self) -> "raw.types.StarGiftAttributeIdPattern": 39 | return raw.types.StarGiftAttributeIdPattern( 40 | document_id=self.sticker_id 41 | ) 42 | -------------------------------------------------------------------------------- /pyrogram/types/messages_and_media/web_app_data.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from ..object import Object 21 | 22 | 23 | class WebAppData(Object): 24 | """Contains data sent from a `Web App `_ to the bot. 25 | 26 | Parameters: 27 | data (``str``): 28 | The data. 29 | 30 | button_text (``str``): 31 | Text of the *web_app* keyboard button, from which the Web App was opened. 32 | 33 | """ 34 | 35 | def __init__( 36 | self, 37 | *, 38 | data: str, 39 | button_text: str, 40 | ): 41 | super().__init__() 42 | 43 | self.data = data 44 | self.button_text = button_text 45 | 46 | @staticmethod 47 | def _parse(action: "raw.types.MessageActionWebViewDataSentMe"): 48 | return WebAppData( 49 | data=action.data, 50 | button_text=action.text 51 | ) 52 | -------------------------------------------------------------------------------- /pyrogram/types/update.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | import pyrogram 20 | 21 | 22 | class Update: 23 | def stop_propagation(self): 24 | raise pyrogram.StopPropagation 25 | 26 | def continue_propagation(self): 27 | raise pyrogram.ContinuePropagation 28 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/business_weekly_open.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from ..object import Object 21 | 22 | 23 | class BusinessWeeklyOpen(Object): 24 | """Business weekly open hours. 25 | 26 | Parameters: 27 | start_minute (``int``): 28 | Start minute of the working day. 29 | 30 | end_minute (``int``): 31 | End minute of the working day. 32 | """ 33 | 34 | def __init__( 35 | self, 36 | *, 37 | start_minute: int, 38 | end_minute: int, 39 | 40 | ): 41 | self.start_minute = start_minute 42 | self.end_minute = end_minute 43 | 44 | @staticmethod 45 | def _parse(weekly_open: "raw.types.BusinessWeeklyOpen" = None) -> "BusinessWeeklyOpen": 46 | return BusinessWeeklyOpen( 47 | start_minute=weekly_open.start_minute, 48 | end_minute=weekly_open.end_minute, 49 | ) 50 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/history_cleared.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class HistoryCleared(Object): 23 | """A service message about a cleared history in chat. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/phone_call_started.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from ..object import Object 21 | 22 | 23 | class PhoneCallStarted(Object): 24 | """A service message about a phone_call started in the chat. 25 | 26 | Parameters: 27 | id (``int``): 28 | Unique call identifier. 29 | 30 | is_video (``bool``): 31 | True, if call was a video call. 32 | """ 33 | 34 | def __init__( 35 | self, *, 36 | id: int, 37 | is_video: bool 38 | ): 39 | super().__init__() 40 | 41 | self.id = id 42 | self.is_video = is_video 43 | 44 | @staticmethod 45 | def _parse(action: "raw.types.MessageActionPhoneCall") -> "PhoneCallStarted": 46 | return PhoneCallStarted( 47 | id=action.call_id, 48 | is_video=action.video 49 | ) 50 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/video_chat_ended.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from pyrogram import raw 20 | from ..object import Object 21 | 22 | 23 | class VideoChatEnded(Object): 24 | """A service message about a voice chat ended in the chat. 25 | 26 | Parameters: 27 | duration (``int``): 28 | Voice chat duration; in seconds. 29 | """ 30 | 31 | def __init__( 32 | self, *, 33 | duration: int 34 | ): 35 | super().__init__() 36 | 37 | self.duration = duration 38 | 39 | @staticmethod 40 | def _parse(action: "raw.types.MessageActionGroupCall") -> "VideoChatEnded": 41 | return VideoChatEnded(duration=action.duration) 42 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/video_chat_members_invited.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from typing import List, Dict 20 | 21 | from pyrogram import raw, types 22 | from ..object import Object 23 | 24 | 25 | class VideoChatMembersInvited(Object): 26 | """A service message about new members invited to a voice chat. 27 | 28 | 29 | Parameters: 30 | users (List of :obj:`~pyrogram.types.User`): 31 | New members that were invited to the voice chat. 32 | """ 33 | 34 | def __init__( 35 | self, *, 36 | users: List["types.User"] 37 | ): 38 | super().__init__() 39 | 40 | self.users = users 41 | 42 | @staticmethod 43 | def _parse( 44 | client, 45 | action: "raw.types.MessageActionInviteToGroupCall", 46 | users: Dict[int, "raw.types.User"] 47 | ) -> "VideoChatMembersInvited": 48 | users = [types.User._parse(client, users[i]) for i in action.users] 49 | 50 | return VideoChatMembersInvited(users=users) 51 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/video_chat_scheduled.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from datetime import datetime 20 | 21 | from pyrogram import raw, utils 22 | from ..object import Object 23 | 24 | 25 | class VideoChatScheduled(Object): 26 | """A service message about a voice chat scheduled in the chat. 27 | 28 | Parameters: 29 | start_date (:py:obj:`~datetime.datetime`): 30 | Point in time when the voice chat is supposed to be started by a chat administrator. 31 | """ 32 | 33 | def __init__( 34 | self, *, 35 | start_date: datetime 36 | ): 37 | super().__init__() 38 | 39 | self.start_date = start_date 40 | 41 | @staticmethod 42 | def _parse(action: "raw.types.MessageActionGroupCallScheduled") -> "VideoChatScheduled": 43 | return VideoChatScheduled(start_date=utils.timestamp_to_datetime(action.schedule_date)) 44 | -------------------------------------------------------------------------------- /pyrogram/types/user_and_chats/video_chat_started.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | from ..object import Object 20 | 21 | 22 | class VideoChatStarted(Object): 23 | """A service message about a voice chat started in the chat. 24 | 25 | Currently holds no information. 26 | """ 27 | 28 | def __init__(self): 29 | super().__init__() 30 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | -------------------------------------------------------------------------------- /tests/filters/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | 19 | class Client: 20 | def __init__(self): 21 | self.me = User("username") 22 | 23 | async def get_me(self): 24 | return self.me 25 | 26 | 27 | class User: 28 | def __init__(self, username: str = None): 29 | self.username = username 30 | 31 | 32 | class Message: 33 | def __init__(self, text: str = None, caption: str = None): 34 | self.text = text 35 | self.caption = caption 36 | self.command = None 37 | -------------------------------------------------------------------------------- /tests/parser/__init__.py: -------------------------------------------------------------------------------- 1 | # Pyrogram - Telegram MTProto API Client Library for Python 2 | # Copyright (C) 2017-present Dan 3 | # 4 | # This file is part of Pyrogram. 5 | # 6 | # Pyrogram is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Lesser General Public License as published 8 | # by the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pyrogram is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public License 17 | # along with Pyrogram. If not, see . 18 | --------------------------------------------------------------------------------