mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-20 08:05:27 +00:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 680dc2b6b8 | |||
| 04d86deb58 | |||
| 03d2359061 | |||
| 29866e2139 | |||
| 7e9537ece2 | |||
| baa01596c3 | |||
| c23eb8ec08 | |||
| 6ae7add722 | |||
| f3bda29e51 | |||
| fe0421a822 | |||
| 0325a024d6 | |||
| 2f65fcc292 | |||
| 2d63c57ed6 | |||
| b73dc5728e | |||
| f452c132fa | |||
| ebf7f3be12 | |||
| dc284a1a73 | |||
| 979988add1 | |||
| 1ae759ff5c | |||
| 1ab91370ac | |||
| 29d073871a | |||
| d03b4ec688 | |||
| 07d9dc7a44 | |||
| f3479cd170 | |||
| 7fcfad41a5 | |||
| c33c541cbe | |||
| 57c2f6e01e | |||
| a52c91996e | |||
| 2345bfbb53 | |||
| cc45f49a4f | |||
| fd6a0fe899 | |||
| 67b0706116 | |||
| 592c6cc6d3 | |||
| 1fc46360ff | |||
| 4ad94cc7f7 | |||
| c6a9fbb5c7 | |||
| af8729769b | |||
| f93f827e33 | |||
| a8f1164b0c | |||
| da11561f87 | |||
| 354a8e0854 | |||
| bc68488c14 | |||
| 19d7939355 | |||
| 3495ce3aeb | |||
| dd9af64a5c | |||
| da3bc6974a | |||
| b1fc0596b9 | |||
| 6d2334c88b | |||
| a0c81ec3d4 | |||
| c8d9898eaa | |||
| 616b0b55ef | |||
| c71612ffae | |||
| 4143d99f56 | |||
| cbe808e471 | |||
| 300ec920a1 | |||
| 075f517458 | |||
| c82a0808d1 | |||
| ea7e5a69aa | |||
| f67e8c0804 | |||
| af130ef5e7 | |||
| 9ef8826f33 | |||
| 61b70efb4c | |||
| 63977ea353 | |||
| ae57d3b7c3 | |||
| 8d76087bed | |||
| 0e90deafb5 | |||
| 39d45124df | |||
| 895403a0b5 | |||
| 8cb177cb2c | |||
| eaf802e07d | |||
| 1ef242a17e | |||
| 7adb4fa2db | |||
| 5c5ee598a2 | |||
| a4ae6f2097 | |||
| fc5a56c15b | |||
| 74112bfd06 | |||
| ab90cd7359 | |||
| 5b0f1697f1 | |||
| 9c7298c17a | |||
| 39abf838fa | |||
| 04b44f4595 | |||
| a0decdac28 | |||
| f77f4b0cf7 |
@@ -1,19 +0,0 @@
|
||||
version = 1
|
||||
|
||||
test_patterns = ["tests/**"]
|
||||
|
||||
exclude_patterns = [
|
||||
"tests/**",
|
||||
"docs/**",
|
||||
"setup.py",
|
||||
"setup-raw.py"
|
||||
]
|
||||
|
||||
[[analyzers]]
|
||||
name = "python"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
runtime_version = "3.x.x"
|
||||
max_line_length = 99
|
||||
skip_doc_coverage = ["module", "magic", "init", "nonpublic"]
|
||||
@@ -16,9 +16,9 @@ jobs:
|
||||
|
||||
- name: Fetch Dependabot metadata
|
||||
id: dependabot-metadata
|
||||
uses: dependabot/fetch-metadata@v1.6.1
|
||||
uses: dependabot/fetch-metadata@v1.6.0
|
||||
|
||||
- uses: actions/checkout@v3.5.2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
@@ -31,8 +31,8 @@ jobs:
|
||||
exclude: CHANGES.rst
|
||||
|
||||
- name: Commit & Push Changes to PR
|
||||
uses: EndBug/add-and-commit@v9.1.3
|
||||
uses: EndBug/add-and-commit@v9.1.4
|
||||
with:
|
||||
message: 'Update version number in other files'
|
||||
committer_name: GitHub Actions
|
||||
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
|
||||
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
|
||||
|
||||
@@ -14,9 +14,9 @@ jobs:
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
|
||||
@@ -19,9 +19,9 @@ jobs:
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'pip'
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
- name: Build docs
|
||||
run: sphinx-build docs/source docs/build/html -W --keep-going -j auto
|
||||
- name: Upload docs
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: HTML Docs
|
||||
retention-days: 7
|
||||
|
||||
@@ -11,7 +11,7 @@ jobs:
|
||||
pull-requests: write # for srvaroa/labeler to add labels in PR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: srvaroa/labeler@v1.6.1
|
||||
- uses: srvaroa/labeler@v1.10.0
|
||||
# Config file at .github/labeler.yml
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
@@ -8,10 +8,12 @@ jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v4.0.1
|
||||
- uses: dessant/lock-threads@v5.0.1
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-inactive-days: '7'
|
||||
issue-lock-reason: ''
|
||||
pr-inactive-days: '7'
|
||||
pr-lock-reason: ''
|
||||
# Don't lock Discussions
|
||||
process-only: 'issues, prs'
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
# PRs never get stale
|
||||
days-before-stale: 3
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
name: Bot API Tests
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
# Run monday and friday morning at 03:07 - odd time to spread load on GitHub Actions
|
||||
- cron: '7 3 * * 1,5'
|
||||
|
||||
jobs:
|
||||
check-conformity:
|
||||
name: check-conformity
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.11]
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -W ignore -m pip install --upgrade pip
|
||||
python -W ignore -m pip install -r requirements.txt
|
||||
python -W ignore -m pip install -r requirements-opts.txt
|
||||
python -W ignore -m pip install -r requirements-dev.txt
|
||||
- name: Compare to official api
|
||||
run: |
|
||||
pytest -v tests/test_official.py --junit-xml=.test_report_official.xml
|
||||
exit $?
|
||||
env:
|
||||
TEST_OFFICIAL: "true"
|
||||
shell: bash --noprofile --norc {0}
|
||||
|
||||
- name: Test Summary
|
||||
id: test_summary
|
||||
uses: test-summary/action@v2.2
|
||||
if: always() # always run, even if tests fail
|
||||
with:
|
||||
paths: .test_report_official.xml
|
||||
@@ -12,10 +12,10 @@ jobs:
|
||||
name: test-type-completeness
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- run: git fetch --depth=1 # https://github.com/actions/checkout/issues/329#issuecomment-674881489
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.9
|
||||
cache: 'pip'
|
||||
@@ -50,6 +50,14 @@ jobs:
|
||||
json.load(open("pr.json", "rb"))["typeCompleteness"]["completenessScore"]
|
||||
)
|
||||
base_text = f"This PR changes type completeness from {round(base, 3)} to {round(pr, 3)}."
|
||||
|
||||
if base == 0:
|
||||
text = f"Something is broken in the workflow. Reported type completeness is 0. 💥"
|
||||
set_summary(text)
|
||||
print(Path("pr.readable").read_text(encoding="utf-8"))
|
||||
error(text)
|
||||
exit(1)
|
||||
|
||||
if pr < (base - 0.001):
|
||||
text = f"{base_text} ❌"
|
||||
set_summary(text)
|
||||
|
||||
@@ -3,9 +3,11 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
schedule:
|
||||
# Run monday and friday morning at 03:07 - odd time to spread load on GitHub Actions
|
||||
- cron: '7 3 * * 1,5'
|
||||
@@ -16,13 +18,13 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12.0-rc.1']
|
||||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'pip'
|
||||
@@ -79,7 +81,7 @@ jobs:
|
||||
|
||||
- name: Test Summary
|
||||
id: test_summary
|
||||
uses: test-summary/action@v2.1
|
||||
uses: test-summary/action@v2.2
|
||||
if: always() # always run, even if tests fail
|
||||
with:
|
||||
paths: |
|
||||
@@ -87,43 +89,9 @@ jobs:
|
||||
.test_report_optionals.xml
|
||||
|
||||
- name: Submit coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
env_vars: OS,PYTHON
|
||||
name: ${{ matrix.os }}-${{ matrix.python-version }}
|
||||
fail_ci_if_error: true
|
||||
|
||||
test_official:
|
||||
name: test-official
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.11]
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -W ignore -m pip install --upgrade pip
|
||||
python -W ignore -m pip install -r requirements.txt
|
||||
python -W ignore -m pip install -r requirements-opts.txt
|
||||
python -W ignore -m pip install -r requirements-dev.txt
|
||||
- name: Compare to official api
|
||||
run: |
|
||||
pytest -v tests/test_official.py --junit-xml=.test_report_official.xml
|
||||
exit $?
|
||||
env:
|
||||
TEST_OFFICIAL: "true"
|
||||
shell: bash --noprofile --norc {0}
|
||||
|
||||
- name: Test Summary
|
||||
id: test_summary
|
||||
uses: test-summary/action@v2.1
|
||||
if: always() # always run, even if tests fail
|
||||
with:
|
||||
paths: .test_report_official.xml
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
+28
-34
@@ -1,41 +1,47 @@
|
||||
# Make sure that the additional_dependencies here match requirements.txt
|
||||
# Make sure that the additional_dependencies here match requirements(-opts).txt
|
||||
|
||||
ci:
|
||||
autofix_prs: false
|
||||
autoupdate_schedule: monthly
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 23.7.0
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.2.1'
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: ruff
|
||||
files: ^(telegram|examples|tests)/.*\.py$
|
||||
additional_dependencies:
|
||||
- httpx~=0.26.0
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.2
|
||||
- aiolimiter~=1.1.0
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 24.1.1
|
||||
hooks:
|
||||
- id: black
|
||||
args:
|
||||
- --diff
|
||||
- --check
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 6.1.0
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/PyCQA/pylint
|
||||
rev: v3.0.0a6
|
||||
rev: v3.0.3
|
||||
hooks:
|
||||
- id: pylint
|
||||
files: ^(telegram|examples)/.*\.py$
|
||||
args:
|
||||
- --rcfile=setup.cfg
|
||||
# run pylint across multiple cpu cores to speed it up-
|
||||
# https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
|
||||
- --jobs=0
|
||||
|
||||
additional_dependencies:
|
||||
- httpx~=0.24.1
|
||||
- tornado~=6.2
|
||||
- httpx~=0.26.0
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.1
|
||||
- cachetools~=5.3.2
|
||||
- aiolimiter~=1.1.0
|
||||
- . # this basically does `pip install -e .`
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.4.1
|
||||
rev: v1.8.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
name: mypy-ptb
|
||||
@@ -44,10 +50,10 @@ repos:
|
||||
- types-pytz
|
||||
- types-cryptography
|
||||
- types-cachetools
|
||||
- httpx~=0.24.1
|
||||
- tornado~=6.2
|
||||
- httpx~=0.26.0
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.1
|
||||
- cachetools~=5.3.2
|
||||
- aiolimiter~=1.1.0
|
||||
- . # this basically does `pip install -e .`
|
||||
- id: mypy
|
||||
@@ -57,34 +63,22 @@ repos:
|
||||
- --no-strict-optional
|
||||
- --follow-imports=silent
|
||||
additional_dependencies:
|
||||
- tornado~=6.2
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.1
|
||||
- cachetools~=5.3.2
|
||||
- . # this basically does `pip install -e .`
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.10.1
|
||||
rev: v3.15.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
files: ^(telegram|examples|tests|docs)/.*\.py$
|
||||
args:
|
||||
- --py38-plus
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.12.0
|
||||
rev: 5.13.2
|
||||
hooks:
|
||||
- id: isort
|
||||
name: isort
|
||||
args:
|
||||
- --diff
|
||||
- --check
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.0.281'
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: ruff
|
||||
files: ^(telegram|examples|tests)/.*\.py$
|
||||
additional_dependencies:
|
||||
- httpx~=0.24.1
|
||||
- tornado~=6.2
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.1
|
||||
- aiolimiter~=1.1.0
|
||||
|
||||
@@ -12,6 +12,7 @@ sphinx:
|
||||
# Optionally build your docs in additional formats such as PDF
|
||||
formats:
|
||||
- pdf
|
||||
- htmlzip
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
|
||||
@@ -25,6 +25,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||
- `Abshar <https://github.com/abxhr>`_
|
||||
- `Alateas <https://github.com/alateas>`_
|
||||
- `Ales Dokshanin <https://github.com/alesdokshanin>`_
|
||||
- `Alexandre <https://github.com/xTudoS>`_
|
||||
- `Alizia <https://github.com/thefunkycat>`_
|
||||
- `Ambro17 <https://github.com/Ambro17>`_
|
||||
- `Andrej Zhilenkov <https://github.com/Andrej730>`_
|
||||
@@ -69,6 +70,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||
- `Joscha Götzer <https://github.com/Rostgnom>`_
|
||||
- `jossalgon <https://github.com/jossalgon>`_
|
||||
- `JRoot3D <https://github.com/JRoot3D>`_
|
||||
- `kenjitagawa <https://github.com/kenjitagawa>`_
|
||||
- `kennethcheo <https://github.com/kennethcheo>`_
|
||||
- `Kirill Vasin <https://github.com/vasinkd>`_
|
||||
- `Kjwon15 <https://github.com/kjwon15>`_
|
||||
@@ -76,6 +78,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||
- `Loo Zheng Yuan <https://github.com/loozhengyuan>`_
|
||||
- `LRezende <https://github.com/lrezende>`_
|
||||
- `Luca Bellanti <https://github.com/Trifase>`_
|
||||
- `Lucas Molinari <https://github.com/lucasmolinari>`_
|
||||
- `macrojames <https://github.com/macrojames>`_
|
||||
- `Matheus Lemos <https://github.com/mlemosf>`_
|
||||
- `Michael Dix <https://github.com/Eisberge>`_
|
||||
|
||||
+168
@@ -4,6 +4,174 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Version 20.8
|
||||
============
|
||||
|
||||
*Released 2024-02-08*
|
||||
|
||||
This is the technical changelog for version 20.8. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- API 7.0 (:pr:`4034` closes :issue:`4033`, :pr:`4038` by `@aelkheir <https://github.com/aelkheir>`__)
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- Fix Type Hint for ``filters`` Parameter of ``MessageHandler`` (:pr:`4039` by `@Palaptin <https://github.com/Palaptin>`__)
|
||||
- Deprecate ``filters.CHAT`` (:pr:`4083` closes :issue:`4062`)
|
||||
- Improve Error Handling in Built-In Webhook Handler (:pr:`3987` closes :issue:`3979`)
|
||||
|
||||
New Features
|
||||
------------
|
||||
|
||||
- Add Parameter ``pattern`` to ``PreCheckoutQueryHandler`` and ``filters.SuccessfulPayment`` (:pr:`4005` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`3752`)
|
||||
- Add Missing Conversions of ``type`` to Corresponding Enum from ``telegram.constants`` (:pr:`4067`)
|
||||
- Add Support for Unix Sockets to ``Updater.start_webhook`` (:pr:`3986` closes :issue:`3978`)
|
||||
- Add ``Bot.do_api_request`` (:pr:`4084` closes :issue:`4053`)
|
||||
- Add ``AsyncContextManager`` as Parent Class to ``BaseUpdateProcessor`` (:pr:`4001`)
|
||||
|
||||
Documentation Improvements
|
||||
--------------------------
|
||||
|
||||
- Documentation Improvements (:pr:`3919`)
|
||||
- Add Docstring to Dunder Methods (:pr:`3929` closes :issue:`3926`)
|
||||
- Documentation Improvements (:pr:`4002`, :pr:`4079` by `@kenjitagawa <https://github.com/kenjitagawa>`__, :pr:`4104` by `@xTudoS <https://github.com/xTudoS>`__)
|
||||
|
||||
Internal Changes
|
||||
----------------
|
||||
|
||||
- Drop Usage of DeepSource (:pr:`4100`)
|
||||
- Improve Type Completeness & Corresponding Workflow (:pr:`4035`)
|
||||
- Bump ``ruff`` and Remove ``sort-all`` (:pr:`4075`)
|
||||
- Move Handler Files to ``_handlers`` Subdirectory (:pr:`4064` by `@lucasmolinari <https://github.com/lucasmolinari>`__ closes :issue:`4060`)
|
||||
- Introduce ``sort-all`` Hook for ``pre-commit`` (:pr:`4052`)
|
||||
- Use Recommended ``pre-commit`` Mirror for ``black`` (:pr:`4051`)
|
||||
- Remove Unused ``DEFAULT_20`` (:pr:`3997`)
|
||||
- Migrate From ``setup.cfg`` to ``pyproject.toml`` Where Possible (:pr:`4088`)
|
||||
|
||||
Dependency Updates
|
||||
------------------
|
||||
|
||||
- Bump ``black`` and ``ruff`` (:pr:`4089`)
|
||||
- Bump ``srvaroa/labeler`` from 1.8.0 to 1.10.0 (:pr:`4048`)
|
||||
- Update ``tornado`` requirement from ~=6.3.3 to ~=6.4 (:pr:`3992`)
|
||||
- Bump ``actions/stale`` from 8 to 9 (:pr:`4046`)
|
||||
- Bump ``actions/setup-python`` from 4 to 5 (:pr:`4047`)
|
||||
- ``pre-commit`` autoupdate (:pr:`4101`)
|
||||
- Bump ``actions/upload-artifact`` from 3 to 4 (:pr:`4045`)
|
||||
- ``pre-commit`` autoupdate (:pr:`3996`)
|
||||
- Bump ``furo`` from 2023.9.10 to 2024.1.29 (:pr:`4094`)
|
||||
- ``pre-commit`` autoupdate (:pr:`4043`)
|
||||
- Bump ``codecov/codecov-action`` from 3 to 4 (:pr:`4091`)
|
||||
- Bump ``EndBug/add-and-commit`` from 9.1.3 to 9.1.4 (:pr:`4090`)
|
||||
- Update ``httpx`` requirement from ~=0.25.2 to ~=0.26.0 (:pr:`4024`)
|
||||
- Bump ``pytest`` from 7.4.3 to 7.4.4 (:pr:`4056`)
|
||||
- Bump ``srvaroa/labeler`` from 1.7.0 to 1.8.0 (:pr:`3993`)
|
||||
- Bump ``test-summary/action`` from 2.1 to 2.2 (:pr:`4044`)
|
||||
- Bump ``dessant/lock-threads`` from 4.0.1 to 5.0.1 (:pr:`3994`)
|
||||
|
||||
|
||||
Version 20.7
|
||||
============
|
||||
|
||||
*Released 2023-11-27*
|
||||
|
||||
This is the technical changelog for version 20.7. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
|
||||
New Features
|
||||
------------
|
||||
|
||||
- Add ``JobQueue.scheduler_configuration`` and Corresponding Warnings (:pr:`3913` closes :issue:`3837`)
|
||||
- Add Parameter ``socket_options`` to ``HTTPXRequest`` (:pr:`3935` closes :issue:`2965`)
|
||||
- Add ``ApplicationBuilder.(get_updates_)socket_options`` (:pr:`3943`)
|
||||
- Improve ``write_timeout`` Handling for Media Methods (:pr:`3952`)
|
||||
- Add ``filters.Mention`` (:pr:`3941` closes :issue:`3799`)
|
||||
- Rename ``proxy_url`` to ``proxy`` and Allow ``httpx.{Proxy, URL}`` as Input (:pr:`3939` closes :issue:`3844`)
|
||||
|
||||
Bug Fixes & Changes
|
||||
-------------------
|
||||
|
||||
- Adjust ``read_timeout`` Behavior for ``Bot.get_updates`` (:pr:`3963` closes :issue:`3893`)
|
||||
- Improve ``BaseHandler.__repr__`` for Callbacks without ``__qualname__`` (:pr:`3934`)
|
||||
- Fix Persistency Issue with Ended Non-Blocking Conversations (:pr:`3962`)
|
||||
- Improve Type Hinting for Arguments with Default Values in ``Bot`` (:pr:`3942`)
|
||||
|
||||
Documentation Improvements
|
||||
--------------------------
|
||||
|
||||
- Add Documentation for ``__aenter__`` and ``__aexit__`` Methods (:pr:`3907` closes :issue:`3886`)
|
||||
- Improve Insertion of Kwargs into ``Bot`` Methods (:pr:`3965`)
|
||||
|
||||
Internal Changes
|
||||
----------------
|
||||
|
||||
- Adjust Tests to New Error Messages (:pr:`3970`)
|
||||
|
||||
Dependency Updates
|
||||
------------------
|
||||
|
||||
- Bump ``pytest-xdist`` from 3.3.1 to 3.4.0 (:pr:`3975`)
|
||||
- ``pre-commit`` autoupdate (:pr:`3967`)
|
||||
- Update ``httpx`` requirement from ~=0.25.1 to ~=0.25.2 (:pr:`3983`)
|
||||
- Bump ``pytest-xdist`` from 3.4.0 to 3.5.0 (:pr:`3982`)
|
||||
- Update ``httpx`` requirement from ~=0.25.0 to ~=0.25.1 (:pr:`3961`)
|
||||
- Bump ``srvaroa/labeler`` from 1.6.1 to 1.7.0 (:pr:`3958`)
|
||||
- Update ``cachetools`` requirement from ~=5.3.1 to ~=5.3.2 (:pr:`3954`)
|
||||
- Bump ``pytest`` from 7.4.2 to 7.4.3 (:pr:`3953`)
|
||||
|
||||
|
||||
Version 20.6
|
||||
============
|
||||
|
||||
*Released 2023-10-03*
|
||||
|
||||
This is the technical changelog for version 20.6. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- Drop Backward Compatibility Layer Introduced in :pr:`3853` (API 6.8) (:pr:`3873`)
|
||||
- Full Support for Bot API 6.9 (:pr:`3898`)
|
||||
|
||||
New Features
|
||||
------------
|
||||
|
||||
- Add Rich Equality Comparison to ``WriteAccessAllowed`` (:pr:`3911` closes :issue:`3909`)
|
||||
- Add ``__repr__`` Methods Added in :pr:`3826` closes :issue:`3770` to Sphinx Documentation (:pr:`3901` closes :issue:`3889`)
|
||||
- Add String Representation for Selected Classes (:pr:`3826` closes :issue:`3770`)
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- Add Support Python 3.12 (:pr:`3915`)
|
||||
- Documentation Improvements (:pr:`3910`)
|
||||
|
||||
Internal Changes
|
||||
----------------
|
||||
|
||||
- Verify Type Hints for Bot Method & Telegram Class Parameters (:pr:`3868`)
|
||||
- Move Bot API Tests to Separate Workflow File (:pr:`3912`)
|
||||
- Fix Failing ``file_size`` Tests (:pr:`3906`)
|
||||
- Set Threshold for DeepSource’s PY-R1000 to High (:pr:`3888`)
|
||||
- One-Time Code Formatting Improvement via ``--preview`` Flag of ``black`` (:pr:`3882`)
|
||||
- Move Dunder Methods to the Top of Class Bodies (:pr:`3883`)
|
||||
- Remove Superfluous ``Defaults.__ne__`` (:pr:`3884`)
|
||||
|
||||
Dependency Updates
|
||||
------------------
|
||||
|
||||
- ``pre-commit`` autoupdate (:pr:`3876`)
|
||||
- Update ``pre-commit`` Dependencies (:pr:`3916`)
|
||||
- Bump ``actions/checkout`` from 3 to 4 (:pr:`3914`)
|
||||
- Update ``httpx`` requirement from ~=0.24.1 to ~=0.25.0 (:pr:`3891`)
|
||||
- Bump ``furo`` from 2023.8.19 to 2023.9.10 (:pr:`3890`)
|
||||
- Bump ``sphinx`` from 7.2.5 to 7.2.6 (:pr:`3892`)
|
||||
- Update ``tornado`` requirement from ~=6.2 to ~=6.3.3 (:pr:`3675`)
|
||||
- Bump ``pytest`` from 7.4.0 to 7.4.2 (:pr:`3881`)
|
||||
|
||||
|
||||
Version 20.5
|
||||
============
|
||||
*Released 2023-09-03*
|
||||
|
||||
+6
-6
@@ -14,7 +14,7 @@
|
||||
:target: https://pypi.org/project/python-telegram-bot/
|
||||
:alt: Supported Python versions
|
||||
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-6.8-blue?logo=telegram
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-7.0-blue?logo=telegram
|
||||
:target: https://core.telegram.org/bots/api-changelog
|
||||
:alt: Supported Bot API versions
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
:target: https://www.gnu.org/licenses/lgpl-3.0.html
|
||||
:alt: LGPLv3 License
|
||||
|
||||
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/Unit%20Tests/badge.svg
|
||||
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/actions/workflows/unit_tests.yml/badge.svg?branch=master
|
||||
:target: https://github.com/python-telegram-bot/python-telegram-bot/
|
||||
:alt: Github Actions workflow
|
||||
|
||||
@@ -93,7 +93,7 @@ Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conju
|
||||
Telegram API support
|
||||
====================
|
||||
|
||||
All types and methods of the Telegram Bot API **6.8** are supported.
|
||||
All types and methods of the Telegram Bot API **7.0** are supported.
|
||||
|
||||
Installing
|
||||
==========
|
||||
@@ -135,7 +135,7 @@ As these features are *optional*, the corresponding 3rd party dependencies are n
|
||||
Instead, they are listed as optional dependencies.
|
||||
This allows to avoid unnecessary dependency conflicts for users who don't need the optional features.
|
||||
|
||||
The only required dependency is `httpx ~= 0.24.1 <https://www.python-httpx.org>`_ for
|
||||
The only required dependency is `httpx ~= 0.26.0 <https://www.python-httpx.org>`_ for
|
||||
``telegram.request.HTTPXRequest``, the default networking backend.
|
||||
|
||||
``python-telegram-bot`` is most useful when used along with additional libraries.
|
||||
@@ -152,8 +152,8 @@ PTB can be installed with optional dependencies:
|
||||
* ``pip install "python-telegram-bot[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
|
||||
* ``pip install "python-telegram-bot[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
|
||||
* ``pip install "python-telegram-bot[rate-limiter]"`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
|
||||
* ``pip install "python-telegram-bot[webhooks]"`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
|
||||
* ``pip install "python-telegram-bot[callback-data]"`` installs the `cachetools~=5.3.1 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
|
||||
* ``pip install "python-telegram-bot[webhooks]"`` installs the `tornado~=6.4 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
|
||||
* ``pip install "python-telegram-bot[callback-data]"`` installs the `cachetools~=5.3.2 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
|
||||
* ``pip install "python-telegram-bot[job-queue]"`` installs the `APScheduler~=3.10.4 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``.
|
||||
|
||||
To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot[socks,webhooks]"``.
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@
|
||||
:target: https://pypi.org/project/python-telegram-bot-raw/
|
||||
:alt: Supported Python versions
|
||||
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-6.8-blue?logo=telegram
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-7.0-blue?logo=telegram
|
||||
:target: https://core.telegram.org/bots/api-changelog
|
||||
:alt: Supported Bot API versions
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
:target: https://www.gnu.org/licenses/lgpl-3.0.html
|
||||
:alt: LGPLv3 License
|
||||
|
||||
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/Unit%20Tests/badge.svg
|
||||
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/actions/workflows/unit_tests.yml/badge.svg?branch=master
|
||||
:target: https://github.com/python-telegram-bot/python-telegram-bot/
|
||||
:alt: Github Actions workflow
|
||||
|
||||
@@ -89,7 +89,7 @@ Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conju
|
||||
Telegram API support
|
||||
====================
|
||||
|
||||
All types and methods of the Telegram Bot API **6.8** are supported.
|
||||
All types and methods of the Telegram Bot API **7.0** are supported.
|
||||
|
||||
Installing
|
||||
==========
|
||||
@@ -136,7 +136,7 @@ As these features are *optional*, the corresponding 3rd party dependencies are n
|
||||
Instead, they are listed as optional dependencies.
|
||||
This allows to avoid unnecessary dependency conflicts for users who don't need the optional features.
|
||||
|
||||
The only required dependency is `httpx ~= 0.24.1 <https://www.python-httpx.org>`_ for
|
||||
The only required dependency is `httpx ~= 0.26.0 <https://www.python-httpx.org>`_ for
|
||||
``telegram.request.HTTPXRequest``, the default networking backend.
|
||||
|
||||
``python-telegram-bot`` is most useful when used along with additional libraries.
|
||||
|
||||
@@ -194,7 +194,7 @@ class AdmonitionInserter:
|
||||
)
|
||||
except NotImplementedError as e:
|
||||
raise NotImplementedError(
|
||||
f"Error generating Sphinx 'Available in' admonition "
|
||||
"Error generating Sphinx 'Available in' admonition "
|
||||
f"(admonition_inserter.py). Class {name_of_class_in_attr} present in "
|
||||
f"attribute {target_attr} of class {name_of_inspected_class_in_docstr}"
|
||||
f" could not be resolved. {str(e)}"
|
||||
@@ -237,7 +237,7 @@ class AdmonitionInserter:
|
||||
)
|
||||
except NotImplementedError as e:
|
||||
raise NotImplementedError(
|
||||
f"Error generating Sphinx 'Available in' admonition "
|
||||
"Error generating Sphinx 'Available in' admonition "
|
||||
f"(admonition_inserter.py). Class {name_of_class_in_prop} present in "
|
||||
f"property {prop_name} of class {name_of_inspected_class_in_docstr}"
|
||||
f" could not be resolved. {str(e)}"
|
||||
@@ -269,7 +269,7 @@ class AdmonitionInserter:
|
||||
)
|
||||
except NotImplementedError as e:
|
||||
raise NotImplementedError(
|
||||
f"Error generating Sphinx 'Returned in' admonition "
|
||||
"Error generating Sphinx 'Returned in' admonition "
|
||||
f"(admonition_inserter.py). {cls}, method {method_name}. "
|
||||
f"Couldn't resolve type hint in return annotation {ret_annot}. {str(e)}"
|
||||
)
|
||||
@@ -342,7 +342,7 @@ class AdmonitionInserter:
|
||||
)
|
||||
except NotImplementedError as e:
|
||||
raise NotImplementedError(
|
||||
f"Error generating Sphinx 'Use in' admonition "
|
||||
"Error generating Sphinx 'Use in' admonition "
|
||||
f"(admonition_inserter.py). {cls}, method {method_name}, parameter "
|
||||
f"{param}: Couldn't resolve type hint {param.annotation}. {str(e)}"
|
||||
)
|
||||
|
||||
@@ -18,51 +18,81 @@
|
||||
import inspect
|
||||
|
||||
keyword_args = [
|
||||
":keyword _sphinx_paramlinks_telegram.Bot.{method}.read_timeout: Value to pass to "
|
||||
":paramref:`telegram.request.BaseRequest.post.read_timeout`. Defaults to {read_timeout}.",
|
||||
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.read_timeout: {read_timeout_type}, optional",
|
||||
":keyword _sphinx_paramlinks_telegram.Bot.{method}.write_timeout: Value to pass to "
|
||||
":paramref:`telegram.request.BaseRequest.post.write_timeout`. Defaults to {write_timeout}.",
|
||||
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.write_timeout: :obj:`float` | :obj:`None`, "
|
||||
"optional",
|
||||
":keyword _sphinx_paramlinks_telegram.Bot.{method}.connect_timeout: Value to pass to "
|
||||
":paramref:`telegram.request.BaseRequest.post.connect_timeout`. Defaults to "
|
||||
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
|
||||
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.connect_timeout: :obj:`float` | "
|
||||
":obj:`None`, optional",
|
||||
":keyword _sphinx_paramlinks_telegram.Bot.{method}.pool_timeout: Value to pass to "
|
||||
":paramref:`telegram.request.BaseRequest.post.pool_timeout`. Defaults to "
|
||||
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
|
||||
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.pool_timeout: :obj:`float` | :obj:`None`, "
|
||||
"optional",
|
||||
":keyword _sphinx_paramlinks_telegram.Bot.{method}.api_kwargs: Arbitrary keyword arguments "
|
||||
"to be passed to the Telegram API.",
|
||||
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.api_kwargs: :obj:`dict`, optional",
|
||||
"Keyword Arguments:",
|
||||
(
|
||||
" read_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
|
||||
" :paramref:`telegram.request.BaseRequest.post.read_timeout`. Defaults to "
|
||||
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`. "
|
||||
),
|
||||
(
|
||||
" write_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
|
||||
" :paramref:`telegram.request.BaseRequest.post.write_timeout`. Defaults to "
|
||||
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`."
|
||||
),
|
||||
(
|
||||
" connect_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
|
||||
" :paramref:`telegram.request.BaseRequest.post.connect_timeout`. Defaults to "
|
||||
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`."
|
||||
),
|
||||
(
|
||||
" pool_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
|
||||
" :paramref:`telegram.request.BaseRequest.post.pool_timeout`. Defaults to "
|
||||
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`."
|
||||
),
|
||||
(
|
||||
" api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments"
|
||||
" to be passed to the Telegram API. See :meth:`~telegram.Bot.do_api_request` for"
|
||||
" limitations."
|
||||
),
|
||||
"",
|
||||
]
|
||||
write_timeout_sub = [":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`", "``20``"]
|
||||
read_timeout_sub = [
|
||||
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`",
|
||||
"``2``. :paramref:`timeout` will be added to this value",
|
||||
|
||||
media_write_timeout_deprecation_methods = [
|
||||
"send_photo",
|
||||
"send_audio",
|
||||
"send_document",
|
||||
"send_sticker",
|
||||
"send_video",
|
||||
"send_video_note",
|
||||
"send_animation",
|
||||
"send_voice",
|
||||
"send_media_group",
|
||||
"set_chat_photo",
|
||||
"upload_sticker_file",
|
||||
"add_sticker_to_set",
|
||||
"create_new_sticker_set",
|
||||
]
|
||||
media_write_timeout_deprecation = [
|
||||
" write_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
|
||||
" :paramref:`telegram.request.BaseRequest.post.write_timeout`. By default, ``20`` "
|
||||
" seconds are used as write timeout."
|
||||
"",
|
||||
"",
|
||||
" .. deprecated:: 20.7",
|
||||
" In future versions, the default value will be changed to "
|
||||
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
|
||||
"",
|
||||
"",
|
||||
]
|
||||
get_updates_read_timeout_addition = [
|
||||
" :paramref:`timeout` will be added to this value.",
|
||||
"",
|
||||
"",
|
||||
" .. versionchanged:: 20.7",
|
||||
" Defaults to :attr:`~telegram.request.BaseRequest.DEFAULT_NONE` instead of ",
|
||||
" ``2``.",
|
||||
]
|
||||
read_timeout_type = [":obj:`float` | :obj:`None`", ":obj:`float`"]
|
||||
|
||||
|
||||
def find_insert_pos_for_kwargs(lines: list[str]) -> int:
|
||||
"""Finds the correct position to insert the keyword arguments and returns the index."""
|
||||
for idx, value in reversed(list(enumerate(lines))): # reversed since :returns: is at the end
|
||||
if value.startswith(":returns:"):
|
||||
if value.startswith("Returns"):
|
||||
return idx
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def is_write_timeout_20(obj: object) -> int:
|
||||
"""inspects the default value of write_timeout parameter of the bot method."""
|
||||
sig = inspect.signature(obj)
|
||||
return 1 if (sig.parameters["write_timeout"].default == 20) else 0
|
||||
|
||||
|
||||
def check_timeout_and_api_kwargs_presence(obj: object) -> int:
|
||||
"""Checks if the method has timeout and api_kwargs keyword only parameters."""
|
||||
sig = inspect.signature(obj)
|
||||
|
||||
@@ -36,7 +36,7 @@ LINE_NUMBERS = {}
|
||||
def _git_branch() -> str:
|
||||
"""Get's the current git sha if available or fall back to `master`"""
|
||||
try:
|
||||
output = subprocess.check_output( # skipcq: BAN-B607
|
||||
output = subprocess.check_output(
|
||||
["git", "describe", "--tags", "--always"], stderr=subprocess.STDOUT
|
||||
)
|
||||
return output.decode().strip()
|
||||
|
||||
+19
-15
@@ -29,11 +29,10 @@ from docs.auxil.admonition_inserter import AdmonitionInserter
|
||||
from docs.auxil.kwargs_insertion import (
|
||||
check_timeout_and_api_kwargs_presence,
|
||||
find_insert_pos_for_kwargs,
|
||||
is_write_timeout_20,
|
||||
get_updates_read_timeout_addition,
|
||||
keyword_args,
|
||||
read_timeout_sub,
|
||||
read_timeout_type,
|
||||
write_timeout_sub,
|
||||
media_write_timeout_deprecation,
|
||||
media_write_timeout_deprecation_methods,
|
||||
)
|
||||
from docs.auxil.link_code import LINE_NUMBERS
|
||||
|
||||
@@ -107,19 +106,24 @@ def autodoc_process_docstring(
|
||||
f"Couldn't find the correct position to insert the keyword args for {obj}."
|
||||
)
|
||||
|
||||
long_write_timeout = is_write_timeout_20(obj)
|
||||
get_updates_sub = 1 if (method_name == "get_updates") else 0
|
||||
get_updates: bool = method_name == "get_updates"
|
||||
# The below can be done in 1 line with itertools.chain, but this must be modified in-place
|
||||
insert_idx = insert_index
|
||||
for i in range(insert_index, insert_index + len(keyword_args)):
|
||||
lines.insert(
|
||||
i,
|
||||
keyword_args[i - insert_index].format(
|
||||
method=method_name,
|
||||
write_timeout=write_timeout_sub[long_write_timeout],
|
||||
read_timeout=read_timeout_sub[get_updates_sub],
|
||||
read_timeout_type=read_timeout_type[get_updates_sub],
|
||||
),
|
||||
)
|
||||
to_insert = keyword_args[i - insert_index]
|
||||
|
||||
if (
|
||||
"post.write_timeout`. Defaults to" in to_insert
|
||||
and method_name in media_write_timeout_deprecation_methods
|
||||
):
|
||||
effective_insert: list[str] = media_write_timeout_deprecation
|
||||
elif get_updates and to_insert.lstrip().startswith("read_timeout"):
|
||||
effective_insert = [to_insert] + get_updates_read_timeout_addition
|
||||
else:
|
||||
effective_insert = [to_insert]
|
||||
|
||||
lines[insert_idx:insert_idx] = effective_insert
|
||||
insert_idx += len(effective_insert)
|
||||
|
||||
ADMONITION_INSERTER.insert_admonitions(
|
||||
obj=typing.cast(collections.abc.Callable, obj),
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
import datetime
|
||||
from enum import Enum
|
||||
|
||||
from docutils.nodes import Element
|
||||
@@ -71,6 +72,12 @@ class TGConstXRefRole(PyXRefRole):
|
||||
if isinstance(value, tuple) and target in (
|
||||
"telegram.constants.BOT_API_VERSION_INFO",
|
||||
"telegram.__version_info__",
|
||||
):
|
||||
return str(value), target
|
||||
if (
|
||||
isinstance(value, datetime.datetime)
|
||||
and value == telegram.constants.ZERO_DATE
|
||||
and target in ("telegram.constants.ZERO_DATE",)
|
||||
):
|
||||
return repr(value), target
|
||||
sphinx_logger.warning(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
sphinx==7.2.5
|
||||
sphinx-pypi-upload
|
||||
furo==2023.8.19
|
||||
sphinx==7.2.6
|
||||
furo==2024.1.29
|
||||
git+https://github.com/harshil21/furo-sphinx-search@v0.2.0.1
|
||||
sphinx-paramlinks==0.6.0
|
||||
sphinxcontrib-mermaid==0.9.2
|
||||
|
||||
+74
-53
@@ -21,9 +21,9 @@ author = "Leandro Toledo"
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = "20.5" # telegram.__version__[:3]
|
||||
version = "20.8" # telegram.__version__[:3]
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = "20.5" # telegram.__version__
|
||||
release = "20.8" # telegram.__version__
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
needs_sphinx = "6.1.3"
|
||||
@@ -77,6 +77,14 @@ napoleon_use_admonition_for_examples = True
|
||||
# and we document the types anyway
|
||||
autodoc_typehints = "none"
|
||||
|
||||
# Show docstring for special members
|
||||
autodoc_default_options = {
|
||||
"special-members": True,
|
||||
# For some reason, __weakref__ can not be ignored by using "inherited-members" in all cases
|
||||
# so we list it here.
|
||||
"exclude-members": "__init__, __weakref__",
|
||||
}
|
||||
|
||||
# Fail on warnings & unresolved references etc
|
||||
nitpicky = True
|
||||
|
||||
@@ -96,7 +104,9 @@ linkcheck_ignore = [
|
||||
]
|
||||
linkcheck_allowed_redirects = {
|
||||
# Redirects to the default version are okay
|
||||
r"https://docs\.python-telegram-bot\.org/.*": r"https://docs\.python-telegram-bot\.org/en/[\w\d\.]+/.*",
|
||||
r"https://docs\.python-telegram-bot\.org/.*": (
|
||||
r"https://docs\.python-telegram-bot\.org/en/[\w\d\.]+/.*"
|
||||
),
|
||||
# pre-commit.ci always redirects to the latest run
|
||||
re.escape(
|
||||
"https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master"
|
||||
@@ -131,71 +141,79 @@ html_theme_options = {
|
||||
"admonition-title-font-size": "0.95rem",
|
||||
"admonition-font-size": "0.92rem",
|
||||
},
|
||||
"announcement": "PTB has undergone significant changes in v20. Please read the documentation "
|
||||
"carefully and also check out the transition guide in the "
|
||||
'<a href="https://github.com/python-telegram-bot/python-telegram-bot/wiki/'
|
||||
'Transition-guide-to-Version-20.0">wiki</a>.',
|
||||
"announcement": (
|
||||
"PTB has undergone significant changes in v20. Please read the documentation "
|
||||
"carefully and also check out the transition guide in the "
|
||||
'<a href="https://github.com/python-telegram-bot/python-telegram-bot/wiki/'
|
||||
'Transition-guide-to-Version-20.0">wiki</a>.'
|
||||
),
|
||||
"footer_icons": [
|
||||
{
|
||||
# Telegram channel logo
|
||||
"name": "Telegram Channel",
|
||||
"url": "https://t.me/pythontelegrambotchannel/",
|
||||
# Following svg is from https://react-icons.github.io/react-icons/search?q=telegram
|
||||
"html": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
|
||||
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
|
||||
'<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.287 5.906c-.778.324-2.334.994'
|
||||
"-4.666 2.01-.378.15-.577.298-.595.442-.03.243.275.339.69.47l.175.055c.408.133."
|
||||
"958.288 1.243.294.26.006.549-.1.868-.32 2.179-1.471 3.304-2.214 3.374-2.23.0"
|
||||
"5-.012.12-.026.166.016.047.041.042.12.037.141-.03.129-1.227 1.241-1.846 1.81"
|
||||
"7-.193.18-.33.307-.358.336a8.154 8.154 0 0 1-.188.186c-.38.366-.664.64.015 1.08"
|
||||
"8.327.216.589.393.85.571.284.194.568.387.936.629.093.06.183.125.27.187.331.23"
|
||||
"6.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.426 "
|
||||
"1.426 0 0 0-.013-.315.337.337 0 0 0-.114-.217.526.526 0 0 0-.31-.093c-.3.005-.7"
|
||||
'63.166-2.984 1.09z"></path></svg>',
|
||||
"html": (
|
||||
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
|
||||
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
|
||||
'<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.287 5.906c-.778.324-2.334.994'
|
||||
"-4.666 2.01-.378.15-.577.298-.595.442-.03.243.275.339.69.47l.175.055c.408.133."
|
||||
"958.288 1.243.294.26.006.549-.1.868-.32 2.179-1.471 3.304-2.214 3.374-2.23.0"
|
||||
"5-.012.12-.026.166.016.047.041.042.12.037.141-.03.129-1.227 1.241-1.846 1.81"
|
||||
"7-.193.18-.33.307-.358.336a8.154 8.154 0 0 1-.188.186c-.38.366-.664.64.015 1.08"
|
||||
"8.327.216.589.393.85.571.284.194.568.387.936.629.093.06.183.125.27.187.331.23"
|
||||
"6.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.426 "
|
||||
"1.426 0 0 0-.013-.315.337.337 0 0 0-.114-.217.526.526 0 0 0-.31-.093c-.3.005-.7"
|
||||
'63.166-2.984 1.09z"></path></svg>'
|
||||
),
|
||||
"class": "",
|
||||
},
|
||||
{ # Github logo
|
||||
"name": "GitHub",
|
||||
"url": "https://github.com/python-telegram-bot/python-telegram-bot/",
|
||||
"html": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
|
||||
'viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 '
|
||||
"2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.4"
|
||||
"9-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23"
|
||||
".82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 "
|
||||
"0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.2"
|
||||
"7 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.5"
|
||||
"1.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 "
|
||||
'1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">'
|
||||
"</path></svg>",
|
||||
"html": (
|
||||
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
|
||||
'viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 '
|
||||
"2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.4"
|
||||
"9-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23"
|
||||
".82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 "
|
||||
"0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.2"
|
||||
"7 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.5"
|
||||
"1.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 "
|
||||
'1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">'
|
||||
"</path></svg>"
|
||||
),
|
||||
"class": "",
|
||||
},
|
||||
{ # PTB website logo - globe
|
||||
"name": "python-telegram-bot website",
|
||||
"url": "https://python-telegram-bot.org/",
|
||||
"html": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
|
||||
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
|
||||
'<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 '
|
||||
"1.855-.143.268-.276.56-.395.872.705.157 1.472.257 2.282.287V1.077zM4.249 3.53"
|
||||
"9c.142-.384.304-.744.481-1.078a6.7 6.7 0 0 1 .597-.933A7.01 7.01 0 0 0 3.051 "
|
||||
"3.05c.362.184.763.349 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9.124 "
|
||||
"9.124 0 0 1-1.565-.667A6.964 6.964 0 0 0 1.018 7.5h2.49zm1.4-2.741a12.344 "
|
||||
"12.344 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332zM8.5 5.09V7.5h"
|
||||
"2.99a12.342 12.342 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.03"
|
||||
"5.987.176 1.914.399 2.741A13.612 13.612 0 0 1 7.5 10.91V8.5H4.51zm3.99 0v2.409"
|
||||
"c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741H8.5zm-3.282 3.696c.12.31"
|
||||
"2.252.604.395.872.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.28"
|
||||
"2.287zm.11 2.276a6.696 6.696 0 0 1-.598-.933 8.853 8.853 0 0 1-.481-1.079 8.38 "
|
||||
"8.38 0 0 0-1.198.49 7.01 7.01 0 0 0 2.276 1.522zm-1.383-2.964A13.36 13.36 0 0 1"
|
||||
" 3.508 8.5h-2.49a6.963 6.963 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667zm"
|
||||
"6.728 2.964a7.009 7.009 0 0 0 2.275-1.521 8.376 8.376 0 0 0-1.197-.49 8.853 "
|
||||
"8.853 0 0 1-.481 1.078 6.688 6.688 0 0 1-.597.933zM8.5 11.909v3.014c.67-.204 "
|
||||
"1.335-.82 1.887-1.855.143-.268.276-.56.395-.872A12.63 12.63 0 0 0 8.5 11.91zm"
|
||||
"3.555-.401c.57.185 1.095.409 1.565.667A6.963 6.963 0 0 0 14.982 8.5h-2.49a1"
|
||||
"3.36 13.36 0 0 1-.437 3.008zM14.982 7.5a6.963 6.963 0 0 0-1.362-3.675c-.47.25"
|
||||
"8-.995.482-1.565.667.248.92.4 1.938.437 3.008h2.49zM11.27 2.461c.177.334.339.6"
|
||||
"94.482 1.078a8.368 8.368 0 0 0 1.196-.49 7.01 7.01 0 0 0-2.275-1.52c.218.283.4"
|
||||
"18.597.597.932zm-.488 1.343a7.765 7.765 0 0 0-.395-.872C9.835 1.897 9.17 1.282 "
|
||||
'8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z"></path></svg>',
|
||||
"html": (
|
||||
'<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
|
||||
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
|
||||
'<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 '
|
||||
"1.855-.143.268-.276.56-.395.872.705.157 1.472.257 2.282.287V1.077zM4.249 3.53"
|
||||
"9c.142-.384.304-.744.481-1.078a6.7 6.7 0 0 1 .597-.933A7.01 7.01 0 0 0 3.051 "
|
||||
"3.05c.362.184.763.349 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9.124 "
|
||||
"9.124 0 0 1-1.565-.667A6.964 6.964 0 0 0 1.018 7.5h2.49zm1.4-2.741a12.344 "
|
||||
"12.344 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332zM8.5 5.09V7.5h"
|
||||
"2.99a12.342 12.342 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.03"
|
||||
"5.987.176 1.914.399 2.741A13.612 13.612 0 0 1 7.5 10.91V8.5H4.51zm3.99 0v2.409"
|
||||
"c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741H8.5zm-3.282 3.696c.12.31"
|
||||
"2.252.604.395.872.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.28"
|
||||
"2.287zm.11 2.276a6.696 6.696 0 0 1-.598-.933 8.853 8.853 0 0 1-.481-1.079 8.38 "
|
||||
"8.38 0 0 0-1.198.49 7.01 7.01 0 0 0 2.276 1.522zm-1.383-2.964A13.36 13.36 0 0 1"
|
||||
" 3.508 8.5h-2.49a6.963 6.963 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667zm"
|
||||
"6.728 2.964a7.009 7.009 0 0 0 2.275-1.521 8.376 8.376 0 0 0-1.197-.49 8.853 "
|
||||
"8.853 0 0 1-.481 1.078 6.688 6.688 0 0 1-.597.933zM8.5 11.909v3.014c.67-.204 "
|
||||
"1.335-.82 1.887-1.855.143-.268.276-.56.395-.872A12.63 12.63 0 0 0 8.5 11.91zm"
|
||||
"3.555-.401c.57.185 1.095.409 1.565.667A6.963 6.963 0 0 0 14.982 8.5h-2.49a1"
|
||||
"3.36 13.36 0 0 1-.437 3.008zM14.982 7.5a6.963 6.963 0 0 0-1.362-3.675c-.47.25"
|
||||
"8-.995.482-1.565.667.248.92.4 1.938.437 3.008h2.49zM11.27 2.461c.177.334.339.6"
|
||||
"94.482 1.078a8.368 8.368 0 0 0 1.196-.49 7.01 7.01 0 0 0-2.275-1.52c.218.283.4"
|
||||
"18.597.597.932zm-.488 1.343a7.765 7.765 0 0 0-.395-.872C9.835 1.897 9.17 1.282 "
|
||||
'8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z"></path></svg>'
|
||||
),
|
||||
"class": "",
|
||||
},
|
||||
],
|
||||
@@ -304,5 +322,8 @@ from docs.auxil.tg_const_role import CONSTANTS_ROLE, TGConstXRefRole
|
||||
def setup(app: Sphinx):
|
||||
app.connect("autodoc-skip-member", autodoc_skip_member)
|
||||
app.connect("autodoc-process-bases", autodoc_process_bases)
|
||||
app.connect("autodoc-process-docstring", autodoc_process_docstring)
|
||||
# The default priority is 500. We want our function to run before napoleon doc-conversion
|
||||
# and sphinx-paramlinks do, b/c otherwise the inserted kwargs in the bot methods won't show
|
||||
# up in the objects.inv file that Sphinx generates (i.e. not in the search).
|
||||
app.connect("autodoc-process-docstring", autodoc_process_docstring, priority=100)
|
||||
app.add_role_to_domain("py", CONSTANTS_ROLE, TGConstXRefRole())
|
||||
|
||||
@@ -49,8 +49,12 @@
|
||||
- Used for sending voice messages
|
||||
* - :meth:`~telegram.Bot.copy_message`
|
||||
- Used for copying the contents of an arbitrary message
|
||||
* - :meth:`~telegram.Bot.copy_messages`
|
||||
- Used for copying the contents of an multiple arbitrary messages
|
||||
* - :meth:`~telegram.Bot.forward_message`
|
||||
- Used for forwarding messages
|
||||
* - :meth:`~telegram.Bot.forward_messages`
|
||||
- Used for forwarding multiple messages at once
|
||||
|
||||
.. raw:: html
|
||||
|
||||
@@ -76,6 +80,10 @@
|
||||
- Used for answering a shipping query
|
||||
* - :meth:`~telegram.Bot.answer_web_app_query`
|
||||
- Used for answering a web app query
|
||||
* - :meth:`~telegram.Bot.delete_message`
|
||||
- Used for deleting messages.
|
||||
* - :meth:`~telegram.Bot.delete_messages`
|
||||
- Used for deleting multiple messages as once.
|
||||
* - :meth:`~telegram.Bot.edit_message_caption`
|
||||
- Used for editing captions
|
||||
* - :meth:`~telegram.Bot.edit_message_media`
|
||||
@@ -88,8 +96,8 @@
|
||||
- Used for editing text messages
|
||||
* - :meth:`~telegram.Bot.stop_poll`
|
||||
- Used for stopping the running poll
|
||||
* - :meth:`~telegram.Bot.delete_message`
|
||||
- Used for deleting messages.
|
||||
* - :meth:`~telegram.Bot.set_message_reaction`
|
||||
- Used for setting reactions on messages
|
||||
|
||||
.. raw:: html
|
||||
|
||||
@@ -157,6 +165,8 @@
|
||||
- Used for getting the number of members in a chat
|
||||
* - :meth:`~telegram.Bot.get_chat_member`
|
||||
- Used for getting a member of a chat
|
||||
* - :meth:`~telegram.Bot.get_user_chat_boosts`
|
||||
- Used for getting the list of boosts added to a chat
|
||||
* - :meth:`~telegram.Bot.leave_chat`
|
||||
- Used for leaving a chat
|
||||
|
||||
|
||||
@@ -21,6 +21,13 @@ Available Types
|
||||
telegram.callbackquery
|
||||
telegram.chat
|
||||
telegram.chatadministratorrights
|
||||
telegram.chatboost
|
||||
telegram.chatboostremoved
|
||||
telegram.chatboostsource
|
||||
telegram.chatboostsourcegiftcode
|
||||
telegram.chatboostsourcegiveaway
|
||||
telegram.chatboostsourcepremium
|
||||
telegram.chatboostupdated
|
||||
telegram.chatinvitelink
|
||||
telegram.chatjoinrequest
|
||||
telegram.chatlocation
|
||||
@@ -38,6 +45,7 @@ Available Types
|
||||
telegram.contact
|
||||
telegram.dice
|
||||
telegram.document
|
||||
telegram.externalreplyinfo
|
||||
telegram.file
|
||||
telegram.forcereply
|
||||
telegram.forumtopic
|
||||
@@ -47,6 +55,11 @@ Available Types
|
||||
telegram.forumtopicreopened
|
||||
telegram.generalforumtopichidden
|
||||
telegram.generalforumtopicunhidden
|
||||
telegram.giveaway
|
||||
telegram.giveawaycompleted
|
||||
telegram.giveawaycreated
|
||||
telegram.giveawaywinners
|
||||
telegram.inaccessiblemessage
|
||||
telegram.inlinekeyboardbutton
|
||||
telegram.inlinekeyboardmarkup
|
||||
telegram.inputfile
|
||||
@@ -61,8 +74,11 @@ Available Types
|
||||
telegram.keyboardbuttonpolltype
|
||||
telegram.keyboardbuttonrequestchat
|
||||
telegram.keyboardbuttonrequestuser
|
||||
telegram.keyboardbuttonrequestusers
|
||||
telegram.linkpreviewoptions
|
||||
telegram.location
|
||||
telegram.loginurl
|
||||
telegram.maybeinaccessiblemessage
|
||||
telegram.menubutton
|
||||
telegram.menubuttoncommands
|
||||
telegram.menubuttondefault
|
||||
@@ -71,21 +87,36 @@ Available Types
|
||||
telegram.messageautodeletetimerchanged
|
||||
telegram.messageentity
|
||||
telegram.messageid
|
||||
telegram.messageorigin
|
||||
telegram.messageoriginchannel
|
||||
telegram.messageoriginchat
|
||||
telegram.messageoriginhiddenuser
|
||||
telegram.messageoriginuser
|
||||
telegram.messagereactioncountupdated
|
||||
telegram.messagereactionupdated
|
||||
telegram.photosize
|
||||
telegram.poll
|
||||
telegram.pollanswer
|
||||
telegram.polloption
|
||||
telegram.proximityalerttriggered
|
||||
telegram.reactioncount
|
||||
telegram.reactiontype
|
||||
telegram.reactiontypecustomemoji
|
||||
telegram.reactiontypeemoji
|
||||
telegram.replykeyboardmarkup
|
||||
telegram.replykeyboardremove
|
||||
telegram.replyparameters
|
||||
telegram.sentwebappmessage
|
||||
telegram.story
|
||||
telegram.switchinlinequerychosenchat
|
||||
telegram.telegramobject
|
||||
telegram.textquote
|
||||
telegram.update
|
||||
telegram.user
|
||||
telegram.userchatboosts
|
||||
telegram.userprofilephotos
|
||||
telegram.usershared
|
||||
telegram.usersshared
|
||||
telegram.venue
|
||||
telegram.video
|
||||
telegram.videochatended
|
||||
|
||||
@@ -4,4 +4,3 @@ Bot
|
||||
.. autoclass:: telegram.Bot
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __reduce__, __deepcopy__
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoost
|
||||
=========
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoost
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostRemoved
|
||||
================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoostRemoved
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostSource
|
||||
===============
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoostSource
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostSourceGiftCode
|
||||
=======================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoostSourceGiftCode
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostSourceGiveaway
|
||||
=======================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoostSourceGiveaway
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostSourcePremium
|
||||
======================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoostSourcePremium
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostUpdated
|
||||
================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoostUpdated
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -4,3 +4,4 @@ telegram.constants Module
|
||||
.. automodule:: telegram.constants
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:inherited-members: Enum, EnumMeta
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostHandler
|
||||
================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ext.ChatBoostHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -5,7 +5,7 @@ filters Module
|
||||
The classes in `filters.py` are sorted alphabetically such that :bysource: still is readable
|
||||
|
||||
.. automodule:: telegram.ext.filters
|
||||
:inherited-members: BaseFilter, MessageFilter, UpdateFilter
|
||||
:inherited-members: BaseFilter, MessageFilter, UpdateFilter, object
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:member-order: bysource
|
||||
@@ -6,6 +6,7 @@ Handlers
|
||||
|
||||
telegram.ext.basehandler
|
||||
telegram.ext.callbackqueryhandler
|
||||
telegram.ext.chatboosthandler
|
||||
telegram.ext.chatjoinrequesthandler
|
||||
telegram.ext.chatmemberhandler
|
||||
telegram.ext.choseninlineresulthandler
|
||||
@@ -14,6 +15,7 @@ Handlers
|
||||
telegram.ext.filters
|
||||
telegram.ext.inlinequeryhandler
|
||||
telegram.ext.messagehandler
|
||||
telegram.ext.messagereactionhandler
|
||||
telegram.ext.pollanswerhandler
|
||||
telegram.ext.pollhandler
|
||||
telegram.ext.precheckoutqueryhandler
|
||||
|
||||
@@ -4,4 +4,3 @@ Job
|
||||
.. autoclass:: telegram.ext.Job
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __call__
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageReactionHandler
|
||||
======================
|
||||
|
||||
.. autoclass:: telegram.ext.MessageReactionHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ExternalReplyInfo
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.ExternalReplyInfo
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
Giveaway
|
||||
========
|
||||
|
||||
.. autoclass:: telegram.Giveaway
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
GiveawayCompleted
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.GiveawayCompleted
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
GiveawayCreated
|
||||
===============
|
||||
|
||||
.. autoclass:: telegram.GiveawayCreated
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
GiveawayWinners
|
||||
===============
|
||||
|
||||
.. autoclass:: telegram.GiveawayWinners
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
InaccessibleMessage
|
||||
===================
|
||||
|
||||
.. autoclass:: telegram.InaccessibleMessage
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -1,5 +1,5 @@
|
||||
KeyboardButtonRequestUser
|
||||
==================================
|
||||
=========================
|
||||
|
||||
.. autoclass:: telegram.KeyboardButtonRequestUser
|
||||
:members:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
KeyboardButtonRequestUsers
|
||||
==========================
|
||||
|
||||
.. autoclass:: telegram.KeyboardButtonRequestUsers
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
LinkPreviewOptions
|
||||
==================
|
||||
|
||||
.. autoclass:: telegram.LinkPreviewOptions
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
MaybeInaccessibleMessage
|
||||
========================
|
||||
|
||||
.. autoclass:: telegram.MaybeInaccessibleMessage
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageOrigin
|
||||
=============
|
||||
|
||||
.. autoclass:: telegram.MessageOrigin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageOriginChannel
|
||||
====================
|
||||
|
||||
.. autoclass:: telegram.MessageOriginChannel
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageOriginChat
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.MessageOriginChat
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,7 @@
|
||||
MessageOriginHiddenUser
|
||||
=======================
|
||||
|
||||
.. autoclass:: telegram.MessageOriginHiddenUser
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageOriginUser
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.MessageOriginUser
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageReactionCountUpdated
|
||||
===========================
|
||||
|
||||
.. autoclass:: telegram.MessageReactionCountUpdated
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageReactionUpdated
|
||||
======================
|
||||
|
||||
.. autoclass:: telegram.MessageReactionUpdated
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ReactionCount
|
||||
=============
|
||||
|
||||
.. autoclass:: telegram.ReactionCount
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ReactionType
|
||||
============
|
||||
|
||||
.. autoclass:: telegram.ReactionType
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ReactionTypeCustomEmoji
|
||||
=======================
|
||||
|
||||
.. autoclass:: telegram.ReactionTypeCustomEmoji
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ReactionTypeEmoji
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.ReactionTypeEmoji
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ReplyParameters
|
||||
===============
|
||||
|
||||
.. autoclass:: telegram.ReplyParameters
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -4,4 +4,3 @@ TelegramObject
|
||||
.. autoclass:: telegram.TelegramObject
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__, __getitem__, __eq__, __hash__, __setstate__, __getstate__, __deepcopy__, __setattr__, __delattr__
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
TextQuote
|
||||
=========
|
||||
|
||||
.. autoclass:: telegram.TextQuote
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
UserChatBoosts
|
||||
==============
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.UserChatBoosts
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -1,5 +1,5 @@
|
||||
UserShared
|
||||
===================
|
||||
==========
|
||||
|
||||
.. autoclass:: telegram.UserShared
|
||||
:members:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
UsersShared
|
||||
===========
|
||||
|
||||
.. autoclass:: telegram.UsersShared
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -61,3 +61,19 @@
|
||||
.. |removed_thumb_url_note| replace:: Removed the deprecated argument and attribute ``thumb_url``.
|
||||
|
||||
.. |removed_thumb_wildcard_note| replace:: Removed the deprecated arguments and attributes ``thumb_*``.
|
||||
|
||||
.. |async_context_manager| replace:: Asynchronous context manager which
|
||||
|
||||
.. |reply_parameters| replace:: Description of the message to reply to.
|
||||
|
||||
.. |rtm_aswr_deprecated| replace:: replacing this argument. PTB will automatically convert this argument to that one, but you should update your code to use the new argument.
|
||||
|
||||
.. |keyword_only_arg| replace:: In future versions, this argument will become a keyword-only argument.
|
||||
|
||||
.. |text_html| replace:: The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same :attr:`~telegram.Message.entities`/:attr:`~telegram.Message.caption_entities` as the original message. For example, Telegram recommends that entities of type :attr:`~telegram.MessageEntity.BLOCKQUOTE` and :attr:`~telegram.MessageEntity.PRE` *should* start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients.
|
||||
|
||||
.. |text_markdown| replace:: |text_html| Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.
|
||||
|
||||
.. |reply_quote| replace:: If set to :obj:`True`, the reply is sent as an actual reply to this message. If ``reply_to_message_id`` is passed, this parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in private chats.
|
||||
|
||||
.. |do_quote| replace:: If set to :obj:`True`, the replied message is quoted. For a dict, it must be the output of :meth:`~telegram.Message.build_reply_arguments` to specify exact ``reply_parameters``. If ``reply_to_message_id`` or ``reply_parameters`` are passed, this parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in private chats.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""This example showcases how PTBs "arbitrary callback data" feature can be used.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
@@ -115,8 +115,7 @@ async def count_click(update: Update, context: CustomContext) -> None:
|
||||
async def print_users(update: Update, context: CustomContext) -> None:
|
||||
"""Show which users have been using this bot."""
|
||||
await update.message.reply_text(
|
||||
"The following user IDs have used this bot: "
|
||||
f'{", ".join(map(str, context.bot_user_ids))}'
|
||||
f"The following user IDs have used this bot: {', '.join(map(str, context.bot_user_ids))}"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""Bot that explains Telegram's "Deep Linking Parameters" functionality.
|
||||
@@ -57,8 +57,7 @@ async def deep_linked_level_1(update: Update, context: ContextTypes.DEFAULT_TYPE
|
||||
bot = context.bot
|
||||
url = helpers.create_deep_linked_url(bot.username, SO_COOL)
|
||||
text = (
|
||||
"Awesome, you just accessed hidden functionality! "
|
||||
"Now let's get back to the private chat."
|
||||
"Awesome, you just accessed hidden functionality! Now let's get back to the private chat."
|
||||
)
|
||||
keyboard = InlineKeyboardMarkup.from_button(
|
||||
InlineKeyboardButton(text="Continue here!", url=url)
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""This is a very simple example on how one could implement a custom error handler."""
|
||||
@@ -40,7 +40,7 @@ async def error_handler(update: object, context: ContextTypes.DEFAULT_TYPE) -> N
|
||||
# You might need to add some logic to deal with messages longer than the 4096 character limit.
|
||||
update_str = update.to_dict() if isinstance(update, Update) else str(update)
|
||||
message = (
|
||||
f"An exception was raised while handling an update\n"
|
||||
"An exception was raised while handling an update\n"
|
||||
f"<pre>update = {html.escape(json.dumps(update_str, indent=2, ensure_ascii=False))}"
|
||||
"</pre>\n\n"
|
||||
f"<pre>context.chat_data = {html.escape(str(context.chat_data))}</pre>\n\n"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""Simple inline keyboard bot with multiple CallbackQueryHandlers.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""Basic example for a bot that can receive payment from user."""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
@@ -59,7 +59,7 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||
if context.user_data:
|
||||
reply_text += (
|
||||
f" You already told me your {', '.join(context.user_data.keys())}. Why don't you "
|
||||
f"tell me something more about yourself? Or change anything I already know."
|
||||
"tell me something more about yourself? Or change anything I already know."
|
||||
)
|
||||
else:
|
||||
reply_text += (
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=import-error
|
||||
"""Simple Bot to reply to Telegram messages.
|
||||
|
||||
This is built on the API wrapper, see echobot.py to see the same example built
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument, import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# pylint: disable=unused-argument,import-error
|
||||
# pylint: disable=unused-argument
|
||||
# This program is dedicated to the public domain under the CC0 license.
|
||||
|
||||
"""
|
||||
@@ -45,8 +45,10 @@ async def web_app_data(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||
# (see webappbot.html)
|
||||
data = json.loads(update.effective_message.web_app_data.data)
|
||||
await update.message.reply_html(
|
||||
text=f"You selected the color with the HEX value <code>{data['hex']}</code>. The "
|
||||
f"corresponding RGB value is <code>{tuple(data['rgb'].values())}</code>.",
|
||||
text=(
|
||||
f"You selected the color with the HEX value <code>{data['hex']}</code>. The "
|
||||
f"corresponding RGB value is <code>{tuple(data['rgb'].values())}</code>."
|
||||
),
|
||||
reply_markup=ReplyKeyboardRemove(),
|
||||
)
|
||||
|
||||
|
||||
+109
-5
@@ -1,21 +1,125 @@
|
||||
# BLACK:
|
||||
[tool.black]
|
||||
line-length = 99
|
||||
target-version = ['py38', 'py39', 'py310', 'py311']
|
||||
|
||||
# ISORT:
|
||||
[tool.isort] # black config
|
||||
profile = "black"
|
||||
line_length = 99
|
||||
|
||||
# RUFF:
|
||||
[tool.ruff]
|
||||
line-length = 99
|
||||
target-version = "py38"
|
||||
show-fixes = true
|
||||
|
||||
[tool.ruff.lint]
|
||||
preview = true
|
||||
explicit-preview-rules = true
|
||||
ignore = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PERF203"]
|
||||
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
|
||||
"G", "ISC", "PT", "ASYNC", "TCH", "CPY", "SLOT", "PERF", "PYI"]
|
||||
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",
|
||||
"RUF023", "Q", "INP",]
|
||||
# Add "FURB" after it's out of preview
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/*.py" = ["B018"]
|
||||
"**/__init__.py" = ["CPY001"]
|
||||
"examples/**.py" = ["CPY001"]
|
||||
"tests/**.py" = ["RUF012"]
|
||||
"tests/**.py" = ["RUF012", "ASYNC101"]
|
||||
|
||||
# PYLINT:
|
||||
[tool.pylint."messages control"]
|
||||
enable = ["useless-suppression"]
|
||||
disable = ["duplicate-code", "too-many-arguments", "too-many-public-methods",
|
||||
"too-few-public-methods", "broad-exception-caught", "too-many-instance-attributes",
|
||||
"fixme", "missing-function-docstring", "missing-class-docstring", "too-many-locals",
|
||||
"too-many-lines", "too-many-branches", "too-many-statements", "cyclic-import"
|
||||
]
|
||||
|
||||
[tool.pylint.main]
|
||||
# run pylint across multiple cpu cores to speed it up-
|
||||
# https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
|
||||
jobs = 0
|
||||
|
||||
[tool.pylint.classes]
|
||||
exclude-protected = ["_unfrozen"]
|
||||
|
||||
# PYTEST:
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
addopts = "--no-success-flaky-report -rsxX"
|
||||
filterwarnings = [
|
||||
"error",
|
||||
"ignore::DeprecationWarning",
|
||||
'ignore:Tasks created via `Application\.create_task` while the application is not running',
|
||||
"ignore::ResourceWarning",
|
||||
# TODO: Write so good code that we don't need to ignore ResourceWarnings anymore
|
||||
# Unfortunately due to https://github.com/pytest-dev/pytest/issues/8343 we can't have this here
|
||||
# and instead do a trick directly in tests/conftest.py
|
||||
# ignore::telegram.utils.deprecate.TelegramDeprecationWarning
|
||||
]
|
||||
markers = [
|
||||
"dev", # If you want to test a specific test, use this
|
||||
"no_req",
|
||||
"req",
|
||||
]
|
||||
asyncio_mode = "auto"
|
||||
|
||||
# MYPY:
|
||||
[tool.mypy]
|
||||
warn_unused_ignores = true
|
||||
warn_unused_configs = true
|
||||
disallow_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_untyped_decorators = true
|
||||
show_error_codes = true
|
||||
python_version = "3.8"
|
||||
|
||||
# For some files, it's easier to just disable strict-optional all together instead of
|
||||
# cluttering the code with `# type: ignore`s or stuff like
|
||||
# `if self.text is None: raise RuntimeError()`
|
||||
[[tool.mypy.overrides]]
|
||||
module = [
|
||||
"telegram._callbackquery",
|
||||
"telegram._file",
|
||||
"telegram._message",
|
||||
"telegram._files.file"
|
||||
]
|
||||
strict_optional = false
|
||||
|
||||
# type hinting for asyncio in webhookhandler is a bit tricky because it depends on the OS
|
||||
[[tool.mypy.overrides]]
|
||||
module = "telegram.ext._utils.webhookhandler"
|
||||
warn_unused_ignores = false
|
||||
|
||||
# The libs listed below are only used for the `customwebhookbot_*.py` examples
|
||||
# let's just ignore type checking for them for now
|
||||
[[tool.mypy.overrides]]
|
||||
module = [
|
||||
"flask.*",
|
||||
"quart.*",
|
||||
"starlette.*",
|
||||
"uvicorn.*",
|
||||
"asgiref.*",
|
||||
"django.*",
|
||||
"apscheduler.*", # not part of `customwebhookbot_*.py` examples
|
||||
]
|
||||
ignore_missing_imports = true
|
||||
|
||||
# COVERAGE:
|
||||
[tool.coverage.run]
|
||||
branch = true
|
||||
source = ["telegram"]
|
||||
parallel = true
|
||||
concurrency = ["thread", "multiprocessing"]
|
||||
omit = [
|
||||
"tests/",
|
||||
"telegram/__main__.py"
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
exclude_also = [
|
||||
"@overload",
|
||||
"@abstractmethod",
|
||||
"if TYPE_CHECKING:"
|
||||
]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
pre-commit # needed for pre-commit hooks in the git commit command
|
||||
|
||||
# For the test suite
|
||||
pytest==7.4.0
|
||||
pytest==7.4.4
|
||||
pytest-asyncio==0.21.1 # needed because pytest doesn't come with native support for coroutines as tests
|
||||
pytest-xdist==3.3.1 # xdist runs tests in parallel
|
||||
pytest-xdist==3.5.0 # xdist runs tests in parallel
|
||||
flaky # Used for flaky tests (flaky decorator)
|
||||
beautifulsoup4 # used in test_official for parsing tg docs
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ cryptography!=3.4,!=3.4.1,!=3.4.2,!=3.4.3,>=39.0.1 # passport
|
||||
aiolimiter~=1.1.0 # rate-limiter!ext
|
||||
|
||||
# tornado is rather stable, but let's not allow the next mayor release without prior testing
|
||||
tornado~=6.2 # webhooks!ext
|
||||
tornado~=6.4 # webhooks!ext
|
||||
|
||||
# Cachetools and APS don't have a strict stability policy.
|
||||
# Let's be cautious for now.
|
||||
cachetools~=5.3.1 # callback-data!ext
|
||||
cachetools~=5.3.2 # callback-data!ext
|
||||
APScheduler~=3.10.4 # job-queue!ext
|
||||
|
||||
# pytz is required by APS and just needs the lower bound due to #2120
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@
|
||||
# versions and only increase the lower bound if necessary
|
||||
|
||||
# httpx has no stable release yet, so let's be cautious for now
|
||||
httpx ~= 0.24.1
|
||||
httpx ~= 0.26.0
|
||||
|
||||
@@ -1,94 +1,8 @@
|
||||
[metadata]
|
||||
license_files = LICENSE, LICENSE.dual, LICENSE.lesser
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = docs/source
|
||||
build-dir = docs/build
|
||||
all_files = 1
|
||||
|
||||
[upload_sphinx]
|
||||
upload-dir = docs/build/html
|
||||
|
||||
[flake8]
|
||||
max-line-length = 99
|
||||
ignore = W503, W605
|
||||
extend-ignore = E203
|
||||
extend-ignore = E203, E704
|
||||
exclude = setup.py, setup-raw.py docs/source/conf.py
|
||||
|
||||
[pylint.message-control]
|
||||
disable = duplicate-code,too-many-arguments,too-many-public-methods,too-few-public-methods,
|
||||
broad-except,too-many-instance-attributes,fixme,missing-function-docstring,
|
||||
missing-class-docstring,too-many-locals,too-many-lines,too-many-branches,
|
||||
too-many-statements
|
||||
enable=useless-suppression ; Warns about unused pylint ignores
|
||||
exclude-protected=_unfrozen
|
||||
|
||||
[tool:pytest]
|
||||
testpaths = tests
|
||||
addopts = --no-success-flaky-report -rsxX
|
||||
filterwarnings =
|
||||
error
|
||||
ignore::DeprecationWarning
|
||||
ignore:Tasks created via `Application\.create_task` while the application is not running
|
||||
ignore::ResourceWarning
|
||||
; TODO: Write so good code that we don't need to ignore ResourceWarnings anymore
|
||||
|
||||
; Unfortunately due to https://github.com/pytest-dev/pytest/issues/8343 we can't have this here
|
||||
; and instead do a trick directly in tests/conftest.py
|
||||
; ignore::telegram.utils.deprecate.TelegramDeprecationWarning
|
||||
markers =
|
||||
dev: If you want to test a specific test, use this
|
||||
no_req
|
||||
req
|
||||
asyncio_mode = auto
|
||||
|
||||
[coverage:run]
|
||||
branch = True
|
||||
source = telegram
|
||||
parallel = True
|
||||
concurrency = thread, multiprocessing
|
||||
omit =
|
||||
tests/
|
||||
telegram/__main__.py
|
||||
|
||||
[coverage:report]
|
||||
exclude_lines =
|
||||
pragma: no cover
|
||||
@overload
|
||||
if TYPE_CHECKING:
|
||||
|
||||
[mypy]
|
||||
warn_unused_ignores = True
|
||||
warn_unused_configs = True
|
||||
disallow_untyped_defs = True
|
||||
disallow_incomplete_defs = True
|
||||
disallow_untyped_decorators = True
|
||||
show_error_codes = True
|
||||
|
||||
# For some files, it's easier to just disable strict-optional all together instead of
|
||||
# cluttering the code with `# type: ignore`s or stuff like
|
||||
# `if self.text is None: raise RuntimeError()`
|
||||
[mypy-telegram._callbackquery,telegram._file,telegram._message,telegram._files.file]
|
||||
strict_optional = False
|
||||
|
||||
# type hinting for asyncio in webhookhandler is a bit tricky because it depends on the OS
|
||||
[mypy-telegram.ext._utils.webhookhandler]
|
||||
warn_unused_ignores = False
|
||||
|
||||
[mypy-apscheduler.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
# The libs listed below are only used for the `customwebhookbot_*.py` examples
|
||||
# let's just ignore type checking for them for now
|
||||
[mypy-uvicorn.*]
|
||||
ignore_missing_imports = True
|
||||
[mypy-starlette.*]
|
||||
ignore_missing_imports = True
|
||||
[mypy-asgiref.*]
|
||||
ignore_missing_imports = True
|
||||
[mypy-flask.*]
|
||||
ignore_missing_imports = True
|
||||
[mypy-quart.*]
|
||||
ignore_missing_imports = True
|
||||
[mypy-django.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
+75
-19
@@ -19,12 +19,7 @@
|
||||
"""A library that provides a Python interface to the Telegram Bot API"""
|
||||
|
||||
__author__ = "devs@python-telegram-bot.org"
|
||||
|
||||
__all__ = ( # Keep this alphabetically ordered
|
||||
"__bot_api_version__",
|
||||
"__bot_api_version_info__",
|
||||
"__version__",
|
||||
"__version_info__",
|
||||
__all__ = (
|
||||
"Animation",
|
||||
"Audio",
|
||||
"Bot",
|
||||
@@ -44,22 +39,28 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"CallbackQuery",
|
||||
"Chat",
|
||||
"ChatAdministratorRights",
|
||||
"ChatBoost",
|
||||
"ChatBoostRemoved",
|
||||
"ChatBoostSource",
|
||||
"ChatBoostSourceGiftCode",
|
||||
"ChatBoostSourceGiveaway",
|
||||
"ChatBoostSourcePremium",
|
||||
"ChatBoostUpdated",
|
||||
"ChatInviteLink",
|
||||
"ChatJoinRequest",
|
||||
"ChatLocation",
|
||||
"ChatMember",
|
||||
"ChatMemberOwner",
|
||||
"ChatMemberAdministrator",
|
||||
"ChatMemberMember",
|
||||
"ChatMemberRestricted",
|
||||
"ChatMemberLeft",
|
||||
"ChatMemberBanned",
|
||||
"ChatMemberLeft",
|
||||
"ChatMemberMember",
|
||||
"ChatMemberOwner",
|
||||
"ChatMemberRestricted",
|
||||
"ChatMemberUpdated",
|
||||
"ChatPermissions",
|
||||
"ChatPhoto",
|
||||
"ChatShared",
|
||||
"ChosenInlineResult",
|
||||
"constants",
|
||||
"Contact",
|
||||
"Credentials",
|
||||
"DataCredentials",
|
||||
@@ -67,7 +68,7 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"Document",
|
||||
"EncryptedCredentials",
|
||||
"EncryptedPassportElement",
|
||||
"error",
|
||||
"ExternalReplyInfo",
|
||||
"File",
|
||||
"FileCredentials",
|
||||
"ForceReply",
|
||||
@@ -80,8 +81,12 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"GameHighScore",
|
||||
"GeneralForumTopicHidden",
|
||||
"GeneralForumTopicUnhidden",
|
||||
"helpers",
|
||||
"Giveaway",
|
||||
"GiveawayCompleted",
|
||||
"GiveawayCreated",
|
||||
"GiveawayWinners",
|
||||
"IdDocumentData",
|
||||
"InaccessibleMessage",
|
||||
"InlineKeyboardButton",
|
||||
"InlineKeyboardMarkup",
|
||||
"InlineQuery",
|
||||
@@ -103,10 +108,10 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"InlineQueryResultLocation",
|
||||
"InlineQueryResultMpeg4Gif",
|
||||
"InlineQueryResultPhoto",
|
||||
"InlineQueryResultsButton",
|
||||
"InlineQueryResultVenue",
|
||||
"InlineQueryResultVideo",
|
||||
"InlineQueryResultVoice",
|
||||
"InlineQueryResultsButton",
|
||||
"InputContactMessageContent",
|
||||
"InputFile",
|
||||
"InputInvoiceMessageContent",
|
||||
@@ -126,10 +131,13 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"KeyboardButtonPollType",
|
||||
"KeyboardButtonRequestChat",
|
||||
"KeyboardButtonRequestUser",
|
||||
"KeyboardButtonRequestUsers",
|
||||
"LabeledPrice",
|
||||
"LinkPreviewOptions",
|
||||
"Location",
|
||||
"LoginUrl",
|
||||
"MaskPosition",
|
||||
"MaybeInaccessibleMessage",
|
||||
"MenuButton",
|
||||
"MenuButtonCommands",
|
||||
"MenuButtonDefault",
|
||||
@@ -138,6 +146,13 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"MessageAutoDeleteTimerChanged",
|
||||
"MessageEntity",
|
||||
"MessageId",
|
||||
"MessageOrigin",
|
||||
"MessageOriginChannel",
|
||||
"MessageOriginChat",
|
||||
"MessageOriginHiddenUser",
|
||||
"MessageOriginUser",
|
||||
"MessageReactionCountUpdated",
|
||||
"MessageReactionUpdated",
|
||||
"OrderInfo",
|
||||
"PassportData",
|
||||
"PassportElementError",
|
||||
@@ -158,9 +173,13 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"PollOption",
|
||||
"PreCheckoutQuery",
|
||||
"ProximityAlertTriggered",
|
||||
"ReactionCount",
|
||||
"ReactionType",
|
||||
"ReactionTypeCustomEmoji",
|
||||
"ReactionTypeEmoji",
|
||||
"ReplyKeyboardMarkup",
|
||||
"ReplyKeyboardRemove",
|
||||
"request",
|
||||
"ReplyParameters",
|
||||
"ResidentialAddress",
|
||||
"SecureData",
|
||||
"SecureValue",
|
||||
@@ -174,10 +193,13 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"SuccessfulPayment",
|
||||
"SwitchInlineQueryChosenChat",
|
||||
"TelegramObject",
|
||||
"TextQuote",
|
||||
"Update",
|
||||
"User",
|
||||
"UserChatBoosts",
|
||||
"UserProfilePhotos",
|
||||
"UserShared",
|
||||
"UsersShared",
|
||||
"Venue",
|
||||
"Video",
|
||||
"VideoChatEnded",
|
||||
@@ -186,11 +208,19 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"VideoChatStarted",
|
||||
"VideoNote",
|
||||
"Voice",
|
||||
"warnings",
|
||||
"WebAppData",
|
||||
"WebAppInfo",
|
||||
"WebhookInfo",
|
||||
"WriteAccessAllowed",
|
||||
"__bot_api_version__",
|
||||
"__bot_api_version_info__",
|
||||
"__version__",
|
||||
"__version_info__",
|
||||
"constants",
|
||||
"error",
|
||||
"helpers",
|
||||
"request",
|
||||
"warnings",
|
||||
)
|
||||
|
||||
|
||||
@@ -212,6 +242,16 @@ from ._botname import BotName
|
||||
from ._callbackquery import CallbackQuery
|
||||
from ._chat import Chat
|
||||
from ._chatadministratorrights import ChatAdministratorRights
|
||||
from ._chatboost import (
|
||||
ChatBoost,
|
||||
ChatBoostRemoved,
|
||||
ChatBoostSource,
|
||||
ChatBoostSourceGiftCode,
|
||||
ChatBoostSourceGiveaway,
|
||||
ChatBoostSourcePremium,
|
||||
ChatBoostUpdated,
|
||||
UserChatBoosts,
|
||||
)
|
||||
from ._chatinvitelink import ChatInviteLink
|
||||
from ._chatjoinrequest import ChatJoinRequest
|
||||
from ._chatlocation import ChatLocation
|
||||
@@ -264,6 +304,7 @@ from ._forumtopic import (
|
||||
from ._games.callbackgame import CallbackGame
|
||||
from ._games.game import Game
|
||||
from ._games.gamehighscore import GameHighScore
|
||||
from ._giveaway import Giveaway, GiveawayCompleted, GiveawayCreated, GiveawayWinners
|
||||
from ._inline.inlinekeyboardbutton import InlineKeyboardButton
|
||||
from ._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
|
||||
from ._inline.inlinequery import InlineQuery
|
||||
@@ -297,13 +338,26 @@ from ._inline.inputtextmessagecontent import InputTextMessageContent
|
||||
from ._inline.inputvenuemessagecontent import InputVenueMessageContent
|
||||
from ._keyboardbutton import KeyboardButton
|
||||
from ._keyboardbuttonpolltype import KeyboardButtonPollType
|
||||
from ._keyboardbuttonrequest import KeyboardButtonRequestChat, KeyboardButtonRequestUser
|
||||
from ._keyboardbuttonrequest import (
|
||||
KeyboardButtonRequestChat,
|
||||
KeyboardButtonRequestUser,
|
||||
KeyboardButtonRequestUsers,
|
||||
)
|
||||
from ._linkpreviewoptions import LinkPreviewOptions
|
||||
from ._loginurl import LoginUrl
|
||||
from ._menubutton import MenuButton, MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp
|
||||
from ._message import Message
|
||||
from ._message import InaccessibleMessage, MaybeInaccessibleMessage, Message
|
||||
from ._messageautodeletetimerchanged import MessageAutoDeleteTimerChanged
|
||||
from ._messageentity import MessageEntity
|
||||
from ._messageid import MessageId
|
||||
from ._messageorigin import (
|
||||
MessageOrigin,
|
||||
MessageOriginChannel,
|
||||
MessageOriginChat,
|
||||
MessageOriginHiddenUser,
|
||||
MessageOriginUser,
|
||||
)
|
||||
from ._messagereactionupdated import MessageReactionCountUpdated, MessageReactionUpdated
|
||||
from ._passport.credentials import (
|
||||
Credentials,
|
||||
DataCredentials,
|
||||
@@ -338,10 +392,12 @@ from ._payment.shippingquery import ShippingQuery
|
||||
from ._payment.successfulpayment import SuccessfulPayment
|
||||
from ._poll import Poll, PollAnswer, PollOption
|
||||
from ._proximityalerttriggered import ProximityAlertTriggered
|
||||
from ._reaction import ReactionCount, ReactionType, ReactionTypeCustomEmoji, ReactionTypeEmoji
|
||||
from ._reply import ExternalReplyInfo, ReplyParameters, TextQuote
|
||||
from ._replykeyboardmarkup import ReplyKeyboardMarkup
|
||||
from ._replykeyboardremove import ReplyKeyboardRemove
|
||||
from ._sentwebappmessage import SentWebAppMessage
|
||||
from ._shared import ChatShared, UserShared
|
||||
from ._shared import ChatShared, UserShared, UsersShared
|
||||
from ._story import Story
|
||||
from ._switchinlinequerychosenchat import SwitchInlineQueryChosenChat
|
||||
from ._telegramobject import TelegramObject
|
||||
|
||||
@@ -27,7 +27,7 @@ from .constants import BOT_API_VERSION
|
||||
|
||||
def _git_revision() -> Optional[str]:
|
||||
try:
|
||||
output = subprocess.check_output( # skipcq: BAN-B607
|
||||
output = subprocess.check_output(
|
||||
["git", "describe", "--long", "--tags"], stderr=subprocess.STDOUT
|
||||
)
|
||||
except (subprocess.SubprocessError, OSError):
|
||||
@@ -35,7 +35,7 @@ def _git_revision() -> Optional[str]:
|
||||
return output.decode().strip()
|
||||
|
||||
|
||||
def print_ver_info() -> None: # skipcq: PY-D0003
|
||||
def print_ver_info() -> None:
|
||||
"""Prints version information for python-telegram-bot, the Bot API and Python."""
|
||||
git_revision = _git_revision()
|
||||
print(f"python-telegram-bot {telegram_ver}" + (f" ({git_revision})" if git_revision else ""))
|
||||
@@ -44,7 +44,7 @@ def print_ver_info() -> None: # skipcq: PY-D0003
|
||||
print(f"Python {sys_version}")
|
||||
|
||||
|
||||
def main() -> None: # skipcq: PY-D0003
|
||||
def main() -> None:
|
||||
"""Prints version information for python-telegram-bot, the Bot API and Python."""
|
||||
print_ver_info()
|
||||
|
||||
|
||||
+1197
-263
File diff suppressed because it is too large
Load Diff
@@ -50,7 +50,7 @@ class BotCommand(TelegramObject):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ("description", "command")
|
||||
__slots__ = ("command", "description")
|
||||
|
||||
def __init__(self, command: str, description: str, *, api_kwargs: Optional[JSONDict] = None):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
@@ -22,6 +22,7 @@ from typing import TYPE_CHECKING, Dict, Final, Optional, Type, Union
|
||||
|
||||
from telegram import constants
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils import enum
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -77,7 +78,7 @@ class BotCommandScope(TelegramObject):
|
||||
|
||||
def __init__(self, type: str, *, api_kwargs: Optional[JSONDict] = None):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.type: str = type
|
||||
self.type: str = enum.get_member(constants.BotCommandScopeType, type, type)
|
||||
self._id_attrs = (self.type,)
|
||||
|
||||
self._freeze()
|
||||
|
||||
+124
-35
@@ -22,11 +22,11 @@ from typing import TYPE_CHECKING, Final, Optional, Sequence, Tuple, Union
|
||||
|
||||
from telegram import constants
|
||||
from telegram._files.location import Location
|
||||
from telegram._message import Message
|
||||
from telegram._message import MaybeInaccessibleMessage, Message
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._user import User
|
||||
from telegram._utils.defaultvalue import DEFAULT_NONE
|
||||
from telegram._utils.types import DVInput, JSONDict, ODVInput, ReplyMarkup
|
||||
from telegram._utils.types import JSONDict, ODVInput, ReplyMarkup
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import (
|
||||
@@ -34,8 +34,10 @@ if TYPE_CHECKING:
|
||||
GameHighScore,
|
||||
InlineKeyboardMarkup,
|
||||
InputMedia,
|
||||
LinkPreviewOptions,
|
||||
MessageEntity,
|
||||
MessageId,
|
||||
ReplyParameters,
|
||||
)
|
||||
|
||||
|
||||
@@ -70,9 +72,11 @@ class CallbackQuery(TelegramObject):
|
||||
from_user (:class:`telegram.User`): Sender.
|
||||
chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
|
||||
the message with the callback button was sent. Useful for high scores in games.
|
||||
message (:class:`telegram.Message`, optional): Message with the callback button that
|
||||
originated the query. Note that message content and message date will not be available
|
||||
if the message is too old.
|
||||
message (:class:`telegram.MaybeInaccessibleMessage`, optional): Message sent by the bot
|
||||
with the callback button that originated the query.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Accept objects of type :class:`telegram.MaybeInaccessibleMessage` since Bot API 7.0.
|
||||
data (:obj:`str`, optional): Data associated with the callback button. Be aware that the
|
||||
message, which originated the query, can contain no callback buttons with this data.
|
||||
inline_message_id (:obj:`str`, optional): Identifier of the message sent via the bot in
|
||||
@@ -85,9 +89,12 @@ class CallbackQuery(TelegramObject):
|
||||
from_user (:class:`telegram.User`): Sender.
|
||||
chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
|
||||
the message with the callback button was sent. Useful for high scores in games.
|
||||
message (:class:`telegram.Message`): Optional. Message with the callback button that
|
||||
originated the query. Note that message content and message date will not be available
|
||||
if the message is too old.
|
||||
message (:class:`telegram.MaybeInaccessibleMessage`): Optional. Message sent by the bot
|
||||
with the callback button that originated the query.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Objects maybe be of type :class:`telegram.MaybeInaccessibleMessage` since Bot API
|
||||
7.0.
|
||||
data (:obj:`str` | :obj:`object`): Optional. Data associated with the callback button.
|
||||
Be aware that the message, which originated the query, can contain no callback buttons
|
||||
with this data.
|
||||
@@ -104,13 +111,13 @@ class CallbackQuery(TelegramObject):
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
"game_short_name",
|
||||
"message",
|
||||
"chat_instance",
|
||||
"id",
|
||||
"from_user",
|
||||
"inline_message_id",
|
||||
"data",
|
||||
"from_user",
|
||||
"game_short_name",
|
||||
"id",
|
||||
"inline_message_id",
|
||||
"message",
|
||||
)
|
||||
|
||||
def __init__(
|
||||
@@ -118,7 +125,7 @@ class CallbackQuery(TelegramObject):
|
||||
id: str,
|
||||
from_user: User,
|
||||
chat_instance: str,
|
||||
message: Optional[Message] = None,
|
||||
message: Optional[MaybeInaccessibleMessage] = None,
|
||||
data: Optional[str] = None,
|
||||
inline_message_id: Optional[str] = None,
|
||||
game_short_name: Optional[str] = None,
|
||||
@@ -127,11 +134,11 @@ class CallbackQuery(TelegramObject):
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
# Required
|
||||
self.id: str = id # pylint: disable=invalid-name
|
||||
self.id: str = id
|
||||
self.from_user: User = from_user
|
||||
self.chat_instance: str = chat_instance
|
||||
# Optionals
|
||||
self.message: Optional[Message] = message
|
||||
self.message: Optional[MaybeInaccessibleMessage] = message
|
||||
self.data: Optional[str] = data
|
||||
self.inline_message_id: Optional[str] = inline_message_id
|
||||
self.game_short_name: Optional[str] = game_short_name
|
||||
@@ -190,6 +197,14 @@ class CallbackQuery(TelegramObject):
|
||||
api_kwargs=api_kwargs,
|
||||
)
|
||||
|
||||
def _get_message(self, action: str = "edit") -> Message:
|
||||
"""Helper method to get the message for the shortcut methods. Must be called only
|
||||
if :attr:`inline_message_id` is *not* set.
|
||||
"""
|
||||
if not isinstance(self.message, Message):
|
||||
raise TypeError(f"Cannot {action} an inaccessible message")
|
||||
return self.message
|
||||
|
||||
async def edit_message_text(
|
||||
self,
|
||||
text: str,
|
||||
@@ -197,6 +212,7 @@ class CallbackQuery(TelegramObject):
|
||||
disable_web_page_preview: ODVInput[bool] = DEFAULT_NONE,
|
||||
reply_markup: Optional["InlineKeyboardMarkup"] = None,
|
||||
entities: Optional[Sequence["MessageEntity"]] = None,
|
||||
link_preview_options: ODVInput["LinkPreviewOptions"] = DEFAULT_NONE,
|
||||
*,
|
||||
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
@@ -217,10 +233,16 @@ class CallbackQuery(TelegramObject):
|
||||
For the documentation of the arguments, please see
|
||||
:meth:`telegram.Bot.edit_message_text` and :meth:`telegram.Message.edit_text`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().edit_message_text(
|
||||
@@ -228,6 +250,7 @@ class CallbackQuery(TelegramObject):
|
||||
text=text,
|
||||
parse_mode=parse_mode,
|
||||
disable_web_page_preview=disable_web_page_preview,
|
||||
link_preview_options=link_preview_options,
|
||||
reply_markup=reply_markup,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
@@ -238,10 +261,11 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.edit_text(
|
||||
return await self._get_message().edit_text(
|
||||
text=text,
|
||||
parse_mode=parse_mode,
|
||||
disable_web_page_preview=disable_web_page_preview,
|
||||
link_preview_options=link_preview_options,
|
||||
reply_markup=reply_markup,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
@@ -277,10 +301,16 @@ class CallbackQuery(TelegramObject):
|
||||
For the documentation of the arguments, please see
|
||||
:meth:`telegram.Bot.edit_message_caption` and :meth:`telegram.Message.edit_caption`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().edit_message_caption(
|
||||
@@ -297,7 +327,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.edit_caption(
|
||||
return await self._get_message().edit_caption(
|
||||
caption=caption,
|
||||
reply_markup=reply_markup,
|
||||
read_timeout=read_timeout,
|
||||
@@ -333,10 +363,16 @@ class CallbackQuery(TelegramObject):
|
||||
:meth:`telegram.Bot.edit_message_reply_markup` and
|
||||
:meth:`telegram.Message.edit_reply_markup`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().edit_message_reply_markup(
|
||||
@@ -350,7 +386,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.edit_reply_markup(
|
||||
return await self._get_message().edit_reply_markup(
|
||||
reply_markup=reply_markup,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
@@ -383,10 +419,16 @@ class CallbackQuery(TelegramObject):
|
||||
For the documentation of the arguments, please see
|
||||
:meth:`telegram.Bot.edit_message_media` and :meth:`telegram.Message.edit_media`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is not an inline message, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().edit_message_media(
|
||||
@@ -401,7 +443,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.edit_media(
|
||||
return await self._get_message().edit_media(
|
||||
media=media,
|
||||
reply_markup=reply_markup,
|
||||
read_timeout=read_timeout,
|
||||
@@ -441,10 +483,16 @@ class CallbackQuery(TelegramObject):
|
||||
:meth:`telegram.Bot.edit_message_live_location` and
|
||||
:meth:`telegram.Message.edit_live_location`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().edit_message_live_location(
|
||||
@@ -464,7 +512,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.edit_live_location(
|
||||
return await self._get_message().edit_live_location(
|
||||
latitude=latitude,
|
||||
longitude=longitude,
|
||||
location=location,
|
||||
@@ -503,10 +551,16 @@ class CallbackQuery(TelegramObject):
|
||||
:meth:`telegram.Bot.stop_message_live_location` and
|
||||
:meth:`telegram.Message.stop_live_location`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().stop_message_live_location(
|
||||
@@ -520,7 +574,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.stop_live_location(
|
||||
return await self._get_message().stop_live_location(
|
||||
reply_markup=reply_markup,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
@@ -531,7 +585,7 @@ class CallbackQuery(TelegramObject):
|
||||
|
||||
async def set_game_score(
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
user_id: int,
|
||||
score: int,
|
||||
force: Optional[bool] = None,
|
||||
disable_edit_message: Optional[bool] = None,
|
||||
@@ -555,10 +609,16 @@ class CallbackQuery(TelegramObject):
|
||||
For the documentation of the arguments, please see
|
||||
:meth:`telegram.Bot.set_game_score` and :meth:`telegram.Message.set_game_score`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, if edited message is sent by the bot, the
|
||||
edited Message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().set_game_score(
|
||||
@@ -575,7 +635,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.set_game_score(
|
||||
return await self._get_message().set_game_score(
|
||||
user_id=user_id,
|
||||
score=score,
|
||||
force=force,
|
||||
@@ -589,7 +649,7 @@ class CallbackQuery(TelegramObject):
|
||||
|
||||
async def get_game_high_scores(
|
||||
self,
|
||||
user_id: Union[int, str],
|
||||
user_id: int,
|
||||
*,
|
||||
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
@@ -611,9 +671,15 @@ class CallbackQuery(TelegramObject):
|
||||
:meth:`telegram.Bot.get_game_high_scores` and
|
||||
:meth:`telegram.Message.get_game_high_scores`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
Tuple[:class:`telegram.GameHighScore`]
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
if self.inline_message_id:
|
||||
return await self.get_bot().get_game_high_scores(
|
||||
@@ -627,7 +693,7 @@ class CallbackQuery(TelegramObject):
|
||||
chat_id=None,
|
||||
message_id=None,
|
||||
)
|
||||
return await self.message.get_game_high_scores(
|
||||
return await self._get_message().get_game_high_scores(
|
||||
user_id=user_id,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
@@ -651,11 +717,17 @@ class CallbackQuery(TelegramObject):
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Message.delete`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
"""
|
||||
return await self.message.delete(
|
||||
return await self._get_message(action="delete").delete(
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
connect_timeout=connect_timeout,
|
||||
@@ -679,11 +751,16 @@ class CallbackQuery(TelegramObject):
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Message.pin`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
"""
|
||||
return await self.message.pin(
|
||||
return await self._get_message(action="pin").pin(
|
||||
disable_notification=disable_notification,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
@@ -707,11 +784,16 @@ class CallbackQuery(TelegramObject):
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Message.unpin`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
"""
|
||||
return await self.message.unpin(
|
||||
return await self._get_message(action="unpin").unpin(
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
connect_timeout=connect_timeout,
|
||||
@@ -725,12 +807,13 @@ class CallbackQuery(TelegramObject):
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
||||
caption_entities: Optional[Sequence["MessageEntity"]] = None,
|
||||
disable_notification: DVInput[bool] = DEFAULT_NONE,
|
||||
disable_notification: ODVInput[bool] = DEFAULT_NONE,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE,
|
||||
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
|
||||
reply_markup: Optional[ReplyMarkup] = None,
|
||||
protect_content: ODVInput[bool] = DEFAULT_NONE,
|
||||
message_thread_id: Optional[int] = None,
|
||||
reply_parameters: Optional["ReplyParameters"] = None,
|
||||
*,
|
||||
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
@@ -749,11 +832,16 @@ class CallbackQuery(TelegramObject):
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Message.copy`.
|
||||
|
||||
.. versionchanged:: 20.8
|
||||
Raises :exc:`TypeError` if :attr:`message` is not accessible.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.MessageId`: On success, returns the MessageId of the sent message.
|
||||
|
||||
Raises:
|
||||
:exc:`TypeError` if :attr:`message` is not accessible.
|
||||
"""
|
||||
return await self.message.copy(
|
||||
return await self._get_message(action="copy").copy(
|
||||
chat_id=chat_id,
|
||||
caption=caption,
|
||||
parse_mode=parse_mode,
|
||||
@@ -769,11 +857,12 @@ class CallbackQuery(TelegramObject):
|
||||
api_kwargs=api_kwargs,
|
||||
protect_content=protect_content,
|
||||
message_thread_id=message_thread_id,
|
||||
reply_parameters=reply_parameters,
|
||||
)
|
||||
|
||||
MAX_ANSWER_TEXT_LENGTH: Final[
|
||||
int
|
||||
] = constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH
|
||||
MAX_ANSWER_TEXT_LENGTH: Final[int] = (
|
||||
constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH
|
||||
)
|
||||
"""
|
||||
:const:`telegram.constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH`
|
||||
|
||||
|
||||
+529
-81
File diff suppressed because it is too large
Load Diff
@@ -31,26 +31,31 @@ class ChatAdministratorRights(TelegramObject):
|
||||
:attr:`can_delete_messages`, :attr:`can_manage_video_chats`, :attr:`can_restrict_members`,
|
||||
:attr:`can_promote_members`, :attr:`can_change_info`, :attr:`can_invite_users`,
|
||||
:attr:`can_post_messages`, :attr:`can_edit_messages`, :attr:`can_pin_messages`,
|
||||
:attr:`can_manage_topics` are equal.
|
||||
:attr:`can_manage_topics`, :attr:`can_post_stories`, :attr:`can_delete_stories`, and
|
||||
:attr:`can_edit_stories` are equal.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
|
||||
.. versionchanged:: 20.0
|
||||
:attr:`can_manage_topics` is considered as well when comparing objects of
|
||||
this type in terms of equality.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
.. versionchanged:: 20.6
|
||||
:attr:`can_post_stories`, :attr:`can_edit_stories`, and :attr:`can_delete_stories` are
|
||||
considered as well when comparing objects of this type in terms of equality.
|
||||
|
||||
Args:
|
||||
is_anonymous (:obj:`bool`): :obj:`True`, if the user's presence in the chat is hidden.
|
||||
can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
|
||||
log, chat statistics, message statistics in channels, see channel members, see
|
||||
anonymous administrators in supergroups and ignore slow mode. Implied by any other
|
||||
administrator privilege.
|
||||
log, chat statistics, boost list in channels, see channel members, report spam
|
||||
messages, see anonymous administrators in supergroups and ignore slow mode.
|
||||
Implied by any other administrator privilege.
|
||||
can_delete_messages (:obj:`bool`): :obj:`True`, if the administrator can delete messages of
|
||||
other users.
|
||||
can_manage_video_chats (:obj:`bool`): :obj:`True`, if the administrator can manage video
|
||||
chats.
|
||||
can_restrict_members (:obj:`bool`): :obj:`True`, if the administrator can restrict, ban or
|
||||
unban chat members.
|
||||
unban chat members, or access supergroup statistics.
|
||||
can_promote_members (:obj:`bool`): :obj:`True`, if the administrator can add new
|
||||
administrators with a subset of their own privileges or demote administrators
|
||||
that they have promoted, directly or indirectly (promoted by administrators that
|
||||
@@ -60,11 +65,23 @@ class ChatAdministratorRights(TelegramObject):
|
||||
can_invite_users (:obj:`bool`): :obj:`True`, if the user is allowed to invite new users to
|
||||
the chat.
|
||||
can_post_messages (:obj:`bool`, optional): :obj:`True`, if the administrator can post
|
||||
messages in the channel; channels only.
|
||||
messages in the channel, or access channel statistics; channels only.
|
||||
can_edit_messages (:obj:`bool`, optional): :obj:`True`, if the administrator can edit
|
||||
messages of other users.
|
||||
can_pin_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to pin
|
||||
messages; groups and supergroups only.
|
||||
can_post_stories (:obj:`bool`, optional): :obj:`True`, if the administrator can post
|
||||
stories in the channel; channels only.
|
||||
|
||||
.. versionadded:: 20.6
|
||||
can_edit_stories (:obj:`bool`, optional): :obj:`True`, if the administrator can edit
|
||||
stories posted by other users; channels only.
|
||||
|
||||
.. versionadded:: 20.6
|
||||
can_delete_stories (:obj:`bool`, optional): :obj:`True`, if the administrator can delete
|
||||
stories posted by other users; channels only.
|
||||
|
||||
.. versionadded:: 20.6
|
||||
can_manage_topics (:obj:`bool`, optional): :obj:`True`, if the user is allowed
|
||||
to create, rename, close, and reopen forum topics; supergroups only.
|
||||
|
||||
@@ -73,15 +90,15 @@ class ChatAdministratorRights(TelegramObject):
|
||||
Attributes:
|
||||
is_anonymous (:obj:`bool`): :obj:`True`, if the user's presence in the chat is hidden.
|
||||
can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
|
||||
log, chat statistics, message statistics in channels, see channel members, see
|
||||
anonymous administrators in supergroups and ignore slow mode. Implied by any other
|
||||
administrator privilege.
|
||||
log, chat statistics, boost list in channels, see channel members, report spam
|
||||
messages, see anonymous administrators in supergroups and ignore slow mode.
|
||||
Implied by any other administrator privilege.
|
||||
can_delete_messages (:obj:`bool`): :obj:`True`, if the administrator can delete messages of
|
||||
other users.
|
||||
can_manage_video_chats (:obj:`bool`): :obj:`True`, if the administrator can manage video
|
||||
chats.
|
||||
can_restrict_members (:obj:`bool`): :obj:`True`, if the administrator can restrict, ban or
|
||||
unban chat members.
|
||||
unban chat members, or access supergroup statistics.
|
||||
can_promote_members (:obj:`bool`): :obj:`True`, if the administrator can add new
|
||||
administrators with a subset of their own privileges or demote administrators that he
|
||||
has promoted, directly or indirectly (promoted by administrators that were appointed by
|
||||
@@ -91,11 +108,23 @@ class ChatAdministratorRights(TelegramObject):
|
||||
can_invite_users (:obj:`bool`): :obj:`True`, if the user is allowed to invite new users to
|
||||
the chat.
|
||||
can_post_messages (:obj:`bool`): Optional. :obj:`True`, if the administrator can post
|
||||
messages in the channel; channels only.
|
||||
messages in the channel, or access channel statistics; channels only.
|
||||
can_edit_messages (:obj:`bool`): Optional. :obj:`True`, if the administrator can edit
|
||||
messages of other users.
|
||||
can_pin_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to pin
|
||||
messages; groups and supergroups only.
|
||||
can_post_stories (:obj:`bool`): Optional. :obj:`True`, if the administrator can post
|
||||
stories in the channel; channels only.
|
||||
|
||||
.. versionadded:: 20.6
|
||||
can_edit_stories (:obj:`bool`): Optional. :obj:`True`, if the administrator can edit
|
||||
stories posted by other users; channels only.
|
||||
|
||||
.. versionadded:: 20.6
|
||||
can_delete_stories (:obj:`bool`): Optional. :obj:`True`, if the administrator can delete
|
||||
stories posted by other users; channels only.
|
||||
|
||||
.. versionadded:: 20.6
|
||||
can_manage_topics (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
|
||||
to create, rename, close, and reopen forum topics; supergroups only.
|
||||
|
||||
@@ -103,18 +132,21 @@ class ChatAdministratorRights(TelegramObject):
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
"is_anonymous",
|
||||
"can_manage_chat",
|
||||
"can_delete_messages",
|
||||
"can_manage_video_chats",
|
||||
"can_restrict_members",
|
||||
"can_promote_members",
|
||||
"can_change_info",
|
||||
"can_invite_users",
|
||||
"can_post_messages",
|
||||
"can_delete_messages",
|
||||
"can_delete_stories",
|
||||
"can_edit_messages",
|
||||
"can_pin_messages",
|
||||
"can_edit_stories",
|
||||
"can_invite_users",
|
||||
"can_manage_chat",
|
||||
"can_manage_topics",
|
||||
"can_manage_video_chats",
|
||||
"can_pin_messages",
|
||||
"can_post_messages",
|
||||
"can_post_stories",
|
||||
"can_promote_members",
|
||||
"can_restrict_members",
|
||||
"is_anonymous",
|
||||
)
|
||||
|
||||
def __init__(
|
||||
@@ -131,6 +163,9 @@ class ChatAdministratorRights(TelegramObject):
|
||||
can_edit_messages: Optional[bool] = None,
|
||||
can_pin_messages: Optional[bool] = None,
|
||||
can_manage_topics: Optional[bool] = None,
|
||||
can_post_stories: Optional[bool] = None,
|
||||
can_edit_stories: Optional[bool] = None,
|
||||
can_delete_stories: Optional[bool] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> None:
|
||||
@@ -148,6 +183,9 @@ class ChatAdministratorRights(TelegramObject):
|
||||
self.can_post_messages: Optional[bool] = can_post_messages
|
||||
self.can_edit_messages: Optional[bool] = can_edit_messages
|
||||
self.can_pin_messages: Optional[bool] = can_pin_messages
|
||||
self.can_post_stories: Optional[bool] = can_post_stories
|
||||
self.can_edit_stories: Optional[bool] = can_edit_stories
|
||||
self.can_delete_stories: Optional[bool] = can_delete_stories
|
||||
self.can_manage_topics: Optional[bool] = can_manage_topics
|
||||
|
||||
self._id_attrs = (
|
||||
@@ -163,6 +201,9 @@ class ChatAdministratorRights(TelegramObject):
|
||||
self.can_edit_messages,
|
||||
self.can_pin_messages,
|
||||
self.can_manage_topics,
|
||||
self.can_post_stories,
|
||||
self.can_edit_stories,
|
||||
self.can_delete_stories,
|
||||
)
|
||||
|
||||
self._freeze()
|
||||
@@ -176,7 +217,7 @@ class ChatAdministratorRights(TelegramObject):
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
return cls(True, True, True, True, True, True, True, True, True, True, True, True)
|
||||
return cls(*(True,) * len(cls.__slots__))
|
||||
|
||||
@classmethod
|
||||
def no_rights(cls) -> "ChatAdministratorRights":
|
||||
@@ -186,6 +227,4 @@ class ChatAdministratorRights(TelegramObject):
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
return cls(
|
||||
False, False, False, False, False, False, False, False, False, False, False, False
|
||||
)
|
||||
return cls(*(False,) * len(cls.__slots__))
|
||||
|
||||
@@ -0,0 +1,408 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2024
|
||||
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains the classes that represent Telegram ChatBoosts."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Dict, Final, Optional, Sequence, Tuple, Type
|
||||
|
||||
from telegram import constants
|
||||
from telegram._chat import Chat
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._user import User
|
||||
from telegram._utils import enum
|
||||
from telegram._utils.argumentparsing import parse_sequence_arg
|
||||
from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import Bot
|
||||
|
||||
|
||||
class ChatBoostSource(TelegramObject):
|
||||
"""
|
||||
Base class for Telegram ChatBoostSource objects. It can be one of:
|
||||
|
||||
* :class:`telegram.ChatBoostSourcePremium`
|
||||
* :class:`telegram.ChatBoostSourceGiftCode`
|
||||
* :class:`telegram.ChatBoostSourceGiveaway`
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`source` is equal.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
source (:obj:`str`): The source of the chat boost. Can be one of:
|
||||
:attr:`~telegram.ChatBoostSource.PREMIUM`, :attr:`~telegram.ChatBoostSource.GIFT_CODE`,
|
||||
or :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
|
||||
|
||||
Attributes:
|
||||
source (:obj:`str`): The source of the chat boost. Can be one of:
|
||||
:attr:`~telegram.ChatBoostSource.PREMIUM`, :attr:`~telegram.ChatBoostSource.GIFT_CODE`,
|
||||
or :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
|
||||
"""
|
||||
|
||||
__slots__ = ("source",)
|
||||
|
||||
PREMIUM: Final[str] = constants.ChatBoostSources.PREMIUM
|
||||
""":const:`telegram.constants.ChatBoostSources.PREMIUM`"""
|
||||
GIFT_CODE: Final[str] = constants.ChatBoostSources.GIFT_CODE
|
||||
""":const:`telegram.constants.ChatBoostSources.GIFT_CODE`"""
|
||||
GIVEAWAY: Final[str] = constants.ChatBoostSources.GIVEAWAY
|
||||
""":const:`telegram.constants.ChatBoostSources.GIVEAWAY`"""
|
||||
|
||||
def __init__(self, source: str, *, api_kwargs: Optional[JSONDict] = None):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
# Required by all subclasses:
|
||||
self.source: str = enum.get_member(constants.ChatBoostSources, source, source)
|
||||
|
||||
self._id_attrs = (self.source,)
|
||||
self._freeze()
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["ChatBoostSource"]:
|
||||
"""See :meth:`telegram.TelegramObject.de_json`."""
|
||||
data = cls._parse_data(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
_class_mapping: Dict[str, Type[ChatBoostSource]] = {
|
||||
cls.PREMIUM: ChatBoostSourcePremium,
|
||||
cls.GIFT_CODE: ChatBoostSourceGiftCode,
|
||||
cls.GIVEAWAY: ChatBoostSourceGiveaway,
|
||||
}
|
||||
|
||||
if cls is ChatBoostSource and data.get("source") in _class_mapping:
|
||||
return _class_mapping[data.pop("source")].de_json(data=data, bot=bot)
|
||||
|
||||
if "user" in data:
|
||||
data["user"] = User.de_json(data.get("user"), bot)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
|
||||
|
||||
class ChatBoostSourcePremium(ChatBoostSource):
|
||||
"""
|
||||
The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium
|
||||
subscription to another user.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
user (:class:`telegram.User`): User that boosted the chat.
|
||||
|
||||
Attributes:
|
||||
source (:obj:`str`): The source of the chat boost. Always
|
||||
:attr:`~telegram.ChatBoostSource.PREMIUM`.
|
||||
user (:class:`telegram.User`): User that boosted the chat.
|
||||
"""
|
||||
|
||||
__slots__ = ("user",)
|
||||
|
||||
def __init__(self, user: User, *, api_kwargs: Optional[JSONDict] = None):
|
||||
super().__init__(source=self.PREMIUM, api_kwargs=api_kwargs)
|
||||
|
||||
with self._unfrozen():
|
||||
self.user: User = user
|
||||
|
||||
|
||||
class ChatBoostSourceGiftCode(ChatBoostSource):
|
||||
"""
|
||||
The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each
|
||||
such code boosts the chat 4 times for the duration of the corresponding Telegram Premium
|
||||
subscription.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
user (:class:`telegram.User`): User for which the gift code was created.
|
||||
|
||||
Attributes:
|
||||
source (:obj:`str`): The source of the chat boost. Always
|
||||
:attr:`~telegram.ChatBoostSource.GIFT_CODE`.
|
||||
user (:class:`telegram.User`): User for which the gift code was created.
|
||||
"""
|
||||
|
||||
__slots__ = ("user",)
|
||||
|
||||
def __init__(self, user: User, *, api_kwargs: Optional[JSONDict] = None):
|
||||
super().__init__(source=self.GIFT_CODE, api_kwargs=api_kwargs)
|
||||
|
||||
with self._unfrozen():
|
||||
self.user: User = user
|
||||
|
||||
|
||||
class ChatBoostSourceGiveaway(ChatBoostSource):
|
||||
"""
|
||||
The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4
|
||||
times for the duration of the corresponding Telegram Premium subscription.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
giveaway_message_id (:obj:`int`): Identifier of a message in the chat with the giveaway;
|
||||
the message could have been deleted already. May be 0 if the message isn't sent yet.
|
||||
user (:class:`telegram.User`, optional): User that won the prize in the giveaway if any.
|
||||
is_unclaimed (:obj:`bool`, optional): :obj:`True`, if the giveaway was completed, but
|
||||
there was no user to win the prize.
|
||||
|
||||
Attributes:
|
||||
source (:obj:`str`): Source of the boost. Always
|
||||
:attr:`~telegram.ChatBoostSource.GIVEAWAY`.
|
||||
giveaway_message_id (:obj:`int`): Identifier of a message in the chat with the giveaway;
|
||||
the message could have been deleted already. May be 0 if the message isn't sent yet.
|
||||
user (:class:`telegram.User`): Optional. User that won the prize in the giveaway if any.
|
||||
is_unclaimed (:obj:`bool`): Optional. :obj:`True`, if the giveaway was completed, but
|
||||
there was no user to win the prize.
|
||||
"""
|
||||
|
||||
__slots__ = ("giveaway_message_id", "is_unclaimed", "user")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
giveaway_message_id: int,
|
||||
user: Optional[User] = None,
|
||||
is_unclaimed: Optional[bool] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(source=self.GIVEAWAY, api_kwargs=api_kwargs)
|
||||
|
||||
with self._unfrozen():
|
||||
self.giveaway_message_id: int = giveaway_message_id
|
||||
self.user: Optional[User] = user
|
||||
self.is_unclaimed: Optional[bool] = is_unclaimed
|
||||
|
||||
|
||||
class ChatBoost(TelegramObject):
|
||||
"""
|
||||
This object contains information about a chat boost.
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`boost_id`, :attr:`add_date`, :attr:`expiration_date`,
|
||||
and :attr:`source` are equal.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
boost_id (:obj:`str`): Unique identifier of the boost.
|
||||
add_date (:obj:`datetime.datetime`): Point in time when the chat was boosted.
|
||||
expiration_date (:obj:`datetime.datetime`): Point in time when the boost
|
||||
will automatically expire, unless the booster's Telegram Premium subscription is
|
||||
prolonged.
|
||||
source (:class:`telegram.ChatBoostSource`): Source of the added boost.
|
||||
|
||||
Attributes:
|
||||
boost_id (:obj:`str`): Unique identifier of the boost.
|
||||
add_date (:obj:`datetime.datetime`): Point in time when the chat was boosted.
|
||||
|datetime_localization|
|
||||
expiration_date (:obj:`datetime.datetime`): Point in time when the boost
|
||||
will automatically expire, unless the booster's Telegram Premium subscription is
|
||||
prolonged. |datetime_localization|
|
||||
source (:class:`telegram.ChatBoostSource`): Source of the added boost.
|
||||
"""
|
||||
|
||||
__slots__ = ("add_date", "boost_id", "expiration_date", "source")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
boost_id: str,
|
||||
add_date: datetime,
|
||||
expiration_date: datetime,
|
||||
source: ChatBoostSource,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
self.boost_id: str = boost_id
|
||||
self.add_date: datetime = add_date
|
||||
self.expiration_date: datetime = expiration_date
|
||||
self.source: ChatBoostSource = source
|
||||
|
||||
self._id_attrs = (self.boost_id, self.add_date, self.expiration_date, self.source)
|
||||
self._freeze()
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["ChatBoost"]:
|
||||
"""See :meth:`telegram.TelegramObject.de_json`."""
|
||||
data = cls._parse_data(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
data["source"] = ChatBoostSource.de_json(data.get("source"), bot)
|
||||
loc_tzinfo = extract_tzinfo_from_defaults(bot)
|
||||
data["add_date"] = from_timestamp(data["add_date"], tzinfo=loc_tzinfo)
|
||||
data["expiration_date"] = from_timestamp(data["expiration_date"], tzinfo=loc_tzinfo)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
|
||||
|
||||
class ChatBoostUpdated(TelegramObject):
|
||||
"""This object represents a boost added to a chat or changed.
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`chat`, and :attr:`boost` are equal.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
chat (:class:`telegram.Chat`): Chat which was boosted.
|
||||
boost (:class:`telegram.ChatBoost`): Information about the chat boost.
|
||||
|
||||
Attributes:
|
||||
chat (:class:`telegram.Chat`): Chat which was boosted.
|
||||
boost (:class:`telegram.ChatBoost`): Information about the chat boost.
|
||||
"""
|
||||
|
||||
__slots__ = ("boost", "chat")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
chat: Chat,
|
||||
boost: ChatBoost,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
self.chat: Chat = chat
|
||||
self.boost: ChatBoost = boost
|
||||
|
||||
self._id_attrs = (self.chat.id, self.boost)
|
||||
self._freeze()
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["ChatBoostUpdated"]:
|
||||
"""See :meth:`telegram.TelegramObject.de_json`."""
|
||||
data = cls._parse_data(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
data["chat"] = Chat.de_json(data.get("chat"), bot)
|
||||
data["boost"] = ChatBoost.de_json(data.get("boost"), bot)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
|
||||
|
||||
class ChatBoostRemoved(TelegramObject):
|
||||
"""
|
||||
This object represents a boost removed from a chat.
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`chat`, :attr:`boost_id`, :attr:`remove_date`, and
|
||||
:attr:`source` are equal.
|
||||
|
||||
Args:
|
||||
chat (:class:`telegram.Chat`): Chat which was boosted.
|
||||
boost_id (:obj:`str`): Unique identifier of the boost.
|
||||
remove_date (:obj:`datetime.datetime`): Point in time when the boost was removed.
|
||||
source (:class:`telegram.ChatBoostSource`): Source of the removed boost.
|
||||
|
||||
Attributes:
|
||||
chat (:class:`telegram.Chat`): Chat which was boosted.
|
||||
boost_id (:obj:`str`): Unique identifier of the boost.
|
||||
remove_date (:obj:`datetime.datetime`): Point in time when the boost was removed.
|
||||
|datetime_localization|
|
||||
source (:class:`telegram.ChatBoostSource`): Source of the removed boost.
|
||||
"""
|
||||
|
||||
__slots__ = ("boost_id", "chat", "remove_date", "source")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
chat: Chat,
|
||||
boost_id: str,
|
||||
remove_date: datetime,
|
||||
source: ChatBoostSource,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
self.chat: Chat = chat
|
||||
self.boost_id: str = boost_id
|
||||
self.remove_date: datetime = remove_date
|
||||
self.source: ChatBoostSource = source
|
||||
|
||||
self._id_attrs = (self.chat, self.boost_id, self.remove_date, self.source)
|
||||
self._freeze()
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["ChatBoostRemoved"]:
|
||||
"""See :meth:`telegram.TelegramObject.de_json`."""
|
||||
data = cls._parse_data(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
data["chat"] = Chat.de_json(data.get("chat"), bot)
|
||||
data["source"] = ChatBoostSource.de_json(data.get("source"), bot)
|
||||
loc_tzinfo = extract_tzinfo_from_defaults(bot)
|
||||
data["remove_date"] = from_timestamp(data["remove_date"], tzinfo=loc_tzinfo)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
|
||||
|
||||
class UserChatBoosts(TelegramObject):
|
||||
"""This object represents a list of boosts added to a chat by a user.
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`boosts` are equal.
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
Args:
|
||||
boosts (Sequence[:class:`telegram.ChatBoost`]): List of boosts added to the chat by the
|
||||
user.
|
||||
|
||||
Attributes:
|
||||
boosts (Tuple[:class:`telegram.ChatBoost`]): List of boosts added to the chat by the user.
|
||||
"""
|
||||
|
||||
__slots__ = ("boosts",)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
boosts: Sequence[ChatBoost],
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
self.boosts: Tuple[ChatBoost, ...] = parse_sequence_arg(boosts)
|
||||
|
||||
self._id_attrs = (self.boosts,)
|
||||
self._freeze()
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["UserChatBoosts"]:
|
||||
"""See :meth:`telegram.TelegramObject.de_json`."""
|
||||
data = cls._parse_data(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
data["boosts"] = ChatBoost.de_list(data.get("boosts"), bot)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user