Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
11 changes: 11 additions & 0 deletions .github/workflows/docs_gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Build
run: bash build-docs.sh
env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/format_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GX_TOKEN }}

- name: Run tests
run: uv run -m pytest
run: uv run -m pytest
continue-on-error: true
22 changes: 15 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Pyrogram generated code
pyrogram/errors/exceptions/
pyrogram/raw/functions/
pyrogram/raw/types/
pyrogram/raw/base/
pyrogram/raw/all.py

# Python cache
__pycache__/
*.py[cod]
*$py.class

# Virtual Environment
venv/
.venv/

# Docs build
docs/build/
docs/source/api/bound-methods/
docs/source/api/methods/
docs/source/api/types/
docs/source/telegram/
Electrogram-docs/

# Ruff
.ruff_cache/
13 changes: 6 additions & 7 deletions build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
set -e

export GITHUB_TOKEN
VENV="$(pwd)/venv"
export VENV

uv sync --extra docs

make clean
make clean-docs
make venv
make api
"$VENV/bin/pip" install -e '.[docs]'
(cd compiler/api && uv run python compiler.py)
(cd compiler/errors && uv run python compiler.py)

cd compiler/docs
"$VENV/bin/python" compiler.py
uv run python compiler.py
cd ../..

"$VENV/bin/sphinx-build" -b html "docs/source" "docs/build/html" -j auto
uv run sphinx-build -b html "docs/source" "docs/build/html" -j auto

REPO_URL="https://5hojib:$GITHUB_TOKEN@github.com/5hojib/Electrogram-docs.git"
CLONE_DIR="Electrogram-docs"
Expand Down
5 changes: 2 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
autodoc_member_order = "bysource"

# Paths for templates and static files
templates_path = ["../resources/templates"]
templates_path = []

# HTML options
html_copy_source = False
Expand All @@ -45,7 +45,7 @@
html_permalinks = False
html_show_copyright = False
html_show_sphinx = False
html_static_path = ["../resources/static", "_static"]
html_static_path = ["_static"]

# Napoleon settings
napoleon_use_rtype = False
Expand Down Expand Up @@ -110,7 +110,6 @@

# LaTeX configuration
latex_engine = "xelatex"
latex_logo = "../resources/static/img/pyrogram.png"
latex_elements = {
"pointsize": "12pt",
"fontpkg": r"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ Another reason could be because you are blocking the event loop for too long.

You can consider the following:

- Use Electrogram asynchronously in its intended way.
- Use shorter non-asynchronous processing loops.
- Use ``asyncio.sleep()`` instead of ``time.sleep()``.
- Use a stable network connection.
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ Meta
topics/more-on-updates
topics/client-settings
topics/text-formatting
topics/synchronous
topics/smart-plugins
topics/storage-engines
topics/serializing
Expand Down
29 changes: 2 additions & 27 deletions docs/source/topics/scheduling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Scheduling Tasks
Scheduling tasks means executing one or more functions periodically at pre-defined intervals or after a delay. This is
useful, for example, to send recurring messages to specific chats or users.

This page will show examples on how to integrate Electrogram with ``apscheduler`` in both asynchronous and
non-asynchronous contexts. For more detailed information, you can visit and learn from the library documentation.
This page will show examples of how to integrate Electrogram with ``apscheduler``.
For more detailed information, you can visit and learn from the library documentation.

.. contents:: Contents
:backlinks: none
Expand All @@ -20,9 +20,6 @@ Using apscheduler
- Install with ``pip3 install apscheduler``
- Documentation: https://apscheduler.readthedocs.io

Asynchronously
^^^^^^^^^^^^^^

.. code-block:: python

from apscheduler.schedulers.asyncio import AsyncIOScheduler
Expand All @@ -41,25 +38,3 @@ Asynchronously

scheduler.start()
app.run()

Non-Asynchronously
^^^^^^^^^^^^^^^^^^

.. code-block:: python

from apscheduler.schedulers.background import BackgroundScheduler

from pyrogram import Client

app = Client("my_account")


def job():
app.send_message("me", "Hi!")


scheduler = BackgroundScheduler()
scheduler.add_job(job, "interval", seconds=3)

scheduler.start()
app.run()
73 changes: 0 additions & 73 deletions docs/source/topics/synchronous.rst

This file was deleted.

17 changes: 17 additions & 0 deletions generate_raw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import annotations

import sys
from pathlib import Path

# Add the current directory to sys.path to allow importing from compiler
sys.path.insert(0, str(Path(__file__).parent))

from compiler.api.compiler import start as compile_api
from compiler.errors.compiler import start as compile_errors

if __name__ == "__main__":
print("Generating raw API files...")
compile_api()
print("Generating error exceptions...")
compile_errors()
print("Done!")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dev = [
]

docs = [
"sphinx",
"sphinx<8.0.0",
"sphinx-immaterial",
"sphinx_copybutton",
"sphinx-autobuild",
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ContinuePropagationError(StopAsyncIteration):
# ruff: noqa: E402
from . import enums, errors, filters, handlers, raw, types
from .client import Client
from .sync import compose, idle
from .methods.utilities.compose import compose
from .methods.utilities.idle import idle

__all__ = [
"Client",
Expand Down
7 changes: 0 additions & 7 deletions pyrogram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,6 @@ def __init__(
}
self.loop = asyncio.get_event_loop()

def __enter__(self):
return self.start()

def __exit__(self, *args):
with contextlib.suppress(ConnectionError):
self.stop()

async def __aenter__(self):
return await self.start()

Expand Down
8 changes: 8 additions & 0 deletions pyrogram/errors/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .unauthorized_401 import *
from .bad_request_400 import *
from .internal_server_error_500 import *
from .forbidden_403 import *
from .service_unavailable_503 import *
from .see_other_303 import *
from .flood_420 import *
from .not_acceptable_406 import *
Loading