2020-03-21 14:43:32 +00:00
|
|
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
2022-01-07 09:23:45 +00:00
|
|
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
2018-01-03 17:30:58 +00:00
|
|
|
#
|
2020-03-21 14:43:32 +00:00
|
|
|
# This file is part of Pyrogram.
|
2018-01-03 17:30:58 +00:00
|
|
|
#
|
2020-03-21 14:43:32 +00:00
|
|
|
# Pyrogram is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License as published
|
|
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2018-01-03 17:30:58 +00:00
|
|
|
#
|
2020-03-21 14:43:32 +00:00
|
|
|
# Pyrogram is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
2018-01-03 17:30:58 +00:00
|
|
|
#
|
2020-03-21 14:43:32 +00:00
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
2018-01-05 02:19:01 +00:00
|
|
|
|
2018-01-05 01:16:30 +00:00
|
|
|
import ast
|
2018-01-03 17:27:43 +00:00
|
|
|
import os
|
2019-05-30 22:19:18 +00:00
|
|
|
import re
|
2018-01-03 17:27:43 +00:00
|
|
|
import shutil
|
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
HOME = "compiler/docs"
|
2019-05-12 17:26:55 +00:00
|
|
|
DESTINATION = "docs/source/telegram"
|
2019-07-09 17:03:46 +00:00
|
|
|
PYROGRAM_API_DEST = "docs/source/api"
|
2018-01-05 01:16:30 +00:00
|
|
|
|
2020-08-22 06:05:05 +00:00
|
|
|
FUNCTIONS_PATH = "pyrogram/raw/functions"
|
|
|
|
TYPES_PATH = "pyrogram/raw/types"
|
|
|
|
BASE_PATH = "pyrogram/raw/base"
|
2018-01-03 17:27:43 +00:00
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
FUNCTIONS_BASE = "functions"
|
|
|
|
TYPES_BASE = "types"
|
2020-08-22 06:05:05 +00:00
|
|
|
BASE_BASE = "base"
|
2018-01-03 17:27:43 +00:00
|
|
|
|
2019-05-30 22:19:18 +00:00
|
|
|
|
|
|
|
def snek(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()
|
2018-01-03 17:27:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def generate(source_path, base):
|
|
|
|
all_entities = {}
|
|
|
|
|
|
|
|
def build(path, level=0):
|
|
|
|
last = path.split("/")[-1]
|
|
|
|
|
|
|
|
for i in os.listdir(path):
|
|
|
|
try:
|
|
|
|
if not i.startswith("__"):
|
|
|
|
build("/".join([path, i]), level=level + 1)
|
|
|
|
except NotADirectoryError:
|
2018-01-21 15:56:50 +00:00
|
|
|
with open(path + "/" + i, encoding="utf-8") as f:
|
2018-01-05 01:16:30 +00:00
|
|
|
p = ast.parse(f.read())
|
|
|
|
|
|
|
|
for node in ast.walk(p):
|
|
|
|
if isinstance(node, ast.ClassDef):
|
|
|
|
name = node.name
|
2019-05-30 22:19:18 +00:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
continue
|
2018-01-05 01:16:30 +00:00
|
|
|
|
2019-05-30 22:19:18 +00:00
|
|
|
full_path = os.path.basename(path) + "/" + snek(name).replace("_", "-") + ".rst"
|
2018-01-03 17:27:43 +00:00
|
|
|
|
|
|
|
if level:
|
|
|
|
full_path = base + "/" + full_path
|
|
|
|
|
2022-04-27 07:04:20 +00:00
|
|
|
namespace = path.split("/")[-1]
|
|
|
|
if namespace in ["base", "types", "functions"]:
|
|
|
|
namespace = ""
|
|
|
|
|
|
|
|
full_name = f"{(namespace + '.') if namespace else ''}{name}"
|
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
os.makedirs(os.path.dirname(DESTINATION + "/" + full_path), exist_ok=True)
|
2018-01-03 17:27:43 +00:00
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
with open(DESTINATION + "/" + full_path, "w", encoding="utf-8") as f:
|
2018-01-03 17:27:43 +00:00
|
|
|
f.write(
|
|
|
|
page_template.format(
|
2022-04-27 07:04:20 +00:00
|
|
|
title=full_name,
|
|
|
|
title_markup="=" * len(full_name),
|
2020-08-22 06:05:05 +00:00
|
|
|
full_class_path="pyrogram.raw.{}".format(
|
2019-05-30 22:19:18 +00:00
|
|
|
".".join(full_path.split("/")[:-1]) + "." + name
|
2018-01-03 17:27:43 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if last not in all_entities:
|
|
|
|
all_entities[last] = []
|
|
|
|
|
|
|
|
all_entities[last].append(name)
|
|
|
|
|
|
|
|
build(source_path)
|
|
|
|
|
2018-06-27 13:27:15 +00:00
|
|
|
for k, v in sorted(all_entities.items()):
|
|
|
|
v = sorted(v)
|
2018-01-03 17:27:43 +00:00
|
|
|
entities = []
|
|
|
|
|
|
|
|
for i in v:
|
2022-04-27 07:04:20 +00:00
|
|
|
entities.append(f'{i} <{snek(i).replace("_", "-")}>')
|
2018-01-03 17:27:43 +00:00
|
|
|
|
|
|
|
if k != base:
|
|
|
|
inner_path = base + "/" + k + "/index" + ".rst"
|
2020-08-22 06:05:05 +00:00
|
|
|
module = "pyrogram.raw.{}.{}".format(base, k)
|
2018-01-03 17:27:43 +00:00
|
|
|
else:
|
2018-09-29 09:38:58 +00:00
|
|
|
for i in sorted(list(all_entities), reverse=True):
|
2018-01-03 17:27:43 +00:00
|
|
|
if i != base:
|
|
|
|
entities.insert(0, "{0}/index".format(i))
|
|
|
|
|
|
|
|
inner_path = base + "/index" + ".rst"
|
2020-08-22 06:05:05 +00:00
|
|
|
module = "pyrogram.raw.{}".format(base)
|
2018-01-03 17:27:43 +00:00
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
with open(DESTINATION + "/" + inner_path, "w", encoding="utf-8") as f:
|
2018-01-08 06:15:38 +00:00
|
|
|
if k == base:
|
|
|
|
f.write(":tocdepth: 1\n\n")
|
2019-05-30 22:19:18 +00:00
|
|
|
k = "Raw " + k
|
2018-01-08 04:17:55 +00:00
|
|
|
|
2018-01-03 17:27:43 +00:00
|
|
|
f.write(
|
|
|
|
toctree.format(
|
|
|
|
title=k.title(),
|
|
|
|
title_markup="=" * len(k),
|
2018-01-06 11:16:29 +00:00
|
|
|
module=module,
|
2018-01-03 17:27:43 +00:00
|
|
|
entities="\n ".join(entities)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
f.write("\n")
|
|
|
|
|
|
|
|
|
2019-07-09 17:03:46 +00:00
|
|
|
def pyrogram_api():
|
|
|
|
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 = dict(
|
|
|
|
utilities="""
|
|
|
|
Utilities
|
|
|
|
start
|
2019-08-13 11:18:01 +00:00
|
|
|
stop
|
2019-07-09 17:03:46 +00:00
|
|
|
run
|
2019-08-13 11:18:01 +00:00
|
|
|
restart
|
2019-07-09 17:03:46 +00:00
|
|
|
add_handler
|
|
|
|
remove_handler
|
|
|
|
stop_transmission
|
|
|
|
export_session_string
|
2019-07-11 17:28:33 +00:00
|
|
|
set_parse_mode
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
messages="""
|
|
|
|
Messages
|
|
|
|
send_message
|
|
|
|
forward_messages
|
2020-12-05 00:35:24 +00:00
|
|
|
copy_message
|
2021-05-09 10:39:49 +00:00
|
|
|
copy_media_group
|
2019-07-09 17:03:46 +00:00
|
|
|
send_photo
|
|
|
|
send_audio
|
|
|
|
send_document
|
|
|
|
send_sticker
|
|
|
|
send_video
|
|
|
|
send_animation
|
|
|
|
send_voice
|
|
|
|
send_video_note
|
|
|
|
send_media_group
|
|
|
|
send_location
|
|
|
|
send_venue
|
|
|
|
send_contact
|
|
|
|
send_cached_media
|
2022-01-07 09:18:51 +00:00
|
|
|
send_reaction
|
2019-07-09 17:03:46 +00:00
|
|
|
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
|
2024-05-31 21:43:26 +00:00
|
|
|
get_available_effects
|
2019-07-09 17:03:46 +00:00
|
|
|
get_messages
|
2024-03-18 11:33:27 +00:00
|
|
|
get_scheduled_messages
|
2024-03-16 08:27:06 +00:00
|
|
|
get_stickers
|
2020-12-20 16:02:54 +00:00
|
|
|
get_media_group
|
2022-04-24 09:56:07 +00:00
|
|
|
get_chat_history
|
|
|
|
get_chat_history_count
|
|
|
|
read_chat_history
|
2019-07-09 17:03:46 +00:00
|
|
|
send_poll
|
2024-05-11 13:10:32 +00:00
|
|
|
view_messages
|
2019-07-09 17:03:46 +00:00
|
|
|
vote_poll
|
|
|
|
stop_poll
|
|
|
|
retract_vote
|
2020-03-30 12:38:57 +00:00
|
|
|
send_dice
|
2020-04-10 11:37:11 +00:00
|
|
|
search_messages
|
2022-01-07 09:18:51 +00:00
|
|
|
search_messages_count
|
2024-06-01 19:31:11 +00:00
|
|
|
search_posts
|
|
|
|
search_posts_count
|
2020-05-23 12:50:14 +00:00
|
|
|
search_global
|
2022-01-07 09:18:51 +00:00
|
|
|
search_global_count
|
2019-07-09 17:03:46 +00:00
|
|
|
download_media
|
2022-04-24 09:56:07 +00:00
|
|
|
stream_media
|
2021-12-22 14:00:03 +00:00
|
|
|
get_discussion_message
|
2022-04-24 09:56:07 +00:00
|
|
|
get_discussion_replies
|
|
|
|
get_discussion_replies_count
|
2022-08-12 15:33:13 +00:00
|
|
|
get_custom_emoji_stickers
|
2023-12-30 11:54:43 +00:00
|
|
|
send_web_page
|
2024-03-12 06:57:01 +00:00
|
|
|
start_bot
|
|
|
|
update_color
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
chats="""
|
|
|
|
Chats
|
|
|
|
join_chat
|
|
|
|
leave_chat
|
2021-12-22 13:39:52 +00:00
|
|
|
ban_chat_member
|
2019-07-09 17:03:46 +00:00
|
|
|
unban_chat_member
|
|
|
|
restrict_chat_member
|
|
|
|
promote_chat_member
|
2019-09-09 13:28:05 +00:00
|
|
|
set_administrator_title
|
2019-07-09 17:03:46 +00:00
|
|
|
set_chat_photo
|
|
|
|
delete_chat_photo
|
|
|
|
set_chat_title
|
|
|
|
set_chat_description
|
2019-08-03 17:09:42 +00:00
|
|
|
set_chat_permissions
|
2019-07-09 17:03:46 +00:00
|
|
|
pin_chat_message
|
|
|
|
unpin_chat_message
|
2020-11-08 12:21:40 +00:00
|
|
|
unpin_all_chat_messages
|
2019-07-09 17:03:46 +00:00
|
|
|
get_chat
|
|
|
|
get_chat_member
|
|
|
|
get_chat_members
|
|
|
|
get_chat_members_count
|
|
|
|
get_dialogs
|
|
|
|
get_dialogs_count
|
2022-04-24 09:56:06 +00:00
|
|
|
set_chat_username
|
2019-08-17 20:23:34 +00:00
|
|
|
get_nearby_chats
|
2019-07-09 17:03:46 +00:00
|
|
|
archive_chats
|
|
|
|
unarchive_chats
|
2019-07-21 21:08:30 +00:00
|
|
|
add_chat_members
|
|
|
|
create_channel
|
|
|
|
create_group
|
|
|
|
create_supergroup
|
|
|
|
delete_channel
|
|
|
|
delete_supergroup
|
2020-12-02 16:27:04 +00:00
|
|
|
delete_user_history
|
2019-10-27 10:02:38 +00:00
|
|
|
set_slow_mode
|
2020-12-12 15:56:26 +00:00
|
|
|
mark_chat_unread
|
2021-03-03 18:02:20 +00:00
|
|
|
get_chat_event_log
|
2021-05-12 07:39:51 +00:00
|
|
|
get_chat_online_count
|
2021-12-23 15:53:03 +00:00
|
|
|
get_send_as_chats
|
|
|
|
set_send_as_chat
|
2022-01-05 11:45:09 +00:00
|
|
|
set_chat_protected_content
|
2023-11-28 08:24:28 +00:00
|
|
|
close_forum_topic
|
|
|
|
create_forum_topic
|
|
|
|
delete_forum_topic
|
|
|
|
edit_forum_topic
|
|
|
|
get_forum_topics
|
|
|
|
get_forum_topics_by_id
|
|
|
|
update_color
|
|
|
|
update_chat_notifications
|
|
|
|
toggle_forum_topics
|
|
|
|
delete_folder
|
|
|
|
export_folder_link
|
|
|
|
get_folders
|
|
|
|
update_folder
|
2023-12-02 13:07:08 +00:00
|
|
|
get_similar_channels
|
2024-01-04 12:24:41 +00:00
|
|
|
join_folder
|
|
|
|
leave_folder
|
2024-03-12 06:57:01 +00:00
|
|
|
toggle_join_to_send
|
|
|
|
toggle_folder_tags
|
|
|
|
set_chat_ttl
|
2024-04-20 11:08:03 +00:00
|
|
|
get_personal_channels
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
users="""
|
|
|
|
Users
|
|
|
|
get_me
|
|
|
|
get_users
|
2022-04-24 09:56:07 +00:00
|
|
|
get_chat_photos
|
|
|
|
get_chat_photos_count
|
2019-07-09 17:03:46 +00:00
|
|
|
set_profile_photo
|
2024-07-16 14:03:37 +00:00
|
|
|
set_personal_channel
|
2019-07-09 17:03:46 +00:00
|
|
|
delete_profile_photos
|
2022-04-24 09:56:06 +00:00
|
|
|
set_username
|
2020-05-02 19:16:52 +00:00
|
|
|
update_profile
|
2019-07-09 17:03:46 +00:00
|
|
|
block_user
|
|
|
|
unblock_user
|
2020-12-02 16:27:04 +00:00
|
|
|
get_common_chats
|
2022-09-03 12:06:46 +00:00
|
|
|
get_default_emoji_statuses
|
2022-09-03 12:18:12 +00:00
|
|
|
set_emoji_status
|
2023-12-17 21:59:23 +00:00
|
|
|
update_status
|
2024-03-12 06:57:01 +00:00
|
|
|
check_username
|
2024-04-01 20:59:55 +00:00
|
|
|
update_birthday
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
2021-03-17 11:40:36 +00:00
|
|
|
invite_links="""
|
|
|
|
Invite Links
|
2021-03-21 21:39:59 +00:00
|
|
|
get_chat_invite_link
|
2021-03-17 11:40:36 +00:00
|
|
|
export_chat_invite_link
|
|
|
|
create_chat_invite_link
|
|
|
|
edit_chat_invite_link
|
|
|
|
revoke_chat_invite_link
|
|
|
|
delete_chat_invite_link
|
2022-04-24 09:56:07 +00:00
|
|
|
get_chat_invite_link_joiners
|
|
|
|
get_chat_invite_link_joiners_count
|
2021-03-21 21:39:59 +00:00
|
|
|
get_chat_admin_invite_links
|
|
|
|
get_chat_admin_invite_links_count
|
2021-03-17 11:40:36 +00:00
|
|
|
get_chat_admins_with_invite_links
|
2022-04-24 09:56:07 +00:00
|
|
|
get_chat_join_requests
|
2021-03-21 21:39:59 +00:00
|
|
|
delete_chat_admin_invite_links
|
2021-12-22 13:12:57 +00:00
|
|
|
approve_chat_join_request
|
2022-04-24 09:56:07 +00:00
|
|
|
approve_all_chat_join_requests
|
2021-12-22 13:12:57 +00:00
|
|
|
decline_chat_join_request
|
2022-04-24 09:56:07 +00:00
|
|
|
decline_all_chat_join_requests
|
2021-03-17 11:40:36 +00:00
|
|
|
""",
|
2019-07-09 17:03:46 +00:00
|
|
|
contacts="""
|
|
|
|
Contacts
|
2021-03-20 09:13:40 +00:00
|
|
|
add_contact
|
|
|
|
delete_contacts
|
|
|
|
import_contacts
|
2019-07-09 17:03:46 +00:00
|
|
|
get_contacts
|
|
|
|
get_contacts_count
|
2024-08-04 12:31:31 +00:00
|
|
|
search_contacts
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
2024-04-05 09:11:20 +00:00
|
|
|
payments="""
|
|
|
|
Payments
|
|
|
|
check_gift_code
|
|
|
|
""",
|
2024-04-30 13:22:00 +00:00
|
|
|
phone="""
|
|
|
|
Phone
|
|
|
|
get_call_members
|
|
|
|
""",
|
2019-07-09 17:03:46 +00:00
|
|
|
password="""
|
2021-03-03 18:02:20 +00:00
|
|
|
Password
|
2019-07-09 17:03:46 +00:00
|
|
|
enable_cloud_password
|
|
|
|
change_cloud_password
|
|
|
|
remove_cloud_password
|
|
|
|
""",
|
|
|
|
bots="""
|
|
|
|
Bots
|
|
|
|
get_inline_bot_results
|
|
|
|
send_inline_bot_result
|
2024-07-29 08:38:48 +00:00
|
|
|
send_invoice
|
2019-07-09 17:03:46 +00:00
|
|
|
answer_callback_query
|
|
|
|
answer_inline_query
|
|
|
|
request_callback_answer
|
|
|
|
send_game
|
|
|
|
set_game_score
|
|
|
|
get_game_high_scores
|
2022-01-07 09:18:51 +00:00
|
|
|
set_bot_commands
|
2022-03-28 11:23:12 +00:00
|
|
|
get_bot_commands
|
|
|
|
delete_bot_commands
|
2022-04-24 09:56:07 +00:00
|
|
|
set_bot_default_privileges
|
|
|
|
get_bot_default_privileges
|
2022-04-24 09:56:07 +00:00
|
|
|
set_chat_menu_button
|
|
|
|
get_chat_menu_button
|
2022-04-24 09:56:07 +00:00
|
|
|
answer_web_app_query
|
2024-05-31 22:01:22 +00:00
|
|
|
answer_pre_checkout_query
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
2024-04-13 12:26:00 +00:00
|
|
|
business="""
|
|
|
|
Business
|
|
|
|
get_business_connection
|
|
|
|
""",
|
2019-08-13 11:18:01 +00:00
|
|
|
authorization="""
|
|
|
|
Authorization
|
|
|
|
connect
|
|
|
|
disconnect
|
|
|
|
initialize
|
|
|
|
terminate
|
|
|
|
send_code
|
|
|
|
resend_code
|
|
|
|
sign_in
|
2020-08-22 06:05:05 +00:00
|
|
|
sign_in_bot
|
2019-08-13 11:18:01 +00:00
|
|
|
sign_up
|
|
|
|
get_password_hint
|
|
|
|
check_password
|
|
|
|
send_recovery_code
|
|
|
|
recover_password
|
|
|
|
accept_terms_of_service
|
2019-09-08 09:58:34 +00:00
|
|
|
log_out
|
2024-08-02 10:21:46 +00:00
|
|
|
get_active_sessions
|
|
|
|
reset_session
|
2024-08-02 16:24:16 +00:00
|
|
|
reset_sessions
|
2019-08-13 11:18:01 +00:00
|
|
|
""",
|
2019-07-09 17:03:46 +00:00
|
|
|
advanced="""
|
|
|
|
Advanced
|
2022-04-24 09:56:07 +00:00
|
|
|
invoke
|
2019-07-09 17:03:46 +00:00
|
|
|
resolve_peer
|
|
|
|
save_file
|
2023-11-28 08:24:28 +00:00
|
|
|
""",
|
|
|
|
stories="""
|
|
|
|
Stories
|
2023-12-07 20:09:17 +00:00
|
|
|
can_send_story
|
|
|
|
copy_story
|
2023-11-28 08:24:28 +00:00
|
|
|
delete_stories
|
2023-12-07 20:54:18 +00:00
|
|
|
edit_story_caption
|
|
|
|
edit_story_media
|
|
|
|
edit_story_privacy
|
2023-12-07 20:09:17 +00:00
|
|
|
forward_story
|
2023-11-28 08:24:28 +00:00
|
|
|
get_all_stories
|
2023-12-07 20:09:17 +00:00
|
|
|
get_chat_stories
|
|
|
|
get_pinned_stories
|
2023-11-28 08:24:28 +00:00
|
|
|
get_stories_archive
|
2023-12-07 20:09:17 +00:00
|
|
|
get_stories
|
|
|
|
hide_stories
|
2024-05-15 18:08:58 +00:00
|
|
|
view_stories
|
2023-12-07 20:09:17 +00:00
|
|
|
pin_stories
|
2023-11-28 08:24:28 +00:00
|
|
|
read_stories
|
|
|
|
send_story
|
|
|
|
""",
|
|
|
|
premium="""
|
|
|
|
Premium
|
|
|
|
apply_boost
|
|
|
|
get_boosts
|
|
|
|
get_boosts_status
|
2024-08-04 12:31:31 +00:00
|
|
|
""",
|
|
|
|
account="""
|
|
|
|
Account
|
|
|
|
get_account_ttl
|
|
|
|
set_account_ttl
|
2019-07-09 17:03:46 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
root = PYROGRAM_API_DEST + "/methods"
|
|
|
|
|
|
|
|
shutil.rmtree(root, ignore_errors=True)
|
|
|
|
os.mkdir(root)
|
|
|
|
|
2019-07-09 17:10:11 +00:00
|
|
|
with open(HOME + "/template/methods.rst") as f:
|
2019-07-09 17:03:46 +00:00
|
|
|
template = f.read()
|
|
|
|
|
|
|
|
with open(root + "/index.rst", "w") as f:
|
|
|
|
fmt_keys = {}
|
|
|
|
|
|
|
|
for k, v in categories.items():
|
|
|
|
name, *methods = get_title_list(v)
|
|
|
|
fmt_keys.update({k: "\n ".join("{0} <{0}>".format(m) for m in methods)})
|
|
|
|
|
|
|
|
for method in methods:
|
|
|
|
with open(root + "/{}.rst".format(method), "w") as f2:
|
|
|
|
title = "{}()".format(method)
|
|
|
|
|
|
|
|
f2.write(title + "\n" + "=" * len(title) + "\n\n")
|
|
|
|
f2.write(".. automethod:: pyrogram.Client.{}()".format(method))
|
|
|
|
|
2022-04-24 09:56:07 +00:00
|
|
|
functions = ["idle", "compose"]
|
2020-08-22 06:05:05 +00:00
|
|
|
|
|
|
|
for func in functions:
|
|
|
|
with open(root + "/{}.rst".format(func), "w") as f2:
|
|
|
|
title = "{}()".format(func)
|
|
|
|
|
|
|
|
f2.write(title + "\n" + "=" * len(title) + "\n\n")
|
|
|
|
f2.write(".. autofunction:: pyrogram.{}()".format(func))
|
|
|
|
|
2019-07-09 17:03:46 +00:00
|
|
|
f.write(template.format(**fmt_keys))
|
|
|
|
|
|
|
|
# Types
|
|
|
|
|
|
|
|
categories = dict(
|
|
|
|
users_chats="""
|
|
|
|
Users & Chats
|
2024-04-01 20:44:28 +00:00
|
|
|
Birthday
|
2024-04-13 12:26:00 +00:00
|
|
|
BusinessConnection
|
2024-03-08 13:21:22 +00:00
|
|
|
BusinessInfo
|
2024-04-13 12:26:00 +00:00
|
|
|
BusinessIntro
|
2024-03-08 13:21:22 +00:00
|
|
|
BusinessMessage
|
|
|
|
BusinessRecipients
|
|
|
|
BusinessWeeklyOpen
|
|
|
|
BusinessWorkingHours
|
2019-07-09 17:03:46 +00:00
|
|
|
User
|
2024-03-12 06:57:01 +00:00
|
|
|
Username
|
2019-07-09 17:03:46 +00:00
|
|
|
Chat
|
|
|
|
ChatPhoto
|
|
|
|
ChatMember
|
|
|
|
ChatPermissions
|
2022-04-24 09:56:06 +00:00
|
|
|
ChatPrivileges
|
2021-03-17 11:40:36 +00:00
|
|
|
ChatInviteLink
|
|
|
|
ChatAdminWithInviteLinks
|
2021-03-03 18:02:20 +00:00
|
|
|
ChatEvent
|
|
|
|
ChatEventFilter
|
2021-03-17 14:11:23 +00:00
|
|
|
ChatMemberUpdated
|
2022-01-07 09:18:51 +00:00
|
|
|
ChatJoinRequest
|
2022-04-24 09:56:07 +00:00
|
|
|
ChatJoiner
|
2019-07-09 17:03:46 +00:00
|
|
|
Dialog
|
2019-09-07 11:28:05 +00:00
|
|
|
Restriction
|
2022-09-03 11:10:27 +00:00
|
|
|
EmojiStatus
|
2023-11-28 08:24:28 +00:00
|
|
|
Folder
|
2024-04-30 13:22:00 +00:00
|
|
|
GroupCallMember
|
2023-11-30 21:45:04 +00:00
|
|
|
ChatColor
|
2024-08-04 12:31:31 +00:00
|
|
|
FoundContacts
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
messages_media="""
|
|
|
|
Messages & Media
|
|
|
|
Message
|
|
|
|
MessageEntity
|
|
|
|
Photo
|
|
|
|
Thumbnail
|
|
|
|
Audio
|
2024-05-31 21:43:26 +00:00
|
|
|
AvailableEffect
|
2019-07-09 17:03:46 +00:00
|
|
|
Document
|
|
|
|
Animation
|
|
|
|
Video
|
|
|
|
Voice
|
|
|
|
VideoNote
|
|
|
|
Contact
|
|
|
|
Location
|
|
|
|
Venue
|
|
|
|
Sticker
|
|
|
|
Game
|
|
|
|
WebPage
|
|
|
|
Poll
|
|
|
|
PollOption
|
2020-03-30 12:38:57 +00:00
|
|
|
Dice
|
2022-01-07 09:18:51 +00:00
|
|
|
Reaction
|
2022-04-24 09:56:07 +00:00
|
|
|
VideoChatScheduled
|
|
|
|
VideoChatStarted
|
|
|
|
VideoChatEnded
|
|
|
|
VideoChatMembersInvited
|
2022-04-24 09:56:07 +00:00
|
|
|
WebAppData
|
2022-09-03 11:47:17 +00:00
|
|
|
MessageReactions
|
|
|
|
ChatReactions
|
2023-11-28 08:24:28 +00:00
|
|
|
Story
|
|
|
|
MyBoost
|
|
|
|
BoostsStatus
|
|
|
|
Giveaway
|
2023-12-27 21:54:46 +00:00
|
|
|
GiveawayResult
|
2024-05-31 22:45:31 +00:00
|
|
|
Invoice
|
2023-11-28 08:24:28 +00:00
|
|
|
GiftCode
|
2024-04-05 09:11:20 +00:00
|
|
|
CheckedGiftCode
|
2024-05-31 22:01:22 +00:00
|
|
|
SuccessfulPayment
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
2022-03-28 11:23:12 +00:00
|
|
|
bot_keyboards="""
|
|
|
|
Bot keyboards
|
2019-07-09 17:03:46 +00:00
|
|
|
ReplyKeyboardMarkup
|
|
|
|
KeyboardButton
|
|
|
|
ReplyKeyboardRemove
|
|
|
|
InlineKeyboardMarkup
|
|
|
|
InlineKeyboardButton
|
2021-03-17 16:13:55 +00:00
|
|
|
LoginUrl
|
2019-07-09 17:03:46 +00:00
|
|
|
ForceReply
|
|
|
|
CallbackQuery
|
|
|
|
GameHighScore
|
|
|
|
CallbackGame
|
2022-04-24 09:56:07 +00:00
|
|
|
WebAppInfo
|
2022-04-24 09:56:07 +00:00
|
|
|
MenuButton
|
|
|
|
MenuButtonCommands
|
|
|
|
MenuButtonWebApp
|
|
|
|
MenuButtonDefault
|
2022-04-24 09:56:07 +00:00
|
|
|
SentWebAppMessage
|
2023-11-28 08:24:28 +00:00
|
|
|
ForumTopic
|
2023-11-29 19:48:40 +00:00
|
|
|
RequestChannelInfo
|
|
|
|
RequestChatInfo
|
|
|
|
RequestUserInfo
|
|
|
|
RequestPollInfo
|
2024-06-07 11:11:51 +00:00
|
|
|
OrderInfo
|
2024-05-31 22:01:22 +00:00
|
|
|
PreCheckoutQuery
|
|
|
|
ShippingAddress
|
2022-03-28 11:23:12 +00:00
|
|
|
""",
|
|
|
|
bot_commands="""
|
|
|
|
Bot commands
|
2021-05-11 08:22:17 +00:00
|
|
|
BotCommand
|
2022-03-28 11:23:12 +00:00
|
|
|
BotCommandScope
|
|
|
|
BotCommandScopeDefault
|
|
|
|
BotCommandScopeAllPrivateChats
|
|
|
|
BotCommandScopeAllGroupChats
|
|
|
|
BotCommandScopeAllChatAdministrators
|
|
|
|
BotCommandScopeChat
|
|
|
|
BotCommandScopeChatAdministrators
|
|
|
|
BotCommandScopeChatMember
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
input_media="""
|
|
|
|
Input Media
|
|
|
|
InputMedia
|
|
|
|
InputMediaPhoto
|
|
|
|
InputMediaVideo
|
|
|
|
InputMediaAudio
|
|
|
|
InputMediaAnimation
|
|
|
|
InputMediaDocument
|
|
|
|
InputPhoneContact
|
|
|
|
""",
|
|
|
|
inline_mode="""
|
|
|
|
Inline Mode
|
|
|
|
InlineQuery
|
|
|
|
InlineQueryResult
|
2022-04-24 09:56:07 +00:00
|
|
|
InlineQueryResultCachedAudio
|
|
|
|
InlineQueryResultCachedDocument
|
|
|
|
InlineQueryResultCachedAnimation
|
|
|
|
InlineQueryResultCachedPhoto
|
|
|
|
InlineQueryResultCachedSticker
|
|
|
|
InlineQueryResultCachedVideo
|
|
|
|
InlineQueryResultCachedVoice
|
2019-07-09 17:03:46 +00:00
|
|
|
InlineQueryResultArticle
|
2022-01-07 09:18:51 +00:00
|
|
|
InlineQueryResultAudio
|
2022-04-24 09:56:07 +00:00
|
|
|
InlineQueryResultContact
|
|
|
|
InlineQueryResultDocument
|
|
|
|
InlineQueryResultAnimation
|
|
|
|
InlineQueryResultLocation
|
|
|
|
InlineQueryResultPhoto
|
|
|
|
InlineQueryResultVenue
|
2022-01-07 09:18:51 +00:00
|
|
|
InlineQueryResultVideo
|
2022-04-24 09:56:07 +00:00
|
|
|
InlineQueryResultVoice
|
2020-04-03 15:15:28 +00:00
|
|
|
ChosenInlineResult
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
input_message_content="""
|
|
|
|
InputMessageContent
|
|
|
|
InputMessageContent
|
|
|
|
InputTextMessageContent
|
2019-08-13 11:18:01 +00:00
|
|
|
""",
|
|
|
|
authorization="""
|
|
|
|
Authorization
|
2024-08-02 10:21:46 +00:00
|
|
|
ActiveSession
|
|
|
|
ActiveSessions
|
2019-08-13 11:18:01 +00:00
|
|
|
SentCode
|
|
|
|
TermsOfService
|
2019-07-09 17:03:46 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
root = PYROGRAM_API_DEST + "/types"
|
|
|
|
|
|
|
|
shutil.rmtree(root, ignore_errors=True)
|
|
|
|
os.mkdir(root)
|
|
|
|
|
2019-07-09 17:10:11 +00:00
|
|
|
with open(HOME + "/template/types.rst") as f:
|
2019-07-09 17:03:46 +00:00
|
|
|
template = f.read()
|
|
|
|
|
|
|
|
with open(root + "/index.rst", "w") as f:
|
|
|
|
fmt_keys = {}
|
|
|
|
|
|
|
|
for k, v in categories.items():
|
|
|
|
name, *types = get_title_list(v)
|
|
|
|
|
|
|
|
fmt_keys.update({k: "\n ".join(types)})
|
|
|
|
|
|
|
|
# noinspection PyShadowingBuiltins
|
|
|
|
for type in types:
|
|
|
|
with open(root + "/{}.rst".format(type), "w") as f2:
|
|
|
|
title = "{}".format(type)
|
|
|
|
|
|
|
|
f2.write(title + "\n" + "=" * len(title) + "\n\n")
|
2020-08-26 06:10:34 +00:00
|
|
|
f2.write(".. autoclass:: pyrogram.types.{}()\n".format(type))
|
2019-07-09 17:03:46 +00:00
|
|
|
|
|
|
|
f.write(template.format(**fmt_keys))
|
|
|
|
|
|
|
|
# Bound Methods
|
|
|
|
|
|
|
|
categories = dict(
|
|
|
|
message="""
|
|
|
|
Message
|
|
|
|
Message.click
|
|
|
|
Message.delete
|
|
|
|
Message.download
|
|
|
|
Message.forward
|
2020-12-05 00:54:07 +00:00
|
|
|
Message.copy
|
2019-07-09 17:03:46 +00:00
|
|
|
Message.pin
|
2021-01-12 21:25:19 +00:00
|
|
|
Message.unpin
|
2021-03-19 19:42:48 +00:00
|
|
|
Message.edit
|
2019-07-09 17:03:46 +00:00
|
|
|
Message.edit_text
|
|
|
|
Message.edit_caption
|
|
|
|
Message.edit_media
|
|
|
|
Message.edit_reply_markup
|
2021-03-19 19:42:48 +00:00
|
|
|
Message.reply
|
2019-07-09 17:03:46 +00:00
|
|
|
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
|
2024-01-17 08:52:00 +00:00
|
|
|
Message.reply_web_page
|
2021-02-27 17:56:28 +00:00
|
|
|
Message.get_media_group
|
2022-03-28 19:03:37 +00:00
|
|
|
Message.react
|
2024-05-05 16:47:04 +00:00
|
|
|
Message.read
|
|
|
|
Message.view
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
chat="""
|
|
|
|
Chat
|
|
|
|
Chat.archive
|
|
|
|
Chat.unarchive
|
|
|
|
Chat.set_title
|
|
|
|
Chat.set_description
|
|
|
|
Chat.set_photo
|
2024-03-12 06:57:01 +00:00
|
|
|
Chat.set_ttl
|
2021-12-22 13:39:52 +00:00
|
|
|
Chat.ban_member
|
2019-07-09 17:03:46 +00:00
|
|
|
Chat.unban_member
|
|
|
|
Chat.restrict_member
|
|
|
|
Chat.promote_member
|
2024-03-12 06:57:01 +00:00
|
|
|
Chat.join
|
|
|
|
Chat.leave
|
|
|
|
Chat.export_invite_link
|
2020-04-06 12:22:38 +00:00
|
|
|
Chat.get_member
|
|
|
|
Chat.get_members
|
|
|
|
Chat.add_members
|
2020-12-12 15:56:26 +00:00
|
|
|
Chat.mark_unread
|
2022-01-05 11:45:09 +00:00
|
|
|
Chat.set_protected_content
|
2022-04-16 16:33:26 +00:00
|
|
|
Chat.unpin_all_messages
|
2023-11-28 08:24:28 +00:00
|
|
|
Chat.mute
|
|
|
|
Chat.unmute
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
user="""
|
|
|
|
User
|
|
|
|
User.archive
|
|
|
|
User.unarchive
|
2019-07-11 15:13:20 +00:00
|
|
|
User.block
|
|
|
|
User.unblock
|
2024-03-12 06:57:01 +00:00
|
|
|
User.get_common_chats
|
2019-07-09 17:03:46 +00:00
|
|
|
""",
|
|
|
|
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
|
2022-02-01 10:01:02 +00:00
|
|
|
""",
|
2024-05-31 22:01:22 +00:00
|
|
|
pre_checkout_query="""
|
|
|
|
PreCheckoutQuery
|
|
|
|
PreCheckoutQuery.answer
|
|
|
|
""",
|
2022-02-01 10:01:02 +00:00
|
|
|
chat_join_request="""
|
|
|
|
ChatJoinRequest
|
|
|
|
ChatJoinRequest.approve
|
|
|
|
ChatJoinRequest.decline
|
2023-11-28 08:24:28 +00:00
|
|
|
""",
|
|
|
|
story="""
|
|
|
|
Story
|
|
|
|
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
|
2024-03-12 06:57:01 +00:00
|
|
|
Story.copy
|
2023-11-28 08:24:28 +00:00
|
|
|
Story.delete
|
2023-12-07 20:54:18 +00:00
|
|
|
Story.edit_media
|
2023-11-28 08:24:28 +00:00
|
|
|
Story.edit_caption
|
|
|
|
Story.edit_privacy
|
|
|
|
Story.react
|
|
|
|
Story.forward
|
2024-03-12 06:57:01 +00:00
|
|
|
Story.download
|
2023-11-28 08:24:28 +00:00
|
|
|
Story.read
|
2024-05-15 18:08:58 +00:00
|
|
|
Story.view
|
2023-11-28 08:24:28 +00:00
|
|
|
""",
|
|
|
|
folder="""
|
|
|
|
Folder
|
|
|
|
Folder.delete
|
2023-12-01 15:38:45 +00:00
|
|
|
Folder.update
|
2023-11-28 08:24:28 +00:00
|
|
|
Folder.include_chat
|
|
|
|
Folder.exclude_chat
|
2024-03-12 06:57:01 +00:00
|
|
|
Folder.update_color
|
2023-12-01 15:38:45 +00:00
|
|
|
Folder.pin_chat
|
|
|
|
Folder.remove_chat
|
2023-11-28 08:24:28 +00:00
|
|
|
Folder.export_link
|
2024-08-02 10:21:46 +00:00
|
|
|
""",
|
|
|
|
active_session="""
|
|
|
|
ActiveSession
|
|
|
|
ActiveSession.reset
|
2019-07-09 17:03:46 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
root = PYROGRAM_API_DEST + "/bound-methods"
|
|
|
|
|
|
|
|
shutil.rmtree(root, ignore_errors=True)
|
|
|
|
os.mkdir(root)
|
|
|
|
|
2019-07-09 17:10:11 +00:00
|
|
|
with open(HOME + "/template/bound-methods.rst") as f:
|
2019-07-09 17:03:46 +00:00
|
|
|
template = f.read()
|
|
|
|
|
|
|
|
with open(root + "/index.rst", "w") as f:
|
|
|
|
fmt_keys = {}
|
|
|
|
|
|
|
|
for k, v in categories.items():
|
|
|
|
name, *bound_methods = get_title_list(v)
|
|
|
|
|
|
|
|
fmt_keys.update({"{}_hlist".format(k): "\n ".join("- :meth:`~{}`".format(bm) for bm in bound_methods)})
|
|
|
|
|
|
|
|
fmt_keys.update(
|
|
|
|
{"{}_toctree".format(k): "\n ".join("{} <{}>".format(bm.split(".")[1], bm) for bm in bound_methods)})
|
|
|
|
|
|
|
|
# noinspection PyShadowingBuiltins
|
|
|
|
for bm in bound_methods:
|
|
|
|
with open(root + "/{}.rst".format(bm), "w") as f2:
|
|
|
|
title = "{}()".format(bm)
|
|
|
|
|
|
|
|
f2.write(title + "\n" + "=" * len(title) + "\n\n")
|
2020-08-22 06:05:05 +00:00
|
|
|
f2.write(".. automethod:: pyrogram.types.{}()".format(bm))
|
2019-07-09 17:03:46 +00:00
|
|
|
|
|
|
|
f.write(template.format(**fmt_keys))
|
|
|
|
|
|
|
|
|
2018-01-05 01:16:30 +00:00
|
|
|
def start():
|
2018-01-05 02:15:48 +00:00
|
|
|
global page_template
|
|
|
|
global toctree
|
|
|
|
|
2019-05-30 22:19:18 +00:00
|
|
|
shutil.rmtree(DESTINATION, ignore_errors=True)
|
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
with open(HOME + "/template/page.txt", encoding="utf-8") as f:
|
2018-01-05 02:15:48 +00:00
|
|
|
page_template = f.read()
|
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
with open(HOME + "/template/toctree.txt", encoding="utf-8") as f:
|
2018-01-05 02:15:48 +00:00
|
|
|
toctree = f.read()
|
|
|
|
|
2018-02-28 00:28:31 +00:00
|
|
|
generate(TYPES_PATH, TYPES_BASE)
|
|
|
|
generate(FUNCTIONS_PATH, FUNCTIONS_BASE)
|
2020-08-22 06:05:05 +00:00
|
|
|
generate(BASE_PATH, BASE_BASE)
|
2019-07-09 17:03:46 +00:00
|
|
|
pyrogram_api()
|
2018-01-05 01:16:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
if "__main__" == __name__:
|
2020-08-22 06:05:05 +00:00
|
|
|
FUNCTIONS_PATH = "../../pyrogram/raw/functions"
|
|
|
|
TYPES_PATH = "../../pyrogram/raw/types"
|
|
|
|
BASE_PATH = "../../pyrogram/raw/base"
|
2018-02-28 00:28:31 +00:00
|
|
|
HOME = "."
|
2019-05-12 17:26:55 +00:00
|
|
|
DESTINATION = "../../docs/source/telegram"
|
2019-07-09 17:03:46 +00:00
|
|
|
PYROGRAM_API_DEST = "../../docs/source/api"
|
2018-01-05 01:16:30 +00:00
|
|
|
|
|
|
|
start()
|