├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml └── workflows │ └── 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 │ │ ├── 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 ├── dev-requirements.txt ├── pyrography ├── __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 ├── emoji.py ├── enums │ ├── __init__.py │ ├── auto_name.py │ ├── chat_action.py │ ├── chat_event_action.py │ ├── chat_member_status.py │ ├── chat_members_filter.py │ ├── chat_type.py │ ├── message_entity_type.py │ ├── message_media_type.py │ ├── message_service_type.py │ ├── messages_filter.py │ ├── next_code_type.py │ ├── parse_mode.py │ ├── poll_type.py │ ├── sent_code_type.py │ └── user_status.py ├── errors │ ├── __init__.py │ └── rpc_error.py ├── file_id.py ├── filters.py ├── handlers │ ├── __init__.py │ ├── callback_query_handler.py │ ├── chat_join_request_handler.py │ ├── chat_member_updated_handler.py │ ├── chosen_inline_result_handler.py │ ├── deleted_messages_handler.py │ ├── disconnect_handler.py │ ├── edited_message_handler.py │ ├── handler.py │ ├── inline_query_handler.py │ ├── message_handler.py │ ├── poll_handler.py │ ├── raw_update_handler.py │ └── user_status_handler.py ├── methods │ ├── __init__.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_password_hint.py │ │ ├── initialize.py │ │ ├── log_out.py │ │ ├── recover_password.py │ │ ├── resend_code.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_web_app_query.py │ │ ├── delete_bot_commands.py │ │ ├── get_bot_commands.py │ │ ├── get_bot_default_privileges.py │ │ ├── get_chat_menu_button.py │ │ ├── get_game_high_scores.py │ │ ├── get_inline_bot_results.py │ │ ├── request_callback_answer.py │ │ ├── send_game.py │ │ ├── send_inline_bot_result.py │ │ ├── set_bot_commands.py │ │ ├── set_bot_default_privileges.py │ │ ├── set_chat_menu_button.py │ │ └── set_game_score.py │ ├── chats │ │ ├── __init__.py │ │ ├── add_chat_members.py │ │ ├── archive_chats.py │ │ ├── ban_chat_member.py │ │ ├── create_channel.py │ │ ├── create_group.py │ │ ├── create_supergroup.py │ │ ├── delete_channel.py │ │ ├── delete_chat_photo.py │ │ ├── delete_supergroup.py │ │ ├── delete_user_history.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_dialogs.py │ │ ├── get_dialogs_count.py │ │ ├── get_nearby_chats.py │ │ ├── get_send_as_chats.py │ │ ├── join_chat.py │ │ ├── leave_chat.py │ │ ├── mark_chat_unread.py │ │ ├── pin_chat_message.py │ │ ├── promote_chat_member.py │ │ ├── restrict_chat_member.py │ │ ├── set_administrator_title.py │ │ ├── set_chat_description.py │ │ ├── set_chat_permissions.py │ │ ├── set_chat_photo.py │ │ ├── set_chat_protected_content.py │ │ ├── set_chat_title.py │ │ ├── set_chat_username.py │ │ ├── set_send_as_chat.py │ │ ├── set_slow_mode.py │ │ ├── unarchive_chats.py │ │ ├── unban_chat_member.py │ │ ├── unpin_all_chat_messages.py │ │ └── unpin_chat_message.py │ ├── contacts │ │ ├── __init__.py │ │ ├── add_contact.py │ │ ├── delete_contacts.py │ │ ├── get_contacts.py │ │ ├── get_contacts_count.py │ │ └── import_contacts.py │ ├── decorators │ │ ├── __init__.py │ │ ├── on_callback_query.py │ │ ├── on_chat_join_request.py │ │ ├── on_chat_member_updated.py │ │ ├── on_chosen_inline_result.py │ │ ├── on_deleted_messages.py │ │ ├── on_disconnect.py │ │ ├── on_edited_message.py │ │ ├── on_inline_query.py │ │ ├── on_message.py │ │ ├── on_poll.py │ │ ├── on_raw_update.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 │ │ ├── copy_media_group.py │ │ ├── copy_message.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_messages.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 │ │ ├── inline_session.py │ │ ├── read_chat_history.py │ │ ├── retract_vote.py │ │ ├── search_global.py │ │ ├── search_global_count.py │ │ ├── search_messages.py │ │ ├── search_messages_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_photo.py │ │ ├── send_poll.py │ │ ├── send_reaction.py │ │ ├── send_sticker.py │ │ ├── send_venue.py │ │ ├── send_video.py │ │ ├── send_video_note.py │ │ ├── send_voice.py │ │ ├── stop_poll.py │ │ ├── stream_media.py │ │ ├── vote_poll.py │ │ └── wait_for.py │ ├── password │ │ ├── __init__.py │ │ ├── change_cloud_password.py │ │ ├── enable_cloud_password.py │ │ └── remove_cloud_password.py │ ├── users │ │ ├── __init__.py │ │ ├── block_user.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_profile_photo.py │ │ ├── set_username.py │ │ ├── unblock_user.py │ │ └── update_profile.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 ├── 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 │ │ ├── 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 │ │ ├── force_reply.py │ │ ├── game_high_score.py │ │ ├── inline_keyboard_button.py │ │ ├── inline_keyboard_markup.py │ │ ├── keyboard_button.py │ │ ├── login_url.py │ │ ├── menu_button.py │ │ ├── menu_button_commands.py │ │ ├── menu_button_default.py │ │ ├── menu_button_web_app.py │ │ ├── reply_keyboard_markup.py │ │ ├── reply_keyboard_remove.py │ │ ├── sent_web_app_message.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_message_content.py │ │ └── input_text_message_content.py │ ├── list.py │ ├── messages_and_media │ │ ├── __init__.py │ │ ├── animation.py │ │ ├── audio.py │ │ ├── contact.py │ │ ├── dice.py │ │ ├── document.py │ │ ├── game.py │ │ ├── location.py │ │ ├── message.py │ │ ├── message_entity.py │ │ ├── message_reactions.py │ │ ├── photo.py │ │ ├── poll.py │ │ ├── poll_option.py │ │ ├── reaction.py │ │ ├── sticker.py │ │ ├── stripped_thumbnail.py │ │ ├── thumbnail.py │ │ ├── venue.py │ │ ├── video.py │ │ ├── video_note.py │ │ ├── voice.py │ │ ├── web_app_data.py │ │ └── web_page.py │ ├── object.py │ ├── update.py │ └── user_and_chats │ │ ├── __init__.py │ │ ├── chat.py │ │ ├── chat_admin_with_invite_links.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_preview.py │ │ ├── chat_privileges.py │ │ ├── chat_reactions.py │ │ ├── dialog.py │ │ ├── emoji_status.py │ │ ├── invite_link_importer.py │ │ ├── restriction.py │ │ ├── user.py │ │ ├── video_chat_ended.py │ │ ├── video_chat_members_invited.py │ │ ├── video_chat_scheduled.py │ │ └── video_chat_started.py └── utils.py ├── requirements.txt ├── setup.py ├── tests ├── __init__.py ├── filters │ ├── __init__.py │ └── test_command.py ├── parser │ ├── __init__.py │ └── test_html.py └── test_file_id.py └── tox.ini /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: delivrance 2 | liberapay: delivrance 3 | open_collective: pyrogram 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Report issues affecting the framework or the documentation 3 | body: 4 | - type: checkboxes 5 | attributes: 6 | label: Checklist 7 | description: Invalid, incomplete or inadequate issue reports may not be taken into consideration 8 | options: 9 | - label: I am sure the error is coming from Pyrogram's code and not elsewhere 10 | required: true 11 | - label: I have searched in the issue tracker for similar bug reports, including closed ones 12 | required: true 13 | - label: I ran `pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip` and reproduced the issue using the latest development version 14 | required: true 15 | 16 | - type: textarea 17 | attributes: 18 | label: Description 19 | description: Provide a clear and concise description of the issue 20 | placeholder: Description... 21 | validations: 22 | required: true 23 | 24 | - type: textarea 25 | attributes: 26 | label: Steps to reproduce 27 | description: Explain precisely how to reproduce the issue 28 | placeholder: | 29 | 1. 30 | 2. 31 | 3. 32 | validations: 33 | required: true 34 | 35 | - type: textarea 36 | attributes: 37 | label: Code example 38 | description: Provide a [minimal, complete, consistently reproducible](https://stackoverflow.com/help/minimal-reproducible-example) and properly formatted example involving normal usages (if applicable) 39 | placeholder: | 40 | from pyrography import Client 41 | ... 42 | render: python 43 | 44 | - type: textarea 45 | attributes: 46 | label: Logs 47 | description: Provide the complete traceback (if applicable) 48 | placeholder: | 49 | Traceback (most recent call last): 50 | File "main.py", line 1, in 51 | ... 52 | render: shell -------------------------------------------------------------------------------- /.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/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.7", "3.8", "3.9", "3.10", "3.11"] 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Set up Python ${{ matrix.python-version }} 18 | uses: actions/setup-python@v2 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 -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | ## Include 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 7 | prune pyrogram/errors/exceptions 8 | prune pyrogram/raw/functions 9 | prune pyrogram/raw/types 10 | prune pyrogram/raw/base 11 | exclude pyrogram/raw/all.py 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VENV := venv 2 | PYTHON := $(VENV)/bin/python 3 | HOST = $(shell ifconfig | grep "inet " | tail -1 | cut -d\ -f2) 4 | TAG = v$(shell grep -E '__version__ = ".*"' pyrography/__init__.py | cut -d\" -f2) 5 | 6 | RM := rm -rf 7 | 8 | .PHONY: venv clean-build clean-api clean api build 9 | 10 | venv: 11 | $(RM) $(VENV) 12 | python3 -m venv $(VENV) 13 | $(PYTHON) -m pip install -U pip wheel setuptools 14 | $(PYTHON) -m pip install -U -r requirements.txt -r dev-requirements.txt 15 | @echo "Created venv with $$($(PYTHON) --version)" 16 | 17 | clean-build: 18 | $(RM) *.egg-info build dist 19 | 20 | clean-api: 21 | $(RM) pyrography/errors/exceptions pyrography/raw/all.py pyrography/raw/base pyrography/raw/functions pyrography/raw/types 22 | 23 | clean: 24 | make clean-build 25 | make clean-api 26 | 27 | api: 28 | cd compiler/api && ../../$(PYTHON) compiler.py 29 | cd compiler/errors && ../../$(PYTHON) compiler.py 30 | 31 | build: 32 | make clean 33 | $(PYTHON) setup.py sdist 34 | $(PYTHON) setup.py bdist_wheel 35 | 36 | tag: 37 | git tag $(TAG) 38 | git push origin $(TAG) 39 | 40 | dtag: 41 | git tag -d $(TAG) 42 | git push origin -d $(TAG) -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 2 | Copyright (C) 2023-present Lelzin λ 3 | 4 | Forked from Pyrogram , 5 | originally copyright (C) 2017-present Dan 6 | 7 | This file is part of Pyrography. 8 | 9 | Pyrography is is free software: you can redistribute it and/or modify it under 10 | the terms of the GNU Lesser General Public License as published by the Free 11 | Software Foundation, either version 3 of the License, or (at your option) any 12 | later version. 13 | 14 | Pyrography is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 17 | for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License along 20 | with Pyrography. If not, see . -------------------------------------------------------------------------------- /compiler/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | -------------------------------------------------------------------------------- /compiler/api/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | -------------------------------------------------------------------------------- /compiler/api/template/combinator.txt: -------------------------------------------------------------------------------- 1 | {notice} 2 | 3 | from io import BytesIO 4 | 5 | from pyrography.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector 6 | from pyrography.raw.core import TLObject 7 | from pyrography 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 pyrography import raw 7 | from pyrography.raw.core import TLObject 8 | 9 | {name} = Union[{types}] 10 | 11 | 12 | # noinspection PyRedeclaration 13 | class {name}: # type: ignore 14 | """{docstring} 15 | """ 16 | 17 | QUALNAME = "pyrography.raw.base.{qualname}" 18 | 19 | def __init__(self): 20 | raise TypeError("Base types can only be used for type checking purposes: " 21 | "you tried to use a base type instance as argument, " 22 | "but you need to instantiate one of its constructors instead. " 23 | "More info: https://docs.pyrogram.org/telegram/base/{doc_name}") 24 | -------------------------------------------------------------------------------- /compiler/docs/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ -------------------------------------------------------------------------------- /compiler/docs/template/bound-methods.rst: -------------------------------------------------------------------------------- 1 | Bound Methods 2 | ============= 3 | 4 | Some Pyrography types define what are called bound methods. Bound methods are functions attached to a type which are 5 | accessed via an instance of that type. They make it even easier to call specific methods by automatically inferring 6 | some of the required arguments. 7 | 8 | .. code-block:: python 9 | 10 | from pyrography import Client 11 | 12 | app = Client("my_account") 13 | 14 | 15 | @app.on_message() 16 | def hello(client, message) 17 | message.reply("hi") 18 | 19 | 20 | app.run() 21 | 22 | ----- 23 | 24 | .. currentmodule:: pyrography.types 25 | 26 | Message 27 | ------- 28 | 29 | .. hlist:: 30 | :columns: 3 31 | 32 | {message_hlist} 33 | 34 | .. toctree:: 35 | :hidden: 36 | 37 | {message_toctree} 38 | 39 | Chat 40 | ---- 41 | 42 | .. hlist:: 43 | :columns: 4 44 | 45 | {chat_hlist} 46 | 47 | .. toctree:: 48 | :hidden: 49 | 50 | {chat_toctree} 51 | 52 | User 53 | ---- 54 | 55 | .. hlist:: 56 | :columns: 2 57 | 58 | {user_hlist} 59 | 60 | .. toctree:: 61 | :hidden: 62 | 63 | {user_toctree} 64 | 65 | CallbackQuery 66 | ------------- 67 | 68 | .. hlist:: 69 | :columns: 3 70 | 71 | {callback_query_hlist} 72 | 73 | .. toctree:: 74 | :hidden: 75 | 76 | {callback_query_toctree} 77 | 78 | InlineQuery 79 | ----------- 80 | 81 | .. hlist:: 82 | :columns: 2 83 | 84 | {inline_query_hlist} 85 | 86 | .. toctree:: 87 | :hidden: 88 | 89 | {inline_query_toctree} 90 | 91 | ChatJoinRequest 92 | --------------- 93 | 94 | .. hlist:: 95 | :columns: 2 96 | 97 | {chat_join_request_hlist} 98 | 99 | .. toctree:: 100 | :hidden: 101 | 102 | {chat_join_request_toctree} 103 | 104 | -------------------------------------------------------------------------------- /compiler/docs/template/page.txt: -------------------------------------------------------------------------------- 1 | {title} 2 | {title_markup} 3 | 4 | .. autoclass:: {full_class_path}() 5 | :members: 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 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | -------------------------------------------------------------------------------- /compiler/errors/sort.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import csv 25 | from pathlib import Path 26 | 27 | for p in Path("source").glob("*.tsv"): 28 | with open(p) as f: 29 | reader = csv.reader(f, delimiter="\t") 30 | dct = {k: v for k, v in reader if k != "id"} 31 | keys = sorted(dct) 32 | 33 | with open(p, "w") as f: 34 | f.write("id\tmessage\n") 35 | 36 | for i, item in enumerate(keys, start=1): 37 | f.write(f"{item}\t{dct[item]}") 38 | 39 | if i != len(keys): 40 | f.write("\n") 41 | -------------------------------------------------------------------------------- /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/403_FORBIDDEN.tsv: -------------------------------------------------------------------------------- 1 | id message 2 | BROADCAST_FORBIDDEN The request can't be used in channels 3 | CHANNEL_PUBLIC_GROUP_NA The channel/supergroup is not available 4 | CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users 5 | CHAT_ADMIN_REQUIRED The method requires chat admin privileges 6 | CHAT_FORBIDDEN You cannot write in this chat 7 | CHAT_SEND_GIFS_FORBIDDEN You can't send animations in this chat 8 | CHAT_SEND_INLINE_FORBIDDEN You cannot use inline bots to send messages in this chat 9 | CHAT_SEND_MEDIA_FORBIDDEN You can't send media messages in this chat 10 | CHAT_SEND_POLL_FORBIDDEN You can't send polls in this chat 11 | CHAT_SEND_STICKERS_FORBIDDEN You can't send stickers in this chat 12 | CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat 13 | EDIT_BOT_INVITE_FORBIDDEN Bots' chat invite links can't be edited 14 | INLINE_BOT_REQUIRED The action must be performed through an inline bot callback 15 | MESSAGE_AUTHOR_REQUIRED You are not the author of this message 16 | MESSAGE_DELETE_FORBIDDEN You don't have rights to delete messages in this chat, most likely because you are not the author of them 17 | POLL_VOTE_REQUIRED Cast a vote in the poll before calling this method 18 | PREMIUM_ACCOUNT_REQUIRED This action requires a premium account 19 | RIGHT_FORBIDDEN You don't have enough rights for this action, or you tried to set one or more admin rights that can't be applied to this kind of chat (channel or supergroup) 20 | SENSITIVE_CHANGE_FORBIDDEN Your sensitive content settings can't be changed at this time 21 | TAKEOUT_REQUIRED The method must be invoked inside a takeout session 22 | USER_BOT_INVALID This method can only be called by a bot 23 | USER_CHANNELS_TOO_MUCH One of the users you tried to add is already in too many channels/supergroups 24 | USER_INVALID The provided user is invalid 25 | USER_IS_BLOCKED The user is blocked 26 | USER_NOT_MUTUAL_CONTACT The provided user is not a mutual contact 27 | USER_PRIVACY_RESTRICTED The user's privacy settings is preventing you to perform this action 28 | USER_RESTRICTED You are limited/restricted. You can't perform this action -------------------------------------------------------------------------------- /compiler/errors/source/406_NOT_ACCEPTABLE.tsv: -------------------------------------------------------------------------------- 1 | id message 2 | AUTH_KEY_DUPLICATED The same authorization key (session file) was used in more than one place simultaneously. You must delete your session file and log in again with your phone number or bot token 3 | CHANNEL_PRIVATE The channel/supergroup is not accessible 4 | FILEREF_UPGRADE_NEEDED The file reference has expired and you must use a refreshed one by obtaining the original media message 5 | FRESH_CHANGE_ADMINS_FORBIDDEN You were just elected admin, you can't add or modify other admins yet 6 | FRESH_CHANGE_PHONE_FORBIDDEN You can't change your phone number because your session was logged-in recently 7 | FRESH_RESET_AUTHORISATION_FORBIDDEN You can't terminate other authorized sessions because the current was logged-in recently 8 | PHONE_NUMBER_INVALID The phone number is invalid 9 | PHONE_PASSWORD_FLOOD You have tried to log-in too many times 10 | STICKERSET_INVALID The sticker set is invalid 11 | STICKERSET_OWNER_ANONYMOUS This sticker set can't be used as the group's sticker set because it was created by one of its anonymous admins 12 | USERPIC_UPLOAD_REQUIRED You must have a profile picture to publish your geolocation 13 | USER_RESTRICTED You are limited/restricted. You can't perform this action -------------------------------------------------------------------------------- /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 | FLOOD_TEST_PHONE_WAIT_X A wait of {value} seconds is required in the test servers 4 | FLOOD_WAIT_X A wait of {value} seconds is required 5 | SLOWMODE_WAIT_X A wait of {value} seconds is required to send messages in this chat. 6 | 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 | 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 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements.txt 2 | 3 | pytest 4 | pytest-asyncio 5 | pytest-cov 6 | twine -------------------------------------------------------------------------------- /pyrography/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | __version__ = "1.0.2" 25 | __license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)" 26 | __copyright__ = ( 27 | 'Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram.\n' 28 | 'Copyright (C) 2023-present Lelzin λ \n\n' 29 | 30 | 'Forked from Pyrogram ,\n' 31 | 'originally copyright (C) 2017-present Dan ' 32 | ) 33 | 34 | from concurrent.futures.thread import ThreadPoolExecutor 35 | 36 | 37 | class StopTransmission(Exception): 38 | pass 39 | 40 | 41 | class StopPropagation(StopAsyncIteration): 42 | pass 43 | 44 | 45 | class ContinuePropagation(StopAsyncIteration): 46 | pass 47 | 48 | 49 | from . import raw, types, filters, handlers, emoji, enums 50 | from .client import Client 51 | from .sync import idle, compose 52 | 53 | crypto_executor = ThreadPoolExecutor(1, thread_name_prefix="CryptoWorker") 54 | -------------------------------------------------------------------------------- /pyrography/connection/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .connection import Connection 25 | -------------------------------------------------------------------------------- /pyrography/connection/transport/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .tcp import * 25 | -------------------------------------------------------------------------------- /pyrography/connection/transport/tcp/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .tcp import TCP 25 | from .tcp_abridged import TCPAbridged 26 | from .tcp_abridged_o import TCPAbridgedO 27 | from .tcp_full import TCPFull 28 | from .tcp_intermediate import TCPIntermediate 29 | from .tcp_intermediate_o import TCPIntermediateO 30 | -------------------------------------------------------------------------------- /pyrography/connection/transport/tcp/tcp_abridged.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | from typing import Optional 26 | 27 | from .tcp import TCP 28 | 29 | log = logging.getLogger(__name__) 30 | 31 | 32 | class TCPAbridged(TCP): 33 | def __init__(self, ipv6: bool, proxy: dict): 34 | super().__init__(ipv6, proxy) 35 | 36 | async def connect(self, address: tuple): 37 | await super().connect(address) 38 | await super().send(b"\xef") 39 | 40 | async def send(self, data: bytes, *args): 41 | length = len(data) // 4 42 | 43 | await super().send( 44 | (bytes([length]) 45 | if length <= 126 46 | else b"\x7f" + length.to_bytes(3, "little")) 47 | + data 48 | ) 49 | 50 | async def recv(self, length: int = 0) -> Optional[bytes]: 51 | length = await super().recv(1) 52 | 53 | if length is None: 54 | return None 55 | 56 | if length == b"\x7f": 57 | length = await super().recv(3) 58 | 59 | if length is None: 60 | return None 61 | 62 | return await super().recv(int.from_bytes(length, "little") * 4) 63 | -------------------------------------------------------------------------------- /pyrography/connection/transport/tcp/tcp_intermediate.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | from struct import pack, unpack 26 | from typing import Optional 27 | 28 | from .tcp import TCP 29 | 30 | log = logging.getLogger(__name__) 31 | 32 | 33 | class TCPIntermediate(TCP): 34 | def __init__(self, ipv6: bool, proxy: dict): 35 | super().__init__(ipv6, proxy) 36 | 37 | async def connect(self, address: tuple): 38 | await super().connect(address) 39 | await super().send(b"\xee" * 4) 40 | 41 | async def send(self, data: bytes, *args): 42 | await super().send(pack(" Optional[bytes]: 45 | length = await super().recv(4) 46 | 47 | if length is None: 48 | return None 49 | 50 | return await super().recv(unpack(" 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | -------------------------------------------------------------------------------- /pyrography/enums/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .chat_action import ChatAction 25 | from .chat_event_action import ChatEventAction 26 | from .chat_member_status import ChatMemberStatus 27 | from .chat_members_filter import ChatMembersFilter 28 | from .chat_type import ChatType 29 | from .message_entity_type import MessageEntityType 30 | from .message_media_type import MessageMediaType 31 | from .message_service_type import MessageServiceType 32 | from .messages_filter import MessagesFilter 33 | from .next_code_type import NextCodeType 34 | from .parse_mode import ParseMode 35 | from .poll_type import PollType 36 | from .sent_code_type import SentCodeType 37 | from .user_status import UserStatus 38 | 39 | __all__ = [ 40 | 'ChatAction', 41 | 'ChatEventAction', 42 | 'ChatMemberStatus', 43 | 'ChatMembersFilter', 44 | 'ChatType', 45 | 'MessageEntityType', 46 | 'MessageMediaType', 47 | 'MessageServiceType', 48 | 'MessagesFilter', 49 | 'NextCodeType', 50 | 'ParseMode', 51 | 'PollType', 52 | 'SentCodeType', 53 | 'UserStatus' 54 | ] 55 | -------------------------------------------------------------------------------- /pyrography/enums/auto_name.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class AutoName(Enum): 28 | def _generate_next_value_(self, *args): 29 | return self.lower() 30 | 31 | def __repr__(self): 32 | return f"pyrography.enums.{self}" 33 | -------------------------------------------------------------------------------- /pyrography/enums/chat_member_status.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import auto 25 | 26 | from .auto_name import AutoName 27 | 28 | 29 | class ChatMemberStatus(AutoName): 30 | """Chat member status enumeration used in :obj:`~pyrography.types.ChatMember`.""" 31 | 32 | OWNER = auto() 33 | "Chat owner" 34 | 35 | ADMINISTRATOR = auto() 36 | "Chat administrator" 37 | 38 | MEMBER = auto() 39 | "Chat member" 40 | 41 | RESTRICTED = auto() 42 | "Restricted chat member" 43 | 44 | LEFT = auto() 45 | "Left chat member" 46 | 47 | BANNED = auto() 48 | "Banned chat member" 49 | -------------------------------------------------------------------------------- /pyrography/enums/chat_members_filter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from .auto_name import AutoName 26 | 27 | 28 | class ChatMembersFilter(AutoName): 29 | """Chat members filter enumeration used in :meth:`~pyrography.Client.get_chat_members`""" 30 | 31 | SEARCH = raw.types.ChannelParticipantsSearch 32 | "Search for members" 33 | 34 | BANNED = raw.types.ChannelParticipantsKicked 35 | "Banned members" 36 | 37 | RESTRICTED = raw.types.ChannelParticipantsBanned 38 | "Restricted members" 39 | 40 | BOTS = raw.types.ChannelParticipantsBots 41 | "Bots" 42 | 43 | RECENT = raw.types.ChannelParticipantsRecent 44 | "Recently active members" 45 | 46 | ADMINISTRATORS = raw.types.ChannelParticipantsAdmins 47 | "Administrators" 48 | -------------------------------------------------------------------------------- /pyrography/enums/chat_type.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import auto 25 | 26 | from .auto_name import AutoName 27 | 28 | 29 | class ChatType(AutoName): 30 | """Chat type enumeration used in :obj:`~pyrography.types.Chat`.""" 31 | 32 | PRIVATE = auto() 33 | "Chat is a private chat with a user" 34 | 35 | BOT = auto() 36 | "Chat is a private chat with a bot" 37 | 38 | GROUP = auto() 39 | "Chat is a basic group" 40 | 41 | SUPERGROUP = auto() 42 | "Chat is a supergroup" 43 | 44 | CHANNEL = auto() 45 | "Chat is a channel" 46 | -------------------------------------------------------------------------------- /pyrography/enums/message_media_type.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import auto 25 | 26 | from .auto_name import AutoName 27 | 28 | 29 | class MessageMediaType(AutoName): 30 | """Message media type enumeration used in :obj:`~pyrography.types.Message`.""" 31 | 32 | AUDIO = auto() 33 | "Audio media" 34 | 35 | DOCUMENT = auto() 36 | "Document media" 37 | 38 | PHOTO = auto() 39 | "Photo media" 40 | 41 | STICKER = auto() 42 | "Sticker media" 43 | 44 | VIDEO = auto() 45 | "Video media" 46 | 47 | ANIMATION = auto() 48 | "Animation media" 49 | 50 | VOICE = auto() 51 | "Voice media" 52 | 53 | VIDEO_NOTE = auto() 54 | "Video note media" 55 | 56 | CONTACT = auto() 57 | "Contact media" 58 | 59 | LOCATION = auto() 60 | "Location media" 61 | 62 | VENUE = auto() 63 | "Venue media" 64 | 65 | POLL = auto() 66 | "Poll media" 67 | 68 | WEB_PAGE = auto() 69 | "Web page media" 70 | 71 | DICE = auto() 72 | "Dice media" 73 | 74 | GAME = auto() 75 | "Game media" 76 | -------------------------------------------------------------------------------- /pyrography/enums/next_code_type.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from .auto_name import AutoName 26 | 27 | 28 | class NextCodeType(AutoName): 29 | """Next code type enumeration used in :obj:`~pyrography.types.SentCode`.""" 30 | 31 | CALL = raw.types.auth.CodeTypeCall 32 | "The code will be sent via a phone call. A synthesized voice will tell the user which verification code to input." 33 | 34 | FLASH_CALL = raw.types.auth.CodeTypeFlashCall 35 | "The code will be sent via a flash phone call, that will be closed immediately." 36 | 37 | MISSED_CALL = raw.types.auth.CodeTypeMissedCall 38 | "Missed call." 39 | 40 | SMS = raw.types.auth.CodeTypeSms 41 | "The code was sent via SMS." 42 | 43 | FRAGMENT_SMS = raw.types.auth.CodeTypeFragmentSms 44 | "The code was sent via Fragment SMS." 45 | -------------------------------------------------------------------------------- /pyrography/enums/parse_mode.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import auto 25 | 26 | from .auto_name import AutoName 27 | 28 | 29 | class ParseMode(AutoName): 30 | """Parse mode enumeration used in various places to set a specific parse mode""" 31 | 32 | DEFAULT = auto() 33 | "Default mode. Markdown and HTML combined" 34 | 35 | MARKDOWN = auto() 36 | "Markdown only mode" 37 | 38 | HTML = auto() 39 | "HTML only mode" 40 | 41 | DISABLED = auto() 42 | "Disabled mode" 43 | -------------------------------------------------------------------------------- /pyrography/enums/poll_type.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import auto 25 | 26 | from .auto_name import AutoName 27 | 28 | 29 | class PollType(AutoName): 30 | """Poll type enumeration used in :obj:`~pyrography.types.Poll`.""" 31 | 32 | QUIZ = auto() 33 | "Quiz poll" 34 | 35 | REGULAR = auto() 36 | "Regular poll" 37 | -------------------------------------------------------------------------------- /pyrography/enums/sent_code_type.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from .auto_name import AutoName 26 | 27 | 28 | class SentCodeType(AutoName): 29 | """Sent code type enumeration used in :obj:`~pyrography.types.SentCode`.""" 30 | 31 | APP = raw.types.auth.SentCodeTypeApp 32 | "The code was sent through the telegram app." 33 | 34 | CALL = raw.types.auth.SentCodeTypeCall 35 | "The code will be sent via a phone call. A synthesized voice will tell the user which verification code to input." 36 | 37 | FLASH_CALL = raw.types.auth.SentCodeTypeFlashCall 38 | "The code will be sent via a flash phone call, that will be closed immediately." 39 | 40 | MISSED_CALL = raw.types.auth.SentCodeTypeMissedCall 41 | "Missed call." 42 | 43 | SMS = raw.types.auth.SentCodeTypeSms 44 | "The code was sent via SMS." 45 | 46 | FRAGMENT_SMS = raw.types.auth.SentCodeTypeFragmentSms 47 | "The code was sent via Fragment SMS." 48 | 49 | EMAIL_CODE = raw.types.auth.SentCodeTypeEmailCode 50 | "The code was sent via email." 51 | -------------------------------------------------------------------------------- /pyrography/enums/user_status.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from enum import auto 25 | 26 | from .auto_name import AutoName 27 | 28 | 29 | class UserStatus(AutoName): 30 | """User status enumeration used in :obj:`~pyrography.types.User`.""" 31 | 32 | ONLINE = auto() 33 | """User is online""" 34 | 35 | OFFLINE = auto() 36 | """User is offline""" 37 | 38 | RECENTLY = auto() 39 | """User was seen recently""" 40 | 41 | LAST_WEEK = auto() 42 | """User was seen last week""" 43 | 44 | LAST_MONTH = auto() 45 | """User was seen last month""" 46 | 47 | LONG_AGO = auto() 48 | """User was seen long ago""" 49 | -------------------------------------------------------------------------------- /pyrography/handlers/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .callback_query_handler import CallbackQueryHandler 25 | from .chat_join_request_handler import ChatJoinRequestHandler 26 | from .chat_member_updated_handler import ChatMemberUpdatedHandler 27 | from .chosen_inline_result_handler import ChosenInlineResultHandler 28 | from .deleted_messages_handler import DeletedMessagesHandler 29 | from .disconnect_handler import DisconnectHandler 30 | from .edited_message_handler import EditedMessageHandler 31 | from .inline_query_handler import InlineQueryHandler 32 | from .message_handler import MessageHandler 33 | from .poll_handler import PollHandler 34 | from .raw_update_handler import RawUpdateHandler 35 | from .user_status_handler import UserStatusHandler 36 | -------------------------------------------------------------------------------- /pyrography/handlers/disconnect_handler.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Callable 25 | 26 | from .handler import Handler 27 | 28 | 29 | class DisconnectHandler(Handler): 30 | """The Disconnect handler class. Used to handle disconnections. It is intended to be used with 31 | :meth:`~pyrography.Client.add_handler` 32 | 33 | For a nicer way to register this handler, have a look at the 34 | :meth:`~pyrography.Client.on_disconnect` decorator. 35 | 36 | Parameters: 37 | callback (``Callable``): 38 | Pass a function that will be called when a disconnection occurs. It takes *(client)* 39 | as positional argument (look at the section below for a detailed description). 40 | 41 | Other parameters: 42 | client (:obj:`~pyrography.Client`): 43 | The Client itself. Useful, for example, when you want to change the proxy before a new connection 44 | is established. 45 | """ 46 | 47 | def __init__(self, callback: Callable): 48 | super().__init__(callback) 49 | -------------------------------------------------------------------------------- /pyrography/handlers/handler.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import inspect 25 | from typing import Callable 26 | 27 | import pyrography 28 | from pyrography.filters import Filter 29 | from pyrography.types import Update 30 | 31 | 32 | class Handler: 33 | def __init__(self, callback: Callable, filters: Filter = None): 34 | self.callback = callback 35 | self.filters = filters 36 | 37 | async def check(self, client: "pyrography.Client", update: Update): 38 | if callable(self.filters): 39 | if inspect.iscoroutinefunction(self.filters.__call__): 40 | return await self.filters(client, update) 41 | else: 42 | return await client.loop.run_in_executor( 43 | client.executor, 44 | self.filters, 45 | client, update 46 | ) 47 | 48 | return True 49 | -------------------------------------------------------------------------------- /pyrography/methods/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .advanced import Advanced 25 | from .auth import Auth 26 | from .bots import Bots 27 | from .chats import Chats 28 | from .contacts import Contacts 29 | from .decorators import Decorators 30 | from .invite_links import InviteLinks 31 | from .messages import Messages 32 | from .password import Password 33 | from .users import Users 34 | from .utilities import Utilities 35 | 36 | 37 | class Methods( 38 | Advanced, 39 | Auth, 40 | Bots, 41 | Contacts, 42 | Password, 43 | Chats, 44 | Users, 45 | Messages, 46 | Decorators, 47 | Utilities, 48 | InviteLinks, 49 | ): 50 | pass 51 | -------------------------------------------------------------------------------- /pyrography/methods/advanced/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .invoke import Invoke 25 | from .resolve_peer import ResolvePeer 26 | from .save_file import SaveFile 27 | 28 | 29 | class Advanced( 30 | Invoke, 31 | ResolvePeer, 32 | SaveFile 33 | ): 34 | pass 35 | -------------------------------------------------------------------------------- /pyrography/methods/auth/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .accept_terms_of_service import AcceptTermsOfService 25 | from .check_password import CheckPassword 26 | from .connect import Connect 27 | from .disconnect import Disconnect 28 | from .get_password_hint import GetPasswordHint 29 | from .initialize import Initialize 30 | from .log_out import LogOut 31 | from .recover_password import RecoverPassword 32 | from .resend_code import ResendCode 33 | from .send_code import SendCode 34 | from .send_recovery_code import SendRecoveryCode 35 | from .sign_in import SignIn 36 | from .sign_in_bot import SignInBot 37 | from .sign_up import SignUp 38 | from .terminate import Terminate 39 | 40 | 41 | class Auth( 42 | AcceptTermsOfService, 43 | CheckPassword, 44 | Connect, 45 | Disconnect, 46 | GetPasswordHint, 47 | Initialize, 48 | LogOut, 49 | RecoverPassword, 50 | ResendCode, 51 | SendCode, 52 | SendRecoveryCode, 53 | SignIn, 54 | SignInBot, 55 | SignUp, 56 | Terminate 57 | ): 58 | pass 59 | -------------------------------------------------------------------------------- /pyrography/methods/auth/accept_terms_of_service.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | 27 | 28 | class AcceptTermsOfService: 29 | async def accept_terms_of_service( 30 | self: "pyrography.Client", 31 | terms_of_service_id: str 32 | ) -> bool: 33 | """Accept the given terms of service. 34 | 35 | .. include:: /_includes/usable-by/users.rst 36 | 37 | Parameters: 38 | terms_of_service_id (``str``): 39 | The terms of service identifier. 40 | """ 41 | r = await self.invoke( 42 | raw.functions.help.AcceptTermsOfService( 43 | id=raw.types.DataJSON( 44 | data=terms_of_service_id 45 | ) 46 | ) 47 | ) 48 | 49 | return bool(r) 50 | -------------------------------------------------------------------------------- /pyrography/methods/auth/connect.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography.session import Session 26 | 27 | 28 | class Connect: 29 | async def connect( 30 | self: "pyrography.Client", 31 | ) -> bool: 32 | """ 33 | Connect the client to Telegram servers. 34 | 35 | Returns: 36 | ``bool``: On success, in case the passed-in session is authorized, True is returned. Otherwise, in case 37 | the session needs to be authorized, False is returned. 38 | 39 | Raises: 40 | ConnectionError: In case you try to connect an already connected client. 41 | """ 42 | if self.is_connected: 43 | raise ConnectionError("Client is already connected") 44 | 45 | await self.load_session() 46 | 47 | self.session = Session( 48 | self, await self.storage.dc_id(), 49 | await self.storage.auth_key(), await self.storage.test_mode() 50 | ) 51 | 52 | await self.session.start() 53 | 54 | self.is_connected = True 55 | 56 | return bool(await self.storage.user_id()) 57 | -------------------------------------------------------------------------------- /pyrography/methods/auth/disconnect.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | 26 | 27 | class Disconnect: 28 | async def disconnect( 29 | self: "pyrography.Client", 30 | ): 31 | """Disconnect the client from Telegram servers. 32 | 33 | Raises: 34 | ConnectionError: In case you try to disconnect an already disconnected client or in case you try to 35 | disconnect a client that needs to be terminated first. 36 | """ 37 | if not self.is_connected: 38 | raise ConnectionError("Client is already disconnected") 39 | 40 | if self.is_initialized: 41 | raise ConnectionError("Can't disconnect an initialized client") 42 | 43 | await self.session.stop() 44 | await self.storage.close() 45 | self.is_connected = False 46 | -------------------------------------------------------------------------------- /pyrography/methods/auth/get_password_hint.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | log = logging.getLogger(__name__) 30 | 31 | 32 | class GetPasswordHint: 33 | async def get_password_hint( 34 | self: "pyrography.Client", 35 | ) -> str: 36 | """Get your Two-Step Verification password hint. 37 | 38 | .. include:: /_includes/usable-by/users.rst 39 | 40 | Returns: 41 | ``str``: On success, the password hint as string is returned. 42 | """ 43 | return (await self.invoke(raw.functions.account.GetPassword())).hint 44 | -------------------------------------------------------------------------------- /pyrography/methods/auth/initialize.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import asyncio 25 | import logging 26 | 27 | import pyrography 28 | 29 | log = logging.getLogger(__name__) 30 | 31 | 32 | class Initialize: 33 | async def initialize( 34 | self: "pyrography.Client", 35 | ): 36 | """Initialize the client by starting up workers. 37 | 38 | This method will start updates and download workers. 39 | It will also load plugins and start the internal dispatcher. 40 | 41 | Raises: 42 | ConnectionError: In case you try to initialize a disconnected client or in case you try to initialize an 43 | already initialized client. 44 | """ 45 | if not self.is_connected: 46 | raise ConnectionError("Can't initialize a disconnected client") 47 | 48 | if self.is_initialized: 49 | raise ConnectionError("Client is already initialized") 50 | 51 | self.load_plugins() 52 | 53 | await self.dispatcher.start() 54 | 55 | self.updates_watchdog_task = asyncio.create_task(self.updates_watchdog()) 56 | 57 | self.is_initialized = True 58 | -------------------------------------------------------------------------------- /pyrography/methods/auth/log_out.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | log = logging.getLogger(__name__) 30 | 31 | 32 | class LogOut: 33 | async def log_out( 34 | self: "pyrography.Client", 35 | ): 36 | """Log out from Telegram and delete the *\\*.session* file. 37 | 38 | When you log out, the current client is stopped and the storage session deleted. 39 | No more API calls can be made until you start the client and re-authorize again. 40 | 41 | .. include:: /_includes/usable-by/users-bots.rst 42 | 43 | Returns: 44 | ``bool``: On success, True is returned. 45 | 46 | Example: 47 | .. code-block:: python 48 | 49 | # Log out. 50 | app.log_out() 51 | """ 52 | await self.invoke(raw.functions.auth.LogOut()) 53 | await self.stop() 54 | await self.storage.delete() 55 | 56 | return True 57 | -------------------------------------------------------------------------------- /pyrography/methods/auth/send_recovery_code.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | log = logging.getLogger(__name__) 30 | 31 | 32 | class SendRecoveryCode: 33 | async def send_recovery_code( 34 | self: "pyrography.Client", 35 | ) -> str: 36 | """Send a code to your email to recover your password. 37 | 38 | .. include:: /_includes/usable-by/users.rst 39 | 40 | Returns: 41 | ``str``: On success, the hidden email pattern is returned and a recovery code is sent to that email. 42 | 43 | Raises: 44 | BadRequest: In case no recovery email was set up. 45 | """ 46 | return (await self.invoke( 47 | raw.functions.auth.RequestPasswordRecovery() 48 | )).email_pattern 49 | -------------------------------------------------------------------------------- /pyrography/methods/chats/create_channel.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | import pyrography 24 | from pyrography import raw 25 | from pyrography import types 26 | 27 | 28 | class CreateChannel: 29 | async def create_channel( 30 | self: "pyrography.Client", 31 | title: str, 32 | description: str = "" 33 | ) -> "types.Chat": 34 | """Create a new broadcast channel. 35 | 36 | .. include:: /_includes/usable-by/users.rst 37 | 38 | Parameters: 39 | title (``str``): 40 | The channel title. 41 | 42 | description (``str``, *optional*): 43 | The channel description. 44 | 45 | Returns: 46 | :obj:`~pyrography.types.Chat`: On success, a chat object is returned. 47 | 48 | Example: 49 | .. code-block:: python 50 | 51 | await app.create_channel("Channel Title", "Channel Description") 52 | """ 53 | r = await self.invoke( 54 | raw.functions.channels.CreateChannel( 55 | title=title, 56 | about=description, 57 | broadcast=True 58 | ) 59 | ) 60 | 61 | return types.Chat._parse_chat(self, r.chats[0]) 62 | -------------------------------------------------------------------------------- /pyrography/methods/chats/delete_channel.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class DeleteChannel: 31 | async def delete_channel( 32 | self: "pyrography.Client", 33 | chat_id: Union[int, str] 34 | ) -> bool: 35 | """Delete a channel. 36 | 37 | .. include:: /_includes/usable-by/users.rst 38 | 39 | Parameters: 40 | chat_id (``int`` | ``str``): 41 | The id of the channel to be deleted. 42 | 43 | Returns: 44 | ``bool``: On success, True is returned. 45 | 46 | Example: 47 | .. code-block:: python 48 | 49 | await app.delete_channel(channel_id) 50 | """ 51 | await self.invoke( 52 | raw.functions.channels.DeleteChannel( 53 | channel=await self.resolve_peer(chat_id) 54 | ) 55 | ) 56 | 57 | return True 58 | -------------------------------------------------------------------------------- /pyrography/methods/chats/delete_supergroup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class DeleteSupergroup: 31 | async def delete_supergroup( 32 | self: "pyrography.Client", 33 | chat_id: Union[int, str] 34 | ) -> bool: 35 | """Delete a supergroup. 36 | 37 | .. include:: /_includes/usable-by/users.rst 38 | 39 | Parameters: 40 | chat_id (``int`` | ``str``): 41 | The id of the supergroup to be deleted. 42 | 43 | Returns: 44 | ``bool``: On success, True is returned. 45 | 46 | Example: 47 | .. code-block:: python 48 | 49 | await app.delete_supergroup(supergroup_id) 50 | """ 51 | await self.invoke( 52 | raw.functions.channels.DeleteChannel( 53 | channel=await self.resolve_peer(chat_id) 54 | ) 55 | ) 56 | 57 | return True 58 | -------------------------------------------------------------------------------- /pyrography/methods/chats/get_chat_online_count.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class GetChatOnlineCount: 31 | async def get_chat_online_count( 32 | self: "pyrography.Client", 33 | chat_id: Union[int, str] 34 | ) -> int: 35 | """Get the number of members that are currently online in a chat. 36 | 37 | .. include:: /_includes/usable-by/users.rst 38 | 39 | Parameters: 40 | chat_id (``int`` | ``str``): 41 | Unique identifier (int) or username (str) of the target chat. 42 | 43 | Returns: 44 | ``int``: On success, the chat members online count is returned. 45 | 46 | Example: 47 | .. code-block:: python 48 | 49 | online = await app.get_chat_online_count(chat_id) 50 | print(online) 51 | """ 52 | return (await self.invoke( 53 | raw.functions.messages.GetOnlines( 54 | peer=await self.resolve_peer(chat_id) 55 | ) 56 | )).onlines 57 | -------------------------------------------------------------------------------- /pyrography/methods/chats/mark_chat_unread.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class MarkChatUnread: 31 | async def mark_chat_unread( 32 | self: "pyrography.Client", 33 | chat_id: Union[int, str], 34 | ) -> bool: 35 | """Mark a chat as unread. 36 | 37 | .. include:: /_includes/usable-by/users.rst 38 | 39 | Parameters: 40 | chat_id (``int`` | ``str``): 41 | Unique identifier (int) or username (str) of the target chat. 42 | 43 | Returns: 44 | ``bool``: On success, True is returned. 45 | """ 46 | 47 | return await self.invoke( 48 | raw.functions.messages.MarkDialogUnread( 49 | peer=await self.resolve_peer(chat_id), 50 | unread=True 51 | ) 52 | ) 53 | -------------------------------------------------------------------------------- /pyrography/methods/chats/set_chat_protected_content.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class SetChatProtectedContent: 31 | async def set_chat_protected_content( 32 | self: "pyrography.Client", 33 | chat_id: Union[int, str], 34 | enabled: bool 35 | ) -> bool: 36 | """Set the chat protected content setting. 37 | 38 | .. include:: /_includes/usable-by/users-bots.rst 39 | 40 | Parameters: 41 | chat_id (``int`` | ``str``): 42 | Unique identifier (int) or username (str) of the target chat. 43 | 44 | enabled (``bool``): 45 | Pass True to enable the protected content setting, False to disable. 46 | 47 | Returns: 48 | ``bool``: On success, True is returned. 49 | """ 50 | 51 | await self.invoke( 52 | raw.functions.messages.ToggleNoForwards( 53 | peer=await self.resolve_peer(chat_id), 54 | enabled=enabled 55 | ) 56 | ) 57 | 58 | return True 59 | -------------------------------------------------------------------------------- /pyrography/methods/contacts/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .add_contact import AddContact 25 | from .delete_contacts import DeleteContacts 26 | from .get_contacts import GetContacts 27 | from .get_contacts_count import GetContactsCount 28 | from .import_contacts import ImportContacts 29 | 30 | 31 | class Contacts( 32 | GetContacts, 33 | DeleteContacts, 34 | ImportContacts, 35 | GetContactsCount, 36 | AddContact 37 | ): 38 | pass 39 | -------------------------------------------------------------------------------- /pyrography/methods/contacts/get_contacts.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | from typing import List 26 | 27 | import pyrography 28 | from pyrography import raw 29 | from pyrography import types 30 | 31 | log = logging.getLogger(__name__) 32 | 33 | 34 | class GetContacts: 35 | async def get_contacts( 36 | self: "pyrography.Client" 37 | ) -> List["types.User"]: 38 | """Get contacts from your Telegram address book. 39 | 40 | .. include:: /_includes/usable-by/users.rst 41 | 42 | Returns: 43 | List of :obj:`~pyrography.types.User`: On success, a list of users is returned. 44 | 45 | Example: 46 | .. code-block:: python 47 | 48 | contacts = await app.get_contacts() 49 | print(contacts) 50 | """ 51 | contacts = await self.invoke(raw.functions.contacts.GetContacts(hash=0)) 52 | return types.List(types.User._parse(self, user) for user in contacts.users) 53 | -------------------------------------------------------------------------------- /pyrography/methods/contacts/get_contacts_count.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | 27 | 28 | class GetContactsCount: 29 | async def get_contacts_count( 30 | self: "pyrography.Client" 31 | ) -> int: 32 | """Get the total count of contacts from your Telegram address book. 33 | 34 | .. include:: /_includes/usable-by/users.rst 35 | 36 | Returns: 37 | ``int``: On success, the contacts count is returned. 38 | 39 | Example: 40 | .. code-block:: python 41 | 42 | count = await app.get_contacts_count() 43 | print(count) 44 | """ 45 | 46 | return len((await self.invoke(raw.functions.contacts.GetContacts(hash=0))).contacts) 47 | -------------------------------------------------------------------------------- /pyrography/methods/decorators/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .on_callback_query import OnCallbackQuery 25 | from .on_chat_join_request import OnChatJoinRequest 26 | from .on_chat_member_updated import OnChatMemberUpdated 27 | from .on_chosen_inline_result import OnChosenInlineResult 28 | from .on_deleted_messages import OnDeletedMessages 29 | from .on_disconnect import OnDisconnect 30 | from .on_edited_message import OnEditedMessage 31 | from .on_inline_query import OnInlineQuery 32 | from .on_message import OnMessage 33 | from .on_poll import OnPoll 34 | from .on_raw_update import OnRawUpdate 35 | from .on_user_status import OnUserStatus 36 | 37 | 38 | class Decorators( 39 | OnMessage, 40 | OnEditedMessage, 41 | OnDeletedMessages, 42 | OnCallbackQuery, 43 | OnRawUpdate, 44 | OnDisconnect, 45 | OnUserStatus, 46 | OnInlineQuery, 47 | OnPoll, 48 | OnChosenInlineResult, 49 | OnChatMemberUpdated, 50 | OnChatJoinRequest 51 | ): 52 | pass 53 | -------------------------------------------------------------------------------- /pyrography/methods/decorators/on_disconnect.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Callable 25 | 26 | import pyrography 27 | 28 | 29 | class OnDisconnect: 30 | def on_disconnect(self=None) -> Callable: 31 | """Decorator for handling disconnections. 32 | 33 | This does the same thing as :meth:`~pyrography.Client.add_handler` using the 34 | :obj:`~pyrography.handlers.DisconnectHandler`. 35 | """ 36 | 37 | def decorator(func: Callable) -> Callable: 38 | if isinstance(self, pyrography.Client): 39 | self.add_handler(pyrography.handlers.DisconnectHandler(func)) 40 | else: 41 | if not hasattr(func, "handlers"): 42 | func.handlers = [] 43 | 44 | func.handlers.append((pyrography.handlers.DisconnectHandler(func), 0)) 45 | 46 | return func 47 | 48 | return decorator 49 | -------------------------------------------------------------------------------- /pyrography/methods/decorators/on_raw_update.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Callable 25 | 26 | import pyrography 27 | 28 | 29 | class OnRawUpdate: 30 | def on_raw_update( 31 | self=None, 32 | group: int = 0 33 | ) -> Callable: 34 | """Decorator for handling raw updates. 35 | 36 | This does the same thing as :meth:`~pyrography.Client.add_handler` using the 37 | :obj:`~pyrography.handlers.RawUpdateHandler`. 38 | 39 | Parameters: 40 | group (``int``, *optional*): 41 | The group identifier, defaults to 0. 42 | """ 43 | 44 | def decorator(func: Callable) -> Callable: 45 | if isinstance(self, pyrography.Client): 46 | self.add_handler(pyrography.handlers.RawUpdateHandler(func), group) 47 | else: 48 | if not hasattr(func, "handlers"): 49 | func.handlers = [] 50 | 51 | func.handlers.append( 52 | ( 53 | pyrography.handlers.RawUpdateHandler(func), 54 | group 55 | ) 56 | ) 57 | 58 | return func 59 | 60 | return decorator 61 | -------------------------------------------------------------------------------- /pyrography/methods/invite_links/delete_chat_invite_link.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class DeleteChatInviteLink: 31 | async def delete_chat_invite_link( 32 | self: "pyrography.Client", 33 | chat_id: Union[int, str], 34 | invite_link: str, 35 | ) -> bool: 36 | """Delete an already revoked invite link. 37 | 38 | .. include:: /_includes/usable-by/users.rst 39 | 40 | Parameters: 41 | chat_id (``int`` | ``str``): 42 | Unique identifier for the target chat or username of the target channel/supergroup 43 | (in the format @username). 44 | 45 | invite_link (``str``): 46 | The revoked invite link to delete. 47 | 48 | Returns: 49 | ``bool``: On success ``True`` is returned. 50 | """ 51 | 52 | return await self.invoke( 53 | raw.functions.messages.DeleteExportedChatInvite( 54 | peer=await self.resolve_peer(chat_id), 55 | link=invite_link, 56 | ) 57 | ) 58 | -------------------------------------------------------------------------------- /pyrography/methods/password/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .change_cloud_password import ChangeCloudPassword 25 | from .enable_cloud_password import EnableCloudPassword 26 | from .remove_cloud_password import RemoveCloudPassword 27 | 28 | 29 | class Password( 30 | RemoveCloudPassword, 31 | ChangeCloudPassword, 32 | EnableCloudPassword 33 | ): 34 | pass 35 | -------------------------------------------------------------------------------- /pyrography/methods/users/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .block_user import BlockUser 25 | from .delete_profile_photos import DeleteProfilePhotos 26 | from .get_chat_photos import GetChatPhotos 27 | from .get_chat_photos_count import GetChatPhotosCount 28 | from .get_common_chats import GetCommonChats 29 | from .get_default_emoji_statuses import GetDefaultEmojiStatuses 30 | from .get_me import GetMe 31 | from .get_users import GetUsers 32 | from .set_emoji_status import SetEmojiStatus 33 | from .set_profile_photo import SetProfilePhoto 34 | from .set_username import SetUsername 35 | from .unblock_user import UnblockUser 36 | from .update_profile import UpdateProfile 37 | 38 | 39 | class Users( 40 | BlockUser, 41 | GetCommonChats, 42 | GetChatPhotos, 43 | SetProfilePhoto, 44 | DeleteProfilePhotos, 45 | GetUsers, 46 | GetMe, 47 | SetUsername, 48 | GetChatPhotosCount, 49 | UnblockUser, 50 | UpdateProfile, 51 | GetDefaultEmojiStatuses, 52 | SetEmojiStatus 53 | ): 54 | pass 55 | -------------------------------------------------------------------------------- /pyrography/methods/users/block_user.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class BlockUser: 31 | async def block_user( 32 | self: "pyrography.Client", 33 | user_id: Union[int, str] 34 | ) -> bool: 35 | """Block a user. 36 | 37 | .. include:: /_includes/usable-by/users.rst 38 | 39 | Parameters: 40 | user_id (``int`` | ``str``):: 41 | Unique identifier (int) or username (str) of the target user. 42 | For you yourself you can simply use "me" or "self". 43 | For a contact that exists in your Telegram address book you can use his phone number (str). 44 | 45 | Returns: 46 | ``bool``: True on success 47 | 48 | Example: 49 | .. code-block:: python 50 | 51 | await app.block_user(user_id) 52 | """ 53 | return bool( 54 | await self.invoke( 55 | raw.functions.contacts.Block( 56 | id=await self.resolve_peer(user_id) 57 | ) 58 | ) 59 | ) 60 | -------------------------------------------------------------------------------- /pyrography/methods/users/get_default_emoji_statuses.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import List 25 | 26 | import pyrography 27 | from pyrography import raw 28 | from pyrography import types 29 | 30 | 31 | class GetDefaultEmojiStatuses: 32 | async def get_default_emoji_statuses( 33 | self: "pyrography.Client", 34 | ) -> List["types.EmojiStatus"]: 35 | """Get the default emoji statuses. 36 | 37 | .. include:: /_includes/usable-by/users-bots.rst 38 | 39 | Returns: 40 | List of :obj:`~pyrography.types.EmojiStatus`: On success, a list of emoji statuses is returned. 41 | 42 | Example: 43 | .. code-block:: python 44 | 45 | default_emoji_statuses = await app.get_default_emoji_statuses() 46 | print(default_emoji_statuses) 47 | """ 48 | r = await self.invoke( 49 | raw.functions.account.GetDefaultEmojiStatuses(hash=0) 50 | ) 51 | 52 | return types.List([types.EmojiStatus._parse(self, i) for i in r.statuses]) 53 | -------------------------------------------------------------------------------- /pyrography/methods/users/get_me.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from pyrography import types 27 | 28 | 29 | class GetMe: 30 | async def get_me( 31 | self: "pyrography.Client" 32 | ) -> "types.User": 33 | """Get your own user identity. 34 | 35 | .. include:: /_includes/usable-by/users-bots.rst 36 | 37 | Returns: 38 | :obj:`~pyrography.types.User`: Information about the own logged in user/bot. 39 | 40 | Example: 41 | .. code-block:: python 42 | 43 | me = await app.get_me() 44 | print(me) 45 | """ 46 | r = await self.invoke( 47 | raw.functions.users.GetFullUser( 48 | id=raw.types.InputUserSelf() 49 | ) 50 | ) 51 | 52 | users = {u.id: u for u in r.users} 53 | 54 | return types.User._parse(self, users[r.full_user.id]) 55 | -------------------------------------------------------------------------------- /pyrography/methods/users/unblock_user.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | 29 | 30 | class UnblockUser: 31 | async def unblock_user( 32 | self: "pyrography.Client", 33 | user_id: Union[int, str] 34 | ) -> bool: 35 | """Unblock a user. 36 | 37 | .. include:: /_includes/usable-by/users.rst 38 | 39 | Parameters: 40 | user_id (``int`` | ``str``):: 41 | Unique identifier (int) or username (str) of the target user. 42 | For you yourself you can simply use "me" or "self". 43 | For a contact that exists in your Telegram address book you can use his phone number (str). 44 | 45 | Returns: 46 | ``bool``: True on success 47 | 48 | Example: 49 | .. code-block:: python 50 | 51 | await app.unblock_user(user_id) 52 | """ 53 | return bool( 54 | await self.invoke( 55 | raw.functions.contacts.Unblock( 56 | id=await self.resolve_peer(user_id) 57 | ) 58 | ) 59 | ) 60 | -------------------------------------------------------------------------------- /pyrography/methods/utilities/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .add_handler import AddHandler 25 | from .export_session_string import ExportSessionString 26 | from .remove_handler import RemoveHandler 27 | from .restart import Restart 28 | from .run import Run 29 | from .start import Start 30 | from .stop import Stop 31 | from .stop_transmission import StopTransmission 32 | 33 | 34 | class Utilities( 35 | AddHandler, 36 | ExportSessionString, 37 | RemoveHandler, 38 | Restart, 39 | Run, 40 | Start, 41 | Stop, 42 | StopTransmission 43 | ): 44 | pass 45 | -------------------------------------------------------------------------------- /pyrography/methods/utilities/export_session_string.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | 26 | 27 | class ExportSessionString: 28 | async def export_session_string( 29 | self: "pyrography.Client" 30 | ): 31 | """Export the current authorized session as a serialized string. 32 | 33 | Session strings are useful for storing in-memory authorized sessions in a portable, serialized string. 34 | More detailed information about session strings can be found at the dedicated page of 35 | :doc:`Storage Engines <../../topics/storage-engines>`. 36 | 37 | Returns: 38 | ``str``: The session serialized into a printable, url-safe string. 39 | 40 | Example: 41 | .. code-block:: python 42 | 43 | s = await app.export_session_string() 44 | """ 45 | return await self.storage.export_session_string() 46 | -------------------------------------------------------------------------------- /pyrography/methods/utilities/stop_transmission.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | 26 | 27 | class StopTransmission: 28 | def stop_transmission(self): 29 | """Stop downloading or uploading a file. 30 | 31 | This method must be called inside a progress callback function in order to stop the transmission at the 32 | desired time. The progress callback is called every time a file chunk is uploaded/downloaded. 33 | 34 | Example: 35 | .. code-block:: python 36 | 37 | # Stop transmission once the upload progress reaches 50% 38 | async def progress(current, total, client): 39 | if (current * 100 / total) > 50: 40 | client.stop_transmission() 41 | 42 | async with app: 43 | await app.send_document( 44 | "me", "file.zip", 45 | progress=progress, 46 | progress_args=(app,)) 47 | """ 48 | raise pyrography.StopTransmission 49 | -------------------------------------------------------------------------------- /pyrography/parser/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .parser import Parser 25 | -------------------------------------------------------------------------------- /pyrography/parser/utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import re 25 | from struct import unpack 26 | 27 | # SMP = Supplementary Multilingual Plane: https://en.wikipedia.org/wiki/Plane_(Unicode)#Overview 28 | SMP_RE = re.compile(r"[\U00010000-\U0010FFFF]") 29 | 30 | 31 | def add_surrogates(text): 32 | # Replace each SMP code point with a surrogate pair 33 | return SMP_RE.sub( 34 | lambda match: # Split SMP in two surrogates 35 | "".join(chr(i) for i in unpack(" 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from importlib import import_module 25 | 26 | from . import types, functions, base, core 27 | from .all import objects 28 | 29 | for k, v in objects.items(): 30 | path, name = v.rsplit(".", 1) 31 | objects[k] = getattr(import_module(path), name) 32 | -------------------------------------------------------------------------------- /pyrography/raw/core/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .future_salt import FutureSalt 25 | from .future_salts import FutureSalts 26 | from .gzip_packed import GzipPacked 27 | from .list import List 28 | from .message import Message 29 | from .msg_container import MsgContainer 30 | from .primitives.bool import Bool, BoolFalse, BoolTrue 31 | from .primitives.bytes import Bytes 32 | from .primitives.double import Double 33 | from .primitives.int import Int, Long, Int128, Int256 34 | from .primitives.string import String 35 | from .primitives.vector import Vector 36 | from .tl_object import TLObject 37 | -------------------------------------------------------------------------------- /pyrography/raw/core/future_salt.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from typing import Any 26 | 27 | from .primitives.int import Int, Long 28 | from .tl_object import TLObject 29 | 30 | 31 | class FutureSalt(TLObject): 32 | ID = 0x0949D9DC 33 | 34 | __slots__ = ["valid_since", "valid_until", "salt"] 35 | 36 | QUALNAME = "FutureSalt" 37 | 38 | def __init__(self, valid_since: int, valid_until: int, salt: int): 39 | self.valid_since = valid_since 40 | self.valid_until = valid_until 41 | self.salt = salt 42 | 43 | @staticmethod 44 | def read(data: BytesIO, *args: Any) -> "FutureSalt": 45 | valid_since = Int.read(data) 46 | valid_until = Int.read(data) 47 | salt = Long.read(data) 48 | 49 | return FutureSalt(valid_since, valid_until, salt) 50 | 51 | def write(self, *args: Any) -> bytes: 52 | b = BytesIO() 53 | 54 | b.write(Int(self.valid_since)) 55 | b.write(Int(self.valid_until)) 56 | b.write(Long(self.salt)) 57 | 58 | return b.getvalue() 59 | -------------------------------------------------------------------------------- /pyrography/raw/core/list.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import List as TList, Any 25 | 26 | from .tl_object import TLObject 27 | 28 | 29 | class List(TList[Any], TLObject): 30 | def __repr__(self) -> str: 31 | return f"pyrography.raw.core.List([{','.join(TLObject.__repr__(i) for i in self)}])" 32 | -------------------------------------------------------------------------------- /pyrography/raw/core/msg_container.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from typing import List, Any 26 | 27 | from .message import Message 28 | from .primitives.int import Int 29 | from .tl_object import TLObject 30 | 31 | 32 | class MsgContainer(TLObject): 33 | ID = 0x73F1F8DC 34 | 35 | __slots__ = ["messages"] 36 | 37 | QUALNAME = "MsgContainer" 38 | 39 | def __init__(self, messages: List[Message]): 40 | self.messages = messages 41 | 42 | @staticmethod 43 | def read(data: BytesIO, *args: Any) -> "MsgContainer": 44 | count = Int.read(data) 45 | return MsgContainer([Message.read(data) for _ in range(count)]) 46 | 47 | def write(self, *args: Any) -> bytes: 48 | b = BytesIO() 49 | 50 | b.write(Int(self.ID, False)) 51 | 52 | count = len(self.messages) 53 | b.write(Int(count)) 54 | 55 | for message in self.messages: 56 | b.write(message.write()) 57 | 58 | return b.getvalue() 59 | -------------------------------------------------------------------------------- /pyrography/raw/core/primitives/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .bool import Bool, BoolFalse, BoolTrue 25 | from .bytes import Bytes 26 | from .double import Double 27 | from .int import Int, Long, Int128, Int256 28 | from .string import String 29 | from .vector import Vector 30 | -------------------------------------------------------------------------------- /pyrography/raw/core/primitives/bool.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from typing import Any 26 | 27 | from ..tl_object import TLObject 28 | 29 | 30 | class BoolFalse(bytes, TLObject): 31 | ID = 0xBC799737 32 | value = False 33 | 34 | @classmethod 35 | def read(cls, *args: Any) -> bool: 36 | return cls.value 37 | 38 | def __new__(cls) -> bytes: # type: ignore 39 | return cls.ID.to_bytes(4, "little") 40 | 41 | 42 | class BoolTrue(BoolFalse): 43 | ID = 0x997275B5 44 | value = True 45 | 46 | 47 | class Bool(bytes, TLObject): 48 | @classmethod 49 | def read(cls, data: BytesIO, *args: Any) -> bool: 50 | return int.from_bytes(data.read(4), "little") == BoolTrue.ID 51 | 52 | def __new__(cls, value: bool) -> bytes: # type: ignore 53 | return BoolTrue() if value else BoolFalse() 54 | -------------------------------------------------------------------------------- /pyrography/raw/core/primitives/bytes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from typing import Any 26 | 27 | from ..tl_object import TLObject 28 | 29 | 30 | class Bytes(bytes, TLObject): 31 | @classmethod 32 | def read(cls, data: BytesIO, *args: Any) -> bytes: 33 | length = int.from_bytes(data.read(1), "little") 34 | 35 | if length <= 253: 36 | x = data.read(length) 37 | data.read(-(length + 1) % 4) 38 | else: 39 | length = int.from_bytes(data.read(3), "little") 40 | x = data.read(length) 41 | data.read(-length % 4) 42 | 43 | return x 44 | 45 | def __new__(cls, value: bytes) -> bytes: # type: ignore 46 | length = len(value) 47 | 48 | if length <= 253: 49 | return ( 50 | bytes([length]) 51 | + value 52 | + bytes(-(length + 1) % 4) 53 | ) 54 | else: 55 | return ( 56 | bytes([254]) 57 | + length.to_bytes(3, "little") 58 | + value 59 | + bytes(-length % 4) 60 | ) 61 | -------------------------------------------------------------------------------- /pyrography/raw/core/primitives/double.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from struct import unpack, pack 26 | from typing import cast, Any 27 | 28 | from ..tl_object import TLObject 29 | 30 | 31 | class Double(bytes, TLObject): 32 | @classmethod 33 | def read(cls, data: BytesIO, *args: Any) -> float: 34 | return cast(float, unpack("d", data.read(8))[0]) 35 | 36 | def __new__(cls, value: float) -> bytes: # type: ignore 37 | return pack("d", value) 38 | -------------------------------------------------------------------------------- /pyrography/raw/core/primitives/int.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from typing import Any 26 | 27 | from ..tl_object import TLObject 28 | 29 | 30 | class Int(bytes, TLObject): 31 | SIZE = 4 32 | 33 | @classmethod 34 | def read(cls, data: BytesIO, signed: bool = True, *args: Any) -> int: 35 | return int.from_bytes(data.read(cls.SIZE), "little", signed=signed) 36 | 37 | def __new__(cls, value: int, signed: bool = True) -> bytes: # type: ignore 38 | return value.to_bytes(cls.SIZE, "little", signed=signed) 39 | 40 | 41 | class Long(Int): 42 | SIZE = 8 43 | 44 | 45 | class Int128(Int): 46 | SIZE = 16 47 | 48 | 49 | class Int256(Int): 50 | SIZE = 32 51 | -------------------------------------------------------------------------------- /pyrography/raw/core/primitives/string.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from io import BytesIO 25 | from typing import cast 26 | 27 | from .bytes import Bytes 28 | 29 | 30 | class String(Bytes): 31 | @classmethod 32 | def read(cls, data: BytesIO, *args) -> str: # type: ignore 33 | return cast(bytes, super(String, String).read(data)).decode(errors="replace") 34 | 35 | def __new__(cls, value: str) -> bytes: # type: ignore 36 | return super().__new__(cls, value.encode()) 37 | -------------------------------------------------------------------------------- /pyrography/session/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .auth import Auth 25 | from .session import Session 26 | -------------------------------------------------------------------------------- /pyrography/session/internals/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .data_center import DataCenter 25 | from .msg_factory import MsgFactory 26 | from .msg_id import MsgId 27 | -------------------------------------------------------------------------------- /pyrography/session/internals/msg_factory.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography.raw.core import Message, MsgContainer, TLObject 25 | from pyrography.raw.functions import Ping 26 | from pyrography.raw.types import MsgsAck, HttpWait 27 | from .msg_id import MsgId 28 | from .seq_no import SeqNo 29 | 30 | not_content_related = (Ping, HttpWait, MsgsAck, MsgContainer) 31 | 32 | 33 | class MsgFactory: 34 | def __init__(self): 35 | self.seq_no = SeqNo() 36 | 37 | def __call__(self, body: TLObject) -> Message: 38 | return Message( 39 | body, 40 | MsgId(), 41 | self.seq_no(not isinstance(body, not_content_related)), 42 | len(body) 43 | ) 44 | -------------------------------------------------------------------------------- /pyrography/session/internals/msg_id.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import logging 25 | import time 26 | 27 | log = logging.getLogger(__name__) 28 | 29 | 30 | class MsgId: 31 | last_time = 0 32 | offset = 0 33 | 34 | def __new__(cls) -> int: 35 | now = int(time.time()) 36 | cls.offset = (cls.offset + 4) if now == cls.last_time else 0 37 | msg_id = (now * 2 ** 32) + cls.offset 38 | cls.last_time = now 39 | 40 | return msg_id 41 | -------------------------------------------------------------------------------- /pyrography/session/internals/seq_no.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | 25 | class SeqNo: 26 | def __init__(self): 27 | self.content_related_messages_sent = 0 28 | 29 | def __call__(self, is_content_related: bool) -> int: 30 | seq_no = (self.content_related_messages_sent * 2) + (1 if is_content_related else 0) 31 | 32 | if is_content_related: 33 | self.content_related_messages_sent += 1 34 | 35 | return seq_no 36 | -------------------------------------------------------------------------------- /pyrography/storage/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .file_storage import FileStorage 25 | from .memory_storage import MemoryStorage 26 | from .storage import Storage 27 | -------------------------------------------------------------------------------- /pyrography/types/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .authorization import * 25 | from .bots_and_keyboards import * 26 | from .inline_mode import * 27 | from .input_media import * 28 | from .input_message_content import * 29 | from .list import List 30 | from .messages_and_media import * 31 | from .object import Object 32 | from .update import * 33 | from .user_and_chats import * 34 | -------------------------------------------------------------------------------- /pyrography/types/authorization/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .sent_code import SentCode 25 | from .terms_of_service import TermsOfService 26 | 27 | __all__ = ["TermsOfService", "SentCode"] 28 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | 26 | from ..object import Object 27 | 28 | 29 | class BotCommand(Object): 30 | """A bot command with the standard slash "/" prefix. 31 | 32 | Parameters: 33 | command (``str``): 34 | Text of the command; 1-32 characters. 35 | Can contain only lowercase English letters, digits and underscores. 36 | 37 | description (``str``): 38 | Description of the command; 1-256 characters. 39 | """ 40 | 41 | def __init__(self, command: str, description: str): 42 | super().__init__() 43 | 44 | self.command = command 45 | self.description = description 46 | 47 | def write(self) -> "raw.types.BotCommand": 48 | return raw.types.BotCommand( 49 | command=self.command, 50 | description=self.description, 51 | ) 52 | 53 | @staticmethod 54 | def read(c: "raw.types.BotCommand") -> "BotCommand": 55 | return BotCommand( 56 | command=c.command, 57 | description=c.description 58 | ) 59 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_all_chat_administrators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from .bot_command_scope import BotCommandScope 27 | 28 | 29 | class BotCommandScopeAllChatAdministrators(BotCommandScope): 30 | """Represents the scope of bot commands, covering all group and supergroup chat administrators. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__("all_chat_administrators") 35 | 36 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 37 | return raw.types.BotCommandScopeChatAdmins() 38 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_all_group_chats.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from .bot_command_scope import BotCommandScope 27 | 28 | 29 | class BotCommandScopeAllGroupChats(BotCommandScope): 30 | """Represents the scope of bot commands, covering all group and supergroup chats. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__("all_group_chats") 35 | 36 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 37 | return raw.types.BotCommandScopeChats() 38 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_all_private_chats.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from .bot_command_scope import BotCommandScope 27 | 28 | 29 | class BotCommandScopeAllPrivateChats(BotCommandScope): 30 | """Represents the scope of bot commands, covering all private chats. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__("all_private_chats") 35 | 36 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 37 | return raw.types.BotCommandScopeUsers() 38 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_chat.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | from .bot_command_scope import BotCommandScope 29 | 30 | 31 | class BotCommandScopeChat(BotCommandScope): 32 | """Represents the scope of bot commands, covering a specific chat. 33 | 34 | Parameters: 35 | chat_id (``int`` | ``str``): 36 | Unique identifier for the target chat or username of the target supergroup (in the format 37 | @supergroupusername). 38 | """ 39 | 40 | def __init__(self, chat_id: Union[int, str]): 41 | super().__init__("chat") 42 | 43 | self.chat_id = chat_id 44 | 45 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 46 | return raw.types.BotCommandScopePeer( 47 | peer=await client.resolve_peer(self.chat_id) 48 | ) 49 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_chat_administrators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | from .bot_command_scope import BotCommandScope 29 | 30 | 31 | class BotCommandScopeChatAdministrators(BotCommandScope): 32 | """Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat. 33 | 34 | Parameters: 35 | chat_id (``int`` | ``str``): 36 | Unique identifier for the target chat or username of the target supergroup (in the format 37 | @supergroupusername). 38 | """ 39 | 40 | def __init__(self, chat_id: Union[int, str]): 41 | super().__init__("chat_administrators") 42 | 43 | self.chat_id = chat_id 44 | 45 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 46 | return raw.types.BotCommandScopePeerAdmins( 47 | peer=await client.resolve_peer(self.chat_id) 48 | ) 49 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_chat_member.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Union 25 | 26 | import pyrography 27 | from pyrography import raw 28 | from .bot_command_scope import BotCommandScope 29 | 30 | 31 | class BotCommandScopeChatMember(BotCommandScope): 32 | """Represents the scope of bot commands, covering a specific member of a group or supergroup chat. 33 | 34 | Parameters: 35 | chat_id (``int`` | ``str``): 36 | Unique identifier for the target chat or username of the target supergroup (in the format 37 | @supergroupusername). 38 | 39 | user_id (``int`` | ``str``): 40 | Unique identifier of the target user. 41 | """ 42 | 43 | def __init__(self, chat_id: Union[int, str], user_id: Union[int, str]): 44 | super().__init__("chat_member") 45 | 46 | self.chat_id = chat_id 47 | self.user_id = user_id 48 | 49 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 50 | return raw.types.BotCommandScopePeerUser( 51 | peer=await client.resolve_peer(self.chat_id), 52 | user_id=await client.resolve_peer(self.user_id) 53 | ) 54 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/bot_command_scope_default.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from .bot_command_scope import BotCommandScope 27 | 28 | 29 | class BotCommandScopeDefault(BotCommandScope): 30 | """Represents the default scope of bot commands. 31 | Default commands are used if no commands with a narrower scope are specified for the user. 32 | """ 33 | 34 | def __init__(self): 35 | super().__init__("default") 36 | 37 | async def write(self, client: "pyrography.Client") -> "raw.base.BotCommandScope": 38 | return raw.types.BotCommandScopeDefault() 39 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/callback_game.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from ..object import Object 25 | 26 | 27 | class CallbackGame(Object): 28 | """Placeholder, currently holds no information. 29 | 30 | Use BotFather to set up your game. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__() 35 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/menu_button.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from ..object import Object 27 | 28 | 29 | class MenuButton(Object): 30 | """Describes the bot's menu button in a private chat. 31 | 32 | It should be one of: 33 | 34 | - :obj:`~pyrography.types.MenuButtonCommands` 35 | - :obj:`~pyrography.types.MenuButtonWebApp` 36 | - :obj:`~pyrography.types.MenuButtonDefault` 37 | 38 | If a menu button other than :obj:`~pyrography.types.MenuButtonDefault` is set for a private chat, then it is applied 39 | in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot 40 | commands. 41 | """ 42 | 43 | def __init__(self, type: str): 44 | super().__init__() 45 | 46 | self.type = type 47 | 48 | async def write(self, client: "pyrography.Client") -> "raw.base.BotMenuButton": 49 | raise NotImplementedError 50 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/menu_button_commands.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from .menu_button import MenuButton 27 | 28 | 29 | class MenuButtonCommands(MenuButton): 30 | """A menu button, which opens the bot's list of commands. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__("commands") 35 | 36 | async def write(self, client: "pyrography.Client") -> "raw.types.BotMenuButtonCommands": 37 | return raw.types.BotMenuButtonCommands() 38 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/menu_button_default.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from .menu_button import MenuButton 27 | 28 | 29 | class MenuButtonDefault(MenuButton): 30 | """Describes that no specific value for the menu button was set. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__("default") 35 | 36 | async def write(self, client: "pyrography.Client") -> "raw.types.BotMenuButtonDefault": 37 | return raw.types.BotMenuButtonDefault() 38 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/menu_button_web_app.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw, types 26 | from .menu_button import MenuButton 27 | 28 | 29 | class MenuButtonWebApp(MenuButton): 30 | """A menu button, which launches a `Web App `_. 31 | 32 | Parameters: 33 | text (``str``): 34 | Text on the button 35 | 36 | web_app (:obj:`~pyrography.types.WebAppInfo`): 37 | Description of the Web App that will be launched when the user presses the button. 38 | The Web App will be able to send an arbitrary message on behalf of the user using the method 39 | :meth:`~pyrography.Client.answer_web_app_query`. 40 | """ 41 | 42 | def __init__( 43 | self, 44 | text: str, 45 | web_app: "types.WebAppInfo" 46 | ): 47 | super().__init__("web_app") 48 | 49 | self.text = text 50 | self.web_app = web_app 51 | 52 | async def write(self, client: "pyrography.Client") -> "raw.types.BotMenuButton": 53 | return raw.types.BotMenuButton( 54 | text=self.text, 55 | url=self.web_app.url 56 | ) 57 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/sent_web_app_message.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw, utils 25 | from ..object import Object 26 | 27 | 28 | class SentWebAppMessage(Object): 29 | """Contains information about an inline message sent by a `Web App `_ on behalf of a user. 30 | 31 | Parameters: 32 | inline_message_id (``str``): 33 | Identifier of the sent inline message. 34 | Available only if there is an inline keyboard attached to the message. 35 | """ 36 | 37 | def __init__( 38 | self, *, 39 | inline_message_id: str, 40 | ): 41 | super().__init__() 42 | 43 | self.inline_message_id = inline_message_id 44 | 45 | @staticmethod 46 | def _parse(obj: "raw.types.WebViewMessageSent"): 47 | return SentWebAppMessage(inline_message_id=utils.pack_inline_message_id(obj.msg_id)) 48 | -------------------------------------------------------------------------------- /pyrography/types/bots_and_keyboards/web_app_info.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from ..object import Object 25 | 26 | 27 | class WebAppInfo(Object): 28 | """Contains information about a `Web App `_. 29 | 30 | Parameters: 31 | url (``str``): 32 | An HTTPS URL of a Web App to be opened with additional data as specified in 33 | `Initializing Web Apps `_. 34 | """ 35 | 36 | def __init__( 37 | self, *, 38 | url: str, 39 | ): 40 | super().__init__() 41 | 42 | self.url = url 43 | -------------------------------------------------------------------------------- /pyrography/types/input_media/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .input_media import InputMedia 25 | from .input_media_animation import InputMediaAnimation 26 | from .input_media_audio import InputMediaAudio 27 | from .input_media_document import InputMediaDocument 28 | from .input_media_photo import InputMediaPhoto 29 | from .input_media_video import InputMediaVideo 30 | from .input_phone_contact import InputPhoneContact 31 | 32 | __all__ = [ 33 | "InputMedia", "InputMediaAnimation", "InputMediaAudio", "InputMediaDocument", "InputMediaPhoto", "InputMediaVideo", 34 | "InputPhoneContact" 35 | ] 36 | -------------------------------------------------------------------------------- /pyrography/types/input_media/input_media.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import List, Union, BinaryIO 25 | 26 | from ..messages_and_media import MessageEntity 27 | from ..object import Object 28 | 29 | 30 | class InputMedia(Object): 31 | """Content of a media message to be sent. 32 | 33 | It should be one of: 34 | 35 | - :obj:`~pyrography.types.InputMediaAnimation` 36 | - :obj:`~pyrography.types.InputMediaDocument` 37 | - :obj:`~pyrography.types.InputMediaAudio` 38 | - :obj:`~pyrography.types.InputMediaPhoto` 39 | - :obj:`~pyrography.types.InputMediaVideo` 40 | """ 41 | 42 | def __init__( 43 | self, 44 | media: Union[str, BinaryIO], 45 | caption: str = "", 46 | parse_mode: str = None, 47 | caption_entities: List[MessageEntity] = None 48 | ): 49 | super().__init__() 50 | 51 | self.media = media 52 | self.caption = caption 53 | self.parse_mode = parse_mode 54 | self.caption_entities = caption_entities 55 | -------------------------------------------------------------------------------- /pyrography/types/input_media/input_phone_contact.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from pyrography.session.internals import MsgId 26 | from ..object import Object 27 | 28 | 29 | class InputPhoneContact(Object): 30 | """A Phone Contact to be added in your Telegram address book. 31 | It is intended to be used with :meth:`~pyrography.Client.add_contacts()` 32 | 33 | Parameters: 34 | phone (``str``): 35 | Contact's phone number 36 | 37 | first_name (``str``): 38 | Contact's first name 39 | 40 | last_name (``str``, *optional*): 41 | Contact's last name 42 | """ 43 | 44 | def __init__(self, phone: str, first_name: str, last_name: str = ""): 45 | super().__init__(None) 46 | 47 | def __new__(cls, 48 | phone: str, 49 | first_name: str, 50 | last_name: str = ""): 51 | return raw.types.InputPhoneContact( 52 | client_id=MsgId(), 53 | phone="+" + phone.strip("+"), 54 | first_name=first_name, 55 | last_name=last_name 56 | ) 57 | -------------------------------------------------------------------------------- /pyrography/types/input_message_content/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .input_message_content import InputMessageContent 25 | from .input_text_message_content import InputTextMessageContent 26 | 27 | __all__ = [ 28 | "InputMessageContent", "InputTextMessageContent" 29 | ] 30 | -------------------------------------------------------------------------------- /pyrography/types/input_message_content/input_message_content.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | 26 | from ..object import Object 27 | 28 | """- :obj:`~pyrography.types.InputLocationMessageContent` 29 | - :obj:`~pyrography.types.InputVenueMessageContent` 30 | - :obj:`~pyrography.types.InputContactMessageContent`""" 31 | 32 | 33 | class InputMessageContent(Object): 34 | """Content of a message to be sent as a result of an inline query. 35 | 36 | Pyrogram currently supports the following types: 37 | 38 | - :obj:`~pyrography.types.InputTextMessageContent` 39 | """ 40 | 41 | def __init__(self): 42 | super().__init__() 43 | 44 | async def write(self, client: "pyrography.Client", reply_markup): 45 | raise NotImplementedError 46 | -------------------------------------------------------------------------------- /pyrography/types/list.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .object import Object 25 | 26 | 27 | class List(list): 28 | __slots__ = [] 29 | 30 | def __str__(self): 31 | # noinspection PyCallByClass 32 | return Object.__str__(self) 33 | 34 | def __repr__(self): 35 | return f"pyrography.types.List([{','.join(Object.__repr__(i) for i in self)}])" 36 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from .animation import Animation 25 | from .audio import Audio 26 | from .contact import Contact 27 | from .dice import Dice 28 | from .document import Document 29 | from .game import Game 30 | from .location import Location 31 | from .message import Message 32 | from .message_entity import MessageEntity 33 | from .photo import Photo 34 | from .poll import Poll 35 | from .poll_option import PollOption 36 | from .reaction import Reaction 37 | from .sticker import Sticker 38 | from .stripped_thumbnail import StrippedThumbnail 39 | from .thumbnail import Thumbnail 40 | from .venue import Venue 41 | from .video import Video 42 | from .video_note import VideoNote 43 | from .voice import Voice 44 | from .web_app_data import WebAppData 45 | from .web_page import WebPage 46 | from .message_reactions import MessageReactions 47 | 48 | __all__ = [ 49 | "Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail", 50 | "StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", 51 | "Reaction", "WebAppData", "MessageReactions" 52 | ] 53 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/dice.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from ..object import Object 27 | 28 | 29 | class Dice(Object): 30 | """A dice with a random value from 1 to 6 for currently supported base emoji. 31 | 32 | Parameters: 33 | emoji (``string``): 34 | Emoji on which the dice throw animation is based. 35 | 36 | value (``int``): 37 | Value of the dice, 1-6 for currently supported base emoji. 38 | """ 39 | 40 | def __init__(self, *, client: "pyrography.Client" = None, emoji: str, value: int): 41 | super().__init__(client) 42 | 43 | self.emoji = emoji 44 | self.value = value 45 | 46 | @staticmethod 47 | def _parse(client, dice: "raw.types.MessageMediaDice") -> "Dice": 48 | return Dice( 49 | emoji=dice.emoticon, 50 | value=dice.value, 51 | client=client 52 | ) 53 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/location.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | 26 | from pyrography import raw 27 | from ..object import Object 28 | 29 | 30 | class Location(Object): 31 | """A point on the map. 32 | 33 | Parameters: 34 | longitude (``float``): 35 | Longitude as defined by sender. 36 | 37 | latitude (``float``): 38 | Latitude as defined by sender. 39 | """ 40 | 41 | def __init__( 42 | self, 43 | *, 44 | client: "pyrography.Client" = None, 45 | longitude: float, 46 | latitude: float 47 | ): 48 | super().__init__(client) 49 | 50 | self.longitude = longitude 51 | self.latitude = latitude 52 | 53 | @staticmethod 54 | def _parse(client, geo_point: "raw.types.GeoPoint") -> "Location": 55 | if isinstance(geo_point, raw.types.GeoPoint): 56 | return Location( 57 | longitude=geo_point.long, 58 | latitude=geo_point.lat, 59 | client=client 60 | ) 61 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/message_reactions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import Optional, List 25 | 26 | import pyrography 27 | from pyrography import raw, types 28 | from ..object import Object 29 | 30 | 31 | class MessageReactions(Object): 32 | """Contains information about a message reactions. 33 | 34 | Parameters: 35 | reactions (List of :obj:`~pyrography.types.Reaction`): 36 | Reactions list. 37 | """ 38 | 39 | def __init__( 40 | self, 41 | *, 42 | client: "pyrography.Client" = None, 43 | reactions: Optional[List["types.Reaction"]] = None, 44 | ): 45 | super().__init__(client) 46 | 47 | self.reactions = reactions 48 | 49 | @staticmethod 50 | def _parse( 51 | client: "pyrography.Client", 52 | message_reactions: Optional["raw.base.MessageReactions"] = None 53 | ) -> Optional["MessageReactions"]: 54 | if not message_reactions: 55 | return None 56 | 57 | return MessageReactions( 58 | client=client, 59 | reactions=[types.Reaction._parse_count(client, reaction) 60 | for reaction in message_reactions.results] 61 | ) 62 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/poll_option.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from ..object import Object 26 | 27 | 28 | class PollOption(Object): 29 | """Contains information about one answer option in a poll. 30 | 31 | Parameters: 32 | text (``str``): 33 | Option text, 1-100 characters. 34 | 35 | voter_count (``int``): 36 | Number of users that voted for this option. 37 | Equals to 0 until you vote. 38 | 39 | data (``bytes``): 40 | The data this poll option is holding. 41 | """ 42 | 43 | def __init__( 44 | self, 45 | *, 46 | client: "pyrography.Client" = None, 47 | text: str, 48 | voter_count: int, 49 | data: bytes 50 | ): 51 | super().__init__(client) 52 | 53 | self.text = text 54 | self.voter_count = voter_count 55 | self.data = data 56 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/stripped_thumbnail.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | from pyrography import raw 26 | from ..object import Object 27 | 28 | 29 | class StrippedThumbnail(Object): 30 | """A stripped thumbnail 31 | 32 | Parameters: 33 | data (``bytes``): 34 | Thumbnail data 35 | """ 36 | 37 | def __init__( 38 | self, 39 | *, 40 | client: "pyrography.Client" = None, 41 | data: bytes 42 | ): 43 | super().__init__(client) 44 | 45 | self.data = data 46 | 47 | @staticmethod 48 | def _parse(client, stripped_thumbnail: "raw.types.PhotoStrippedSize") -> "StrippedThumbnail": 49 | return StrippedThumbnail( 50 | data=stripped_thumbnail.bytes, 51 | client=client 52 | ) 53 | -------------------------------------------------------------------------------- /pyrography/types/messages_and_media/web_app_data.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from ..object import Object 26 | 27 | 28 | class WebAppData(Object): 29 | """Contains data sent from a `Web App `_ to the bot. 30 | 31 | Parameters: 32 | data (``str``): 33 | The data. 34 | 35 | button_text (``str``): 36 | Text of the *web_app* keyboard button, from which the Web App was opened. 37 | 38 | """ 39 | 40 | def __init__( 41 | self, 42 | *, 43 | data: str, 44 | button_text: str, 45 | ): 46 | super().__init__() 47 | 48 | self.data = data 49 | self.button_text = button_text 50 | 51 | @staticmethod 52 | def _parse(action: "raw.types.MessageActionWebViewDataSentMe"): 53 | return WebAppData( 54 | data=action.data, 55 | button_text=action.text 56 | ) 57 | -------------------------------------------------------------------------------- /pyrography/types/update.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | import pyrography 25 | 26 | 27 | class Update: 28 | def stop_propagation(self): 29 | raise pyrography.StopPropagation 30 | 31 | def continue_propagation(self): 32 | raise pyrography.ContinuePropagation 33 | -------------------------------------------------------------------------------- /pyrography/types/user_and_chats/restriction.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from ..object import Object 26 | 27 | 28 | class Restriction(Object): 29 | """A restriction applied to bots or chats. 30 | 31 | Parameters: 32 | platform (``str``): 33 | The platform the restriction is applied to, e.g. "ios", "android" 34 | 35 | reason (``str``): 36 | The restriction reason, e.g. "porn", "copyright". 37 | 38 | text (``str``): 39 | The restriction text. 40 | """ 41 | 42 | def __init__(self, *, platform: str, reason: str, text: str): 43 | super().__init__(None) 44 | 45 | self.platform = platform 46 | self.reason = reason 47 | self.text = text 48 | 49 | @staticmethod 50 | def _parse(restriction: "raw.types.RestrictionReason") -> "Restriction": 51 | return Restriction( 52 | platform=restriction.platform, 53 | reason=restriction.reason, 54 | text=restriction.text 55 | ) 56 | -------------------------------------------------------------------------------- /pyrography/types/user_and_chats/video_chat_ended.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from pyrography import raw 25 | from ..object import Object 26 | 27 | 28 | class VideoChatEnded(Object): 29 | """A service message about a voice chat ended in the chat. 30 | 31 | Parameters: 32 | duration (``int``): 33 | Voice chat duration; in seconds. 34 | """ 35 | 36 | def __init__( 37 | self, *, 38 | duration: int 39 | ): 40 | super().__init__() 41 | 42 | self.duration = duration 43 | 44 | @staticmethod 45 | def _parse(action: "raw.types.MessageActionGroupCall") -> "VideoChatEnded": 46 | return VideoChatEnded(duration=action.duration) 47 | -------------------------------------------------------------------------------- /pyrography/types/user_and_chats/video_chat_members_invited.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from typing import List, Dict 25 | 26 | from pyrography import raw, types 27 | from ..object import Object 28 | 29 | 30 | class VideoChatMembersInvited(Object): 31 | """A service message about new members invited to a voice chat. 32 | 33 | 34 | Parameters: 35 | users (List of :obj:`~pyrography.types.User`): 36 | New members that were invited to the voice chat. 37 | """ 38 | 39 | def __init__( 40 | self, *, 41 | users: List["types.User"] 42 | ): 43 | super().__init__() 44 | 45 | self.users = users 46 | 47 | @staticmethod 48 | def _parse( 49 | client, 50 | action: "raw.types.MessageActionInviteToGroupCall", 51 | users: Dict[int, "raw.types.User"] 52 | ) -> "VideoChatMembersInvited": 53 | users = [types.User._parse(client, users[i]) for i in action.users] 54 | 55 | return VideoChatMembersInvited(users=users) 56 | -------------------------------------------------------------------------------- /pyrography/types/user_and_chats/video_chat_scheduled.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from datetime import datetime 25 | 26 | from pyrography import raw, utils 27 | from ..object import Object 28 | 29 | 30 | class VideoChatScheduled(Object): 31 | """A service message about a voice chat scheduled in the chat. 32 | 33 | Parameters: 34 | start_date (:py:obj:`~datetime.datetime`): 35 | Point in time when the voice chat is supposed to be started by a chat administrator. 36 | """ 37 | 38 | def __init__( 39 | self, *, 40 | start_date: datetime 41 | ): 42 | super().__init__() 43 | 44 | self.start_date = start_date 45 | 46 | @staticmethod 47 | def _parse(action: "raw.types.MessageActionGroupCallScheduled") -> "VideoChatScheduled": 48 | return VideoChatScheduled(start_date=utils.timestamp_to_datetime(action.schedule_date)) 49 | -------------------------------------------------------------------------------- /pyrography/types/user_and_chats/video_chat_started.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | from ..object import Object 25 | 26 | 27 | class VideoChatStarted(Object): 28 | """A service message about a voice chat started in the chat. 29 | 30 | Currently holds no information. 31 | """ 32 | 33 | def __init__(self): 34 | super().__init__() 35 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyaes==1.6.1 2 | pysocks==1.7.1 3 | rich~=13.4.2 4 | TgCrypto~=1.2.5 -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | -------------------------------------------------------------------------------- /tests/filters/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | 24 | class Client: 25 | def __init__(self): 26 | self.me = User("username") 27 | 28 | async def get_me(self): 29 | return self.me 30 | 31 | 32 | class User: 33 | def __init__(self, username: str = None): 34 | self.username = username 35 | 36 | 37 | class Message: 38 | def __init__(self, text: str = None, caption: str = None): 39 | self.text = text 40 | self.caption = caption 41 | self.command = None 42 | -------------------------------------------------------------------------------- /tests/parser/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pyrography - A wonderful Pyrogram fork inspired by Pyromod & AmanoTeam/Pyrogram. 3 | Copyright (C) 2023-present Lelzin λ 4 | 5 | Forked from Pyrogram , 6 | originally copyright (C) 2017-present Dan 7 | 8 | This file is part of Pyrography. 9 | 10 | Pyrography is is free software: you can redistribute it and/or modify it under 11 | the terms of the GNU Lesser General Public License as published by the Free 12 | Software Foundation, either version 3 of the License, or (at your option) any 13 | later version. 14 | 15 | Pyrography is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 18 | for more details. 19 | 20 | You should have received a copy of the GNU Lesser General Public License along 21 | with Pyrography. If not, see . 22 | """ 23 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [testenv] 2 | deps = -rdev-requirements.txt 3 | commands = coverage run -m pytest {posargs} 4 | skip_install = true --------------------------------------------------------------------------------