diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 9a4efc8c..61a2a41e 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -6,6 +6,7 @@ import shutil from pathlib import Path +# Paths HOME = "compiler/docs" DESTINATION = "docs/source/telegram" PYROGRAM_API_DEST = "docs/source/api" @@ -18,13 +19,33 @@ TYPES_BASE = "types" BASE_BASE = "base" +METHODS_PATH = "pyrogram/methods" +TYPES_LIB_PATH = "pyrogram/types" +ENUMS_LIB_PATH = "pyrogram/enums" + +# Titles mapping for categories that need a pretty name +METHODS_TITLES = { + "auth": "Authorization", + "business": "Telegram Business", +} + +TYPES_TITLES = { + "bots_and_keyboards": "Bot keyboards", + "bot_commands": "Bot commands", + "business": "Telegram Business", + "messages_and_media": "Messages & Media", + "user_and_chats": "Users & Chats", + "input_message_content": "Input Message Content", + "input_privacy_rule": "Input Privacy Rule", +} + def snake(s: str): s = re.sub(r"(.)([A-Z][a-z]+)", r"\1_\2", s) return re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", s).lower() -def generate(source_path, base) -> None: +def generate_raw(source_path, base) -> None: all_entities = {} def build(path, level=0) -> None: @@ -114,772 +135,290 @@ def build(path, level=0) -> None: def pyrogram_api() -> None: - def get_title_list(s: str) -> list: - return [i.strip() for i in [j.strip() for j in s.split("\n") if j] if i] - - # Methods - - categories = { - "utilities": """ - Utilities - start - stop - run - run_sync - restart - add_handler - remove_handler - stop_transmission - export_session_string - set_parse_mode - """, - "messages": """ - Messages - send_message - forward_messages - copy_message - copy_media_group - send_photo - send_audio - send_document - send_sticker - send_video - send_animation - send_voice - send_video_note - send_web_page - send_media_group - send_location - send_venue - send_contact - send_cached_media - send_reaction - send_paid_reaction - send_paid_media - edit_message_text - edit_message_caption - edit_message_media - edit_message_reply_markup - edit_inline_text - edit_inline_caption - edit_inline_media - edit_inline_reply_markup - send_chat_action - delete_messages - delete_scheduled_messages - get_available_effects - get_messages - get_scheduled_messages - get_media_group - get_chat_history - get_chat_history_count - read_chat_history - send_poll - vote_poll - stop_poll - retract_vote - send_dice - search_messages - search_messages_count - search_global - search_global_count - search_global_hashtag_messages - search_global_hashtag_messages_count - download_media - stream_media - get_discussion_message - get_discussion_replies - get_discussion_replies_count - get_custom_emoji_stickers - translate_text - """, - "chats": """ - Chats - join_chat - leave_chat - ban_chat_member - unban_chat_member - restrict_chat_member - promote_chat_member - set_administrator_title - set_chat_photo - delete_chat_photo - delete_folder - export_folder_link - set_chat_title - set_chat_description - set_chat_permissions - pin_chat_message - unpin_chat_message - unpin_all_chat_messages - get_chat - get_chat_member - get_chat_members - get_chat_members_count - get_dialogs - get_dialogs_count - get_folders - get_forum_topics - get_forum_topics_by_id - set_chat_username - archive_chats - unarchive_chats - add_chat_members - create_channel - create_group - create_supergroup - delete_channel - delete_supergroup - delete_user_history - set_slow_mode - mark_chat_unread - get_chat_event_log - get_chat_online_count - get_send_as_chats - set_send_as_chat - set_chat_protected_content - close_forum_topic - close_general_topic - create_forum_topic - delete_forum_topic - edit_forum_topic - edit_general_topic - hide_general_topic - reopen_forum_topic - reopen_general_topic - unhide_general_topic - update_color - delete_chat_history - update_folder - """, - "users": """ - Users - delete_account - get_me - get_users - get_chat_photos - get_chat_photos_count - set_profile_photo - delete_profile_photos - set_username - update_birthday - update_personal_chat - update_profile - block_user - unblock_user - get_common_chats - get_default_emoji_statuses - set_emoji_status - """, - "stories": """ - Stories - delete_stories - edit_story - export_story_link - forward_story - get_all_stories - get_stories - get_stories_history - get_peer_stories - send_story - """, - "stickers": """ - Stickers - add_sticker_to_set - create_sticker_set - get_sticker_set - """, - "invite_links": """ - Invite Links - get_chat_invite_link - export_chat_invite_link - create_chat_invite_link - edit_chat_invite_link - revoke_chat_invite_link - delete_chat_invite_link - get_chat_invite_link_joiners - get_chat_invite_link_joiners_count - get_chat_admin_invite_links - get_chat_admin_invite_links_count - get_chat_admins_with_invite_links - get_chat_join_requests - delete_chat_admin_invite_links - approve_chat_join_request - approve_all_chat_join_requests - decline_chat_join_request - decline_all_chat_join_requests - """, - "contacts": """ - Contacts - add_contact - delete_contacts - import_contacts - get_contacts - get_contacts_count - search_contacts - """, - "password": """ - Password - enable_cloud_password - change_cloud_password - remove_cloud_password - """, - "bots": """ - Bots - get_inline_bot_results - send_inline_bot_result - answer_callback_query - answer_inline_query - request_callback_answer - send_game - set_game_score - get_game_high_scores - set_bot_commands - get_bot_commands - delete_bot_commands - set_bot_default_privileges - get_bot_default_privileges - set_chat_menu_button - get_chat_menu_button - answer_web_app_query - get_bot_info - set_bot_info - get_collectible_item_info - get_available_gifts - get_user_gifts - sell_gift - send_gift - toggle_gift_is_saved - """, - "business": """ - Telegram Business - answer_pre_checkout_query - answer_shipping_query - create_invoice_link - get_business_connection - get_stars_transactions - get_stars_transactions_by_id - refund_star_payment - send_invoice - get_payment_form - send_payment_form - """, - "authorization": """ - Authorization - connect - disconnect - initialize - terminate - send_code - resend_code - sign_in - sign_in_bot - sign_up - get_password_hint - check_password - send_recovery_code - recover_password - accept_terms_of_service - log_out - get_active_sessions - reset_session - reset_sessions - """, - "advanced": """ - Advanced - invoke - resolve_peer - save_file - """, - "account": """ - Account - get_account_ttl - set_account_ttl - set_privacy - get_privacy - """, - } + # Discovery logic + + methods_categories = {} + methods_path = Path(METHODS_PATH) + if not methods_path.exists(): + methods_path = Path("../../") / METHODS_PATH + + for entry in sorted(methods_path.iterdir()): + if entry.is_dir() and entry.name != "decorators": + category_name = entry.name + methods = [] + for file in sorted(entry.glob("*.py")): + if file.name == "__init__.py": + continue - root = PYROGRAM_API_DEST + "/methods" + # Check if it defines a class or is special function (idle, compose) + with open(file, encoding="utf-8") as f: + tree = ast.parse(f.read()) - shutil.rmtree(root, ignore_errors=True) - Path(root).mkdir() - - with Path(HOME, "template/methods.rst").open() as f: - template = f.read() - - with Path(root, "index.rst").open("w") as f: - fmt_keys = {} - - for k, v in categories.items(): - name, *methods = get_title_list(v) - fmt_keys.update({k: "\n ".join(f"{m} <{m}>" for m in methods)}) - - for method in methods: - with Path(root, f"{method}.rst").open("w") as f2: - title = f"{method}()" - - f2.write(title + "\n" + "=" * len(title) + "\n\n") - f2.write(f".. automethod:: pyrogram.Client.{method}()") - - functions = ["idle", "compose"] - - for func in functions: - with Path(root, f"{func}.rst").open("w") as f2: - title = f"{func}()" - - f2.write(title + "\n" + "=" * len(title) + "\n\n") - f2.write(f".. autofunction:: pyrogram.{func}()") - - f.write(template.format(**fmt_keys)) - - # Types - - categories = { - "users_chats": """ - Users & Chats - Birthday - BusinessInfo - BusinessMessage - BusinessRecipients - BusinessWeeklyOpen - BusinessWorkingHours - User - Chat - ChatPreview - ChatPhoto - ChatMember - ChatPermissions - ChatPrivileges - ChatInviteLink - ChatAdminWithInviteLinks - ChatEvent - ChatEventFilter - ChatMemberUpdated - ChatJoinRequest - ChatJoinedByRequest - ChatJoiner - Dialog - Folder - Restriction - EmojiStatus - ForumTopic - PeerUser - PeerChannel - BotInfo - ChatColor - FoundContacts - PrivacyRule - CollectibleItemInfo - """, - "messages_media": """ - Messages & Media - Message - MessageEntity - Photo - Thumbnail - Audio - AvailableEffect - Document - Animation - AlternativeVideo - LabeledPrice - Video - Voice - VideoNote - Contact - Location - Venue - Sticker - StickerSet - ContactRegistered - ScreenshotTaken - Game - GiftedPremium - Gift - UserGift - Giveaway - GiveawayLaunched - GiveawayResult - MessageStory - WebPage - WebPageEmpty - WebPagePreview - Poll - PollOption - Dice - VideoChatScheduled - VideoChatStarted - VideoChatEnded - VideoChatMembersInvited - WebAppData - MessageReactions - MessageReactor - ChatReactions - ForumTopicCreated - ForumTopicEdited - ForumTopicClosed - ForumTopicReopened - GeneralTopicHidden - GeneralTopicUnhidden - Reaction - ReactionTypePaid - ReactionCount - ReactionType - MessageReactionUpdated - MessageReactionCountUpdated - TranslatedText - DraftMessage - """, - "stories": """ - Stories - Story - StoryDeleted - StoryForwardHeader - StorySkipped - StoriesPrivacyRules - StoryViews - MediaArea - MediaAreaChannelPost - MediaAreaCoordinates - InputMediaArea - InputMediaAreaChannelPost - """, - "bot": """ - Bot - BotAllowed - BotApp - BotBusinessConnection - """, - "bot_keyboards": """ - Bot keyboards - ReplyKeyboardMarkup - KeyboardButton - KeyboardButtonStyle - ReplyKeyboardRemove - InlineKeyboardMarkup - InlineKeyboardButton - InlineKeyboardButtonBuy - RequestPeerTypeChannel - RequestPeerTypeChat - RequestPeerTypeUser - RequestedChats - RequestedChat - RequestedUser - LoginUrl - ForceReply - CallbackQuery - GameHighScore - CallbackGame - WebAppInfo - MenuButton - MenuButtonCommands - MenuButtonWebApp - MenuButtonDefault - SentWebAppMessage - PreCheckoutQuery - """, - "bot_commands": """ - Bot commands - BotCommand - BotCommandScope - BotCommandScopeDefault - BotCommandScopeAllPrivateChats - BotCommandScopeAllGroupChats - BotCommandScopeAllChatAdministrators - BotCommandScopeChat - BotCommandScopeChatAdministrators - BotCommandScopeChatMember - """, - "business": """ - Telegram Business - ExtendedMediaPreview - InputStarsTransaction - Invoice - PaidMedia - PaidMediaPreview - PaymentForm - PaymentInfo - PaymentRefunded - ShippingAddress - ShippingOption - ShippingQuery - StarsStatus - StarsTransaction - SuccessfulPayment - """, - "input_media": """ - Input Media - InputMedia - InputMediaPhoto - InputMediaVideo - InputMediaAudio - InputMediaAnimation - InputMediaDocument - InputPhoneContact - """, - "inline_mode": """ - Inline Mode - InlineQuery - InlineQueryResult - InlineQueryResultCachedAudio - InlineQueryResultCachedDocument - InlineQueryResultCachedAnimation - InlineQueryResultCachedPhoto - InlineQueryResultCachedSticker - InlineQueryResultCachedVideo - InlineQueryResultCachedVoice - InlineQueryResultArticle - InlineQueryResultAudio - InlineQueryResultContact - InlineQueryResultDocument - InlineQueryResultAnimation - InlineQueryResultLocation - InlineQueryResultPhoto - InlineQueryResultVenue - InlineQueryResultVideo - InlineQueryResultVoice - ChosenInlineResult - """, - "pre_checkout_query": """ - PreCheckoutQuery - PreCheckoutQuery.answer - """, - "shipping_query": """ - ShippingQuery - ShippingQuery.answer - """, - "input_message_content": """ - InputMessageContent - InputMessageContent - InputReplyToMessage - InputReplyToStory - InputTextMessageContent - InputLocationMessageContent - InputVenueMessageContent - InputContactMessageContent - InputInvoiceMessageContent - """, - "authorization": """ - Authorization - ActiveSession - ActiveSessions - SentCode - TermsOfService - """, - "input_privacy_rule": """ - InputPrivacyRule - InputPrivacyRuleAllowAll - InputPrivacyRuleAllowContacts - InputPrivacyRuleAllowPremium - InputPrivacyRuleAllowUsers - InputPrivacyRuleAllowChats - InputPrivacyRuleDisallowAll - InputPrivacyRuleDisallowContacts - InputPrivacyRuleDisallowUsers - InputPrivacyRuleDisallowChats - """, - } + has_class = any( + isinstance(node, ast.ClassDef) for node in ast.walk(tree) + ) + is_special = file.stem in ["idle", "compose"] - root = PYROGRAM_API_DEST + "/types" + if has_class or is_special: + methods.append(file.stem) - shutil.rmtree(root, ignore_errors=True) - Path(root).mkdir() - - with Path(HOME, "template/types.rst").open() as f: - template = f.read() - - with Path(root, "index.rst").open("w") as f: - fmt_keys = {} - - for k, v in categories.items(): - name, *types = get_title_list(v) - - fmt_keys.update({k: "\n ".join(types)}) - - for type in types: - with Path(root, f"{type}.rst").open("w") as f2: - title = f"{type}" - - f2.write(title + "\n" + "=" * len(title) + "\n\n") - f2.write(f".. autoclass:: pyrogram.types.{type}()\n") - - f.write(template.format(**fmt_keys)) - - # Bound Methods - - categories = { - "message": """ - Message - Message.ask - Message.click - Message.delete - Message.download - Message.forward - Message.copy - Message.pin - Message.unpin - Message.edit - Message.edit_text - Message.edit_caption - Message.edit_media - Message.edit_reply_markup - Message.reply - Message.reply_text - Message.reply_animation - Message.reply_audio - Message.reply_cached_media - Message.reply_chat_action - Message.reply_contact - Message.reply_document - Message.reply_game - Message.reply_inline_bot_result - Message.reply_location - Message.reply_media_group - Message.reply_photo - Message.reply_poll - Message.reply_sticker - Message.reply_venue - Message.reply_video - Message.reply_video_note - Message.reply_voice - Message.reply_web_page - Message.get_media_group - Message.react - Message.wait_for_click - Message.pay - """, - "usergift": """ - UserGift - UserGift.toggle - """, - "chat": """ - Chat - Chat.ask - Chat.listen - Chat.stop_listening - Chat.archive - Chat.unarchive - Chat.set_title - Chat.set_description - Chat.set_photo - Chat.ban_member - Chat.unban_member - Chat.restrict_member - Chat.promote_member - Chat.get_member - Chat.get_members - Chat.add_members - Chat.join - Chat.leave - Chat.mark_unread - Chat.set_protected_content - Chat.unpin_all_messages - """, - "user": """ - User - User.ask - User.listen - User.stop_listening - User.archive - User.unarchive - User.block - User.unblock - """, - "story": """ - Story - Story.delete - Story.download - Story.react - Story.edit - Story.edit_animation - Story.edit_caption - Story.edit_photo - Story.edit_privacy - Story.edit_video - Story.export_link - Story.forward - Story.reply_text - Story.reply_animation - Story.reply_audio - Story.reply_cached_media - Story.reply_media_group - Story.reply_photo - Story.reply_sticker - Story.reply_video - Story.reply_video_note - Story.reply_voice - """, - "callback_query": """ - Callback Query - CallbackQuery.answer - CallbackQuery.edit_message_text - CallbackQuery.edit_message_caption - CallbackQuery.edit_message_media - CallbackQuery.edit_message_reply_markup - """, - "inline_query": """ - InlineQuery - InlineQuery.answer - """, - "pre_checkout_query": """ - PreCheckoutQuery - PreCheckoutQuery.answer - """, - "shipping_query": """ - ShippingQuery - ShippingQuery.answer - """, - "chat_join_request": """ - ChatJoinRequest - ChatJoinRequest.approve - ChatJoinRequest.decline - """, - "active_session": """ - ActiveSession - ActiveSession.reset - """, - } + if methods: + title = METHODS_TITLES.get( + category_name, + category_name.replace("_", " ").title(), + ) + methods_categories[category_name] = (title, methods) + + types_categories = {} + types_lib_path = Path(TYPES_LIB_PATH) + if not types_lib_path.exists(): + types_lib_path = Path("../../") / TYPES_LIB_PATH + + for entry in sorted(types_lib_path.iterdir()): + if entry.is_dir(): + category_name = entry.name + types = [] + for file in sorted(entry.glob("*.py")): + if file.name == "__init__.py": + continue + with Path(file).open(encoding="utf-8") as f: + try: + tree = ast.parse(f.read()) + except Exception: + continue + for node in ast.walk(tree): + if isinstance(node, ast.ClassDef): + types.append(node.name) + if types: + title = TYPES_TITLES.get( + category_name, + category_name.replace("_", " ").title(), + ) + types_categories[category_name] = (title, sorted(types)) - root = PYROGRAM_API_DEST + "/bound-methods" + bound_methods_categories = {} + for file in sorted(types_lib_path.rglob("*.py")): + if file.name == "__init__.py": + continue + with Path(file).open(encoding="utf-8") as f: + try: + tree = ast.parse(f.read()) + except Exception: + continue + for node in ast.walk(tree): + if isinstance(node, ast.ClassDef): + class_name = node.name + class_bound_methods = [] + for item in node.body: + if isinstance(item, (ast.AsyncFunctionDef, ast.FunctionDef)): + docstring = ast.get_docstring(item) + if docstring and "Bound method" in docstring: + class_bound_methods.append(f"{class_name}.{item.name}") + if class_bound_methods: + if class_name not in bound_methods_categories: + bound_methods_categories[class_name] = [] + bound_methods_categories[class_name].extend( + sorted(class_bound_methods), + ) - shutil.rmtree(root, ignore_errors=True) - Path(root).mkdir() + enums_lib_path = Path(ENUMS_LIB_PATH) + if not enums_lib_path.exists(): + enums_lib_path = Path("../../") / ENUMS_LIB_PATH - with Path(HOME, "template/bound-methods.rst").open() as f: - template = f.read() + enums_list = [] + for file in sorted(enums_lib_path.glob("*.py")): + if file.name in ["__init__.py", "auto_name.py"]: + continue + with Path(file).open(encoding="utf-8") as f: + try: + tree = ast.parse(f.read()) + except Exception: + continue + for node in ast.walk(tree): + if isinstance(node, ast.ClassDef): + enums_list.append(node.name) - with Path(root, "index.rst").open("w") as f: - fmt_keys = {} + # Methods Generation - for k, v in categories.items(): - _name, *bound_methods = get_title_list(v) + root = PYROGRAM_API_DEST + "/methods" + shutil.rmtree(root, ignore_errors=True) + Path(root).mkdir(parents=True, exist_ok=True) + + with Path(root, "index.rst").open("w", encoding="utf-8") as f: + f.write("Available Methods\n=================\n\n") + f.write( + "This page is about Electrogram methods. All the methods listed here are bound to a :class:`~pyrogram.Client` instance,\n", + ) + f.write( + "except for :meth:`~pyrogram.idle()` and :meth:`~pyrogram.compose()`, which are special functions that can be found in\n", + ) + f.write("the main package directly.\n\n") + f.write(".. code-block:: python\n\n") + f.write(" from pyrogram import Client\n\n") + f.write(' app = Client("my_account")\n\n') + f.write(" with app:\n") + f.write(' app.send_message("me", "hi")\n\n') + f.write("-----\n\n") + + for cat_name, (title, methods) in methods_categories.items(): + if cat_name == "utilities": + f.write(".. currentmodule:: pyrogram.Client\n\n") + f.write(f"{title}\n" + "-" * len(title) + "\n\n") + f.write(".. autosummary::\n :nosignatures:\n\n") + for m in sorted(methods): + if m not in ["idle", "compose"]: + f.write(f" {m}\n") + f.write("\n.. toctree::\n :hidden:\n\n") + for m in sorted(methods): + if m not in ["idle", "compose"]: + f.write(f" {m} <{m}>\n") + f.write("\n.. currentmodule:: pyrogram\n\n") + f.write(".. autosummary::\n :nosignatures:\n\n") + if "idle" in methods: + f.write(" idle\n") + if "compose" in methods: + f.write(" compose\n") + f.write("\n.. toctree::\n :hidden:\n\n") + if "idle" in methods: + f.write(" idle \n") + if "compose" in methods: + f.write(" compose \n") + f.write("\n") + else: + f.write(".. currentmodule:: pyrogram.Client\n\n") + f.write(f"{title}\n" + "-" * len(title) + "\n\n") + if cat_name == "advanced": + f.write( + "Methods used only when dealing with the raw Telegram API.\n", + ) + f.write( + "Learn more about how to use the raw API at :doc:`Advanced Usage <../../topics/advanced-usage>`.\n\n", + ) + f.write(".. autosummary::\n :nosignatures:\n\n") + for m in sorted(methods): + f.write(f" {m}\n") + f.write("\n.. toctree::\n :hidden:\n\n") + for m in sorted(methods): + f.write(f" {m} <{m}>\n") + f.write("\n") + + for m in methods: + with Path(root, f"{m}.rst").open("w", encoding="utf-8") as f2: + title_m = f"{m}()" + f2.write(title_m + "\n" + "=" * len(title_m) + "\n\n") + if m in ["idle", "compose"]: + f2.write(f".. autofunction:: pyrogram.{m}()") + else: + f2.write(f".. automethod:: pyrogram.Client.{m}()") + + # Types Generation - fmt_keys.update( - { - f"{k}_hlist": "\n ".join( - f"- :meth:`~{bm}`" for bm in bound_methods - ), - }, - ) + root = PYROGRAM_API_DEST + "/types" + shutil.rmtree(root, ignore_errors=True) + Path(root).mkdir(parents=True, exist_ok=True) + + with Path(root, "index.rst").open("w", encoding="utf-8") as f: + f.write("Available Types\n===============\n\n") + f.write( + "This page is about Electrogram Types. All types listed here are available through the ``pyrogram.types`` package.\n", + ) + f.write( + "Unless required as argument to a client method, most of the types don't need to be manually instantiated because they\n", + ) + f.write( + "are only returned by other methods. You also don't need to import them, unless you want to type-hint your variables.\n\n", + ) + f.write(".. code-block:: python\n\n") + f.write(" from pyrogram.types import User, Message, ...\n\n") + f.write(".. note::\n\n") + f.write( + " Optional fields always exist inside the object, but they could be empty and contain the value of ``None``.\n", + ) + f.write( + " Empty fields aren't shown when, for example, using ``print(message)`` and this means that\n", + ) + f.write( + ' ``hasattr(message, "photo")`` always returns ``True``.\n\n', + ) + f.write( + " To tell whether a field is set or not, do a simple boolean check: ``if message.photo: ...``.\n\n", + ) + f.write("-----\n\n") + f.write(".. currentmodule:: pyrogram.types\n\n") + + for cat_name, (title, t_list) in sorted(types_categories.items()): + f.write(f"{title}\n" + "-" * len(title) + "\n\n") + f.write(".. autosummary::\n :nosignatures:\n\n") + f.writelines(f" {t}\n" for t in sorted(t_list)) + f.write("\n.. toctree::\n :hidden:\n\n") + f.writelines(f" {t} <{t}>\n" for t in sorted(t_list)) + f.write("\n") - fmt_keys.update( - { - f"{k}_toctree": "\n ".join( - "{} <{}>".format(bm.split(".")[1], bm) - for bm in bound_methods - ), - }, + for t in t_list: + with Path(root, f"{t}.rst").open("w", encoding="utf-8") as f2: + f2.write(t + "\n" + "=" * len(t) + "\n\n") + f2.write(f".. autoclass:: pyrogram.types.{t}()\n") + + # Bound Methods Generation + + root = PYROGRAM_API_DEST + "/bound-methods" + shutil.rmtree(root, ignore_errors=True) + Path(root).mkdir(parents=True, exist_ok=True) + + with Path(root, "index.rst").open("w", encoding="utf-8") as f: + f.write("Bound Methods\n=============\n\n") + f.write( + "Some Electrogram types define what are called bound methods. Bound methods are functions attached to a type which are\n", + ) + f.write( + "accessed via an instance of that type. They make it even easier to call specific methods by automatically inferring\n", + ) + f.write("some of the required arguments.\n\n") + f.write(".. code-block:: python\n\n") + f.write(" from pyrogram import Client\n\n") + f.write(' app = Client("my_account")\n\n\n') + f.write(" @app.on_message()\n") + f.write(" def hello(client, message)\n") + f.write(' message.reply("hi")\n\n\n') + f.write(" app.run()\n\n") + f.write("-----\n\n") + f.write(".. currentmodule:: pyrogram.types\n\n") + + for class_name, bound_methods in sorted(bound_methods_categories.items()): + f.write(f"{class_name}\n" + "-" * len(class_name) + "\n\n") + f.write(".. hlist::\n :columns: 1\n\n") + f.writelines(f" - :meth:`~{bm}`\n" for bm in sorted(bound_methods)) + f.write("\n.. toctree::\n :hidden:\n\n") + f.writelines( + f" {bm.split('.')[1]} <{bm}>\n" for bm in sorted(bound_methods) ) + f.write("\n") for bm in bound_methods: - with Path(root, f"{bm}.rst").open("w") as f2: - title = f"{bm}()" - - f2.write(title + "\n" + "=" * len(title) + "\n\n") + with Path(root, f"{bm}.rst").open("w", encoding="utf-8") as f2: + title_bm = f"{bm}()" + f2.write(title_bm + "\n" + "=" * len(title_bm) + "\n\n") f2.write(f".. automethod:: pyrogram.types.{bm}()") - f.write(template.format(**fmt_keys)) + # Enums Generation + + if enums_list: + root = PYROGRAM_API_DEST + "/enums" + shutil.rmtree(root, ignore_errors=True) + Path(root).mkdir(parents=True, exist_ok=True) + + with Path(root, "index.rst").open("w", encoding="utf-8") as f: + f.write("Available Enums\n===============\n\n") + f.write(".. currentmodule:: pyrogram.enums\n\n") + f.write(".. autosummary::\n :nosignatures:\n\n") + f.writelines(f" {e}\n" for e in sorted(enums_list)) + f.write("\n.. toctree::\n :hidden:\n\n") + f.writelines(f" {e} <{e}>\n" for e in sorted(enums_list)) + + for e in enums_list: + with Path(root, f"{e}.rst").open("w", encoding="utf-8") as f2: + f2.write(e + "\n" + "=" * len(e) + "\n\n") + f2.write(f".. autoclass:: pyrogram.enums.{e}()\n :members:\n") def start() -> None: @@ -893,9 +432,9 @@ def start() -> None: with Path(HOME, "template/toctree.txt").open(encoding="utf-8") as f: toctree = f.read() - generate(TYPES_PATH, TYPES_BASE) - generate(FUNCTIONS_PATH, FUNCTIONS_BASE) - generate(BASE_PATH, BASE_BASE) + generate_raw(TYPES_PATH, TYPES_BASE) + generate_raw(FUNCTIONS_PATH, FUNCTIONS_BASE) + generate_raw(BASE_PATH, BASE_BASE) pyrogram_api() @@ -903,6 +442,9 @@ def start() -> None: FUNCTIONS_PATH = "../../pyrogram/raw/functions" TYPES_PATH = "../../pyrogram/raw/types" BASE_PATH = "../../pyrogram/raw/base" + METHODS_PATH = "../../pyrogram/methods" + TYPES_LIB_PATH = "../../pyrogram/types" + ENUMS_LIB_PATH = "../../pyrogram/enums" HOME = "." DESTINATION = "../../docs/source/telegram" PYROGRAM_API_DEST = "../../docs/source/api" diff --git a/compiler/docs/template/bound-methods.rst b/compiler/docs/template/bound-methods.rst deleted file mode 100644 index 3daa629c..00000000 --- a/compiler/docs/template/bound-methods.rst +++ /dev/null @@ -1,167 +0,0 @@ -Bound Methods -============= - -Some Electrogram types define what are called bound methods. Bound methods are functions attached to a type which are -accessed via an instance of that type. They make it even easier to call specific methods by automatically inferring -some of the required arguments. - -.. code-block:: python - - from pyrogram import Client - - app = Client("my_account") - - - @app.on_message() - def hello(client, message) - message.reply("hi") - - - app.run() - ------ - -.. currentmodule:: pyrogram.types - -Message -------- - -.. hlist:: - :columns: 1 - - {message_hlist} - -.. toctree:: - :hidden: - - {message_toctree} - -UserGift --------- - -.. hlist:: - :columns: 1 - - {usergift_hlist} - -.. toctree:: - :hidden: - - {usergift_toctree} - -Story ------ - -.. hlist:: - :columns: 1 - - {story_hlist} - -.. toctree:: - :hidden: - - {story_toctree} - -Chat ----- - -.. hlist:: - :columns: 1 - - {chat_hlist} - -.. toctree:: - :hidden: - - {chat_toctree} - -User ----- - -.. hlist:: - :columns: 1 - - {user_hlist} - -.. toctree:: - :hidden: - - {user_toctree} - -CallbackQuery -------------- - -.. hlist:: - :columns: 1 - - {callback_query_hlist} - -.. toctree:: - :hidden: - - {callback_query_toctree} - -InlineQuery ------------ - -.. hlist:: - :columns: 1 - - {inline_query_hlist} - -.. toctree:: - :hidden: - - {inline_query_toctree} - -PreCheckoutQuery ----------------- - -.. hlist:: - :columns: 1 - - {pre_checkout_query_hlist} - -.. toctree:: - :hidden: - - {pre_checkout_query_toctree} - -ShippingQuery -------------- - -.. hlist:: - :columns: 1 - - {shipping_query_hlist} - -.. toctree:: - :hidden: - - {shipping_query_toctree} - -ChatJoinRequest ---------------- - -.. hlist:: - :columns: 1 - - {chat_join_request_hlist} - -.. toctree:: - :hidden: - - {chat_join_request_toctree} - -ActiveSession -------------- - -.. hlist:: - :columns: 1 - - {active_session_hlist} - -.. toctree:: - :hidden: - - {active_session_toctree} diff --git a/compiler/docs/template/enums.rst b/compiler/docs/template/enums.rst deleted file mode 100644 index c7b61921..00000000 --- a/compiler/docs/template/enums.rst +++ /dev/null @@ -1,21 +0,0 @@ -Enumerations -============ - -This page is about Pyrogram enumerations. -Enumerations are types that hold a group of related values to be used whenever a constant value is required. -They will help you deal with those values in a type-safe way and also enable code completion so that you can be sure -to apply only a valid value among the expected ones. - ------ - -.. currentmodule:: pyrogram.enums - -.. autosummary:: - :nosignatures: - - {enums_hlist} - -.. toctree:: - :hidden: - - {enums_toctree} diff --git a/compiler/docs/template/methods.rst b/compiler/docs/template/methods.rst deleted file mode 100644 index 1fbedc04..00000000 --- a/compiler/docs/template/methods.rst +++ /dev/null @@ -1,220 +0,0 @@ -Available Methods -================= - -This page is about Electrogram methods. All the methods listed here are bound to a :class:`~pyrogram.Client` instance, -except for :meth:`~pyrogram.idle()` and :meth:`~pyrogram.compose()`, which are special functions that can be found in -the main package directly. - -.. code-block:: python - - from pyrogram import Client - - app = Client("my_account") - - with app: - app.send_message("me", "hi") - ------ - -.. currentmodule:: pyrogram.Client - -Utilities ---------- - -.. autosummary:: - :nosignatures: - - {utilities} - -.. toctree:: - :hidden: - - {utilities} - -.. currentmodule:: pyrogram - -.. autosummary:: - :nosignatures: - - idle - compose - -.. toctree:: - :hidden: - - idle - compose - -.. currentmodule:: pyrogram.Client - -Messages --------- - -.. autosummary:: - :nosignatures: - - {messages} - -.. toctree:: - :hidden: - - {messages} - -Stories -------- - -.. autosummary:: - :nosignatures: - - {stories} - -.. toctree:: - :hidden: - - {stories} - -Chats ------ - -.. autosummary:: - :nosignatures: - - {chats} - -.. toctree:: - :hidden: - - {chats} - -Stickers --------- - -.. autosummary:: - :nosignatures: - - {stickers} - -.. toctree:: - :hidden: - - {stickers} - -Telegram Business ------------------ - -.. autosummary:: - :nosignatures: - - {business} - -.. toctree:: - :hidden: - - {business} - -Users ------ - -.. autosummary:: - :nosignatures: - - {users} - -.. toctree:: - :hidden: - - {users} - -Invite Links ------------- - -.. autosummary:: - :nosignatures: - - {invite_links} - -.. toctree:: - :hidden: - - {invite_links} - -Contacts --------- - -.. autosummary:: - :nosignatures: - - {contacts} - -.. toctree:: - :hidden: - - {contacts} - -Password --------- - -.. autosummary:: - :nosignatures: - - {password} - -.. toctree:: - :hidden: - - {password} - -Bots ----- - -.. autosummary:: - :nosignatures: - - {bots} - -.. toctree:: - :hidden: - - {bots} - -Authorization -------------- - -.. autosummary:: - :nosignatures: - - {authorization} - -.. toctree:: - :hidden: - - {authorization} - -Account -------- - -.. autosummary:: - :nosignatures: - - {account} - -.. toctree:: - :hidden: - - {account} - -Advanced --------- - -Methods used only when dealing with the raw Telegram API. -Learn more about how to use the raw API at :doc:`Advanced Usage <../../topics/advanced-usage>`. - -.. autosummary:: - :nosignatures: - - {advanced} - -.. toctree:: - :hidden: - - {advanced} diff --git a/compiler/docs/template/types.rst b/compiler/docs/template/types.rst deleted file mode 100644 index 3618120a..00000000 --- a/compiler/docs/template/types.rst +++ /dev/null @@ -1,178 +0,0 @@ -Available Types -=============== - -This page is about Electrogram Types. All types listed here are available through the ``pyrogram.types`` package. -Unless required as argument to a client method, most of the types don't need to be manually instantiated because they -are only returned by other methods. You also don't need to import them, unless you want to type-hint your variables. - -.. code-block:: python - - from pyrogram.types import User, Message, ... - -.. note:: - - Optional fields always exist inside the object, but they could be empty and contain the value of ``None``. - Empty fields aren't shown when, for example, using ``print(message)`` and this means that - ``hasattr(message, "photo")`` always returns ``True``. - - To tell whether a field is set or not, do a simple boolean check: ``if message.photo: ...``. - ------ - -.. currentmodule:: pyrogram.types - -Users & Chats -------------- - -.. autosummary:: - :nosignatures: - - {users_chats} - -.. toctree:: - :hidden: - - {users_chats} - -Messages & Media ----------------- - -.. autosummary:: - :nosignatures: - - {messages_media} - -.. toctree:: - :hidden: - - {messages_media} - -Stories -------- - -.. autosummary:: - :nosignatures: - - {stories} - -.. toctree:: - :hidden: - - {stories} - -Bot ---- - -.. autosummary:: - :nosignatures: - - {bot} - -.. toctree:: - :hidden: - - {bot} - -Bot keyboards -------------- - -.. autosummary:: - :nosignatures: - - {bot_keyboards} - -.. toctree:: - :hidden: - - {bot_keyboards} - -Bot commands ------------- - -.. autosummary:: - :nosignatures: - - {bot_commands} - -.. toctree:: - :hidden: - - {bot_commands} - -Telegram Business ------------------ - -.. autosummary:: - :nosignatures: - - {business} - -.. toctree:: - :hidden: - - {business} - -Input Media ------------ - -.. autosummary:: - :nosignatures: - - {input_media} - -.. toctree:: - :hidden: - - {input_media} - -Inline Mode ------------ - -.. autosummary:: - :nosignatures: - - {inline_mode} - -.. toctree:: - :hidden: - - {inline_mode} - -InputMessageContent -------------------- - -.. autosummary:: - :nosignatures: - - {input_message_content} - -.. toctree:: - :hidden: - - {input_message_content} - -Authorization -------------- - -.. autosummary:: - :nosignatures: - - {authorization} - -.. toctree:: - :hidden: - - {authorization} - -InputPrivacyRule ----------------- - -.. autosummary:: - :nosignatures: - - {input_privacy_rule} - -.. toctree:: - :hidden: - - {input_privacy_rule} \ No newline at end of file diff --git a/docs/source/_static/css/custom.css b/docs/source/_static/css/custom.css index 01b413bb..2ac5792e 100644 --- a/docs/source/_static/css/custom.css +++ b/docs/source/_static/css/custom.css @@ -1,24 +1,69 @@ -body{ - --color-green: darkgreen; - --color-red: darkred; +:root { + --md-primary-fg-color: #3f51b5; + --md-primary-fg-color--light: #7986cb; + --md-primary-fg-color--dark: #303f9f; + --md-accent-fg-color: #3f51b5; +} + +body { + --color-green: #2e7d32; + --color-red: #c62828; } .usable-by { - border: 1px ; - border-radius: .2em; - padding: 2px 5px; - background-color: #FFFFFF00; + border: 1px solid #e0e0e0; + border-radius: .4em; + padding: 4px 8px; + background-color: #f5f5f5; + font-size: 0.9em; + font-weight: 500; + display: inline-block; + margin-bottom: 1em; +} + +[data-md-color-scheme="slate"] .usable-by { + border-color: #37474f; + background-color: #263238; + color: #eceff1; } -a .pre{ - color:lightgrey; +a .pre { + color: inherit; + font-weight: 500; } .md-main a { + text-decoration: none; + color: var(--md-primary-fg-color); + transition: color 0.3s; +} + +.md-main a:hover { + color: var(--md-primary-fg-color--light); text-decoration: underline; - color:lightgrey; } .md-sidebar a { text-decoration: none; } + +/* Improve code blocks */ +.highlight { + border-radius: 4px; +} + +/* Improve tables */ +table.docutils { + width: 100%; + border-collapse: collapse; +} + +table.docutils td, table.docutils th { + padding: 8px 12px; + border: 1px solid #e0e0e0; +} + +[data-md-color-scheme="slate"] table.docutils td, +[data-md-color-scheme="slate"] table.docutils th { + border-color: #37474f; +} diff --git a/docs/source/api/enums/AccentColor.rst b/docs/source/api/enums/AccentColor.rst index 9e777fa6..47452bcd 100644 --- a/docs/source/api/enums/AccentColor.rst +++ b/docs/source/api/enums/AccentColor.rst @@ -3,6 +3,3 @@ AccentColor .. autoclass:: pyrogram.enums.AccentColor() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/BusinessSchedule.rst b/docs/source/api/enums/BusinessSchedule.rst index b3a58d28..e96bc47c 100644 --- a/docs/source/api/enums/BusinessSchedule.rst +++ b/docs/source/api/enums/BusinessSchedule.rst @@ -3,6 +3,3 @@ BusinessSchedule .. autoclass:: pyrogram.enums.BusinessSchedule() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ChatAction.rst b/docs/source/api/enums/ChatAction.rst index b66df5fd..d24b64f3 100644 --- a/docs/source/api/enums/ChatAction.rst +++ b/docs/source/api/enums/ChatAction.rst @@ -3,6 +3,3 @@ ChatAction .. autoclass:: pyrogram.enums.ChatAction() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ChatEventAction.rst b/docs/source/api/enums/ChatEventAction.rst index 0403e781..d70000d2 100644 --- a/docs/source/api/enums/ChatEventAction.rst +++ b/docs/source/api/enums/ChatEventAction.rst @@ -3,6 +3,3 @@ ChatEventAction .. autoclass:: pyrogram.enums.ChatEventAction() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ChatJoinType.rst b/docs/source/api/enums/ChatJoinType.rst index 3470453e..d2aab04a 100644 --- a/docs/source/api/enums/ChatJoinType.rst +++ b/docs/source/api/enums/ChatJoinType.rst @@ -3,6 +3,3 @@ ChatJoinType .. autoclass:: pyrogram.enums.ChatJoinType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ChatMemberStatus.rst b/docs/source/api/enums/ChatMemberStatus.rst index bff23eda..10348617 100644 --- a/docs/source/api/enums/ChatMemberStatus.rst +++ b/docs/source/api/enums/ChatMemberStatus.rst @@ -3,6 +3,3 @@ ChatMemberStatus .. autoclass:: pyrogram.enums.ChatMemberStatus() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ChatMembersFilter.rst b/docs/source/api/enums/ChatMembersFilter.rst index 5a970ffc..16347134 100644 --- a/docs/source/api/enums/ChatMembersFilter.rst +++ b/docs/source/api/enums/ChatMembersFilter.rst @@ -3,6 +3,3 @@ ChatMembersFilter .. autoclass:: pyrogram.enums.ChatMembersFilter() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ChatType.rst b/docs/source/api/enums/ChatType.rst index dd653055..799f3afc 100644 --- a/docs/source/api/enums/ChatType.rst +++ b/docs/source/api/enums/ChatType.rst @@ -3,6 +3,3 @@ ChatType .. autoclass:: pyrogram.enums.ChatType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ClientPlatform.rst b/docs/source/api/enums/ClientPlatform.rst index 3ac289f7..7447db7b 100644 --- a/docs/source/api/enums/ClientPlatform.rst +++ b/docs/source/api/enums/ClientPlatform.rst @@ -3,6 +3,3 @@ ClientPlatform .. autoclass:: pyrogram.enums.ClientPlatform() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/FolderColor.rst b/docs/source/api/enums/FolderColor.rst index 0f727d28..892fc047 100644 --- a/docs/source/api/enums/FolderColor.rst +++ b/docs/source/api/enums/FolderColor.rst @@ -3,6 +3,3 @@ FolderColor .. autoclass:: pyrogram.enums.FolderColor() :members: - -.. raw:: html - :file: ./cleanup.html diff --git a/docs/source/api/enums/ListenerTypes.rst b/docs/source/api/enums/ListenerTypes.rst index 39d8b960..1ba2022f 100644 --- a/docs/source/api/enums/ListenerTypes.rst +++ b/docs/source/api/enums/ListenerTypes.rst @@ -3,6 +3,3 @@ ListenerTypes .. autoclass:: pyrogram.enums.ListenerTypes() :members: - -.. raw:: html - :file: ./cleanup.html diff --git a/docs/source/api/enums/MessageEntityType.rst b/docs/source/api/enums/MessageEntityType.rst index c7a8965f..baa399cd 100644 --- a/docs/source/api/enums/MessageEntityType.rst +++ b/docs/source/api/enums/MessageEntityType.rst @@ -3,6 +3,3 @@ MessageEntityType .. autoclass:: pyrogram.enums.MessageEntityType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/MessageMediaType.rst b/docs/source/api/enums/MessageMediaType.rst index 04e439d2..b1fb3b8a 100644 --- a/docs/source/api/enums/MessageMediaType.rst +++ b/docs/source/api/enums/MessageMediaType.rst @@ -3,6 +3,3 @@ MessageMediaType .. autoclass:: pyrogram.enums.MessageMediaType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/MessageServiceType.rst b/docs/source/api/enums/MessageServiceType.rst index 2de56818..93ad3d92 100644 --- a/docs/source/api/enums/MessageServiceType.rst +++ b/docs/source/api/enums/MessageServiceType.rst @@ -3,6 +3,3 @@ MessageServiceType .. autoclass:: pyrogram.enums.MessageServiceType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/MessagesFilter.rst b/docs/source/api/enums/MessagesFilter.rst index 09090707..a2aea707 100644 --- a/docs/source/api/enums/MessagesFilter.rst +++ b/docs/source/api/enums/MessagesFilter.rst @@ -3,6 +3,3 @@ MessagesFilter .. autoclass:: pyrogram.enums.MessagesFilter() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/NextCodeType.rst b/docs/source/api/enums/NextCodeType.rst index 46164e47..38b2bd54 100644 --- a/docs/source/api/enums/NextCodeType.rst +++ b/docs/source/api/enums/NextCodeType.rst @@ -3,6 +3,3 @@ NextCodeType .. autoclass:: pyrogram.enums.NextCodeType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ParseMode.rst b/docs/source/api/enums/ParseMode.rst index 1bcc74da..312367e5 100644 --- a/docs/source/api/enums/ParseMode.rst +++ b/docs/source/api/enums/ParseMode.rst @@ -3,6 +3,3 @@ ParseMode .. autoclass:: pyrogram.enums.ParseMode() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/PollType.rst b/docs/source/api/enums/PollType.rst index d00f9ce8..815d72aa 100644 --- a/docs/source/api/enums/PollType.rst +++ b/docs/source/api/enums/PollType.rst @@ -3,6 +3,3 @@ PollType .. autoclass:: pyrogram.enums.PollType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/PrivacyKey.rst b/docs/source/api/enums/PrivacyKey.rst index 88ced4cc..f7f43216 100644 --- a/docs/source/api/enums/PrivacyKey.rst +++ b/docs/source/api/enums/PrivacyKey.rst @@ -3,6 +3,3 @@ PrivacyKey .. autoclass:: pyrogram.enums.PrivacyKey() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ProfileColor.rst b/docs/source/api/enums/ProfileColor.rst index 8b75006b..93bbfd67 100644 --- a/docs/source/api/enums/ProfileColor.rst +++ b/docs/source/api/enums/ProfileColor.rst @@ -3,6 +3,3 @@ ProfileColor .. autoclass:: pyrogram.enums.ProfileColor() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/ReactionType.rst b/docs/source/api/enums/ReactionType.rst index 59692fba..b53fadc8 100644 --- a/docs/source/api/enums/ReactionType.rst +++ b/docs/source/api/enums/ReactionType.rst @@ -3,6 +3,3 @@ ReactionType .. autoclass:: pyrogram.enums.ReactionType() :members: - -.. raw:: html - :file: ./cleanup.html diff --git a/docs/source/api/enums/ReplyColor.rst b/docs/source/api/enums/ReplyColor.rst index 519f2e35..f4e38bd3 100644 --- a/docs/source/api/enums/ReplyColor.rst +++ b/docs/source/api/enums/ReplyColor.rst @@ -3,6 +3,3 @@ ReplyColor .. autoclass:: pyrogram.enums.ReplyColor() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/SentCodeType.rst b/docs/source/api/enums/SentCodeType.rst index d738b195..0931ac62 100644 --- a/docs/source/api/enums/SentCodeType.rst +++ b/docs/source/api/enums/SentCodeType.rst @@ -3,6 +3,3 @@ SentCodeType .. autoclass:: pyrogram.enums.SentCodeType() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/StoriesPrivacyRules.rst b/docs/source/api/enums/StoriesPrivacyRules.rst index 995cd073..05f6307a 100644 --- a/docs/source/api/enums/StoriesPrivacyRules.rst +++ b/docs/source/api/enums/StoriesPrivacyRules.rst @@ -3,6 +3,3 @@ StoriesPrivacyRules .. autoclass:: pyrogram.enums.StoriesPrivacyRules() :members: - -.. raw:: html - :file: ./cleanup.html diff --git a/docs/source/api/enums/StoryPrivacy.rst b/docs/source/api/enums/StoryPrivacy.rst index 8438febf..14e3cd42 100644 --- a/docs/source/api/enums/StoryPrivacy.rst +++ b/docs/source/api/enums/StoryPrivacy.rst @@ -3,6 +3,3 @@ StoryPrivacy .. autoclass:: pyrogram.enums.StoryPrivacy() :members: - -.. raw:: html - :file: ./cleanup.html diff --git a/docs/source/api/enums/UserStatus.rst b/docs/source/api/enums/UserStatus.rst index c9a77e1b..8afd0343 100644 --- a/docs/source/api/enums/UserStatus.rst +++ b/docs/source/api/enums/UserStatus.rst @@ -3,6 +3,3 @@ UserStatus .. autoclass:: pyrogram.enums.UserStatus() :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/cleanup.html b/docs/source/api/enums/cleanup.html deleted file mode 100644 index bb9db780..00000000 --- a/docs/source/api/enums/cleanup.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/docs/source/api/enums/index.rst b/docs/source/api/enums/index.rst index 446d7408..100ee56b 100644 --- a/docs/source/api/enums/index.rst +++ b/docs/source/api/enums/index.rst @@ -1,12 +1,5 @@ -Enumerations -============ - -This page is about Electrogram enumerations. -Enumerations are types that hold a group of related values to be used whenever a constant value is required. -They will help you deal with those values in a type-safe way and also enable code completion so that you can be sure -to apply only a valid value among the expected ones. - ------ +Available Enums +=============== .. currentmodule:: pyrogram.enums @@ -43,29 +36,29 @@ to apply only a valid value among the expected ones. .. toctree:: :hidden: - AccentColor - BusinessSchedule - ChatAction - ChatEventAction - ChatJoinType - ChatMemberStatus - ChatMembersFilter - ChatType - ClientPlatform - FolderColor - ListenerTypes - MessageEntityType - MessageMediaType - MessageServiceType - MessagesFilter - NextCodeType - ParseMode - PollType - PrivacyKey - ProfileColor - ReactionType - ReplyColor - SentCodeType - StoriesPrivacyRules - StoryPrivacy - UserStatus + AccentColor + BusinessSchedule + ChatAction + ChatEventAction + ChatJoinType + ChatMemberStatus + ChatMembersFilter + ChatType + ClientPlatform + FolderColor + ListenerTypes + MessageEntityType + MessageMediaType + MessageServiceType + MessagesFilter + NextCodeType + ParseMode + PollType + PrivacyKey + ProfileColor + ReactionType + ReplyColor + SentCodeType + StoriesPrivacyRules + StoryPrivacy + UserStatus diff --git a/docs/source/conf.py b/docs/source/conf.py index b4f675b7..b481aadd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -83,8 +83,8 @@ { "media": "(prefers-color-scheme: light)", "scheme": "default", - "primary": "blue-grey", - "accent": "light-blue", + "primary": "indigo", + "accent": "indigo", "toggle": { "icon": "material/lightbulb-outline", "name": "Switch to dark mode", @@ -93,8 +93,8 @@ { "media": "(prefers-color-scheme: dark)", "scheme": "slate", - "primary": "blue-grey", - "accent": "lime", + "primary": "indigo", + "accent": "indigo", "toggle": { "icon": "material/lightbulb", "name": "Switch to light mode", @@ -102,6 +102,16 @@ }, ], "toc_title_is_page_title": True, + "social": [ + { + "icon": "fontawesome/brands/github", + "link": "https://github.com/AeonOrg/Electrogram", + }, + { + "icon": "fontawesome/brands/telegram", + "link": "https://t.me/AeonOrg", + }, + ], } # HTML resources diff --git a/pyrogram/methods/__init__.py b/pyrogram/methods/__init__.py index 72cbd88c..498f82ec 100644 --- a/pyrogram/methods/__init__.py +++ b/pyrogram/methods/__init__.py @@ -12,6 +12,7 @@ from .messages import Messages from .password import Password from .stickers import Stickers +from .stories import Stories from .users import Users from .utilities import Utilities @@ -25,6 +26,7 @@ class Methods( Password, Chats, Stickers, + Stories, Users, Messages, Decorators, diff --git a/pyrogram/methods/stories/__init__.py b/pyrogram/methods/stories/__init__.py new file mode 100644 index 00000000..0f43b5c7 --- /dev/null +++ b/pyrogram/methods/stories/__init__.py @@ -0,0 +1,25 @@ +from __future__ import annotations + +from .delete_stories import DeleteStories +from .edit_story import EditStory +from .export_story_link import ExportStoryLink +from .forward_story import ForwardStory +from .get_all_stories import GetAllStories +from .get_peer_stories import GetPeerStories +from .get_stories import GetStories +from .get_stories_history import GetUserStoriesHistory +from .send_story import SendStory + + +class Stories( + DeleteStories, + EditStory, + ExportStoryLink, + ForwardStory, + GetAllStories, + GetPeerStories, + GetStories, + GetUserStoriesHistory, + SendStory, +): + pass diff --git a/pyrogram/methods/users/delete_stories.py b/pyrogram/methods/stories/delete_stories.py similarity index 100% rename from pyrogram/methods/users/delete_stories.py rename to pyrogram/methods/stories/delete_stories.py diff --git a/pyrogram/methods/users/edit_story.py b/pyrogram/methods/stories/edit_story.py similarity index 100% rename from pyrogram/methods/users/edit_story.py rename to pyrogram/methods/stories/edit_story.py diff --git a/pyrogram/methods/users/export_story_link.py b/pyrogram/methods/stories/export_story_link.py similarity index 100% rename from pyrogram/methods/users/export_story_link.py rename to pyrogram/methods/stories/export_story_link.py diff --git a/pyrogram/methods/users/forward_story.py b/pyrogram/methods/stories/forward_story.py similarity index 100% rename from pyrogram/methods/users/forward_story.py rename to pyrogram/methods/stories/forward_story.py diff --git a/pyrogram/methods/users/get_all_stories.py b/pyrogram/methods/stories/get_all_stories.py similarity index 100% rename from pyrogram/methods/users/get_all_stories.py rename to pyrogram/methods/stories/get_all_stories.py diff --git a/pyrogram/methods/users/get_peer_stories.py b/pyrogram/methods/stories/get_peer_stories.py similarity index 100% rename from pyrogram/methods/users/get_peer_stories.py rename to pyrogram/methods/stories/get_peer_stories.py diff --git a/pyrogram/methods/users/get_stories.py b/pyrogram/methods/stories/get_stories.py similarity index 100% rename from pyrogram/methods/users/get_stories.py rename to pyrogram/methods/stories/get_stories.py diff --git a/pyrogram/methods/users/get_stories_history.py b/pyrogram/methods/stories/get_stories_history.py similarity index 100% rename from pyrogram/methods/users/get_stories_history.py rename to pyrogram/methods/stories/get_stories_history.py diff --git a/pyrogram/methods/users/send_story.py b/pyrogram/methods/stories/send_story.py similarity index 100% rename from pyrogram/methods/users/send_story.py rename to pyrogram/methods/stories/send_story.py diff --git a/pyrogram/methods/users/__init__.py b/pyrogram/methods/users/__init__.py index 74cff52b..37583abd 100644 --- a/pyrogram/methods/users/__init__.py +++ b/pyrogram/methods/users/__init__.py @@ -3,21 +3,12 @@ from .block_user import BlockUser from .delete_account import DeleteAccount from .delete_profile_photos import DeleteProfilePhotos -from .delete_stories import DeleteStories -from .edit_story import EditStory -from .export_story_link import ExportStoryLink -from .forward_story import ForwardStory -from .get_all_stories import GetAllStories from .get_chat_photos import GetChatPhotos from .get_chat_photos_count import GetChatPhotosCount from .get_common_chats import GetCommonChats from .get_default_emoji_statuses import GetDefaultEmojiStatuses from .get_me import GetMe -from .get_peer_stories import GetPeerStories -from .get_stories import GetStories -from .get_stories_history import GetUserStoriesHistory from .get_users import GetUsers -from .send_story import SendStory from .set_emoji_status import SetEmojiStatus from .set_profile_photo import SetProfilePhoto from .set_username import SetUsername @@ -29,21 +20,13 @@ class Users( BlockUser, - DeleteStories, DeleteAccount, - EditStory, - ExportStoryLink, - ForwardStory, GetCommonChats, GetChatPhotos, SetProfilePhoto, DeleteProfilePhotos, GetUsers, GetMe, - GetAllStories, - GetStories, - GetUserStoriesHistory, - GetPeerStories, SetUsername, GetChatPhotosCount, UnblockUser, @@ -52,6 +35,5 @@ class Users( UpdateProfile, GetDefaultEmojiStatuses, SetEmojiStatus, - SendStory, ): pass diff --git a/pyrogram/types/__init__.py b/pyrogram/types/__init__.py index 00091aa5..92b232fe 100644 --- a/pyrogram/types/__init__.py +++ b/pyrogram/types/__init__.py @@ -1,6 +1,8 @@ from __future__ import annotations from .authorization import * +from .bot_commands import * +from .bots import * from .bots_and_keyboards import * from .business import * from .inline_mode import * @@ -11,7 +13,217 @@ from .messages_and_media import * from .object import Object from .payments import * +from .stories import * from .update import * from .user_and_chats import * -__all__ = ["List", "Object"] +__all__ = [ + "ActiveSession", + "ActiveSessions", + "AlternativeVideo", + "Animation", + "Audio", + "AvailableEffect", + "Birthday", + "BotAllowed", + "BotApp", + "BotBusinessConnection", + "BotCommand", + "BotCommandScope", + "BotCommandScopeAllChatAdministrators", + "BotCommandScopeAllGroupChats", + "BotCommandScopeAllPrivateChats", + "BotCommandScopeChat", + "BotCommandScopeChatAdministrators", + "BotCommandScopeChatMember", + "BotCommandScopeDefault", + "BotInfo", + "BusinessInfo", + "BusinessMessage", + "BusinessRecipients", + "BusinessWeeklyOpen", + "BusinessWorkingHours", + "CallbackGame", + "CallbackQuery", + "Chat", + "ChatAdminWithInviteLinks", + "ChatColor", + "ChatEvent", + "ChatEventFilter", + "ChatInviteLink", + "ChatJoinRequest", + "ChatJoinedByRequest", + "ChatJoiner", + "ChatMember", + "ChatMemberUpdated", + "ChatPermissions", + "ChatPhoto", + "ChatPreview", + "ChatPrivileges", + "ChatReactions", + "ChosenInlineResult", + "CollectibleItemInfo", + "Contact", + "ContactRegistered", + "Dialog", + "Dice", + "Document", + "DraftMessage", + "EmojiStatus", + "ExportedStoryLink", + "ExtendedMediaPreview", + "Folder", + "ForceReply", + "ForumTopic", + "ForumTopicClosed", + "ForumTopicCreated", + "ForumTopicEdited", + "ForumTopicReopened", + "FoundContacts", + "Game", + "GameHighScore", + "GeneralTopicHidden", + "GeneralTopicUnhidden", + "Gift", + "GiftedPremium", + "Giveaway", + "GiveawayLaunched", + "GiveawayResult", + "InlineKeyboardButton", + "InlineKeyboardButtonBuy", + "InlineKeyboardMarkup", + "InlineQuery", + "InlineQueryResult", + "InlineQueryResultAnimation", + "InlineQueryResultArticle", + "InlineQueryResultAudio", + "InlineQueryResultCachedAnimation", + "InlineQueryResultCachedAudio", + "InlineQueryResultCachedDocument", + "InlineQueryResultCachedPhoto", + "InlineQueryResultCachedSticker", + "InlineQueryResultCachedVideo", + "InlineQueryResultCachedVoice", + "InlineQueryResultContact", + "InlineQueryResultDocument", + "InlineQueryResultLocation", + "InlineQueryResultPhoto", + "InlineQueryResultVenue", + "InlineQueryResultVideo", + "InlineQueryResultVoice", + "InputContactMessageContent", + "InputInvoiceMessageContent", + "InputLocationMessageContent", + "InputMedia", + "InputMediaAnimation", + "InputMediaArea", + "InputMediaAreaChannelPost", + "InputMediaAudio", + "InputMediaDocument", + "InputMediaPhoto", + "InputMediaVideo", + "InputMessageContent", + "InputPhoneContact", + "InputPrivacyRule", + "InputPrivacyRuleAllowAll", + "InputPrivacyRuleAllowChats", + "InputPrivacyRuleAllowContacts", + "InputPrivacyRuleAllowPremium", + "InputPrivacyRuleAllowUsers", + "InputPrivacyRuleDisallowAll", + "InputPrivacyRuleDisallowChats", + "InputPrivacyRuleDisallowContacts", + "InputPrivacyRuleDisallowUsers", + "InputReplyToMessage", + "InputReplyToStory", + "InputStarsTransaction", + "InputTextMessageContent", + "InputVenueMessageContent", + "InviteLinkImporter", + "Invoice", + "KeyboardButton", + "KeyboardButtonStyle", + "LabeledPrice", + "List", + "Location", + "LoginUrl", + "MediaArea", + "MediaAreaChannelPost", + "MediaAreaCoordinates", + "MenuButton", + "MenuButtonCommands", + "MenuButtonDefault", + "MenuButtonWebApp", + "Message", + "MessageEntity", + "MessageReactionCountUpdated", + "MessageReactionUpdated", + "MessageReactions", + "MessageReactor", + "MessageStory", + "Object", + "PaidMedia", + "PaidMediaPreview", + "PaymentForm", + "PaymentInfo", + "PaymentRefunded", + "PeerChannel", + "PeerUser", + "Photo", + "Poll", + "PollOption", + "PreCheckoutQuery", + "PrivacyRule", + "Reaction", + "ReactionCount", + "ReactionType", + "ReactionTypeCustomEmoji", + "ReactionTypeEmoji", + "ReactionTypePaid", + "ReplyKeyboardMarkup", + "ReplyKeyboardRemove", + "RequestPeerTypeChannel", + "RequestPeerTypeChat", + "RequestPeerTypeUser", + "RequestedChat", + "RequestedChats", + "RequestedUser", + "Restriction", + "ScreenshotTaken", + "SentCode", + "SentWebAppMessage", + "ShippingAddress", + "ShippingOption", + "ShippingQuery", + "StarsStatus", + "StarsTransaction", + "Sticker", + "StickerSet", + "StoriesPrivacyRules", + "Story", + "StoryDeleted", + "StoryForwardHeader", + "StorySkipped", + "StoryViews", + "StrippedThumbnail", + "SuccessfulPayment", + "TermsOfService", + "Thumbnail", + "TranslatedText", + "User", + "UserGift", + "Username", + "Venue", + "Video", + "VideoChatEnded", + "VideoChatMembersInvited", + "VideoChatScheduled", + "VideoChatStarted", + "VideoNote", + "Voice", + "WebAppData", + "WebAppInfo", + "WebPage", + "WebPageEmpty", + "WebPagePreview", +] diff --git a/pyrogram/types/bot_commands/__init__.py b/pyrogram/types/bot_commands/__init__.py new file mode 100644 index 00000000..eeaaba9d --- /dev/null +++ b/pyrogram/types/bot_commands/__init__.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +from .bot_command import BotCommand +from .bot_command_scope import BotCommandScope +from .bot_command_scope_all_chat_administrators import ( + BotCommandScopeAllChatAdministrators, +) +from .bot_command_scope_all_group_chats import BotCommandScopeAllGroupChats +from .bot_command_scope_all_private_chats import BotCommandScopeAllPrivateChats +from .bot_command_scope_chat import BotCommandScopeChat +from .bot_command_scope_chat_administrators import BotCommandScopeChatAdministrators +from .bot_command_scope_chat_member import BotCommandScopeChatMember +from .bot_command_scope_default import BotCommandScopeDefault diff --git a/pyrogram/types/bots_and_keyboards/bot_command.py b/pyrogram/types/bot_commands/bot_command.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command.py rename to pyrogram/types/bot_commands/bot_command.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope.py b/pyrogram/types/bot_commands/bot_command_scope.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope.py rename to pyrogram/types/bot_commands/bot_command_scope.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_all_chat_administrators.py b/pyrogram/types/bot_commands/bot_command_scope_all_chat_administrators.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_all_chat_administrators.py rename to pyrogram/types/bot_commands/bot_command_scope_all_chat_administrators.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_all_group_chats.py b/pyrogram/types/bot_commands/bot_command_scope_all_group_chats.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_all_group_chats.py rename to pyrogram/types/bot_commands/bot_command_scope_all_group_chats.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_all_private_chats.py b/pyrogram/types/bot_commands/bot_command_scope_all_private_chats.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_all_private_chats.py rename to pyrogram/types/bot_commands/bot_command_scope_all_private_chats.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_chat.py b/pyrogram/types/bot_commands/bot_command_scope_chat.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_chat.py rename to pyrogram/types/bot_commands/bot_command_scope_chat.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_chat_administrators.py b/pyrogram/types/bot_commands/bot_command_scope_chat_administrators.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_chat_administrators.py rename to pyrogram/types/bot_commands/bot_command_scope_chat_administrators.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_chat_member.py b/pyrogram/types/bot_commands/bot_command_scope_chat_member.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_chat_member.py rename to pyrogram/types/bot_commands/bot_command_scope_chat_member.py diff --git a/pyrogram/types/bots_and_keyboards/bot_command_scope_default.py b/pyrogram/types/bot_commands/bot_command_scope_default.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_command_scope_default.py rename to pyrogram/types/bot_commands/bot_command_scope_default.py diff --git a/pyrogram/types/bots/__init__.py b/pyrogram/types/bots/__init__.py new file mode 100644 index 00000000..e2515b28 --- /dev/null +++ b/pyrogram/types/bots/__init__.py @@ -0,0 +1,6 @@ +from __future__ import annotations + +from .bot_allowed import BotAllowed +from .bot_app import BotApp +from .bot_business_connection import BotBusinessConnection +from .bot_info import BotInfo diff --git a/pyrogram/types/bots_and_keyboards/bot_allowed.py b/pyrogram/types/bots/bot_allowed.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_allowed.py rename to pyrogram/types/bots/bot_allowed.py diff --git a/pyrogram/types/bots_and_keyboards/bot_app.py b/pyrogram/types/bots/bot_app.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_app.py rename to pyrogram/types/bots/bot_app.py diff --git a/pyrogram/types/bots_and_keyboards/bot_business_connection.py b/pyrogram/types/bots/bot_business_connection.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_business_connection.py rename to pyrogram/types/bots/bot_business_connection.py diff --git a/pyrogram/types/bots_and_keyboards/bot_info.py b/pyrogram/types/bots/bot_info.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/bot_info.py rename to pyrogram/types/bots/bot_info.py diff --git a/pyrogram/types/bots_and_keyboards/__init__.py b/pyrogram/types/bots_and_keyboards/__init__.py index 90078fda..a8583bbc 100644 --- a/pyrogram/types/bots_and_keyboards/__init__.py +++ b/pyrogram/types/bots_and_keyboards/__init__.py @@ -1,26 +1,31 @@ from __future__ import annotations -from .bot_allowed import BotAllowed -from .bot_app import BotApp -from .bot_business_connection import BotBusinessConnection -from .bot_command import BotCommand -from .bot_command_scope import BotCommandScope -from .bot_command_scope_all_chat_administrators import ( +from pyrogram.types.bot_commands.bot_command import BotCommand +from pyrogram.types.bot_commands.bot_command_scope import BotCommandScope +from pyrogram.types.bot_commands.bot_command_scope_all_chat_administrators import ( BotCommandScopeAllChatAdministrators, ) -from .bot_command_scope_all_group_chats import ( +from pyrogram.types.bot_commands.bot_command_scope_all_group_chats import ( BotCommandScopeAllGroupChats, ) -from .bot_command_scope_all_private_chats import ( +from pyrogram.types.bot_commands.bot_command_scope_all_private_chats import ( BotCommandScopeAllPrivateChats, ) -from .bot_command_scope_chat import BotCommandScopeChat -from .bot_command_scope_chat_administrators import ( +from pyrogram.types.bot_commands.bot_command_scope_chat import BotCommandScopeChat +from pyrogram.types.bot_commands.bot_command_scope_chat_administrators import ( BotCommandScopeChatAdministrators, ) -from .bot_command_scope_chat_member import BotCommandScopeChatMember -from .bot_command_scope_default import BotCommandScopeDefault -from .bot_info import BotInfo +from pyrogram.types.bot_commands.bot_command_scope_chat_member import ( + BotCommandScopeChatMember, +) +from pyrogram.types.bot_commands.bot_command_scope_default import ( + BotCommandScopeDefault, +) +from pyrogram.types.bots.bot_allowed import BotAllowed +from pyrogram.types.bots.bot_app import BotApp +from pyrogram.types.bots.bot_business_connection import BotBusinessConnection +from pyrogram.types.bots.bot_info import BotInfo + from .callback_game import CallbackGame from .callback_query import CallbackQuery from .collectible_item_info import CollectibleItemInfo diff --git a/pyrogram/types/input_media/__init__.py b/pyrogram/types/input_media/__init__.py index faae56d1..85c79a7c 100644 --- a/pyrogram/types/input_media/__init__.py +++ b/pyrogram/types/input_media/__init__.py @@ -1,9 +1,12 @@ from __future__ import annotations +from pyrogram.types.stories.input_media_area import InputMediaArea +from pyrogram.types.stories.input_media_area_channel_post import ( + InputMediaAreaChannelPost, +) + from .input_media import InputMedia from .input_media_animation import InputMediaAnimation -from .input_media_area import InputMediaArea -from .input_media_area_channel_post import InputMediaAreaChannelPost from .input_media_audio import InputMediaAudio from .input_media_document import InputMediaDocument from .input_media_photo import InputMediaPhoto diff --git a/pyrogram/types/messages_and_media/__init__.py b/pyrogram/types/messages_and_media/__init__.py index 73f5aa8a..24297d15 100644 --- a/pyrogram/types/messages_and_media/__init__.py +++ b/pyrogram/types/messages_and_media/__init__.py @@ -1,5 +1,15 @@ from __future__ import annotations +from pyrogram.types.stories.media_area import MediaArea +from pyrogram.types.stories.media_area_channel_post import MediaAreaChannelPost +from pyrogram.types.stories.media_area_coordinates import MediaAreaCoordinates +from pyrogram.types.stories.stories_privacy_rules import StoriesPrivacyRules +from pyrogram.types.stories.story import Story +from pyrogram.types.stories.story_deleted import StoryDeleted +from pyrogram.types.stories.story_forward_header import StoryForwardHeader +from pyrogram.types.stories.story_skipped import StorySkipped +from pyrogram.types.stories.story_views import StoryViews + from .alternative_video import AlternativeVideo from .animation import Animation from .audio import Audio @@ -17,9 +27,6 @@ from .giveaway_result import GiveawayResult from .labeled_price import LabeledPrice from .location import Location -from .media_area import MediaArea -from .media_area_channel_post import MediaAreaChannelPost -from .media_area_coordinates import MediaAreaCoordinates from .message import Message from .message_entity import MessageEntity from .message_reaction_count_updated import ( @@ -44,12 +51,6 @@ from .screenshot_taken import ScreenshotTaken from .sticker import Sticker from .stickerset import StickerSet -from .stories_privacy_rules import StoriesPrivacyRules -from .story import Story -from .story_deleted import StoryDeleted -from .story_forward_header import StoryForwardHeader -from .story_skipped import StorySkipped -from .story_views import StoryViews from .stripped_thumbnail import StrippedThumbnail from .thumbnail import Thumbnail from .translated_text import TranslatedText diff --git a/pyrogram/types/stories/__init__.py b/pyrogram/types/stories/__init__.py new file mode 100644 index 00000000..fef7a49e --- /dev/null +++ b/pyrogram/types/stories/__init__.py @@ -0,0 +1,13 @@ +from __future__ import annotations + +from .input_media_area import InputMediaArea +from .input_media_area_channel_post import InputMediaAreaChannelPost +from .media_area import MediaArea +from .media_area_channel_post import MediaAreaChannelPost +from .media_area_coordinates import MediaAreaCoordinates +from .stories_privacy_rules import StoriesPrivacyRules +from .story import Story +from .story_deleted import StoryDeleted +from .story_forward_header import StoryForwardHeader +from .story_skipped import StorySkipped +from .story_views import StoryViews diff --git a/pyrogram/types/input_media/input_media_area.py b/pyrogram/types/stories/input_media_area.py similarity index 100% rename from pyrogram/types/input_media/input_media_area.py rename to pyrogram/types/stories/input_media_area.py diff --git a/pyrogram/types/input_media/input_media_area_channel_post.py b/pyrogram/types/stories/input_media_area_channel_post.py similarity index 100% rename from pyrogram/types/input_media/input_media_area_channel_post.py rename to pyrogram/types/stories/input_media_area_channel_post.py diff --git a/pyrogram/types/messages_and_media/media_area.py b/pyrogram/types/stories/media_area.py similarity index 100% rename from pyrogram/types/messages_and_media/media_area.py rename to pyrogram/types/stories/media_area.py diff --git a/pyrogram/types/messages_and_media/media_area_channel_post.py b/pyrogram/types/stories/media_area_channel_post.py similarity index 100% rename from pyrogram/types/messages_and_media/media_area_channel_post.py rename to pyrogram/types/stories/media_area_channel_post.py diff --git a/pyrogram/types/messages_and_media/media_area_coordinates.py b/pyrogram/types/stories/media_area_coordinates.py similarity index 100% rename from pyrogram/types/messages_and_media/media_area_coordinates.py rename to pyrogram/types/stories/media_area_coordinates.py diff --git a/pyrogram/types/messages_and_media/stories_privacy_rules.py b/pyrogram/types/stories/stories_privacy_rules.py similarity index 100% rename from pyrogram/types/messages_and_media/stories_privacy_rules.py rename to pyrogram/types/stories/stories_privacy_rules.py diff --git a/pyrogram/types/messages_and_media/story.py b/pyrogram/types/stories/story.py similarity index 100% rename from pyrogram/types/messages_and_media/story.py rename to pyrogram/types/stories/story.py diff --git a/pyrogram/types/messages_and_media/story_deleted.py b/pyrogram/types/stories/story_deleted.py similarity index 100% rename from pyrogram/types/messages_and_media/story_deleted.py rename to pyrogram/types/stories/story_deleted.py diff --git a/pyrogram/types/messages_and_media/story_forward_header.py b/pyrogram/types/stories/story_forward_header.py similarity index 100% rename from pyrogram/types/messages_and_media/story_forward_header.py rename to pyrogram/types/stories/story_forward_header.py diff --git a/pyrogram/types/messages_and_media/story_skipped.py b/pyrogram/types/stories/story_skipped.py similarity index 100% rename from pyrogram/types/messages_and_media/story_skipped.py rename to pyrogram/types/stories/story_skipped.py diff --git a/pyrogram/types/messages_and_media/story_views.py b/pyrogram/types/stories/story_views.py similarity index 100% rename from pyrogram/types/messages_and_media/story_views.py rename to pyrogram/types/stories/story_views.py