mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-19 15:45:13 +00:00
Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6d009d3ac | |||
| 153894728c | |||
| 5fa457974d | |||
| 3ec7bb819c | |||
| 040cd2c2fc | |||
| 474f9c9693 | |||
| e18ca0d5e1 | |||
| 7331fff3fc | |||
| 23536ee759 | |||
| 2d8d43f2a5 | |||
| 8a542e22a0 | |||
| c0716dd344 | |||
| 668b49b048 | |||
| 22eb434a62 | |||
| ae2858783a | |||
| 2c227d5977 | |||
| 437261f716 | |||
| 1b98e440fa | |||
| d30ba3d1ef | |||
| 20e0f87f6b | |||
| bd9b0bd126 | |||
| 5d11d7fd42 | |||
| 099ab5d9fa | |||
| 26f943771b | |||
| 9c263fbd1a | |||
| 277031cfb2 | |||
| c513d51147 | |||
| bb6c85609a | |||
| 5b6cd3a33b | |||
| 1cf63c26c5 | |||
| 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 |
@@ -1,20 +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"]
|
||||
cyclomatic_complexity_threshold = "high"
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
- name: Fetch Dependabot metadata
|
||||
id: dependabot-metadata
|
||||
uses: dependabot/fetch-metadata@v1.6.0
|
||||
uses: dependabot/fetch-metadata@v2.0.0
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -31,7 +31,7 @@ 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
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
steps:
|
||||
- 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
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name: Test Documentation Build
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- doc-fixes
|
||||
paths:
|
||||
- telegram/**
|
||||
- docs/**
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- doc-fixes
|
||||
|
||||
jobs:
|
||||
test-sphinx-build:
|
||||
@@ -21,7 +20,7 @@ jobs:
|
||||
steps:
|
||||
- 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 +34,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.7.0
|
||||
- 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
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
name: Bot API Tests
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- telegram/**
|
||||
- tests/**
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
@@ -22,7 +23,7 @@ jobs:
|
||||
steps:
|
||||
- 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
|
||||
@@ -33,7 +34,7 @@ jobs:
|
||||
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
|
||||
pytest -v tests/test_official/test_official.py --junit-xml=.test_report_official.xml
|
||||
exit $?
|
||||
env:
|
||||
TEST_OFFICIAL: "true"
|
||||
@@ -41,7 +42,7 @@ jobs:
|
||||
|
||||
- name: Test Summary
|
||||
id: test_summary
|
||||
uses: test-summary/action@v2.1
|
||||
uses: test-summary/action@v2.3
|
||||
if: always() # always run, even if tests fail
|
||||
with:
|
||||
paths: .test_report_official.xml
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
name: Check Type Completeness
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- telegram/**
|
||||
- requirements.txt
|
||||
- requirements-opts.txt
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
@@ -15,7 +17,7 @@ jobs:
|
||||
- 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 +52,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)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
name: Unit Tests
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- telegram/**
|
||||
- tests/**
|
||||
- requirements.txt
|
||||
- requirements-opts.txt
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
@@ -22,7 +25,7 @@ jobs:
|
||||
steps:
|
||||
- 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 +82,7 @@ jobs:
|
||||
|
||||
- name: Test Summary
|
||||
id: test_summary
|
||||
uses: test-summary/action@v2.1
|
||||
uses: test-summary/action@v2.3
|
||||
if: always() # always run, even if tests fail
|
||||
with:
|
||||
paths: |
|
||||
@@ -87,8 +90,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
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
+29
-37
@@ -1,53 +1,58 @@
|
||||
# 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.10.1
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.3.5'
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: ruff
|
||||
additional_dependencies:
|
||||
- httpx~=0.27
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.3
|
||||
- aiolimiter~=1.1.0
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 24.3.0
|
||||
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.1
|
||||
rev: v3.1.0
|
||||
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
|
||||
|
||||
files: ^(?!(tests|docs)).*\.py$
|
||||
additional_dependencies:
|
||||
- httpx~=0.25.2
|
||||
- tornado~=6.3.3
|
||||
- httpx~=0.27
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.2
|
||||
- cachetools~=5.3.3
|
||||
- aiolimiter~=1.1.0
|
||||
- . # this basically does `pip install -e .`
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.6.1
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
name: mypy-ptb
|
||||
files: ^telegram/.*\.py$
|
||||
files: ^(?!(tests|examples|docs)).*\.py$
|
||||
additional_dependencies:
|
||||
- types-pytz
|
||||
- types-cryptography
|
||||
- types-cachetools
|
||||
- httpx~=0.25.2
|
||||
- tornado~=6.3.3
|
||||
- httpx~=0.27
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.2
|
||||
- cachetools~=5.3.3
|
||||
- aiolimiter~=1.1.0
|
||||
- . # this basically does `pip install -e .`
|
||||
- id: mypy
|
||||
@@ -57,34 +62,21 @@ repos:
|
||||
- --no-strict-optional
|
||||
- --follow-imports=silent
|
||||
additional_dependencies:
|
||||
- tornado~=6.3.3
|
||||
- tornado~=6.4
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.2
|
||||
- cachetools~=5.3.3
|
||||
- . # this basically does `pip install -e .`
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.15.0
|
||||
rev: v3.15.2
|
||||
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.1.5'
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: ruff
|
||||
files: ^(telegram|examples|tests)/.*\.py$
|
||||
additional_dependencies:
|
||||
- httpx~=0.25.2
|
||||
- tornado~=6.3.3
|
||||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.2
|
||||
- aiolimiter~=1.1.0
|
||||
|
||||
+41
-30
@@ -7,45 +7,56 @@ version: 2
|
||||
|
||||
# Build documentation in the docs/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/source/conf.py
|
||||
configuration: docs/source/conf.py
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF
|
||||
formats:
|
||||
- pdf
|
||||
- pdf
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
install:
|
||||
- method: pip
|
||||
path: .
|
||||
- requirements: docs/requirements-docs.txt
|
||||
install:
|
||||
- method: pip
|
||||
path: .
|
||||
- requirements: docs/requirements-docs.txt
|
||||
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3" # latest stable cpython version
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3" # latest stable cpython version
|
||||
jobs:
|
||||
post_build:
|
||||
# Based on https://github.com/readthedocs/readthedocs.org/issues/3242#issuecomment-1410321534
|
||||
# This provides a HTML zip file for download, with the same structure as the hosted website
|
||||
- mkdir --parents $READTHEDOCS_OUTPUT/htmlzip
|
||||
- cp --recursive $READTHEDOCS_OUTPUT/html $READTHEDOCS_OUTPUT/$READTHEDOCS_PROJECT
|
||||
# Hide the "other versions" dropdown. This is a workaround for those versions being shown,
|
||||
# but not being accessible, as they are not built. Also, they hide the actual sidebar menu
|
||||
# that is relevant only on ReadTheDocs.
|
||||
- echo "#furo-readthedocs-versions{display:none}" >> $READTHEDOCS_OUTPUT/$READTHEDOCS_PROJECT/_static/styles/furo-extensions.css
|
||||
- cd $READTHEDOCS_OUTPUT ; zip --recurse-path --symlinks htmlzip/$READTHEDOCS_PROJECT.zip $READTHEDOCS_PROJECT
|
||||
|
||||
search:
|
||||
ranking: # bump up rank of commonly searched pages: (default: 0, values range from -10 to 10)
|
||||
telegram.bot.html: 7
|
||||
telegram.message.html: 3
|
||||
telegram.update.html: 3
|
||||
telegram.user.html: 2
|
||||
telegram.chat.html: 2
|
||||
telegram.ext.application.html: 3
|
||||
telegram.ext.filters.html: 3
|
||||
telegram.ext.callbackcontext.html: 2
|
||||
telegram.ext.inlinekeyboardbutton.html: 1
|
||||
ranking: # bump up rank of commonly searched pages: (default: 0, values range from -10 to 10)
|
||||
telegram.bot.html: 7
|
||||
telegram.message.html: 3
|
||||
telegram.update.html: 3
|
||||
telegram.user.html: 2
|
||||
telegram.chat.html: 2
|
||||
telegram.ext.application.html: 3
|
||||
telegram.ext.filters.html: 3
|
||||
telegram.ext.callbackcontext.html: 2
|
||||
telegram.ext.inlinekeyboardbutton.html: 1
|
||||
|
||||
telegram.passport*.html: -7
|
||||
telegram.passport*.html: -7
|
||||
|
||||
ignore:
|
||||
- changelog.html
|
||||
- coc.html
|
||||
- bot_methods.html#
|
||||
- bot_methods.html
|
||||
# Defaults
|
||||
- search.html
|
||||
- search/index.html
|
||||
- 404.html
|
||||
- 404/index.html'
|
||||
ignore:
|
||||
- changelog.html
|
||||
- coc.html
|
||||
- bot_methods.html#
|
||||
- bot_methods.html
|
||||
# Defaults
|
||||
- search.html
|
||||
- search/index.html
|
||||
- 404.html
|
||||
- 404/index.html'
|
||||
|
||||
@@ -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>`_
|
||||
|
||||
+174
-2
@@ -4,12 +4,184 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Version 20.6
|
||||
Version 21.1
|
||||
==============
|
||||
|
||||
*Released 2024-04-12*
|
||||
|
||||
This is the technical changelog for version 21.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- API 7.2 (:pr:`4180` closes :issue:`4179` and :issue:`4181`, :issue:`4181`)
|
||||
- Make ``ChatAdministratorRights/ChatMemberAdministrator.can_*_stories`` Required (API 7.1) (:pr:`4192`)
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- Refactor Debug logging in ``Bot`` to Improve Type Hinting (:pr:`4151` closes :issue:`4010`)
|
||||
|
||||
New Features
|
||||
------------
|
||||
|
||||
- Make ``Message.reply_*`` Reply in the Same Topic by Default (:pr:`4170` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`4139`)
|
||||
- Accept Socket Objects for Webhooks (:pr:`4161` closes :issue:`4078`)
|
||||
- Add ``Update.effective_sender`` (:pr:`4168` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`4085`)
|
||||
|
||||
Documentation Improvements
|
||||
--------------------------
|
||||
|
||||
- Documentation Improvements (:pr:`4171`, :pr:`4158` by `@teslaedison <https://github.com/teslaedison>`__)
|
||||
|
||||
Internal Changes
|
||||
----------------
|
||||
|
||||
- Temporarily Mark Tests with ``get_sticker_set`` as XFAIL due to API 7.2 Update (:pr:`4190`)
|
||||
|
||||
Dependency Updates
|
||||
------------------
|
||||
|
||||
- ``pre-commit`` autoupdate (:pr:`4184`)
|
||||
- Bump ``dependabot/fetch-metadata`` from 1.6.0 to 2.0.0 (:pr:`4185`)
|
||||
|
||||
|
||||
Version 21.0.1
|
||||
==============
|
||||
|
||||
*Released 2024-03-06*
|
||||
|
||||
This is the technical changelog for version 21.0.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- Remove ``docs`` from Package (:pr:`4150`)
|
||||
|
||||
|
||||
Version 21.0
|
||||
============
|
||||
|
||||
*Released 2024-03-06*
|
||||
|
||||
This is the technical changelog for version 21.0. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
|
||||
Major Changes
|
||||
-------------
|
||||
|
||||
- Remove Functionality Deprecated in API 7.0 (:pr:`4114` closes :issue:`4099`)
|
||||
- API 7.1 (:pr:`4118`)
|
||||
|
||||
New Features
|
||||
------------
|
||||
|
||||
- Add Parameter ``media_write_timeout`` to ``HTTPXRequest`` and Method ``ApplicationBuilder.media_write_timeout`` (:pr:`4120` closes :issue:`3864`)
|
||||
- Handle Properties in ``TelegramObject.__setstate__`` (:pr:`4134` closes :issue:`4111`)
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- Add Missing Slot to ``Updater`` (:pr:`4130` closes :issue:`4127`)
|
||||
|
||||
Documentation Improvements
|
||||
--------------------------
|
||||
|
||||
- Improve HTML Download of Documentation (:pr:`4146` closes :issue:`4050`)
|
||||
- Documentation Improvements (:pr:`4109`, :issue:`4116`)
|
||||
- Update Copyright to 2024 (:pr:`4121` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`4041`)
|
||||
|
||||
Internal Changes
|
||||
----------------
|
||||
|
||||
- Apply ``pre-commit`` Checks More Widely (:pr:`4135`)
|
||||
- Refactor and Overhaul ``test_official`` (:pr:`4087` closes :issue:`3874`)
|
||||
- Run Unit Tests in PRs on Requirements Changes (:pr:`4144`)
|
||||
- Make ``Updater.stop`` Independent of ``CancelledError`` (:pr:`4126`)
|
||||
|
||||
Dependency Updates
|
||||
------------------
|
||||
|
||||
- Relax Upper Bound for ``httpx`` Dependency (:pr:`4148`)
|
||||
- Bump ``test-summary/action`` from 2.2 to 2.3 (:pr:`4142`)
|
||||
- Update ``cachetools`` requirement from ~=5.3.2 to ~=5.3.3 (:pr:`4141`)
|
||||
- Update ``httpx`` requirement from ~=0.26.0 to ~=0.27.0 (:pr:`4131`)
|
||||
|
||||
|
||||
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.6. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
|
||||
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
|
||||
------------
|
||||
|
||||
+6
-10
@@ -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.9-blue?logo=telegram
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-7.2-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
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
:target: https://app.codacy.com/gh/python-telegram-bot/python-telegram-bot/dashboard
|
||||
:alt: Code quality: Codacy
|
||||
|
||||
.. image:: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot.svg/?label=active+issues
|
||||
:target: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot/?ref=repository-badge
|
||||
:alt: Code quality: DeepSource
|
||||
|
||||
.. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
|
||||
:target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
|
||||
:alt: pre-commit.ci status
|
||||
@@ -93,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.9** are supported.
|
||||
All types and methods of the Telegram Bot API **7.2** are supported.
|
||||
|
||||
Installing
|
||||
==========
|
||||
@@ -135,7 +131,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.25.2 <https://www.python-httpx.org>`_ for
|
||||
The only required dependency is `httpx ~= 0.27 <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 +148,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.3.3 <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[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.3 <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]"``.
|
||||
|
||||
+6
-10
@@ -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.9-blue?logo=telegram
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-7.2-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
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
:target: https://app.codacy.com/gh/python-telegram-bot/python-telegram-bot/dashboard
|
||||
:alt: Code quality: Codacy
|
||||
|
||||
.. image:: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot.svg/?label=active+issues
|
||||
:target: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot/?ref=repository-badge
|
||||
:alt: Code quality: DeepSource
|
||||
|
||||
.. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
|
||||
:target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
|
||||
:alt: pre-commit.ci status
|
||||
@@ -89,7 +85,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.9** are supported.
|
||||
All types and methods of the Telegram Bot API **7.2** are supported.
|
||||
|
||||
Installing
|
||||
==========
|
||||
@@ -108,12 +104,12 @@ You can also install ``python-telegram-bot-raw`` from source, though this is usu
|
||||
|
||||
$ git clone https://github.com/python-telegram-bot/python-telegram-bot
|
||||
$ cd python-telegram-bot
|
||||
$ python setup-raw.py install
|
||||
$ python setup_raw.py install
|
||||
|
||||
Note
|
||||
----
|
||||
|
||||
Installing the ``.tar.gz`` archive available on PyPi directly via ``pip`` will *not* work as expected, as ``pip`` does not recognize that it should use ``setup-raw.py`` instead of ``setup.py``.
|
||||
Installing the ``.tar.gz`` archive available on PyPi directly via ``pip`` will *not* work as expected, as ``pip`` does not recognize that it should use ``setup_raw.py`` instead of ``setup.py``.
|
||||
|
||||
Verifying Releases
|
||||
------------------
|
||||
@@ -136,7 +132,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.25.2 <https://www.python-httpx.org>`_ for
|
||||
The only required dependency is `httpx ~= 0.27 <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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -64,7 +64,7 @@ class AdmonitionInserter:
|
||||
ForwardRef('DefaultValue[DVValueType]')
|
||||
"""
|
||||
|
||||
METHOD_NAMES_FOR_BOT_AND_APPBUILDER: dict[type, str] = {
|
||||
METHOD_NAMES_FOR_BOT_AND_APPBUILDER: typing.ClassVar[dict[type, str]] = {
|
||||
cls: tuple(m[0] for m in _iter_own_public_methods(cls)) # m[0] means we take only names
|
||||
for cls in (telegram.Bot, telegram.ext.ApplicationBuilder)
|
||||
}
|
||||
@@ -159,7 +159,7 @@ class AdmonitionInserter:
|
||||
telegram.ext, inspect.isclass
|
||||
)
|
||||
|
||||
for class_name, inspected_class in classes_to_inspect:
|
||||
for _class_name, inspected_class in classes_to_inspect:
|
||||
# We need to make "<class 'telegram._files.sticker.StickerSet'>" into
|
||||
# "telegram.StickerSet" because that's the way the classes are mentioned in
|
||||
# docstrings.
|
||||
@@ -197,8 +197,8 @@ class AdmonitionInserter:
|
||||
"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)}"
|
||||
)
|
||||
f" could not be resolved. {e!s}"
|
||||
) from e
|
||||
|
||||
# Properties need to be parsed separately because they act like attributes but not
|
||||
# listed as attributes.
|
||||
@@ -240,8 +240,8 @@ class AdmonitionInserter:
|
||||
"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)}"
|
||||
)
|
||||
f" could not be resolved. {e!s}"
|
||||
) from e
|
||||
|
||||
return self._generate_admonitions(attrs_for_class, admonition_type="available_in")
|
||||
|
||||
@@ -271,8 +271,8 @@ class AdmonitionInserter:
|
||||
raise NotImplementedError(
|
||||
"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)}"
|
||||
)
|
||||
f"Couldn't resolve type hint in return annotation {ret_annot}. {e!s}"
|
||||
) from e
|
||||
|
||||
return self._generate_admonitions(methods_for_class, admonition_type="returned_in")
|
||||
|
||||
@@ -297,7 +297,7 @@ class AdmonitionInserter:
|
||||
|
||||
# inspect methods of all telegram classes for return statements that indicate
|
||||
# that this given method is a shortcut for a Bot method
|
||||
for class_name, cls in inspect.getmembers(telegram, predicate=inspect.isclass):
|
||||
for _class_name, cls in inspect.getmembers(telegram, predicate=inspect.isclass):
|
||||
# no need to inspect Bot's own methods, as Bot can't have shortcuts in Bot
|
||||
if cls is telegram.Bot:
|
||||
continue
|
||||
@@ -344,8 +344,8 @@ class AdmonitionInserter:
|
||||
raise NotImplementedError(
|
||||
"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)}"
|
||||
)
|
||||
f"{param}: Couldn't resolve type hint {param.annotation}. {e!s}"
|
||||
) from e
|
||||
|
||||
return self._generate_admonitions(methods_for_class, admonition_type="use_in")
|
||||
|
||||
@@ -359,17 +359,19 @@ class AdmonitionInserter:
|
||||
If no key phrases are found, the admonition will be inserted at the very end.
|
||||
"""
|
||||
for idx, value in list(enumerate(lines)):
|
||||
if (
|
||||
value.startswith(".. seealso:")
|
||||
# The docstring contains heading "Examples:", but Sphinx will have it converted
|
||||
# to ".. admonition: Examples":
|
||||
or value.startswith(".. admonition:: Examples")
|
||||
or value.startswith(".. version")
|
||||
# The space after ":param" is important because docstring can contain ":paramref:"
|
||||
# in its plain text in the beginning of a line (e.g. ExtBot):
|
||||
or value.startswith(":param ")
|
||||
# some classes (like "Credentials") have no params, so insert before attrs:
|
||||
or value.startswith(".. attribute::")
|
||||
if value.startswith(
|
||||
(
|
||||
".. seealso:",
|
||||
# The docstring contains heading "Examples:", but Sphinx will have it converted
|
||||
# to ".. admonition: Examples":
|
||||
".. admonition:: Examples",
|
||||
".. version",
|
||||
# The space after ":param" is important because docstring can contain
|
||||
# ":paramref:" in its plain text in the beginning of a line (e.g. ExtBot):
|
||||
":param ",
|
||||
# some classes (like "Credentials") have no params, so insert before attrs:
|
||||
".. attribute::",
|
||||
)
|
||||
):
|
||||
return idx
|
||||
return len(lines) - 1
|
||||
@@ -411,7 +413,7 @@ class AdmonitionInserter:
|
||||
# so its page needs no admonitions.
|
||||
continue
|
||||
|
||||
attrs = sorted(attrs)
|
||||
sorted_attrs = sorted(attrs)
|
||||
|
||||
# e.g. for admonition type "use_in" the title will be "Use in" and CSS class "use-in".
|
||||
admonition = f"""
|
||||
@@ -419,11 +421,11 @@ class AdmonitionInserter:
|
||||
.. admonition:: {admonition_type.title().replace("_", " ")}
|
||||
:class: {admonition_type.replace("_", "-")}
|
||||
"""
|
||||
if len(attrs) > 1:
|
||||
for target_attr in attrs:
|
||||
if len(sorted_attrs) > 1:
|
||||
for target_attr in sorted_attrs:
|
||||
admonition += "\n * " + target_attr
|
||||
else:
|
||||
admonition += f"\n {attrs[0]}"
|
||||
admonition += f"\n {sorted_attrs[0]}"
|
||||
|
||||
admonition += "\n " # otherwise an unexpected unindent warning will be issued
|
||||
admonition_for_class[cls] = admonition
|
||||
@@ -516,12 +518,12 @@ class AdmonitionInserter:
|
||||
# If it isn't resolved, we'll have the program throw an exception to be sure.
|
||||
try:
|
||||
cls = self._resolve_class(m.group("class_name"))
|
||||
except AttributeError:
|
||||
except AttributeError as exc:
|
||||
# skip known ForwardRef's that need not be resolved to a Telegram class
|
||||
if self.FORWARD_REF_SKIP_PATTERN.match(str(arg)):
|
||||
pass
|
||||
else:
|
||||
raise NotImplementedError(f"Could not process ForwardRef: {arg}")
|
||||
raise NotImplementedError(f"Could not process ForwardRef: {arg}") from exc
|
||||
else:
|
||||
yield cls
|
||||
|
||||
@@ -587,6 +589,7 @@ class AdmonitionInserter:
|
||||
# If neither option works, this is not a PTB class.
|
||||
except (NameError, AttributeError):
|
||||
continue
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -16,6 +16,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 inspect
|
||||
from typing import List
|
||||
|
||||
keyword_args = [
|
||||
"Keyword Arguments:",
|
||||
@@ -41,7 +42,8 @@ keyword_args = [
|
||||
),
|
||||
(
|
||||
" api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments"
|
||||
" to be passed to the Telegram API."
|
||||
" to be passed to the Telegram API. See :meth:`~telegram.Bot.do_api_request` for"
|
||||
" limitations."
|
||||
),
|
||||
"",
|
||||
]
|
||||
@@ -83,13 +85,12 @@ get_updates_read_timeout_addition = [
|
||||
]
|
||||
|
||||
|
||||
def find_insert_pos_for_kwargs(lines: list[str]) -> int:
|
||||
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"):
|
||||
return idx
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
def check_timeout_and_api_kwargs_presence(obj: object) -> int:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -20,6 +20,8 @@ to link to the correct files & lines on github. Can be simplified once
|
||||
https://github.com/sphinx-doc/sphinx/issues/1556 is closed
|
||||
"""
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Dict, Tuple
|
||||
|
||||
from sphinx.util import logging
|
||||
|
||||
@@ -30,13 +32,13 @@ sphinx_logger = logging.getLogger(__name__)
|
||||
|
||||
# must be a module-level variable so that it can be written to by the `autodoc-process-docstring`
|
||||
# event handler in `sphinx_hooks.py`
|
||||
LINE_NUMBERS = {}
|
||||
LINE_NUMBERS: Dict[str, Tuple[Path, int, int]] = {}
|
||||
|
||||
|
||||
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()
|
||||
@@ -52,7 +54,7 @@ git_branch = _git_branch()
|
||||
base_url = "https://github.com/python-telegram-bot/python-telegram-bot/blob/"
|
||||
|
||||
|
||||
def linkcode_resolve(_, info):
|
||||
def linkcode_resolve(_, info) -> str:
|
||||
"""See www.sphinx-doc.org/en/master/usage/extensions/linkcode.html"""
|
||||
combined = ".".join((info["module"], info["fullname"]))
|
||||
# special casing for ExtBot which is due to the special structure of extbot.rst
|
||||
@@ -71,7 +73,7 @@ def linkcode_resolve(_, info):
|
||||
line_info = LINE_NUMBERS.get(info["module"])
|
||||
|
||||
if not line_info:
|
||||
return
|
||||
return None
|
||||
|
||||
file, start_line, end_line = line_info
|
||||
return f"{base_url}{git_branch}/{file}#L{start_line}-L{end_line}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -67,9 +67,9 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
|
||||
return True
|
||||
break
|
||||
|
||||
if name == "filter" and obj.__module__ == "telegram.ext.filters":
|
||||
if not included_in_obj:
|
||||
return True # return True to exclude from docs.
|
||||
if name == "filter" and obj.__module__ == "telegram.ext.filters" and not included_in_obj:
|
||||
return True # return True to exclude from docs.
|
||||
return None
|
||||
|
||||
|
||||
def autodoc_process_docstring(
|
||||
@@ -118,7 +118,7 @@ def autodoc_process_docstring(
|
||||
):
|
||||
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
|
||||
effective_insert = [to_insert, *get_updates_read_timeout_addition]
|
||||
else:
|
||||
effective_insert = [to_insert]
|
||||
|
||||
@@ -166,11 +166,11 @@ def autodoc_process_docstring(
|
||||
autodoc_process_docstring(app, "method", f"{name}.__init__", obj.__init__, options, lines)
|
||||
|
||||
|
||||
def autodoc_process_bases(app, name, obj, option, bases: list):
|
||||
def autodoc_process_bases(app, name, obj, option, bases: list) -> None:
|
||||
"""Here we fine tune how the base class's classes are displayed."""
|
||||
for idx, base in enumerate(bases):
|
||||
for idx, raw_base in enumerate(bases):
|
||||
# let's use a string representation of the object
|
||||
base = str(base)
|
||||
base = str(raw_base)
|
||||
|
||||
# Special case for abstract context managers which are wrongly resoled for some reason
|
||||
if base.startswith("typing.AbstractAsyncContextManager"):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -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,14 +72,21 @@ 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(
|
||||
f"%s:%d: WARNING: Did not convert reference %s. :{CONSTANTS_ROLE}: is not supposed"
|
||||
"%s:%d: WARNING: Did not convert reference %s. :%s: is not supposed"
|
||||
" to be used with this type of target.",
|
||||
refnode.source,
|
||||
refnode.line,
|
||||
refnode.rawsource,
|
||||
CONSTANTS_ROLE,
|
||||
)
|
||||
return title, target
|
||||
except Exception as exc:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
sphinx==7.2.6
|
||||
sphinx-pypi-upload
|
||||
furo==2023.9.10
|
||||
git+https://github.com/harshil21/furo-sphinx-search@v0.2.0.1
|
||||
furo==2024.1.29
|
||||
furo-sphinx-search @ git+https://github.com/harshil21/furo-sphinx-search@v0.2.0.1
|
||||
sphinx-paramlinks==0.6.0
|
||||
sphinxcontrib-mermaid==0.9.2
|
||||
sphinx-copybutton==0.5.2
|
||||
|
||||
+10
-15
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -8,12 +7,12 @@ from pathlib import Path
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
from sphinx.application import Sphinx
|
||||
|
||||
sys.path.insert(0, os.path.abspath("../.."))
|
||||
sys.path.insert(0, str(Path("../..").resolve().absolute()))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
# General information about the project.
|
||||
project = "python-telegram-bot"
|
||||
copyright = "2015-2023, Leandro Toledo"
|
||||
copyright = "2015-2024, Leandro Toledo"
|
||||
author = "Leandro Toledo"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
@@ -21,9 +20,9 @@ author = "Leandro Toledo"
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = "20.7" # telegram.__version__[:3]
|
||||
version = "21.1" # telegram.__version__[:3]
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = "20.7" # telegram.__version__
|
||||
release = "21.1" # telegram.__version__
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
needs_sphinx = "6.1.3"
|
||||
@@ -80,7 +79,9 @@ autodoc_typehints = "none"
|
||||
# Show docstring for special members
|
||||
autodoc_default_options = {
|
||||
"special-members": True,
|
||||
"exclude-members": "__init__",
|
||||
# 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
|
||||
@@ -139,12 +140,6 @@ 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>.'
|
||||
),
|
||||
"footer_icons": [
|
||||
{
|
||||
# Telegram channel logo
|
||||
@@ -308,13 +303,13 @@ texinfo_documents = [
|
||||
# Due to Sphinx behaviour, these imports only work when imported here, not at top of module.
|
||||
|
||||
# Not used but must be imported for the linkcode extension to find it
|
||||
from docs.auxil.link_code import linkcode_resolve
|
||||
from docs.auxil.sphinx_hooks import (
|
||||
from docs.auxil.link_code import linkcode_resolve # noqa: E402, F401
|
||||
from docs.auxil.sphinx_hooks import ( # noqa: E402
|
||||
autodoc_process_bases,
|
||||
autodoc_process_docstring,
|
||||
autodoc_skip_member,
|
||||
)
|
||||
from docs.auxil.tg_const_role import CONSTANTS_ROLE, TGConstXRefRole
|
||||
from docs.auxil.tg_const_role import CONSTANTS_ROLE, TGConstXRefRole # noqa: E402
|
||||
|
||||
|
||||
def setup(app: Sphinx):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -105,6 +113,10 @@
|
||||
:align: left
|
||||
:widths: 1 4
|
||||
|
||||
* - :meth:`~telegram.Bot.approve_chat_join_request`
|
||||
- Used for approving a chat join request
|
||||
* - :meth:`~telegram.Bot.decline_chat_join_request`
|
||||
- Used for declining a chat join request
|
||||
* - :meth:`~telegram.Bot.ban_chat_member`
|
||||
- Used for banning a member from the chat
|
||||
* - :meth:`~telegram.Bot.unban_chat_member`
|
||||
@@ -129,10 +141,6 @@
|
||||
- Used for editing a non-primary invite link
|
||||
* - :meth:`~telegram.Bot.revoke_chat_invite_link`
|
||||
- Used for revoking an invite link created by the bot
|
||||
* - :meth:`~telegram.Bot.approve_chat_join_request`
|
||||
- Used for approving a chat join request
|
||||
* - :meth:`~telegram.Bot.decline_chat_join_request`
|
||||
- Used for declining a chat join request
|
||||
* - :meth:`~telegram.Bot.set_chat_photo`
|
||||
- Used for setting a photo to a chat
|
||||
* - :meth:`~telegram.Bot.delete_chat_photo`
|
||||
@@ -147,6 +155,8 @@
|
||||
- Used for unpinning a message
|
||||
* - :meth:`~telegram.Bot.unpin_all_chat_messages`
|
||||
- Used for unpinning all pinned chat messages
|
||||
* - :meth:`~telegram.Bot.get_business_connection`
|
||||
- Used for getting information about the business account.
|
||||
* - :meth:`~telegram.Bot.get_user_profile_photos`
|
||||
- Used for obtaining user's profile pictures
|
||||
* - :meth:`~telegram.Bot.get_chat`
|
||||
@@ -157,6 +167,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
|
||||
|
||||
@@ -227,6 +239,8 @@
|
||||
- Used for setting a sticker set of a chat
|
||||
* - :meth:`~telegram.Bot.delete_chat_sticker_set`
|
||||
- Used for deleting the set sticker set of a chat
|
||||
* - :meth:`~telegram.Bot.replace_sticker_in_set`
|
||||
- Used for replacing a sticker in a set
|
||||
* - :meth:`~telegram.Bot.set_sticker_position_in_set`
|
||||
- Used for moving a sticker's position in the set
|
||||
* - :meth:`~telegram.Bot.set_sticker_set_title`
|
||||
|
||||
@@ -6,6 +6,7 @@ Available Types
|
||||
|
||||
telegram.animation
|
||||
telegram.audio
|
||||
telegram.birthdate
|
||||
telegram.botcommand
|
||||
telegram.botcommandscope
|
||||
telegram.botcommandscopeallchatadministrators
|
||||
@@ -18,9 +19,23 @@ Available Types
|
||||
telegram.botdescription
|
||||
telegram.botname
|
||||
telegram.botshortdescription
|
||||
telegram.businessconnection
|
||||
telegram.businessintro
|
||||
telegram.businesslocation
|
||||
telegram.businessopeninghours
|
||||
telegram.businessopeninghoursinterval
|
||||
telegram.businessmessagesdeleted
|
||||
telegram.callbackquery
|
||||
telegram.chat
|
||||
telegram.chatadministratorrights
|
||||
telegram.chatboost
|
||||
telegram.chatboostadded
|
||||
telegram.chatboostremoved
|
||||
telegram.chatboostsource
|
||||
telegram.chatboostsourcegiftcode
|
||||
telegram.chatboostsourcegiveaway
|
||||
telegram.chatboostsourcepremium
|
||||
telegram.chatboostupdated
|
||||
telegram.chatinvitelink
|
||||
telegram.chatjoinrequest
|
||||
telegram.chatlocation
|
||||
@@ -38,6 +53,7 @@ Available Types
|
||||
telegram.contact
|
||||
telegram.dice
|
||||
telegram.document
|
||||
telegram.externalreplyinfo
|
||||
telegram.file
|
||||
telegram.forcereply
|
||||
telegram.forumtopic
|
||||
@@ -47,6 +63,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
|
||||
@@ -60,9 +81,11 @@ Available Types
|
||||
telegram.keyboardbutton
|
||||
telegram.keyboardbuttonpolltype
|
||||
telegram.keyboardbuttonrequestchat
|
||||
telegram.keyboardbuttonrequestuser
|
||||
telegram.keyboardbuttonrequestusers
|
||||
telegram.linkpreviewoptions
|
||||
telegram.location
|
||||
telegram.loginurl
|
||||
telegram.maybeinaccessiblemessage
|
||||
telegram.menubutton
|
||||
telegram.menubuttoncommands
|
||||
telegram.menubuttondefault
|
||||
@@ -71,21 +94,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.shareduser
|
||||
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
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
Birthdate
|
||||
=========
|
||||
|
||||
.. autoclass:: telegram.Birthdate
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -4,4 +4,3 @@ Bot
|
||||
.. autoclass:: telegram.Bot
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__, __reduce__, __deepcopy__
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessConnection
|
||||
==================
|
||||
|
||||
.. autoclass:: telegram.BusinessConnection
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessIntro
|
||||
==================
|
||||
|
||||
.. autoclass:: telegram.BusinessIntro
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessLocation
|
||||
==================
|
||||
|
||||
.. autoclass:: telegram.BusinessLocation
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessMessagesDeleted
|
||||
=======================
|
||||
|
||||
.. autoclass:: telegram.BusinessMessagesDeleted
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessOpeningHours
|
||||
====================
|
||||
|
||||
.. autoclass:: telegram.BusinessOpeningHours
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessOpeningHoursInterval
|
||||
============================
|
||||
|
||||
.. autoclass:: telegram.BusinessOpeningHoursInterval
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoost
|
||||
=========
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ChatBoost
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
ChatBoostAdded
|
||||
==============
|
||||
|
||||
.. autoclass:: telegram.ChatBoostAdded
|
||||
: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,6 @@ telegram.constants Module
|
||||
.. automodule:: telegram.constants
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:no-undoc-members:
|
||||
:inherited-members: Enum, EnumMeta, str, int
|
||||
:exclude-members: __format__, __new__, __repr__, __str__
|
||||
|
||||
@@ -4,4 +4,3 @@ Application
|
||||
.. autoclass:: telegram.ext.Application
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__
|
||||
|
||||
@@ -4,4 +4,3 @@ BaseHandler
|
||||
.. autoclass:: telegram.ext.BaseHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessConnectionHandler
|
||||
=========================
|
||||
|
||||
.. autoclass:: telegram.ext.BusinessConnectionHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessMessagesDeletedHandler
|
||||
==============================
|
||||
|
||||
.. autoclass:: telegram.ext.BusinessMessagesDeletedHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,8 @@
|
||||
ChatBoostHandler
|
||||
================
|
||||
|
||||
.. versionadded:: 20.8
|
||||
|
||||
.. autoclass:: telegram.ext.ChatBoostHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -4,4 +4,3 @@ ConversationHandler
|
||||
.. autoclass:: telegram.ext.ConversationHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__
|
||||
|
||||
@@ -4,4 +4,3 @@ ExtBot
|
||||
.. autoclass:: telegram.ext.ExtBot
|
||||
:show-inheritance:
|
||||
:members: insert_callback_data, defaults, rate_limiter, initialize, shutdown, callback_data_cache
|
||||
:special-members: __repr__
|
||||
|
||||
@@ -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
|
||||
@@ -5,7 +5,10 @@ Handlers
|
||||
:titlesonly:
|
||||
|
||||
telegram.ext.basehandler
|
||||
telegram.ext.businessconnectionhandler
|
||||
telegram.ext.businessmessagesdeletedhandler
|
||||
telegram.ext.callbackqueryhandler
|
||||
telegram.ext.chatboosthandler
|
||||
telegram.ext.chatjoinrequesthandler
|
||||
telegram.ext.chatmemberhandler
|
||||
telegram.ext.choseninlineresulthandler
|
||||
@@ -14,6 +17,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__, __repr__
|
||||
|
||||
@@ -4,4 +4,3 @@ JobQueue
|
||||
.. autoclass:: telegram.ext.JobQueue
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
MessageReactionHandler
|
||||
======================
|
||||
|
||||
.. autoclass:: telegram.ext.MessageReactionHandler
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -4,4 +4,3 @@ Updater
|
||||
.. autoclass:: telegram.ext.Updater
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:special-members: __repr__
|
||||
|
||||
@@ -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,6 +0,0 @@
|
||||
KeyboardButtonRequestUser
|
||||
==================================
|
||||
|
||||
.. autoclass:: telegram.KeyboardButtonRequestUser
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -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:
|
||||
@@ -0,0 +1,7 @@
|
||||
SharedUser
|
||||
==========
|
||||
|
||||
.. autoclass:: telegram.SharedUser
|
||||
: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,6 +0,0 @@
|
||||
UserShared
|
||||
===================
|
||||
|
||||
.. autoclass:: telegram.UserShared
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
UsersShared
|
||||
===========
|
||||
|
||||
.. autoclass:: telegram.UsersShared
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -62,4 +62,22 @@
|
||||
|
||||
.. |removed_thumb_wildcard_note| replace:: Removed the deprecated arguments and attributes ``thumb_*``.
|
||||
|
||||
.. |async_context_manager| replace:: Asynchronous context manager which
|
||||
.. |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:: This argument is now 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.
|
||||
|
||||
.. |non_optional_story_argument| replace:: As of this version, this argument is now required. In accordance with our `stability policy <https://docs.python-telegram-bot.org/en/stable/stability_policy.html>`__, the signature will be kept as optional for now, though they are mandatory and an error will be raised if you don't pass it.
|
||||
|
||||
.. |business_id_str| replace:: Unique identifier of the business connection on behalf of which the message will be sent.
|
||||
|
||||
+10
-2
@@ -20,7 +20,13 @@ bot.
|
||||
|
||||
import logging
|
||||
|
||||
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, helpers
|
||||
from telegram import (
|
||||
InlineKeyboardButton,
|
||||
InlineKeyboardMarkup,
|
||||
LinkPreviewOptions,
|
||||
Update,
|
||||
helpers,
|
||||
)
|
||||
from telegram.constants import ParseMode
|
||||
from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, filters
|
||||
|
||||
@@ -70,7 +76,9 @@ async def deep_linked_level_2(update: Update, context: ContextTypes.DEFAULT_TYPE
|
||||
bot = context.bot
|
||||
url = helpers.create_deep_linked_url(bot.username, USING_ENTITIES)
|
||||
text = f'You can also mask the deep-linked URLs as links: <a href="{url}">▶️ CLICK HERE</a>.'
|
||||
await update.message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
|
||||
await update.message.reply_text(
|
||||
text, parse_mode=ParseMode.HTML, link_preview_options=LinkPreviewOptions(is_disabled=True)
|
||||
)
|
||||
|
||||
|
||||
async def deep_linked_level_3(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
|
||||
+111
-3
@@ -1,20 +1,128 @@
|
||||
# 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", "SLOT", "PERF", "PYI", "FLY", "AIR"]
|
||||
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",
|
||||
"RUF023", "Q", "INP", "W"]
|
||||
# Add "FURB" after it's out of preview
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/*.py" = ["B018"]
|
||||
"tests/**.py" = ["RUF012"]
|
||||
"tests/**.py" = ["RUF012", "ASYNC101"]
|
||||
"docs/**.py" = ["INP001"]
|
||||
|
||||
# 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"
|
||||
log_format = "%(funcName)s - Line %(lineno)d - %(message)s"
|
||||
# log_level = "DEBUG" # uncomment to see DEBUG logs
|
||||
|
||||
# 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,7 +1,7 @@
|
||||
pre-commit # needed for pre-commit hooks in the git commit command
|
||||
|
||||
# For the test suite
|
||||
pytest==7.4.3
|
||||
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.5.0 # xdist runs tests in parallel
|
||||
flaky # Used for flaky tests (flaky decorator)
|
||||
|
||||
@@ -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.3.3 # 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.2 # callback-data!ext
|
||||
cachetools~=5.3.3 # callback-data!ext
|
||||
APScheduler~=3.10.4 # job-queue!ext
|
||||
|
||||
# pytz is required by APS and just needs the lower bound due to #2120
|
||||
|
||||
+3
-2
@@ -5,5 +5,6 @@
|
||||
# When dependencies release new versions and tests succeed, we should try to expand the allowed
|
||||
# versions and only increase the lower bound if necessary
|
||||
|
||||
# httpx has no stable release yet, so let's be cautious for now
|
||||
httpx ~= 0.25.2
|
||||
# httpx has no stable release yet, but we've had no stability problems since v20.0a0 either
|
||||
# Since there have been requests to relax the bound a bit, we allow versions < 1.0.0
|
||||
httpx ~= 0.27
|
||||
|
||||
@@ -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
|
||||
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, cyclic-import
|
||||
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
|
||||
extend-ignore = E203, E704
|
||||
exclude = setup.py, setup_raw.py docs/source/conf.py
|
||||
|
||||
@@ -4,15 +4,16 @@ import subprocess
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
|
||||
def get_requirements():
|
||||
def get_requirements() -> List[str]:
|
||||
"""Build the requirements list for this project"""
|
||||
requirements_list = []
|
||||
|
||||
with Path("requirements.txt").open() as reqs:
|
||||
with Path("requirements.txt").open(encoding="utf-8") as reqs:
|
||||
for install in reqs:
|
||||
if install.startswith("#"):
|
||||
continue
|
||||
@@ -21,11 +22,11 @@ def get_requirements():
|
||||
return requirements_list
|
||||
|
||||
|
||||
def get_packages_requirements(raw=False):
|
||||
def get_packages_requirements(raw: bool = False) -> Tuple[List[str], List[str]]:
|
||||
"""Build the package & requirements list for this project"""
|
||||
reqs = get_requirements()
|
||||
|
||||
exclude = ["tests*"]
|
||||
exclude = ["tests*", "docs*"]
|
||||
if raw:
|
||||
exclude.append("telegram.ext*")
|
||||
|
||||
@@ -34,68 +35,69 @@ def get_packages_requirements(raw=False):
|
||||
return packs, reqs
|
||||
|
||||
|
||||
def get_optional_requirements(raw=False):
|
||||
def get_optional_requirements(raw: bool = False) -> Dict[str, List[str]]:
|
||||
"""Build the optional dependencies"""
|
||||
requirements = defaultdict(list)
|
||||
|
||||
with Path("requirements-opts.txt").open() as reqs:
|
||||
with Path("requirements-opts.txt").open(encoding="utf-8") as reqs:
|
||||
for line in reqs:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
effective_line = line.strip()
|
||||
if not effective_line or effective_line.startswith("#"):
|
||||
continue
|
||||
dependency, names = line.split("#")
|
||||
dependency, names = effective_line.split("#")
|
||||
dependency = dependency.strip()
|
||||
for name in names.split(","):
|
||||
name = name.strip()
|
||||
if name.endswith("!ext"):
|
||||
effective_name = name.strip()
|
||||
if effective_name.endswith("!ext"):
|
||||
if raw:
|
||||
continue
|
||||
else:
|
||||
name = name[:-4]
|
||||
requirements["ext"].append(dependency)
|
||||
requirements[name].append(dependency)
|
||||
effective_name = effective_name[:-4]
|
||||
requirements["ext"].append(dependency)
|
||||
requirements[effective_name].append(dependency)
|
||||
requirements["all"].append(dependency)
|
||||
|
||||
return requirements
|
||||
|
||||
|
||||
def get_setup_kwargs(raw=False):
|
||||
def get_setup_kwargs(raw: bool = False) -> Dict[str, Any]:
|
||||
"""Builds a dictionary of kwargs for the setup function"""
|
||||
packages, requirements = get_packages_requirements(raw=raw)
|
||||
|
||||
raw_ext = "-raw" if raw else ""
|
||||
readme = Path(f'README{"_RAW" if raw else ""}.rst')
|
||||
|
||||
version_file = Path("telegram/_version.py").read_text()
|
||||
version_file = Path("telegram/_version.py").read_text(encoding="utf-8")
|
||||
first_part = version_file.split("# SETUP.PY MARKER")[0]
|
||||
exec(first_part)
|
||||
exec(first_part) # pylint: disable=exec-used
|
||||
|
||||
kwargs = dict(
|
||||
script_name=f"setup{raw_ext}.py",
|
||||
name=f"python-telegram-bot{raw_ext}",
|
||||
version=locals()["__version__"],
|
||||
author="Leandro Toledo",
|
||||
author_email="devs@python-telegram-bot.org",
|
||||
license="LGPLv3",
|
||||
url="https://python-telegram-bot.org/",
|
||||
# Keywords supported by PyPI can be found at https://github.com/pypa/warehouse/blob/aafc5185e57e67d43487ce4faa95913dd4573e14/warehouse/templates/packaging/detail.html#L20-L58
|
||||
project_urls={
|
||||
return {
|
||||
"script_name": f"setup{raw_ext}.py",
|
||||
"name": f"python-telegram-bot{raw_ext}",
|
||||
"version": locals()["__version__"],
|
||||
"author": "Leandro Toledo",
|
||||
"author_email": "devs@python-telegram-bot.org",
|
||||
"license": "LGPLv3",
|
||||
"url": "https://python-telegram-bot.org/",
|
||||
# Keywords supported by PyPI can be found at
|
||||
# https://github.com/pypa/warehouse/blob/aafc5185e57e67d43487ce4faa95913dd4573e14/
|
||||
# warehouse/templates/packaging/detail.html#L20-L58
|
||||
"project_urls": {
|
||||
"Documentation": "https://docs.python-telegram-bot.org",
|
||||
"Bug Tracker": "https://github.com/python-telegram-bot/python-telegram-bot/issues",
|
||||
"Source Code": "https://github.com/python-telegram-bot/python-telegram-bot",
|
||||
"News": "https://t.me/pythontelegrambotchannel",
|
||||
"Changelog": "https://docs.python-telegram-bot.org/en/stable/changelog.html",
|
||||
},
|
||||
download_url=f"https://pypi.org/project/python-telegram-bot{raw_ext}/",
|
||||
keywords="python telegram bot api wrapper",
|
||||
description="We have made you a wrapper you can't refuse",
|
||||
long_description=readme.read_text(),
|
||||
long_description_content_type="text/x-rst",
|
||||
packages=packages,
|
||||
install_requires=requirements,
|
||||
extras_require=get_optional_requirements(raw=raw),
|
||||
include_package_data=True,
|
||||
classifiers=[
|
||||
"download_url": f"https://pypi.org/project/python-telegram-bot{raw_ext}/",
|
||||
"keywords": "python telegram bot api wrapper",
|
||||
"description": "We have made you a wrapper you can't refuse",
|
||||
"long_description": readme.read_text(encoding="utf-8"),
|
||||
"long_description_content_type": "text/x-rst",
|
||||
"packages": packages,
|
||||
"install_requires": requirements,
|
||||
"extras_require": get_optional_requirements(raw=raw),
|
||||
"include_package_data": True,
|
||||
"classifiers": [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
|
||||
@@ -111,16 +113,14 @@ def get_setup_kwargs(raw=False):
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
],
|
||||
python_requires=">=3.8",
|
||||
)
|
||||
|
||||
return kwargs
|
||||
"python_requires": ">=3.8",
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
# If we're building, build ptb-raw as well
|
||||
if set(sys.argv[1:]) in [{"bdist_wheel"}, {"sdist"}, {"sdist", "bdist_wheel"}]:
|
||||
args = ["python", "setup-raw.py"]
|
||||
args = ["python", "setup_raw.py"]
|
||||
args.extend(sys.argv[1:])
|
||||
subprocess.run(args, check=True, capture_output=True)
|
||||
|
||||
|
||||
+91
-22
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -19,14 +19,10 @@
|
||||
"""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",
|
||||
"Birthdate",
|
||||
"Bot",
|
||||
"BotCommand",
|
||||
"BotCommandScope",
|
||||
@@ -40,26 +36,39 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"BotDescription",
|
||||
"BotName",
|
||||
"BotShortDescription",
|
||||
"BusinessConnection",
|
||||
"BusinessIntro",
|
||||
"BusinessLocation",
|
||||
"BusinessMessagesDeleted",
|
||||
"BusinessOpeningHours",
|
||||
"BusinessOpeningHoursInterval",
|
||||
"CallbackGame",
|
||||
"CallbackQuery",
|
||||
"Chat",
|
||||
"ChatAdministratorRights",
|
||||
"ChatBoost",
|
||||
"ChatBoostAdded",
|
||||
"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 +76,7 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"Document",
|
||||
"EncryptedCredentials",
|
||||
"EncryptedPassportElement",
|
||||
"error",
|
||||
"ExternalReplyInfo",
|
||||
"File",
|
||||
"FileCredentials",
|
||||
"ForceReply",
|
||||
@@ -80,8 +89,12 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"GameHighScore",
|
||||
"GeneralForumTopicHidden",
|
||||
"GeneralForumTopicUnhidden",
|
||||
"helpers",
|
||||
"Giveaway",
|
||||
"GiveawayCompleted",
|
||||
"GiveawayCreated",
|
||||
"GiveawayWinners",
|
||||
"IdDocumentData",
|
||||
"InaccessibleMessage",
|
||||
"InlineKeyboardButton",
|
||||
"InlineKeyboardMarkup",
|
||||
"InlineQuery",
|
||||
@@ -103,10 +116,10 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"InlineQueryResultLocation",
|
||||
"InlineQueryResultMpeg4Gif",
|
||||
"InlineQueryResultPhoto",
|
||||
"InlineQueryResultsButton",
|
||||
"InlineQueryResultVenue",
|
||||
"InlineQueryResultVideo",
|
||||
"InlineQueryResultVoice",
|
||||
"InlineQueryResultsButton",
|
||||
"InputContactMessageContent",
|
||||
"InputFile",
|
||||
"InputInvoiceMessageContent",
|
||||
@@ -125,11 +138,13 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"KeyboardButton",
|
||||
"KeyboardButtonPollType",
|
||||
"KeyboardButtonRequestChat",
|
||||
"KeyboardButtonRequestUser",
|
||||
"KeyboardButtonRequestUsers",
|
||||
"LabeledPrice",
|
||||
"LinkPreviewOptions",
|
||||
"Location",
|
||||
"LoginUrl",
|
||||
"MaskPosition",
|
||||
"MaybeInaccessibleMessage",
|
||||
"MenuButton",
|
||||
"MenuButtonCommands",
|
||||
"MenuButtonDefault",
|
||||
@@ -138,6 +153,13 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"MessageAutoDeleteTimerChanged",
|
||||
"MessageEntity",
|
||||
"MessageId",
|
||||
"MessageOrigin",
|
||||
"MessageOriginChannel",
|
||||
"MessageOriginChat",
|
||||
"MessageOriginHiddenUser",
|
||||
"MessageOriginUser",
|
||||
"MessageReactionCountUpdated",
|
||||
"MessageReactionUpdated",
|
||||
"OrderInfo",
|
||||
"PassportData",
|
||||
"PassportElementError",
|
||||
@@ -158,13 +180,18 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"PollOption",
|
||||
"PreCheckoutQuery",
|
||||
"ProximityAlertTriggered",
|
||||
"ReactionCount",
|
||||
"ReactionType",
|
||||
"ReactionTypeCustomEmoji",
|
||||
"ReactionTypeEmoji",
|
||||
"ReplyKeyboardMarkup",
|
||||
"ReplyKeyboardRemove",
|
||||
"request",
|
||||
"ReplyParameters",
|
||||
"ResidentialAddress",
|
||||
"SecureData",
|
||||
"SecureValue",
|
||||
"SentWebAppMessage",
|
||||
"SharedUser",
|
||||
"ShippingAddress",
|
||||
"ShippingOption",
|
||||
"ShippingQuery",
|
||||
@@ -174,10 +201,12 @@ __all__ = ( # Keep this alphabetically ordered
|
||||
"SuccessfulPayment",
|
||||
"SwitchInlineQueryChosenChat",
|
||||
"TelegramObject",
|
||||
"TextQuote",
|
||||
"Update",
|
||||
"User",
|
||||
"UserChatBoosts",
|
||||
"UserProfilePhotos",
|
||||
"UserShared",
|
||||
"UsersShared",
|
||||
"Venue",
|
||||
"Video",
|
||||
"VideoChatEnded",
|
||||
@@ -186,15 +215,24 @@ __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",
|
||||
)
|
||||
|
||||
|
||||
from . import _version, constants, error, helpers, request, warnings
|
||||
from ._birthdate import Birthdate
|
||||
from ._bot import Bot
|
||||
from ._botcommand import BotCommand
|
||||
from ._botcommandscope import (
|
||||
@@ -209,9 +247,28 @@ from ._botcommandscope import (
|
||||
)
|
||||
from ._botdescription import BotDescription, BotShortDescription
|
||||
from ._botname import BotName
|
||||
from ._business import (
|
||||
BusinessConnection,
|
||||
BusinessIntro,
|
||||
BusinessLocation,
|
||||
BusinessMessagesDeleted,
|
||||
BusinessOpeningHours,
|
||||
BusinessOpeningHoursInterval,
|
||||
)
|
||||
from ._callbackquery import CallbackQuery
|
||||
from ._chat import Chat
|
||||
from ._chatadministratorrights import ChatAdministratorRights
|
||||
from ._chatboost import (
|
||||
ChatBoost,
|
||||
ChatBoostAdded,
|
||||
ChatBoostRemoved,
|
||||
ChatBoostSource,
|
||||
ChatBoostSourceGiftCode,
|
||||
ChatBoostSourceGiveaway,
|
||||
ChatBoostSourcePremium,
|
||||
ChatBoostUpdated,
|
||||
UserChatBoosts,
|
||||
)
|
||||
from ._chatinvitelink import ChatInviteLink
|
||||
from ._chatjoinrequest import ChatJoinRequest
|
||||
from ._chatlocation import ChatLocation
|
||||
@@ -264,6 +321,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 +355,22 @@ 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, 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 +405,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, SharedUser, UsersShared
|
||||
from ._story import Story
|
||||
from ._switchinlinequerychosenchat import SwitchInlineQueryChosenChat
|
||||
from ._telegramobject import TelegramObject
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# !/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/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 an object that represents a Telegram Birthday."""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
|
||||
class Birthdate(TelegramObject):
|
||||
"""
|
||||
This object represents a user's birthday.
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal, if their :attr:`day`, and :attr:`month` are equal.
|
||||
|
||||
.. versionadded:: 21.1
|
||||
|
||||
Args:
|
||||
day (:obj:`int`): Day of the user's birth; 1-31.
|
||||
month (:obj:`int`): Month of the user's birth; 1-12.
|
||||
year (:obj:`int`, optional): Year of the user's birth.
|
||||
|
||||
Attributes:
|
||||
day (:obj:`int`): Day of the user's birth; 1-31.
|
||||
month (:obj:`int`): Month of the user's birth; 1-12.
|
||||
year (:obj:`int`): Optional. Year of the user's birth.
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ("day", "month", "year")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
day: int,
|
||||
month: int,
|
||||
year: Optional[int] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
|
||||
# Required
|
||||
self.day: int = day
|
||||
self.month: int = month
|
||||
# Optional
|
||||
self.year: Optional[int] = year
|
||||
|
||||
self._id_attrs = (
|
||||
self.day,
|
||||
self.month,
|
||||
)
|
||||
|
||||
self._freeze()
|
||||
|
||||
def to_date(self, year: Optional[int] = None) -> datetime:
|
||||
"""Return the birthdate as a datetime object.
|
||||
|
||||
Args:
|
||||
year (:obj:`int`, optional): The year to use. Required, if the :attr:`year` was not
|
||||
present.
|
||||
|
||||
Returns:
|
||||
:obj:`datetime.datetime`: The birthdate as a datetime object.
|
||||
"""
|
||||
if self.year is None and year is None:
|
||||
raise ValueError(
|
||||
"The `year` argument is required if the `year` attribute was not present."
|
||||
)
|
||||
|
||||
return datetime(year or self.year, self.month, self.day) # type: ignore[arg-type]
|
||||
+1271
-284
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2023
|
||||
# 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
|
||||
@@ -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()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user