mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-19 15:45:13 +00:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc3863ac9a | |||
| c57e9fa5d6 | |||
| 7078059e80 | |||
| c34e19edfd | |||
| 2fc04e1e10 | |||
| 08006013c3 | |||
| 4c61403322 | |||
| b0faae9d47 | |||
| 4868565b71 | |||
| 486ceaa6cf | |||
| 54ce1d8d82 | |||
| 17ae6a7028 | |||
| c6e12b1958 | |||
| ed9496b91a | |||
| 7823822a41 | |||
| a9e53af3d1 | |||
| e69069d2c8 | |||
| 511222c191 | |||
| 036910ec0c | |||
| 3cd8a409ee | |||
| 83676dec16 | |||
| 9ebd48903b | |||
| 1cf000c806 | |||
| 150328799a | |||
| 6d7134608f | |||
| 8266870ed7 | |||
| 519dee7e0c | |||
| 753f3727aa | |||
| 892a66d0e8 | |||
| d5e5874f96 | |||
| a5dacab8a9 | |||
| 76d8eaf0f2 | |||
| 1e4f31f1bb | |||
| 3464f24129 |
+31
-29
@@ -157,45 +157,47 @@ Check-list for PRs
|
||||
This checklist is a non-exhaustive reminder of things that should be done before a PR is merged, both for you as contributor and for the maintainers.
|
||||
Feel free to copy (parts of) the checklist to the PR description to remind you or the maintainers of open points or if you have questions on anything.
|
||||
|
||||
- Added ``.. versionadded:: NEXT.VERSION``, ``.. versionchanged:: NEXT.VERSION``, ``.. deprecated:: NEXT.VERSION`` or ``.. versionremoved:: NEXT.VERSION`` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
|
||||
- Created new or adapted existing unit tests
|
||||
- Documented code changes according to the `CSI standard <https://standards.mousepawmedia.com/en/stable/csi.html>`__
|
||||
- Added myself alphabetically to ``AUTHORS.rst`` (optional)
|
||||
- Added new classes & modules to the docs and all suitable ``__all__`` s
|
||||
- Checked the `Stability Policy <https://docs.python-telegram-bot.org/stability_policy.html>`_ in case of deprecations or changes to documented behavior
|
||||
.. code-block:: markdown
|
||||
|
||||
**If the PR contains API changes (otherwise, you can ignore this passage)**
|
||||
## Check-list for PRs
|
||||
|
||||
- Checked the Bot API specific sections of the `Stability Policy <https://docs.python-telegram-bot.org/stability_policy.html>`_
|
||||
- Created a PR to remove functionality deprecated in the previous Bot API release (`see here <https://docs.python-telegram-bot.org/en/stable/stability_policy.html#case-2>`_)
|
||||
- [ ] Added `.. versionadded:: NEXT.VERSION`, ``.. versionchanged:: NEXT.VERSION``, ``.. deprecated:: NEXT.VERSION`` or ``.. versionremoved:: NEXT.VERSION` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
|
||||
- [ ] Created new or adapted existing unit tests
|
||||
- [ ] Documented code changes according to the [CSI standard](https://standards.mousepawmedia.com/en/stable/csi.html)
|
||||
- [ ] Added myself alphabetically to `AUTHORS.rst` (optional)
|
||||
- [ ] Added new classes & modules to the docs and all suitable ``__all__`` s
|
||||
- [ ] Checked the [Stability Policy](https://docs.python-telegram-bot.org/stability_policy.html) in case of deprecations or changes to documented behavior
|
||||
|
||||
- New classes:
|
||||
**If the PR contains API changes (otherwise, you can ignore this passage)**
|
||||
|
||||
- Added ``self._id_attrs`` and corresponding documentation
|
||||
- ``__init__`` accepts ``api_kwargs`` as kw-only
|
||||
- [ ] Checked the Bot API specific sections of the [Stability Policy](https://docs.python-telegram-bot.org/stability_policy.html)
|
||||
- [ ] Created a PR to remove functionality deprecated in the previous Bot API release ([see here](https://docs.python-telegram-bot.org/en/stable/stability_policy.html#case-2))
|
||||
|
||||
- Added new shortcuts:
|
||||
- New Classes
|
||||
|
||||
- In :class:`~telegram.Chat` & :class:`~telegram.User` for all methods that accept ``chat/user_id``
|
||||
- In :class:`~telegram.Message` for all methods that accept ``chat_id`` and ``message_id``
|
||||
- For new :class:`~telegram.Message` shortcuts: Added ``quote`` argument if methods accepts ``reply_to_message_id``
|
||||
- In :class:`~telegram.CallbackQuery` for all methods that accept either ``chat_id`` and ``message_id`` or ``inline_message_id``
|
||||
- [ ] Added `self._id_attrs` and corresponding documentation
|
||||
- [ ] `__init__` accepts `api_kwargs` as keyword-only
|
||||
|
||||
- If relevant:
|
||||
- Added New Shortcuts
|
||||
|
||||
- Added new constants at :mod:`telegram.constants` and shortcuts to them as class variables
|
||||
- Link new and existing constants in docstrings instead of hard-coded numbers and strings
|
||||
- Add new message types to :attr:`telegram.Message.effective_attachment`
|
||||
- Added new handlers for new update types
|
||||
- [ ] In [`telegram.Chat`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.chat.html) \& [`telegram.User`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.user.html) for all methods that accept `chat/user_id`
|
||||
- [ ] In [`telegram.Message`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.message.html) for all methods that accept `chat_id` and `message_id`
|
||||
- [ ] For new `telegram.Message` shortcuts: Added `quote` argument if methods accept `reply_to_message_id`
|
||||
- [ ] In [`telegram.CallbackQuery`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.callbackquery.html) for all methods that accept either `chat_id` and `message_id` or `inline_message_id`
|
||||
|
||||
- Add the handlers to the warning loop in the :class:`~telegram.ext.ConversationHandler`
|
||||
- If Relevant
|
||||
|
||||
- Added new filters for new message (sub)types
|
||||
- Added or updated documentation for the changed class(es) and/or method(s)
|
||||
- Added the new method(s) to ``_extbot.py``
|
||||
- Added or updated ``bot_methods.rst``
|
||||
- Updated the Bot API version number in all places: ``README.rst`` (including the badge) and ``telegram.constants.BOT_API_VERSION_INFO``
|
||||
- Added logic for arbitrary callback data in :class:`telegram.ext.ExtBot` for new methods that either accept a ``reply_markup`` in some form or have a return type that is/contains :class:`~telegram.Message`
|
||||
- [ ] Added new constants at `telegram.constants` and shortcuts to them as class variables
|
||||
- [ ] Linked new and existing constants in docstrings instead of hard-coded numbers and strings
|
||||
- [ ] Added new message types to `telegram.Message.effective_attachment`
|
||||
- [ ] Added new handlers for new update types
|
||||
- [ ] Added the handlers to the warning loop in the [`telegram.ext.ConversationHandler`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.conversationhandler.html)
|
||||
- [ ] Added new filters for new message (sub)types
|
||||
- [ ] Added or updated documentation for the changed class(es) and/or method(s)
|
||||
- [ ] Added the new method(s) to `_extbot.py`
|
||||
- [ ] Added or updated `bot_methods.rst`
|
||||
- [ ] Updated the Bot API version number in all places: `README.rst` (including the badge) and `telegram.constants.BOT_API_VERSION_INFO`
|
||||
- [ ] Added logic for arbitrary callback data in `telegram.ext.ExtBot` for new methods that either accept a `reply_markup` in some form or have a return type that is/contains [`telegram.Message`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.message.html)
|
||||
|
||||
Documenting
|
||||
===========
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<b>We've just released {tag}</b>.
|
||||
Thank you to everyone who contributed to this release.
|
||||
As usual, upgrade using <code>pip install -U python-telegram-bot</code>.
|
||||
|
||||
The release notes can be found <a href="https://docs.python-telegram-bot.org/en/{tag}/changelog.html">here</a>.
|
||||
@@ -0,0 +1,66 @@
|
||||
name: Chango
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
create-chango-fragment:
|
||||
permissions:
|
||||
# Give the default GITHUB_TOKEN write permission to commit and push the
|
||||
# added or changed files to the repository.
|
||||
contents: write
|
||||
name: Create chango Fragment
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
IS_RELEASE_PR: ${{ steps.check_title.outputs.IS_RELEASE_PR }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
# needed for commit and push step at the end
|
||||
persist-credentials: true
|
||||
- name: Check PR Title
|
||||
id: check_title
|
||||
run: | # zizmor: ignore[template-injection]
|
||||
if [[ "$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]')" =~ ^bump\ version\ to\ .* ]]; then
|
||||
echo "COMMIT_AND_PUSH=false" >> $GITHUB_OUTPUT
|
||||
echo "IS_RELEASE_PR=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "COMMIT_AND_PUSH=true" >> $GITHUB_OUTPUT
|
||||
echo "IS_RELEASE_PR=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Create the new fragment
|
||||
- uses: Bibo-Joshi/chango@9d6bd9d7612eca5fab2c5161687011be59baaf19 # v0.4.0
|
||||
with:
|
||||
github-token: ${{ secrets.CHANGO_PAT }}
|
||||
query-issue-types: true
|
||||
commit-and-push: ${{ steps.check_title.outputs.COMMIT_AND_PUSH }}
|
||||
|
||||
# Run `chango release` if applicable - needs some additional setup.
|
||||
- name: Set up Python
|
||||
if: steps.check_title.outputs.IS_RELEASE_PR == 'true'
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Do Release
|
||||
if: steps.check_title.outputs.IS_RELEASE_PR == 'true'
|
||||
run: |
|
||||
cd ./target-repo
|
||||
git add changes/unreleased/*
|
||||
pip install . -r docs/requirements-docs.txt
|
||||
VERSION_TAG=$(python -c "from telegram import __version__; print(f'{__version__}')")
|
||||
chango release --uid $VERSION_TAG
|
||||
|
||||
- name: Commit & Push
|
||||
if: steps.check_title.outputs.IS_RELEASE_PR == 'true'
|
||||
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
|
||||
with:
|
||||
commit_message: "Do chango Release"
|
||||
repository: ./target-repo
|
||||
@@ -1,9 +1,10 @@
|
||||
name: Test Documentation Build
|
||||
name: Test Admonitions Generation
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- telegram/**
|
||||
- docs/**
|
||||
- .github/workflows/docs-admonitions.yml
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
@@ -11,15 +12,15 @@ on:
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
test-sphinx-build:
|
||||
name: test-sphinx-build
|
||||
test-admonitions:
|
||||
name: Test Admonitions Generation
|
||||
runs-on: ${{matrix.os}}
|
||||
permissions:
|
||||
# for uploading artifacts
|
||||
actions: write
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.10']
|
||||
python-version: ['3.12']
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
@@ -27,7 +28,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'pip'
|
||||
@@ -37,17 +38,4 @@ jobs:
|
||||
python -W ignore -m pip install --upgrade pip
|
||||
python -W ignore -m pip install -r requirements-dev-all.txt
|
||||
- name: Test autogeneration of admonitions
|
||||
run: pytest -v --tb=short tests/docs/admonition_inserter.py
|
||||
- name: Build docs
|
||||
run: sphinx-build docs/source docs/build/html -W --keep-going -j auto
|
||||
- name: Upload docs
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
with:
|
||||
name: HTML Docs
|
||||
retention-days: 7
|
||||
path: |
|
||||
# Exclude the .doctrees folder and .buildinfo file from the artifact
|
||||
# since they are not needed and add to the size
|
||||
docs/build/html/*
|
||||
!docs/build/html/.doctrees
|
||||
!docs/build/html/.buildinfo
|
||||
run: pytest -v --tb=short tests/docs/admonition_inserter.py
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.10']
|
||||
python-version: ['3.12']
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: False
|
||||
steps:
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
@@ -31,11 +31,11 @@ jobs:
|
||||
python -W ignore -m pip install --upgrade pip
|
||||
python -W ignore -m pip install -r requirements-dev-all.txt
|
||||
- name: Check Links
|
||||
run: sphinx-build docs/source docs/build/html -W --keep-going -j auto -b linkcheck
|
||||
run: sphinx-build docs/source docs/build/html --keep-going -j auto -b linkcheck
|
||||
- name: Upload linkcheck output
|
||||
# Run also if the previous steps failed
|
||||
if: always()
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: linkcheck-output
|
||||
path: docs/build/html/output.*
|
||||
|
||||
@@ -21,13 +21,13 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Install the latest version of uv
|
||||
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
|
||||
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
|
||||
- name: Run zizmor
|
||||
run: uvx zizmor --persona=pedantic --format sarif . > results.sarif
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Upload SARIF file
|
||||
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
|
||||
uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
category: zizmor
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
pull-requests: write # for srvaroa/labeler to add labels in PR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: srvaroa/labeler@fe4b1c73bb8abf2f14a44a6912a8b4fee835d631 # v1.12.0
|
||||
- uses: srvaroa/labeler@0a20eccb8c94a1ee0bed5f16859aece1c45c3e55 # v1.13.0
|
||||
# Config file at .github/labeler.yml
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install pypa/build
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: python3 -m build
|
||||
- name: Store the distribution packages
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
@@ -55,12 +55,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
- name: Publish to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
|
||||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
|
||||
|
||||
compute-signatures:
|
||||
name: Compute SHA1 Sums and Sign with Sigstore
|
||||
@@ -74,7 +74,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
@@ -92,7 +92,7 @@ jobs:
|
||||
./dist/*.tar.gz
|
||||
./dist/*.whl
|
||||
- name: Store the distribution packages and signatures
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: python-package-distributions-and-signatures
|
||||
path: dist/
|
||||
@@ -110,8 +110,11 @@ jobs:
|
||||
actions: read # for downloading artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: python-package-distributions-and-signatures
|
||||
path: dist/
|
||||
@@ -119,13 +122,14 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ needs.build.outputs.TAG }}
|
||||
# Create a tag and a GitHub Release. The description can be changed later, as for now
|
||||
# we don't define it through this workflow.
|
||||
# Create a tag and a GitHub Release. The description is filled by the static template, we
|
||||
# just insert the correct tag in the template.
|
||||
run: >-
|
||||
sed "s/{tag}/$TAG/g" .github/workflows/assets/release_template.html |
|
||||
gh release create
|
||||
"$TAG"
|
||||
--repo '${{ github.repository }}'
|
||||
--generate-notes
|
||||
--notes-file -
|
||||
- name: Upload artifact signatures to GitHub Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -137,3 +141,30 @@ jobs:
|
||||
gh release upload
|
||||
"$TAG" dist/**
|
||||
--repo '${{ github.repository }}'
|
||||
|
||||
telegram-channel:
|
||||
name: Publish to Telegram Channel
|
||||
needs:
|
||||
- github-release
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: release_pypi
|
||||
permissions: {}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Publish to Telegram Channel
|
||||
env:
|
||||
TAG: ${{ needs.build.outputs.TAG }}
|
||||
# This secret is configured only for the `pypi-release` branch
|
||||
BOT_TOKEN: ${{ secrets.CHANNEL_BOT_TOKEN }}
|
||||
run: >-
|
||||
sed "s/{tag}/$TAG/g" .github/workflows/assets/release_template.html |
|
||||
curl
|
||||
-X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage"
|
||||
-d "chat_id=@pythontelegrambotchannel"
|
||||
-d "parse_mode=HTML"
|
||||
--data-urlencode "text@-"
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install pypa/build
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: python3 -m build
|
||||
- name: Store the distribution packages
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
@@ -55,12 +55,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
- name: Publish to Test PyPI
|
||||
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
|
||||
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
|
||||
with:
|
||||
repository-url: https://test.pypi.org/legacy/
|
||||
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: python-package-distributions
|
||||
path: dist/
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
./dist/*.tar.gz
|
||||
./dist/*.whl
|
||||
- name: Store the distribution packages and signatures
|
||||
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: python-package-distributions-and-signatures
|
||||
path: dist/
|
||||
@@ -112,8 +112,11 @@ jobs:
|
||||
actions: read # for downloading artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Download all the dists
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: python-package-distributions-and-signatures
|
||||
path: dist/
|
||||
@@ -121,14 +124,15 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ needs.build.outputs.TAG }}
|
||||
# Create a GitHub Release *draft*. The description can be changed later, as for now
|
||||
# we don't define it through this workflow.
|
||||
# Create a tag and a GitHub Release *draft*. The description is filled by the static
|
||||
# template, we just insert the correct tag in the template.
|
||||
run: >-
|
||||
sed "s/{tag}/$TAG/g" .github/workflows/assets/release_template.html |
|
||||
gh release create
|
||||
"$TAG"
|
||||
--repo '${{ github.repository }}'
|
||||
--generate-notes
|
||||
--draft
|
||||
--notes-file -
|
||||
- name: Upload artifact signatures to GitHub Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
||||
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'pip'
|
||||
@@ -92,14 +92,14 @@ jobs:
|
||||
.test_report_optionals_junit.xml
|
||||
|
||||
- name: Submit coverage
|
||||
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
|
||||
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
|
||||
with:
|
||||
env_vars: OS,PYTHON
|
||||
name: ${{ matrix.os }}-${{ matrix.python-version }}
|
||||
fail_ci_if_error: true
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload test results to Codecov
|
||||
uses: codecov/test-results-action@4e79e65778be1cecd5df25e14af1eafb6df80ea9 # v1.0.2
|
||||
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
files: .test_report_no_optionals_junit.xml,.test_report_optionals_junit.xml
|
||||
|
||||
@@ -7,7 +7,7 @@ ci:
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.8.6'
|
||||
rev: 'v0.11.9'
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: ruff
|
||||
@@ -18,18 +18,18 @@ repos:
|
||||
- cachetools>=5.3.3,<5.5.0
|
||||
- aiolimiter~=1.1,<1.3
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 24.10.0
|
||||
rev: 25.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
args:
|
||||
- --diff
|
||||
- --check
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 7.1.1
|
||||
rev: 7.2.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/PyCQA/pylint
|
||||
rev: v3.3.3
|
||||
rev: v3.3.6
|
||||
hooks:
|
||||
- id: pylint
|
||||
files: ^(?!(tests|docs)).*\.py$
|
||||
@@ -41,7 +41,7 @@ repos:
|
||||
- aiolimiter~=1.1,<1.3
|
||||
- . # this basically does `pip install -e .`
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.14.1
|
||||
rev: v1.15.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
name: mypy-ptb
|
||||
@@ -74,7 +74,7 @@ repos:
|
||||
args:
|
||||
- --py39-plus
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.13.2
|
||||
rev: 6.0.1
|
||||
hooks:
|
||||
- id: isort
|
||||
name: isort
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ python:
|
||||
install:
|
||||
- method: pip
|
||||
path: .
|
||||
- requirements: docs/requirements-docs.txt
|
||||
- requirements: requirements-dev-all.txt
|
||||
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
|
||||
+4
-4
@@ -7,10 +7,8 @@ The current development team includes
|
||||
|
||||
- `Hinrich Mahler <https://github.com/Bibo-Joshi>`_ (maintainer)
|
||||
- `Poolitzer <https://github.com/Poolitzer>`_ (community liaison)
|
||||
- `Shivam <https://github.com/Starry69>`_
|
||||
- `Harshil <https://github.com/harshil21>`_
|
||||
- `Dmitry Kolomatskiy <https://github.com/lemontree210>`_
|
||||
- `Aditya <https://github.com/clot27>`_
|
||||
- `Abdelrahman <https://github.com/aelkheir>`_
|
||||
|
||||
Emeritus maintainers include
|
||||
`Jannes Höke <https://github.com/jh0ker>`_ (`@jh0ker <https://t.me/jh0ker>`_ on Telegram),
|
||||
@@ -21,7 +19,7 @@ Contributors
|
||||
|
||||
The following wonderful people contributed directly or indirectly to this project:
|
||||
|
||||
- `Abdelrahman <https://github.com/aelkheir>`_
|
||||
- `Aditya <https://github.com/clot27>`_
|
||||
- `Abshar <https://github.com/abxhr>`_
|
||||
- `Abubakar Alaya <https://github.com/Ecode2>`_
|
||||
- `Alateas <https://github.com/alateas>`_
|
||||
@@ -42,6 +40,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||
- `daimajia <https://github.com/daimajia>`_
|
||||
- `Daniel Reed <https://github.com/nmlorg>`_
|
||||
- `D David Livingston <https://github.com/daviddl9>`_
|
||||
- `Dmitry Kolomatskiy <https://github.com/lemontree210>`_
|
||||
- `DonalDuck004 <https://github.com/DonalDuck004>`_
|
||||
- `Eana Hufwe <https://github.com/blueset>`_
|
||||
- `Ehsan Online <https://github.com/ehsanonline>`_
|
||||
@@ -122,6 +121,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||
- `Sam Mosleh <https://github.com/sam-mosleh>`_
|
||||
- `Sascha <https://github.com/saschalalala>`_
|
||||
- `Shelomentsev D <https://github.com/shelomentsevd>`_
|
||||
- `Shivam <https://github.com/Starry69>`_
|
||||
- `Shivam Saini <https://github.com/shivamsn97>`_
|
||||
- `Siloé Garcez <https://github.com/roast-lord>`_
|
||||
- `Simon Schürrle <https://github.com/SitiSchu>`_
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@
|
||||
:target: https://pypi.org/project/python-telegram-bot/
|
||||
:alt: Supported Python versions
|
||||
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-8.3-blue?logo=telegram
|
||||
.. image:: https://img.shields.io/badge/Bot%20API-9.0-blue?logo=telegram
|
||||
:target: https://core.telegram.org/bots/api-changelog
|
||||
:alt: Supported Bot API version
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
:target: https://pypistats.org/packages/python-telegram-bot
|
||||
:alt: PyPi Package Monthly Download
|
||||
|
||||
.. image:: https://readthedocs.org/projects/python-telegram-bot/badge/?version=stable
|
||||
.. image:: https://app.readthedocs.org/projects/python-telegram-bot/badge/?version=stable
|
||||
:target: https://docs.python-telegram-bot.org/en/stable/
|
||||
:alt: Documentation Status
|
||||
|
||||
@@ -81,7 +81,7 @@ After installing_ the library, be sure to check out the section on `working with
|
||||
Telegram API support
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
All types and methods of the Telegram Bot API **8.3** are natively supported by this library.
|
||||
All types and methods of the Telegram Bot API **9.0** are natively supported by this library.
|
||||
In addition, Bot API functionality not yet natively included can still be used as described `in our wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Bot-API-Forward-Compatibility>`_.
|
||||
|
||||
Notable Features
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
breaking = """This release removes all functionality that was deprecated in v20.x. This is in line with our :ref:`stability policy <stability-policy>`.
|
||||
This includes the following changes:
|
||||
|
||||
- Removed ``filters.CHAT`` (all messages have an associated chat) and ``filters.StatusUpdate.USER_SHARED`` (use ``filters.StatusUpdate.USERS_SHARED`` instead).
|
||||
- Removed ``Defaults.disable_web_page_preview`` and ``Defaults.quote``. Use ``Defaults.link_preview_options`` and ``Defaults.do_quote`` instead.
|
||||
- Removed ``ApplicationBuilder.(get_updates_)proxy_url`` and ``HTTPXRequest.proxy_url``. Use ``ApplicationBuilder.(get_updates_)proxy`` and ``HTTPXRequest.proxy`` instead.
|
||||
- Removed the ``*_timeout`` arguments of ``Application.run_polling`` and ``Updater.start_webhook``. Instead, specify the values via ``ApplicationBuilder.get_updates_*_timeout``.
|
||||
- Removed ``constants.InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH``. Use ``constants.InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTH`` instead.
|
||||
- Removed the argument ``quote`` of ``Message.reply_*``. Use ``do_quote`` instead.
|
||||
- Removed the superfluous ``EncryptedPassportElement.credentials`` without replacement.
|
||||
- Changed attribute value of ``PassportFile.file_date`` from :obj:`int` to :class:`datetime.datetime`. Make sure to adjust your code accordingly.
|
||||
- Changed the attribute value of ``PassportElementErrors.file_hashes`` from :obj:`list` to :obj:`tuple`. Make sure to adjust your code accordingly.
|
||||
- Make ``BaseRequest.read_timeout`` an abstract property. If you subclass ``BaseRequest``, you need to implement this property.
|
||||
- The default value for ``write_timeout`` now defaults to ``DEFAULT_NONE`` also for bot methods that send media. Previously, it was ``20``. If you subclass ``BaseRequest``, make sure to use your desired write timeout if ``RequestData.multipart_data`` is set.
|
||||
"""
|
||||
[[pull_requests]]
|
||||
uid = "4671"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = ["4659"]
|
||||
@@ -0,0 +1,5 @@
|
||||
documentation = "Add `chango <https://chango.readthedocs.io/stable/>`_ As Changelog Management Tool"
|
||||
[[pull_requests]]
|
||||
uid = "4672"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = ["4321"]
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump github/codeql-action from 3.28.8 to 3.28.10"
|
||||
[[pull_requests]]
|
||||
uid = "4697"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump srvaroa/labeler from 1.12.0 to 1.13.0"
|
||||
[[pull_requests]]
|
||||
uid = "4698"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump astral-sh/setup-uv from 5.2.2 to 5.3.1"
|
||||
[[pull_requests]]
|
||||
uid = "4699"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump Bibo-Joshi/chango from 0.3.1 to 0.3.2"
|
||||
[[pull_requests]]
|
||||
uid = "4700"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4"
|
||||
[[pull_requests]]
|
||||
uid = "4701"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump pytest from 8.3.4 to 8.3.5"
|
||||
[[pull_requests]]
|
||||
uid = "4709"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump sphinx from 8.1.3 to 8.2.3"
|
||||
[[pull_requests]]
|
||||
uid = "4710"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump Bibo-Joshi/chango from 0.3.2 to 0.4.0"
|
||||
[[pull_requests]]
|
||||
uid = "4712"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump Version to v22.0"
|
||||
[[pull_requests]]
|
||||
uid = "4719"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
breaking = "Drop backward compatibility for ``user_id`` in ``send_gift`` by updating the order of parameters. Please adapt your code accordingly or use keyword arguments."
|
||||
[[pull_requests]]
|
||||
uid = "4692"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,9 @@
|
||||
documentation = "Documentation Improvements. Among others, add missing ``Returns`` field in ``User.get_profile_photos``"
|
||||
[[pull_requests]]
|
||||
uid = "4730"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4740"
|
||||
author_uid = "aelkheir"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
bugfixes = "Ensure execution of ``Bot.shutdown()`` even if ``Bot.get_me()`` fails in ``Bot.initialize()``"
|
||||
[[pull_requests]]
|
||||
uid = "4733"
|
||||
author_uid = "Poolitzer"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump codecov/test-results-action from 1.0.2 to 1.1.0"
|
||||
[[pull_requests]]
|
||||
uid = "4741"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump actions/setup-python from 5.4.0 to 5.5.0"
|
||||
[[pull_requests]]
|
||||
uid = "4742"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump github/codeql-action from 3.28.10 to 3.28.13"
|
||||
[[pull_requests]]
|
||||
uid = "4743"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump astral-sh/setup-uv from 5.3.1 to 5.4.1"
|
||||
[[pull_requests]]
|
||||
uid = "4744"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump actions/download-artifact from 4.1.8 to 4.2.1"
|
||||
[[pull_requests]]
|
||||
uid = "4745"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Reenable ``test_official`` Blocked by Debug Remnant"
|
||||
[[pull_requests]]
|
||||
uid = "4746"
|
||||
author_uid = "aelkheir"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
documentation = "Update ``AUTHORS.rst``, Adding `@aelkheir <https://github.com/aelkheir>`_ to Active Development Team"
|
||||
[[pull_requests]]
|
||||
uid = "4747"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump `pre-commit` Hooks to Latest Versions"
|
||||
[[pull_requests]]
|
||||
uid = "4748"
|
||||
author_uid = "pre-commit-ci"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,51 @@
|
||||
features = "Full Support for Bot API 9.0"
|
||||
deprecations = """This release comes with several deprecations, in line with our :ref:`stability policy <stability-policy>`.
|
||||
This includes the following:
|
||||
|
||||
- Deprecated ``telegram.constants.StarTransactionsLimit.NANOSTAR_MIN_AMOUNT`` and ``telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT``. These members will be replaced by ``telegram.constants.NanostarLimit.MIN_AMOUNT`` and ``telegram.constants.NanostarLimit.MAX_AMOUNT``.
|
||||
- Deprecated the class ``telegram.constants.StarTransactions``. Its only member ``telegram.constants.StarTransactions.NANOSTAR_VALUE`` will be replaced by ``telegram.constants.Nanostar.VALUE``.
|
||||
- Bot API 9.0 deprecated ``BusinessConnection.can_reply`` in favor of ``BusinessConnection.rights``
|
||||
- Bot API 9.0 deprecated ``ChatFullInfo.can_send_gift`` in favor of ``ChatFullInfo.accepted_gift_types``.
|
||||
- Bot API 9.0 introduced these new required fields to existing classes:
|
||||
- ``TransactionPartnerUser.transaction_type``
|
||||
- ``ChatFullInfo.accepted_gift_types``
|
||||
|
||||
Passing these values as positional arguments is deprecated. We encourage you to use keyword arguments instead, as the the signature will be updated in a future release.
|
||||
|
||||
These deprecations are backward compatible, but we strongly recommend to update your code to use the new members.
|
||||
"""
|
||||
[[pull_requests]]
|
||||
uid = "4756"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = ["4754"]
|
||||
[[pull_requests]]
|
||||
uid = "4757"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4759"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4763"
|
||||
author_uid = "aelkheir"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4766"
|
||||
author_uid = "Bibo-Joshi"
|
||||
[[pull_requests]]
|
||||
uid = "4769"
|
||||
author_uid = "aelkheir"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4773"
|
||||
author_uid = "aelkheir"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4781"
|
||||
author_uid = "aelkheir"
|
||||
closes_threads = []
|
||||
[[pull_requests]]
|
||||
uid = "4782"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Fine-tune ``chango`` and release workflows"
|
||||
[[pull_requests]]
|
||||
uid = "4758"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = ["4720"]
|
||||
@@ -0,0 +1,6 @@
|
||||
bugfixes = "Fix Handling of ``Defaults`` for ``InputPaidMedia``"
|
||||
|
||||
[[pull_requests]]
|
||||
uid = "4761"
|
||||
author_uid = "ngrogolev"
|
||||
closes_threads = ["4753"]
|
||||
@@ -0,0 +1,5 @@
|
||||
documentation = "Clarify Documentation and Type Hints of ``InputMedia`` and ``InputPaidMedia``. Note that the ``media`` parameter accepts only objects of type ``str`` and ``InputFile``. The respective subclasses of ``Input(Paid)Media`` each accept a broader range of input type for the ``media`` parameter."
|
||||
[[pull_requests]]
|
||||
uid = "4762"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump codecov/codecov-action from 5.1.2 to 5.4.2"
|
||||
[[pull_requests]]
|
||||
uid = "4775"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump actions/upload-artifact from 4.5.0 to 4.6.2"
|
||||
[[pull_requests]]
|
||||
uid = "4776"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump stefanzweifel/git-auto-commit-action from 5.1.0 to 5.2.0"
|
||||
[[pull_requests]]
|
||||
uid = "4777"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump github/codeql-action from 3.28.13 to 3.28.16"
|
||||
[[pull_requests]]
|
||||
uid = "4778"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
internal = "Bump actions/download-artifact from 4.2.1 to 4.3.0"
|
||||
[[pull_requests]]
|
||||
uid = "4779"
|
||||
author_uid = "dependabot"
|
||||
closes_threads = []
|
||||
@@ -0,0 +1,5 @@
|
||||
other = "Bump Version to v22.1"
|
||||
[[pull_requests]]
|
||||
uid = "4791"
|
||||
author_uid = "Bibo-Joshi"
|
||||
closes_threads = []
|
||||
@@ -1,8 +1,14 @@
|
||||
.. _ptb-changelog:
|
||||
Version 21.11.1
|
||||
===============
|
||||
|
||||
=========
|
||||
Changelog
|
||||
=========
|
||||
*Released 2025-03-01*
|
||||
|
||||
This is the technical changelog for version 21.11. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
|
||||
|
||||
Documentation Improvements
|
||||
--------------------------
|
||||
|
||||
- Fix ReadTheDocs Build (:pr:`4695`)
|
||||
|
||||
Version 21.11
|
||||
=============
|
||||
@@ -0,0 +1,105 @@
|
||||
# noqa: INP001
|
||||
# pylint: disable=import-error
|
||||
"""Configuration for the chango changelog tool"""
|
||||
|
||||
import re
|
||||
from collections.abc import Collection
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from chango import Version
|
||||
from chango.concrete import DirectoryChanGo, DirectoryVersionScanner, HeaderVersionHistory
|
||||
from chango.concrete.sections import GitHubSectionChangeNote, Section, SectionVersionNote
|
||||
|
||||
version_scanner = DirectoryVersionScanner(base_directory=".", unreleased_directory="unreleased")
|
||||
|
||||
|
||||
class ChangoSectionChangeNote(
|
||||
GitHubSectionChangeNote.with_sections( # type: ignore[misc]
|
||||
[
|
||||
Section(uid="highlights", title="Highlights", sort_order=0),
|
||||
Section(uid="breaking", title="Breaking Changes", sort_order=1),
|
||||
Section(uid="security", title="Security Changes", sort_order=2),
|
||||
Section(uid="deprecations", title="Deprecations", sort_order=3),
|
||||
Section(uid="features", title="New Features", sort_order=4),
|
||||
Section(uid="bugfixes", title="Bug Fixes", sort_order=5),
|
||||
Section(uid="dependencies", title="Dependencies", sort_order=6),
|
||||
Section(uid="other", title="Other Changes", sort_order=7),
|
||||
Section(uid="documentation", title="Documentation", sort_order=8),
|
||||
Section(uid="internal", title="Internal Changes", sort_order=9),
|
||||
]
|
||||
)
|
||||
):
|
||||
"""Custom change note type for PTB. Mainly overrides get_sections to map labels to sections"""
|
||||
|
||||
OWNER = "python-telegram-bot"
|
||||
REPOSITORY = "python-telegram-bot"
|
||||
|
||||
@classmethod
|
||||
def get_sections(
|
||||
cls,
|
||||
labels: Collection[str],
|
||||
issue_types: Optional[Collection[str]],
|
||||
) -> set[str]:
|
||||
"""Override get_sections to have customized auto-detection of relevant sections based on
|
||||
the pull request and linked issues. Certainly not perfect in all cases, but should be a
|
||||
good start for most PRs.
|
||||
"""
|
||||
combined_labels = set(labels) | (set(issue_types or []))
|
||||
|
||||
mapping = {
|
||||
"🐛 bug": "bugfixes",
|
||||
"💡 feature": "features",
|
||||
"🧹 chore": "internal",
|
||||
"⚙️ bot-api": "features",
|
||||
"⚙️ documentation": "documentation",
|
||||
"⚙️ tests": "internal",
|
||||
"⚙️ ci-cd": "internal",
|
||||
"⚙️ security": "security",
|
||||
"⚙️ examples": "documentation",
|
||||
"⚙️ type-hinting": "other",
|
||||
"🛠 refactor": "internal",
|
||||
"🛠 breaking": "breaking",
|
||||
"⚙️ dependencies": "dependencies",
|
||||
"🔗 github-actions": "internal",
|
||||
"🛠 code-quality": "internal",
|
||||
}
|
||||
|
||||
# we want to return *all* from the mapping that are in the combined_labels
|
||||
# removing superfluous sections from the fragment is a tad easier than adding them
|
||||
found = {section for label, section in mapping.items() if label in combined_labels}
|
||||
|
||||
# if we have not found any sections, we default to "other"
|
||||
return found or {"other"}
|
||||
|
||||
|
||||
class CustomChango(DirectoryChanGo):
|
||||
"""Custom ChanGo class for overriding release"""
|
||||
|
||||
def release(self, version: Version) -> bool:
|
||||
"""replace "14.5" with version.uid except in the contrib guide
|
||||
then call super
|
||||
"""
|
||||
root = Path(__file__).parent.parent / "telegram"
|
||||
python_files = root.rglob("*.py")
|
||||
pattern = re.compile(r"NEXT\.VERSION")
|
||||
excluded_paths = {root / "docs/source/contribute.rst"}
|
||||
for file_path in python_files:
|
||||
if str(file_path) in excluded_paths:
|
||||
continue
|
||||
|
||||
content = file_path.read_text(encoding="utf-8")
|
||||
modified = pattern.sub(version.uid, content)
|
||||
|
||||
if content != modified:
|
||||
file_path.write_text(modified, encoding="utf-8")
|
||||
|
||||
return super().release(version)
|
||||
|
||||
|
||||
chango_instance = CustomChango(
|
||||
change_note_type=ChangoSectionChangeNote,
|
||||
version_note_type=SectionVersionNote,
|
||||
version_history_type=HeaderVersionHistory,
|
||||
scanner=version_scanner,
|
||||
)
|
||||
@@ -47,29 +47,29 @@ keyword_args = [
|
||||
"",
|
||||
]
|
||||
|
||||
media_write_timeout_deprecation_methods = [
|
||||
"send_photo",
|
||||
media_write_timeout_change_methods = [
|
||||
"add_sticker_to_set",
|
||||
"create_new_sticker_set",
|
||||
"send_animation",
|
||||
"send_audio",
|
||||
"send_document",
|
||||
"send_media_group",
|
||||
"send_photo",
|
||||
"send_sticker",
|
||||
"send_video",
|
||||
"send_video_note",
|
||||
"send_animation",
|
||||
"send_voice",
|
||||
"send_media_group",
|
||||
"set_chat_photo",
|
||||
"upload_sticker_file",
|
||||
"add_sticker_to_set",
|
||||
"create_new_sticker_set",
|
||||
]
|
||||
media_write_timeout_deprecation = [
|
||||
media_write_timeout_change = [
|
||||
" write_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to "
|
||||
" :paramref:`telegram.request.BaseRequest.post.write_timeout`. By default, ``20`` "
|
||||
" seconds are used as write timeout."
|
||||
"",
|
||||
"",
|
||||
" .. deprecated:: 20.7",
|
||||
" In future versions, the default value will be changed to "
|
||||
" .. versionchanged:: 22.0",
|
||||
" The default value changed to "
|
||||
" :attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
|
||||
"",
|
||||
"",
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
#
|
||||
# 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 collections.abc
|
||||
import contextlib
|
||||
import inspect
|
||||
import re
|
||||
import typing
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
|
||||
@@ -32,11 +32,15 @@ from docs.auxil.kwargs_insertion import (
|
||||
find_insert_pos_for_kwargs,
|
||||
get_updates_read_timeout_addition,
|
||||
keyword_args,
|
||||
media_write_timeout_deprecation,
|
||||
media_write_timeout_deprecation_methods,
|
||||
media_write_timeout_change,
|
||||
media_write_timeout_change_methods,
|
||||
)
|
||||
from docs.auxil.link_code import LINE_NUMBERS
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import collections.abc
|
||||
|
||||
|
||||
ADMONITION_INSERTER = AdmonitionInserter()
|
||||
|
||||
# Some base classes are implementation detail
|
||||
@@ -116,9 +120,9 @@ def autodoc_process_docstring(
|
||||
|
||||
if (
|
||||
"post.write_timeout`. Defaults to" in to_insert
|
||||
and method_name in media_write_timeout_deprecation_methods
|
||||
and method_name in media_write_timeout_change_methods
|
||||
):
|
||||
effective_insert: list[str] = media_write_timeout_deprecation
|
||||
effective_insert: list[str] = media_write_timeout_change
|
||||
elif get_updates and to_insert.lstrip().startswith("read_timeout"):
|
||||
effective_insert = [to_insert, *get_updates_read_timeout_addition]
|
||||
else:
|
||||
@@ -128,7 +132,7 @@ def autodoc_process_docstring(
|
||||
insert_idx += len(effective_insert)
|
||||
|
||||
ADMONITION_INSERTER.insert_admonitions(
|
||||
obj=typing.cast(collections.abc.Callable, obj),
|
||||
obj=typing.cast("collections.abc.Callable", obj),
|
||||
docstring_lines=lines,
|
||||
)
|
||||
|
||||
@@ -136,7 +140,7 @@ def autodoc_process_docstring(
|
||||
# (where applicable)
|
||||
if what == "class":
|
||||
ADMONITION_INSERTER.insert_admonitions(
|
||||
obj=typing.cast(type, obj), # since "what" == class, we know it's not just object
|
||||
obj=typing.cast("type", obj), # since "what" == class, we know it's not just object
|
||||
docstring_lines=lines,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
sphinx==8.1.3
|
||||
chango~=0.4.0
|
||||
sphinx==8.2.3
|
||||
furo==2024.8.6
|
||||
furo-sphinx-search @ git+https://github.com/harshil21/furo-sphinx-search@v0.2.0.1
|
||||
sphinx-paramlinks==0.6.0
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
.. include:: ../../CHANGES.rst
|
||||
.. _ptb-changelog:
|
||||
|
||||
=========
|
||||
Changelog
|
||||
=========
|
||||
|
||||
.. chango::
|
||||
|
||||
.. include:: ../../changes/LEGACY.rst
|
||||
@@ -8,6 +8,11 @@ from pathlib import Path
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
from sphinx.application import Sphinx
|
||||
|
||||
if sys.version_info < (3, 12):
|
||||
# Due to dependency on chango
|
||||
raise RuntimeError("This documentation needs at least Python 3.12")
|
||||
|
||||
|
||||
sys.path.insert(0, str(Path("../..").resolve().absolute()))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
@@ -36,6 +41,7 @@ needs_sphinx = "8.1.3"
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
"chango.sphinx_ext",
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.napoleon",
|
||||
"sphinx.ext.intersphinx",
|
||||
@@ -52,6 +58,9 @@ extensions = [
|
||||
if os.environ.get("READTHEDOCS", "") == "True":
|
||||
extensions.append("sphinx_build_compatibility.extension")
|
||||
|
||||
# Configuration for the chango sphinx directive
|
||||
chango_pyproject_toml_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# For shorter links to Wiki in docstrings
|
||||
extlinks = {
|
||||
"wiki": ("https://github.com/python-telegram-bot/python-telegram-bot/wiki/%s", "%s"),
|
||||
@@ -116,6 +125,8 @@ linkcheck_ignore = [
|
||||
# The doc-fixes branch may not always exist - doesn't matter, we only link to it from the
|
||||
# contributing guide
|
||||
re.escape("https://docs.python-telegram-bot.org/en/doc-fixes"),
|
||||
# Apparently has some human-verification check and gives 403 in the sphinx build
|
||||
re.escape("https://stackoverflow.com/questions/tagged/python-telegram-bot"),
|
||||
]
|
||||
linkcheck_allowed_redirects = {
|
||||
# Redirects to the default version are okay
|
||||
|
||||
@@ -61,7 +61,7 @@ for this one, too!
|
||||
:any:`examples.nestedconversationbot`
|
||||
-------------------------------------
|
||||
|
||||
A even more complex example of a bot that uses the nested
|
||||
An even more complex example of a bot that uses the nested
|
||||
``ConversationHandler``\ s. While it’s certainly not that complex that
|
||||
you couldn’t built it without nested ``ConversationHanldler``\ s, it
|
||||
gives a good impression on how to work with them. Of course, there is a
|
||||
|
||||
@@ -161,8 +161,6 @@
|
||||
- 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`
|
||||
@@ -396,6 +394,60 @@
|
||||
- Used for obtaining the bot's Telegram Stars transactions
|
||||
* - :meth:`~telegram.Bot.refund_star_payment`
|
||||
- Used for refunding a payment in Telegram Stars
|
||||
* - :meth:`~telegram.Bot.gift_premium_subscription`
|
||||
- Used for gifting Telegram Premium to another user.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
</details>
|
||||
<br>
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<details>
|
||||
<summary>Business Related Methods</summary>
|
||||
|
||||
.. list-table::
|
||||
:align: left
|
||||
:widths: 1 4
|
||||
|
||||
* - :meth:`~telegram.Bot.get_business_connection`
|
||||
- Used for getting information about the business account.
|
||||
* - :meth:`~telegram.Bot.get_business_account_gifts`
|
||||
- Used for getting gifts owned by the business account.
|
||||
* - :meth:`~telegram.Bot.get_business_account_star_balance`
|
||||
- Used for getting the amount of Stars owned by the business account.
|
||||
* - :meth:`~telegram.Bot.read_business_message`
|
||||
- Used for marking a message as read.
|
||||
* - :meth:`~telegram.Bot.delete_story`
|
||||
- Used for deleting business stories posted by the bot.
|
||||
* - :meth:`~telegram.Bot.delete_business_messages`
|
||||
- Used for deleting business messages.
|
||||
* - :meth:`~telegram.Bot.remove_business_account_profile_photo`
|
||||
- Used for removing the business accounts profile photo
|
||||
* - :meth:`~telegram.Bot.set_business_account_name`
|
||||
- Used for setting the business account name.
|
||||
* - :meth:`~telegram.Bot.set_business_account_username`
|
||||
- Used for setting the business account username.
|
||||
* - :meth:`~telegram.Bot.set_business_account_bio`
|
||||
- Used for setting the business account bio.
|
||||
* - :meth:`~telegram.Bot.set_business_account_gift_settings`
|
||||
- Used for setting the business account gift settings.
|
||||
* - :meth:`~telegram.Bot.set_business_account_profile_photo`
|
||||
- Used for setting the business accounts profile photo
|
||||
* - :meth:`~telegram.Bot.post_story`
|
||||
- Used for posting a story on behalf of business account.
|
||||
* - :meth:`~telegram.Bot.edit_story`
|
||||
- Used for editing business stories posted by the bot.
|
||||
* - :meth:`~telegram.Bot.convert_gift_to_stars`
|
||||
- Used for converting owned reqular gifts to stars.
|
||||
* - :meth:`~telegram.Bot.upgrade_gift`
|
||||
- Used for upgrading owned regular gifts to unique ones.
|
||||
* - :meth:`~telegram.Bot.transfer_gift`
|
||||
- Used for transferring owned unique gifts to another user.
|
||||
* - :meth:`~telegram.Bot.transfer_business_account_stars`
|
||||
- Used for transfering Stars from the business account balance to the bot's balance.
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
.. _stability-policy:
|
||||
|
||||
Stability Policy
|
||||
================
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
AcceptedGiftTypes
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.AcceptedGiftTypes
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -4,6 +4,7 @@ Available Types
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
|
||||
telegram.acceptedgifttypes
|
||||
telegram.animation
|
||||
telegram.audio
|
||||
telegram.birthdate
|
||||
@@ -19,6 +20,7 @@ Available Types
|
||||
telegram.botdescription
|
||||
telegram.botname
|
||||
telegram.botshortdescription
|
||||
telegram.businessbotrights
|
||||
telegram.businessconnection
|
||||
telegram.businessintro
|
||||
telegram.businesslocation
|
||||
@@ -75,6 +77,7 @@ Available Types
|
||||
telegram.forumtopicreopened
|
||||
telegram.generalforumtopichidden
|
||||
telegram.generalforumtopicunhidden
|
||||
telegram.giftinfo
|
||||
telegram.giveaway
|
||||
telegram.giveawaycompleted
|
||||
telegram.giveawaycreated
|
||||
@@ -92,13 +95,20 @@ Available Types
|
||||
telegram.inputpaidmedia
|
||||
telegram.inputpaidmediaphoto
|
||||
telegram.inputpaidmediavideo
|
||||
telegram.inputprofilephoto
|
||||
telegram.inputprofilephotoanimated
|
||||
telegram.inputprofilephotostatic
|
||||
telegram.inputpolloption
|
||||
telegram.inputstorycontent
|
||||
telegram.inputstorycontentphoto
|
||||
telegram.inputstorycontentvideo
|
||||
telegram.keyboardbutton
|
||||
telegram.keyboardbuttonpolltype
|
||||
telegram.keyboardbuttonrequestchat
|
||||
telegram.keyboardbuttonrequestusers
|
||||
telegram.linkpreviewoptions
|
||||
telegram.location
|
||||
telegram.locationaddress
|
||||
telegram.loginurl
|
||||
telegram.maybeinaccessiblemessage
|
||||
telegram.menubutton
|
||||
@@ -116,12 +126,17 @@ Available Types
|
||||
telegram.messageoriginuser
|
||||
telegram.messagereactioncountupdated
|
||||
telegram.messagereactionupdated
|
||||
telegram.ownedgift
|
||||
telegram.ownedgiftregular
|
||||
telegram.ownedgifts
|
||||
telegram.ownedgiftunique
|
||||
telegram.paidmedia
|
||||
telegram.paidmediainfo
|
||||
telegram.paidmediaphoto
|
||||
telegram.paidmediapreview
|
||||
telegram.paidmediapurchased
|
||||
telegram.paidmediavideo
|
||||
telegram.paidmessagepricechanged
|
||||
telegram.photosize
|
||||
telegram.poll
|
||||
telegram.pollanswer
|
||||
@@ -138,9 +153,23 @@ Available Types
|
||||
telegram.sentwebappmessage
|
||||
telegram.shareduser
|
||||
telegram.story
|
||||
telegram.storyarea
|
||||
telegram.storyareaposition
|
||||
telegram.storyareatype
|
||||
telegram.storyareatypelink
|
||||
telegram.storyareatypelocation
|
||||
telegram.storyareatypesuggestedreaction
|
||||
telegram.storyareatypeuniquegift
|
||||
telegram.storyareatypeweather
|
||||
telegram.switchinlinequerychosenchat
|
||||
telegram.telegramobject
|
||||
telegram.textquote
|
||||
telegram.uniquegift
|
||||
telegram.uniquegiftbackdrop
|
||||
telegram.uniquegiftbackdropcolors
|
||||
telegram.uniquegiftinfo
|
||||
telegram.uniquegiftmodel
|
||||
telegram.uniquegiftsymbol
|
||||
telegram.update
|
||||
telegram.user
|
||||
telegram.userchatboosts
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
BusinessBotRights
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.BusinessBotRights
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,7 @@
|
||||
GiftInfo
|
||||
========
|
||||
|
||||
.. autoclass:: telegram.GiftInfo
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
InputProfilePhoto
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.InputProfilePhoto
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
InputProfilePhotoAnimated
|
||||
=========================
|
||||
|
||||
.. autoclass:: telegram.InputProfilePhotoAnimated
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
InputProfilePhotoStatic
|
||||
=======================
|
||||
|
||||
.. autoclass:: telegram.InputProfilePhotoStatic
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
InputStoryContent
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.InputStoryContent
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
InputStoryContentPhoto
|
||||
======================
|
||||
|
||||
.. autoclass:: telegram.InputStoryContentPhoto
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
InputStoryContentVideo
|
||||
======================
|
||||
|
||||
.. autoclass:: telegram.InputStoryContentVideo
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
LocationAddress
|
||||
===============
|
||||
|
||||
.. autoclass:: telegram.LocationAddress
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
OwnedGift
|
||||
=========
|
||||
|
||||
.. autoclass:: telegram.OwnedGift
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
OwnedGiftRegular
|
||||
================
|
||||
|
||||
.. autoclass:: telegram.OwnedGiftRegular
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
OwnedGifts
|
||||
==========
|
||||
|
||||
.. autoclass:: telegram.OwnedGifts
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
OwnedGiftUnique
|
||||
===============
|
||||
|
||||
.. autoclass:: telegram.OwnedGiftUnique
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
PaidMessagePriceChanged
|
||||
=======================
|
||||
|
||||
.. autoclass:: telegram.PaidMessagePriceChanged
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -22,6 +22,7 @@ Your bot can accept payments from Telegram users. Please see the `introduction t
|
||||
telegram.shippingaddress
|
||||
telegram.shippingoption
|
||||
telegram.shippingquery
|
||||
telegram.staramount
|
||||
telegram.startransaction
|
||||
telegram.startransactions
|
||||
telegram.successfulpayment
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
StarAmount
|
||||
==========
|
||||
|
||||
.. autoclass:: telegram.StarAmount
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryArea
|
||||
=========
|
||||
|
||||
.. autoclass:: telegram.StoryArea
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaPosition
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.StoryAreaPosition
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaType
|
||||
=============
|
||||
|
||||
.. autoclass:: telegram.StoryAreaType
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaTypeLink
|
||||
=================
|
||||
|
||||
.. autoclass:: telegram.StoryAreaTypeLink
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaTypeLocation
|
||||
=====================
|
||||
|
||||
.. autoclass:: telegram.StoryAreaTypeLocation
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaTypeSuggestedReaction
|
||||
==============================
|
||||
|
||||
.. autoclass:: telegram.StoryAreaTypeSuggestedReaction
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaTypeUniqueGift
|
||||
=======================
|
||||
|
||||
.. autoclass:: telegram.StoryAreaTypeUniqueGift
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,6 @@
|
||||
StoryAreaTypeWeather
|
||||
====================
|
||||
|
||||
.. autoclass:: telegram.StoryAreaTypeWeather
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,7 @@
|
||||
UniqueGift
|
||||
==========
|
||||
|
||||
.. autoclass:: telegram.UniqueGift
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
UniqueGiftBackdrop
|
||||
==================
|
||||
|
||||
.. autoclass:: telegram.UniqueGiftBackdrop
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
UniqueGiftBackdropColors
|
||||
========================
|
||||
|
||||
.. autoclass:: telegram.UniqueGiftBackdropColors
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
UniqueGiftInfo
|
||||
==============
|
||||
|
||||
.. autoclass:: telegram.UniqueGiftInfo
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
UniqueGiftModel
|
||||
===============
|
||||
|
||||
.. autoclass:: telegram.UniqueGiftModel
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
UniqueGiftSymbol
|
||||
================
|
||||
|
||||
.. autoclass:: telegram.UniqueGiftSymbol
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -69,7 +69,7 @@ async def list_button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> Non
|
||||
# Get the data from the callback_data.
|
||||
# If you're using a type checker like MyPy, you'll have to use typing.cast
|
||||
# to make the checker get the expected type of the callback_data
|
||||
number, number_list = cast(tuple[int, list[int]], query.data)
|
||||
number, number_list = cast("tuple[int, list[int]]", query.data)
|
||||
# append the number to the list
|
||||
number_list.append(number)
|
||||
|
||||
|
||||
+6
-2
@@ -105,6 +105,11 @@ search-paths = ["telegram"]
|
||||
[tool.hatch.build]
|
||||
packages = ["telegram"]
|
||||
|
||||
# CHANGO
|
||||
[tool.chango]
|
||||
sys_path = "changes"
|
||||
chango_instance = { name= "chango_instance", module = "config" }
|
||||
|
||||
# BLACK:
|
||||
[tool.black]
|
||||
line-length = 99
|
||||
@@ -120,8 +125,7 @@ line-length = 99
|
||||
show-fixes = true
|
||||
|
||||
[tool.ruff.lint]
|
||||
preview = true
|
||||
explicit-preview-rules = true # TODO: Drop this when RUF022 and RUF023 are out of preview
|
||||
typing-extensions = false
|
||||
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", "RUF022",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
build
|
||||
|
||||
# For the test suite
|
||||
pytest==8.3.4
|
||||
pytest==8.3.5
|
||||
|
||||
# needed because pytest doesn't come with native support for coroutines as tests
|
||||
pytest-asyncio==0.21.2
|
||||
|
||||
+64
-1
@@ -20,6 +20,7 @@
|
||||
|
||||
__author__ = "devs@python-telegram-bot.org"
|
||||
__all__ = (
|
||||
"AcceptedGiftTypes",
|
||||
"AffiliateInfo",
|
||||
"Animation",
|
||||
"Audio",
|
||||
@@ -46,6 +47,7 @@ __all__ = (
|
||||
"BotDescription",
|
||||
"BotName",
|
||||
"BotShortDescription",
|
||||
"BusinessBotRights",
|
||||
"BusinessConnection",
|
||||
"BusinessIntro",
|
||||
"BusinessLocation",
|
||||
@@ -103,6 +105,7 @@ __all__ = (
|
||||
"GeneralForumTopicHidden",
|
||||
"GeneralForumTopicUnhidden",
|
||||
"Gift",
|
||||
"GiftInfo",
|
||||
"Gifts",
|
||||
"Giveaway",
|
||||
"GiveawayCompleted",
|
||||
@@ -150,7 +153,13 @@ __all__ = (
|
||||
"InputPaidMediaPhoto",
|
||||
"InputPaidMediaVideo",
|
||||
"InputPollOption",
|
||||
"InputProfilePhoto",
|
||||
"InputProfilePhotoAnimated",
|
||||
"InputProfilePhotoStatic",
|
||||
"InputSticker",
|
||||
"InputStoryContent",
|
||||
"InputStoryContentPhoto",
|
||||
"InputStoryContentVideo",
|
||||
"InputTextMessageContent",
|
||||
"InputVenueMessageContent",
|
||||
"Invoice",
|
||||
@@ -161,6 +170,7 @@ __all__ = (
|
||||
"LabeledPrice",
|
||||
"LinkPreviewOptions",
|
||||
"Location",
|
||||
"LocationAddress",
|
||||
"LoginUrl",
|
||||
"MaskPosition",
|
||||
"MaybeInaccessibleMessage",
|
||||
@@ -180,12 +190,17 @@ __all__ = (
|
||||
"MessageReactionCountUpdated",
|
||||
"MessageReactionUpdated",
|
||||
"OrderInfo",
|
||||
"OwnedGift",
|
||||
"OwnedGiftRegular",
|
||||
"OwnedGiftUnique",
|
||||
"OwnedGifts",
|
||||
"PaidMedia",
|
||||
"PaidMediaInfo",
|
||||
"PaidMediaPhoto",
|
||||
"PaidMediaPreview",
|
||||
"PaidMediaPurchased",
|
||||
"PaidMediaVideo",
|
||||
"PaidMessagePriceChanged",
|
||||
"PassportData",
|
||||
"PassportElementError",
|
||||
"PassportElementErrorDataField",
|
||||
@@ -227,11 +242,20 @@ __all__ = (
|
||||
"ShippingAddress",
|
||||
"ShippingOption",
|
||||
"ShippingQuery",
|
||||
"StarAmount",
|
||||
"StarTransaction",
|
||||
"StarTransactions",
|
||||
"Sticker",
|
||||
"StickerSet",
|
||||
"Story",
|
||||
"StoryArea",
|
||||
"StoryAreaPosition",
|
||||
"StoryAreaType",
|
||||
"StoryAreaTypeLink",
|
||||
"StoryAreaTypeLocation",
|
||||
"StoryAreaTypeSuggestedReaction",
|
||||
"StoryAreaTypeUniqueGift",
|
||||
"StoryAreaTypeWeather",
|
||||
"SuccessfulPayment",
|
||||
"SwitchInlineQueryChosenChat",
|
||||
"TelegramObject",
|
||||
@@ -244,6 +268,12 @@ __all__ = (
|
||||
"TransactionPartnerTelegramAds",
|
||||
"TransactionPartnerTelegramApi",
|
||||
"TransactionPartnerUser",
|
||||
"UniqueGift",
|
||||
"UniqueGiftBackdrop",
|
||||
"UniqueGiftBackdropColors",
|
||||
"UniqueGiftInfo",
|
||||
"UniqueGiftModel",
|
||||
"UniqueGiftSymbol",
|
||||
"Update",
|
||||
"User",
|
||||
"UserChatBoosts",
|
||||
@@ -272,6 +302,7 @@ __all__ = (
|
||||
"warnings",
|
||||
)
|
||||
|
||||
from telegram._payment.stars.staramount import StarAmount
|
||||
from telegram._payment.stars.startransactions import StarTransaction, StarTransactions
|
||||
from telegram._payment.stars.transactionpartner import (
|
||||
TransactionPartner,
|
||||
@@ -301,6 +332,7 @@ from ._botcommandscope import (
|
||||
from ._botdescription import BotDescription, BotShortDescription
|
||||
from ._botname import BotName
|
||||
from ._business import (
|
||||
BusinessBotRights,
|
||||
BusinessConnection,
|
||||
BusinessIntro,
|
||||
BusinessLocation,
|
||||
@@ -352,6 +384,11 @@ from ._chatpermissions import ChatPermissions
|
||||
from ._choseninlineresult import ChosenInlineResult
|
||||
from ._copytextbutton import CopyTextButton
|
||||
from ._dice import Dice
|
||||
from ._files._inputstorycontent import (
|
||||
InputStoryContent,
|
||||
InputStoryContentPhoto,
|
||||
InputStoryContentVideo,
|
||||
)
|
||||
from ._files.animation import Animation
|
||||
from ._files.audio import Audio
|
||||
from ._files.chatphoto import ChatPhoto
|
||||
@@ -370,6 +407,11 @@ from ._files.inputmedia import (
|
||||
InputPaidMediaPhoto,
|
||||
InputPaidMediaVideo,
|
||||
)
|
||||
from ._files.inputprofilephoto import (
|
||||
InputProfilePhoto,
|
||||
InputProfilePhotoAnimated,
|
||||
InputProfilePhotoStatic,
|
||||
)
|
||||
from ._files.inputsticker import InputSticker
|
||||
from ._files.location import Location
|
||||
from ._files.photosize import PhotoSize
|
||||
@@ -391,7 +433,7 @@ from ._forumtopic import (
|
||||
from ._games.callbackgame import CallbackGame
|
||||
from ._games.game import Game
|
||||
from ._games.gamehighscore import GameHighScore
|
||||
from ._gifts import Gift, Gifts
|
||||
from ._gifts import AcceptedGiftTypes, Gift, GiftInfo, Gifts
|
||||
from ._giveaway import Giveaway, GiveawayCompleted, GiveawayCreated, GiveawayWinners
|
||||
from ._inline.inlinekeyboardbutton import InlineKeyboardButton
|
||||
from ._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
|
||||
@@ -443,6 +485,7 @@ from ._messageorigin import (
|
||||
MessageOriginUser,
|
||||
)
|
||||
from ._messagereactionupdated import MessageReactionCountUpdated, MessageReactionUpdated
|
||||
from ._ownedgift import OwnedGift, OwnedGiftRegular, OwnedGifts, OwnedGiftUnique
|
||||
from ._paidmedia import (
|
||||
PaidMedia,
|
||||
PaidMediaInfo,
|
||||
@@ -451,6 +494,7 @@ from ._paidmedia import (
|
||||
PaidMediaPurchased,
|
||||
PaidMediaVideo,
|
||||
)
|
||||
from ._paidmessagepricechanged import PaidMessagePriceChanged
|
||||
from ._passport.credentials import (
|
||||
Credentials,
|
||||
DataCredentials,
|
||||
@@ -506,8 +550,27 @@ from ._replykeyboardremove import ReplyKeyboardRemove
|
||||
from ._sentwebappmessage import SentWebAppMessage
|
||||
from ._shared import ChatShared, SharedUser, UsersShared
|
||||
from ._story import Story
|
||||
from ._storyarea import (
|
||||
LocationAddress,
|
||||
StoryArea,
|
||||
StoryAreaPosition,
|
||||
StoryAreaType,
|
||||
StoryAreaTypeLink,
|
||||
StoryAreaTypeLocation,
|
||||
StoryAreaTypeSuggestedReaction,
|
||||
StoryAreaTypeUniqueGift,
|
||||
StoryAreaTypeWeather,
|
||||
)
|
||||
from ._switchinlinequerychosenchat import SwitchInlineQueryChosenChat
|
||||
from ._telegramobject import TelegramObject
|
||||
from ._uniquegift import (
|
||||
UniqueGift,
|
||||
UniqueGiftBackdrop,
|
||||
UniqueGiftBackdropColors,
|
||||
UniqueGiftInfo,
|
||||
UniqueGiftModel,
|
||||
UniqueGiftSymbol,
|
||||
)
|
||||
from ._update import Update
|
||||
from ._user import User
|
||||
from ._userprofilephotos import UserProfilePhotos
|
||||
|
||||
+1028
-27
File diff suppressed because it is too large
Load Diff
+208
-10
@@ -30,20 +30,172 @@ from telegram._user import User
|
||||
from telegram._utils.argumentparsing import de_json_optional, de_list_optional, parse_sequence_arg
|
||||
from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
|
||||
from telegram._utils.types import JSONDict
|
||||
from telegram._utils.warnings import warn
|
||||
from telegram._utils.warnings_transition import (
|
||||
build_deprecation_warning_message,
|
||||
warn_about_deprecated_attr_in_property,
|
||||
)
|
||||
from telegram.warnings import PTBDeprecationWarning
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import Bot
|
||||
|
||||
|
||||
class BusinessBotRights(TelegramObject):
|
||||
"""
|
||||
This object represents the rights of a business bot.
|
||||
|
||||
Objects of this class are comparable in terms of equality.
|
||||
Two objects of this class are considered equal, if all their attributes are equal.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Args:
|
||||
can_reply (:obj:`bool`, optional): True, if the bot can send and edit messages in the
|
||||
private chats that had incoming messages in the last 24 hours.
|
||||
can_read_messages (:obj:`bool`, optional): True, if the bot can mark incoming private
|
||||
messages as read.
|
||||
can_delete_sent_messages (:obj:`bool`, optional): True, if the bot can delete messages
|
||||
sent by the bot.
|
||||
can_delete_all_messages (:obj:`bool`, optional): True, if the bot can delete all private
|
||||
messages in managed chats.
|
||||
can_edit_name (:obj:`bool`, optional): True, if the bot can edit the first and last name
|
||||
of the business account.
|
||||
can_edit_bio (:obj:`bool`, optional): True, if the bot can edit the bio of the
|
||||
business account.
|
||||
can_edit_profile_photo (:obj:`bool`, optional): True, if the bot can edit the profile
|
||||
photo of the business account.
|
||||
can_edit_username (:obj:`bool`, optional): True, if the bot can edit the username of the
|
||||
business account.
|
||||
can_change_gift_settings (:obj:`bool`, optional): True, if the bot can change the privacy
|
||||
settings pertaining to gifts for the business account.
|
||||
can_view_gifts_and_stars (:obj:`bool`, optional): True, if the bot can view gifts and the
|
||||
amount of Telegram Stars owned by the business account.
|
||||
can_convert_gifts_to_stars (:obj:`bool`, optional): True, if the bot can convert regular
|
||||
gifts owned by the business account to Telegram Stars.
|
||||
can_transfer_and_upgrade_gifts (:obj:`bool`, optional): True, if the bot can transfer and
|
||||
upgrade gifts owned by the business account.
|
||||
can_transfer_stars (:obj:`bool`, optional): True, if the bot can transfer Telegram Stars
|
||||
received by the business account to its own account, or use them to upgrade and
|
||||
transfer gifts.
|
||||
can_manage_stories (:obj:`bool`, optional): True, if the bot can post, edit and delete
|
||||
stories on behalf of the business account.
|
||||
|
||||
Attributes:
|
||||
can_reply (:obj:`bool`): Optional. True, if the bot can send and edit messages in the
|
||||
private chats that had incoming messages in the last 24 hours.
|
||||
can_read_messages (:obj:`bool`): Optional. True, if the bot can mark incoming private
|
||||
messages as read.
|
||||
can_delete_sent_messages (:obj:`bool`): Optional. True, if the bot can delete messages
|
||||
sent by the bot.
|
||||
can_delete_all_messages (:obj:`bool`): Optional. True, if the bot can delete all private
|
||||
messages in managed chats.
|
||||
can_edit_name (:obj:`bool`): Optional. True, if the bot can edit the first and last name
|
||||
of the business account.
|
||||
can_edit_bio (:obj:`bool`): Optional. True, if the bot can edit the bio of the
|
||||
business account.
|
||||
can_edit_profile_photo (:obj:`bool`): Optional. True, if the bot can edit the profile
|
||||
photo of the business account.
|
||||
can_edit_username (:obj:`bool`): Optional. True, if the bot can edit the username of the
|
||||
business account.
|
||||
can_change_gift_settings (:obj:`bool`): Optional. True, if the bot can change the privacy
|
||||
settings pertaining to gifts for the business account.
|
||||
can_view_gifts_and_stars (:obj:`bool`): Optional. True, if the bot can view gifts and the
|
||||
amount of Telegram Stars owned by the business account.
|
||||
can_convert_gifts_to_stars (:obj:`bool`): Optional. True, if the bot can convert regular
|
||||
gifts owned by the business account to Telegram Stars.
|
||||
can_transfer_and_upgrade_gifts (:obj:`bool`): Optional. True, if the bot can transfer and
|
||||
upgrade gifts owned by the business account.
|
||||
can_transfer_stars (:obj:`bool`): Optional. True, if the bot can transfer Telegram Stars
|
||||
received by the business account to its own account, or use them to upgrade and
|
||||
transfer gifts.
|
||||
can_manage_stories (:obj:`bool`): Optional. True, if the bot can post, edit and delete
|
||||
stories on behalf of the business account.
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
"can_change_gift_settings",
|
||||
"can_convert_gifts_to_stars",
|
||||
"can_delete_all_messages",
|
||||
"can_delete_sent_messages",
|
||||
"can_edit_bio",
|
||||
"can_edit_name",
|
||||
"can_edit_profile_photo",
|
||||
"can_edit_username",
|
||||
"can_manage_stories",
|
||||
"can_read_messages",
|
||||
"can_reply",
|
||||
"can_transfer_and_upgrade_gifts",
|
||||
"can_transfer_stars",
|
||||
"can_view_gifts_and_stars",
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
can_reply: Optional[bool] = None,
|
||||
can_read_messages: Optional[bool] = None,
|
||||
can_delete_sent_messages: Optional[bool] = None,
|
||||
can_delete_all_messages: Optional[bool] = None,
|
||||
can_edit_name: Optional[bool] = None,
|
||||
can_edit_bio: Optional[bool] = None,
|
||||
can_edit_profile_photo: Optional[bool] = None,
|
||||
can_edit_username: Optional[bool] = None,
|
||||
can_change_gift_settings: Optional[bool] = None,
|
||||
can_view_gifts_and_stars: Optional[bool] = None,
|
||||
can_convert_gifts_to_stars: Optional[bool] = None,
|
||||
can_transfer_and_upgrade_gifts: Optional[bool] = None,
|
||||
can_transfer_stars: Optional[bool] = None,
|
||||
can_manage_stories: Optional[bool] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.can_reply: Optional[bool] = can_reply
|
||||
self.can_read_messages: Optional[bool] = can_read_messages
|
||||
self.can_delete_sent_messages: Optional[bool] = can_delete_sent_messages
|
||||
self.can_delete_all_messages: Optional[bool] = can_delete_all_messages
|
||||
self.can_edit_name: Optional[bool] = can_edit_name
|
||||
self.can_edit_bio: Optional[bool] = can_edit_bio
|
||||
self.can_edit_profile_photo: Optional[bool] = can_edit_profile_photo
|
||||
self.can_edit_username: Optional[bool] = can_edit_username
|
||||
self.can_change_gift_settings: Optional[bool] = can_change_gift_settings
|
||||
self.can_view_gifts_and_stars: Optional[bool] = can_view_gifts_and_stars
|
||||
self.can_convert_gifts_to_stars: Optional[bool] = can_convert_gifts_to_stars
|
||||
self.can_transfer_and_upgrade_gifts: Optional[bool] = can_transfer_and_upgrade_gifts
|
||||
self.can_transfer_stars: Optional[bool] = can_transfer_stars
|
||||
self.can_manage_stories: Optional[bool] = can_manage_stories
|
||||
|
||||
self._id_attrs = (
|
||||
self.can_reply,
|
||||
self.can_read_messages,
|
||||
self.can_delete_sent_messages,
|
||||
self.can_delete_all_messages,
|
||||
self.can_edit_name,
|
||||
self.can_edit_bio,
|
||||
self.can_edit_profile_photo,
|
||||
self.can_edit_username,
|
||||
self.can_change_gift_settings,
|
||||
self.can_view_gifts_and_stars,
|
||||
self.can_convert_gifts_to_stars,
|
||||
self.can_transfer_and_upgrade_gifts,
|
||||
self.can_transfer_stars,
|
||||
self.can_manage_stories,
|
||||
)
|
||||
|
||||
self._freeze()
|
||||
|
||||
|
||||
class BusinessConnection(TelegramObject):
|
||||
"""
|
||||
Describes the connection of the bot with a business account.
|
||||
|
||||
Objects of this class are comparable in terms of equality. Two objects of this class are
|
||||
considered equal if their :attr:`id`, :attr:`user`, :attr:`user_chat_id`, :attr:`date`,
|
||||
:attr:`can_reply`, and :attr:`is_enabled` are equal.
|
||||
:attr:`rights`, and :attr:`is_enabled` are equal.
|
||||
|
||||
.. versionadded:: 21.1
|
||||
.. versionchanged:: 22.1
|
||||
Equality comparison now considers :attr:`rights` instead of :attr:`can_reply`.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier of the business connection.
|
||||
@@ -51,9 +203,15 @@ class BusinessConnection(TelegramObject):
|
||||
user_chat_id (:obj:`int`): Identifier of a private chat with the user who created the
|
||||
business connection.
|
||||
date (:obj:`datetime.datetime`): Date the connection was established in Unix time.
|
||||
can_reply (:obj:`bool`): True, if the bot can act on behalf of the business account in
|
||||
chats that were active in the last 24 hours.
|
||||
can_reply (:obj:`bool`, optional): True, if the bot can act on behalf of the business
|
||||
account in chats that were active in the last 24 hours.
|
||||
|
||||
.. deprecated:: 22.1
|
||||
Bot API 9.0 deprecated this argument in favor of :paramref:`rights`.
|
||||
is_enabled (:obj:`bool`): True, if the connection is active.
|
||||
rights (:class:`BusinessBotRights`, optional): Rights of the business bot.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Attributes:
|
||||
id (:obj:`str`): Unique identifier of the business connection.
|
||||
@@ -61,16 +219,18 @@ class BusinessConnection(TelegramObject):
|
||||
user_chat_id (:obj:`int`): Identifier of a private chat with the user who created the
|
||||
business connection.
|
||||
date (:obj:`datetime.datetime`): Date the connection was established in Unix time.
|
||||
can_reply (:obj:`bool`): True, if the bot can act on behalf of the business account in
|
||||
chats that were active in the last 24 hours.
|
||||
is_enabled (:obj:`bool`): True, if the connection is active.
|
||||
rights (:class:`BusinessBotRights`): Optional. Rights of the business bot.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
"can_reply",
|
||||
"_can_reply",
|
||||
"date",
|
||||
"id",
|
||||
"is_enabled",
|
||||
"rights",
|
||||
"user",
|
||||
"user_chat_id",
|
||||
)
|
||||
@@ -81,30 +241,67 @@ class BusinessConnection(TelegramObject):
|
||||
user: "User",
|
||||
user_chat_id: int,
|
||||
date: dtm.datetime,
|
||||
can_reply: bool,
|
||||
is_enabled: bool,
|
||||
can_reply: Optional[bool] = None,
|
||||
# temporarily optional to account for changed signature
|
||||
# tags: deprecated 22.1; bot api 9.0
|
||||
is_enabled: Optional[bool] = None,
|
||||
rights: Optional[BusinessBotRights] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
if is_enabled is None:
|
||||
raise TypeError("Missing required argument `is_enabled`")
|
||||
|
||||
if can_reply is not None:
|
||||
warn(
|
||||
PTBDeprecationWarning(
|
||||
version="22.1",
|
||||
message=build_deprecation_warning_message(
|
||||
deprecated_name="can_reply",
|
||||
new_name="rights",
|
||||
bot_api_version="9.0",
|
||||
object_type="parameter",
|
||||
),
|
||||
),
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.id: str = id
|
||||
self.user: User = user
|
||||
self.user_chat_id: int = user_chat_id
|
||||
self.date: dtm.datetime = date
|
||||
self.can_reply: bool = can_reply
|
||||
self._can_reply: Optional[bool] = can_reply
|
||||
self.is_enabled: bool = is_enabled
|
||||
self.rights: Optional[BusinessBotRights] = rights
|
||||
|
||||
self._id_attrs = (
|
||||
self.id,
|
||||
self.user,
|
||||
self.user_chat_id,
|
||||
self.date,
|
||||
self.can_reply,
|
||||
self.rights,
|
||||
self.is_enabled,
|
||||
)
|
||||
|
||||
self._freeze()
|
||||
|
||||
@property
|
||||
def can_reply(self) -> Optional[bool]:
|
||||
""":obj:`bool`: Optional. True, if the bot can act on behalf of the business account in
|
||||
chats that were active in the last 24 hours.
|
||||
|
||||
.. deprecated:: 22.1
|
||||
Bot API 9.0 deprecated this argument in favor of :attr:`rights`
|
||||
"""
|
||||
warn_about_deprecated_attr_in_property(
|
||||
deprecated_attr_name="can_reply",
|
||||
new_attr_name="rights",
|
||||
bot_api_version="9.0",
|
||||
ptb_version="22.1",
|
||||
)
|
||||
return self._can_reply
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: JSONDict, bot: Optional["Bot"] = None) -> "BusinessConnection":
|
||||
"""See :meth:`telegram.TelegramObject.de_json`."""
|
||||
@@ -115,6 +312,7 @@ class BusinessConnection(TelegramObject):
|
||||
|
||||
data["date"] = from_timestamp(data.get("date"), tzinfo=loc_tzinfo)
|
||||
data["user"] = de_json_optional(data.get("user"), User, bot)
|
||||
data["rights"] = de_json_optional(data.get("rights"), BusinessBotRights, bot)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
|
||||
|
||||
@@ -3506,6 +3506,41 @@ class _ChatBase(TelegramObject):
|
||||
**{"chat_id" if self.type == Chat.CHANNEL else "user_id": self.id},
|
||||
)
|
||||
|
||||
async def transfer_gift(
|
||||
self,
|
||||
business_connection_id: str,
|
||||
owned_gift_id: str,
|
||||
star_count: Optional[int] = None,
|
||||
*,
|
||||
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> bool:
|
||||
"""Shortcut for::
|
||||
|
||||
await bot.transfer_gift(new_owner_chat_id=update.effective_chat.id, *args, **kwargs )
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Bot.transfer_gift`.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
"""
|
||||
return await self.get_bot().transfer_gift(
|
||||
new_owner_chat_id=self.id,
|
||||
business_connection_id=business_connection_id,
|
||||
owned_gift_id=owned_gift_id,
|
||||
star_count=star_count,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
connect_timeout=connect_timeout,
|
||||
pool_timeout=pool_timeout,
|
||||
api_kwargs=api_kwargs,
|
||||
)
|
||||
|
||||
async def verify(
|
||||
self,
|
||||
custom_description: Optional[str] = None,
|
||||
@@ -3568,6 +3603,40 @@ class _ChatBase(TelegramObject):
|
||||
api_kwargs=api_kwargs,
|
||||
)
|
||||
|
||||
async def read_business_message(
|
||||
self,
|
||||
business_connection_id: str,
|
||||
message_id: int,
|
||||
*,
|
||||
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> bool:
|
||||
"""Shortcut for::
|
||||
|
||||
await bot.read_business_message(chat_id=update.effective_chat.id, *args, **kwargs)
|
||||
|
||||
For the documentation of the arguments, please see
|
||||
:meth:`telegram.Bot.read_business_message`.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
"""
|
||||
return await self.get_bot().read_business_message(
|
||||
chat_id=self.id,
|
||||
business_connection_id=business_connection_id,
|
||||
message_id=message_id,
|
||||
read_timeout=read_timeout,
|
||||
write_timeout=write_timeout,
|
||||
connect_timeout=connect_timeout,
|
||||
pool_timeout=pool_timeout,
|
||||
api_kwargs=api_kwargs,
|
||||
)
|
||||
|
||||
|
||||
class Chat(_ChatBase):
|
||||
"""This object represents a chat.
|
||||
|
||||
@@ -27,10 +27,17 @@ from telegram._chat import Chat, _ChatBase
|
||||
from telegram._chatlocation import ChatLocation
|
||||
from telegram._chatpermissions import ChatPermissions
|
||||
from telegram._files.chatphoto import ChatPhoto
|
||||
from telegram._gifts import AcceptedGiftTypes
|
||||
from telegram._reaction import ReactionType
|
||||
from telegram._utils.argumentparsing import de_json_optional, de_list_optional, parse_sequence_arg
|
||||
from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
|
||||
from telegram._utils.types import JSONDict
|
||||
from telegram._utils.warnings import warn
|
||||
from telegram._utils.warnings_transition import (
|
||||
build_deprecation_warning_message,
|
||||
warn_about_deprecated_attr_in_property,
|
||||
)
|
||||
from telegram.warnings import PTBDeprecationWarning
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import Bot, BusinessIntro, BusinessLocation, BusinessOpeningHours, Message
|
||||
@@ -64,6 +71,10 @@ class ChatFullInfo(_ChatBase):
|
||||
message in the chat.
|
||||
|
||||
.. versionadded:: 21.2
|
||||
accepted_gift_types (:class:`telegram.AcceptedGiftTypes`): Information about types of
|
||||
gifts that are accepted by the chat or by the corresponding user for private chats.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
title (:obj:`str`, optional): Title, for supergroups, channels and group chats.
|
||||
username (:obj:`str`, optional): Username, for private chats, supergroups and channels if
|
||||
available.
|
||||
@@ -204,6 +215,10 @@ class ChatFullInfo(_ChatBase):
|
||||
|
||||
.. versionadded:: 21.11
|
||||
|
||||
.. deprecated:: 22.1
|
||||
Bot API 9.0 introduced :paramref:`accepted_gift_types`, replacing this argument.
|
||||
Hence, this argument will be removed in future versions.
|
||||
|
||||
Attributes:
|
||||
id (:obj:`int`): Unique identifier for this chat.
|
||||
type (:obj:`str`): Type of chat, can be either :attr:`PRIVATE`, :attr:`GROUP`,
|
||||
@@ -218,6 +233,10 @@ class ChatFullInfo(_ChatBase):
|
||||
message in the chat.
|
||||
|
||||
.. versionadded:: 21.2
|
||||
accepted_gift_types (:class:`telegram.AcceptedGiftTypes`): Information about types of
|
||||
gifts that are accepted by the chat or by the corresponding user for private chats.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
title (:obj:`str`, optional): Title, for supergroups, channels and group chats.
|
||||
username (:obj:`str`, optional): Username, for private chats, supergroups and channels if
|
||||
available.
|
||||
@@ -357,16 +376,15 @@ class ChatFullInfo(_ChatBase):
|
||||
sent or forwarded to the channel chat. The field is available only for channel chats.
|
||||
|
||||
.. versionadded:: 21.4
|
||||
can_send_gift (:obj:`bool`): Optional. :obj:`True`, if gifts can be sent to the chat.
|
||||
|
||||
.. versionadded:: 21.11
|
||||
|
||||
.. _accent colors: https://core.telegram.org/bots/api#accent-colors
|
||||
.. _topics: https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
"_can_send_gift",
|
||||
"accent_color_id",
|
||||
"accepted_gift_types",
|
||||
"active_usernames",
|
||||
"available_reactions",
|
||||
"background_custom_emoji_id",
|
||||
@@ -375,7 +393,6 @@ class ChatFullInfo(_ChatBase):
|
||||
"business_intro",
|
||||
"business_location",
|
||||
"business_opening_hours",
|
||||
"can_send_gift",
|
||||
"can_send_paid_media",
|
||||
"can_set_sticker_set",
|
||||
"custom_emoji_sticker_set_name",
|
||||
@@ -452,7 +469,10 @@ class ChatFullInfo(_ChatBase):
|
||||
linked_chat_id: Optional[int] = None,
|
||||
location: Optional[ChatLocation] = None,
|
||||
can_send_paid_media: Optional[bool] = None,
|
||||
# tags: deprecated 22.1; bot api 9.0
|
||||
can_send_gift: Optional[bool] = None,
|
||||
# temporarily optional to account for changed signature
|
||||
accepted_gift_types: Optional[AcceptedGiftTypes] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
@@ -466,6 +486,22 @@ class ChatFullInfo(_ChatBase):
|
||||
is_forum=is_forum,
|
||||
api_kwargs=api_kwargs,
|
||||
)
|
||||
if accepted_gift_types is None:
|
||||
raise TypeError("`accepted_gift_type` is a required argument since Bot API 9.0")
|
||||
|
||||
if can_send_gift is not None:
|
||||
warn(
|
||||
PTBDeprecationWarning(
|
||||
"22.1",
|
||||
build_deprecation_warning_message(
|
||||
deprecated_name="can_send_gift",
|
||||
new_name="accepted_gift_types",
|
||||
object_type="parameter",
|
||||
bot_api_version="9.0",
|
||||
),
|
||||
),
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
# Required and unique to this class-
|
||||
with self._unfrozen():
|
||||
@@ -518,7 +554,27 @@ class ChatFullInfo(_ChatBase):
|
||||
self.business_location: Optional[BusinessLocation] = business_location
|
||||
self.business_opening_hours: Optional[BusinessOpeningHours] = business_opening_hours
|
||||
self.can_send_paid_media: Optional[bool] = can_send_paid_media
|
||||
self.can_send_gift: Optional[bool] = can_send_gift
|
||||
self._can_send_gift: Optional[bool] = can_send_gift
|
||||
self.accepted_gift_types: AcceptedGiftTypes = accepted_gift_types
|
||||
|
||||
@property
|
||||
def can_send_gift(self) -> Optional[bool]:
|
||||
"""
|
||||
:obj:`bool`: Optional. :obj:`True`, if gifts can be sent to the chat.
|
||||
|
||||
.. deprecated:: 22.1
|
||||
As Bot API 9.0 replaces this attribute with :attr:`accepted_gift_types`, this attribute
|
||||
will be removed in future versions.
|
||||
|
||||
"""
|
||||
warn_about_deprecated_attr_in_property(
|
||||
deprecated_attr_name="can_send_gift",
|
||||
new_attr_name="accepted_gift_types",
|
||||
bot_api_version="9.0",
|
||||
ptb_version="22.1",
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._can_send_gift
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: JSONDict, bot: Optional["Bot"] = None) -> "ChatFullInfo":
|
||||
@@ -533,6 +589,9 @@ class ChatFullInfo(_ChatBase):
|
||||
)
|
||||
|
||||
data["photo"] = de_json_optional(data.get("photo"), ChatPhoto, bot)
|
||||
data["accepted_gift_types"] = de_json_optional(
|
||||
data.get("accepted_gift_types"), AcceptedGiftTypes, bot
|
||||
)
|
||||
|
||||
from telegram import ( # pylint: disable=import-outside-toplevel
|
||||
BusinessIntro,
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2025
|
||||
# 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 objects that represent paid media in Telegram."""
|
||||
|
||||
import datetime as dtm
|
||||
from typing import Final, Optional, Union
|
||||
|
||||
from telegram import constants
|
||||
from telegram._files.inputfile import InputFile
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils import enum
|
||||
from telegram._utils.files import parse_file_input
|
||||
from telegram._utils.types import FileInput, JSONDict
|
||||
|
||||
|
||||
class InputStoryContent(TelegramObject):
|
||||
"""This object describes the content of a story to post. Currently, it can be one of:
|
||||
|
||||
* :class:`telegram.InputStoryContentPhoto`
|
||||
* :class:`telegram.InputStoryContentVideo`
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Args:
|
||||
type (:obj:`str`): Type of the content.
|
||||
|
||||
Attributes:
|
||||
type (:obj:`str`): Type of the content.
|
||||
"""
|
||||
|
||||
__slots__ = ("type",)
|
||||
|
||||
PHOTO: Final[str] = constants.InputStoryContentType.PHOTO
|
||||
""":const:`telegram.constants.InputStoryContentType.PHOTO`"""
|
||||
VIDEO: Final[str] = constants.InputStoryContentType.VIDEO
|
||||
""":const:`telegram.constants.InputStoryContentType.VIDEO`"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
type: str, # pylint: disable=redefined-builtin
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> None:
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.type: str = enum.get_member(constants.InputStoryContentType, type, type)
|
||||
|
||||
self._freeze()
|
||||
|
||||
@staticmethod
|
||||
def _parse_file_input(file_input: FileInput) -> Union[str, InputFile]:
|
||||
# We use local_mode=True because we don't have access to the actual setting and want
|
||||
# things to work in local mode.
|
||||
return parse_file_input(file_input, attach=True, local_mode=True)
|
||||
|
||||
|
||||
class InputStoryContentPhoto(InputStoryContent):
|
||||
"""Describes a photo to post as a story.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Args:
|
||||
photo (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
||||
optional): The photo to post as a story. The photo must be of the
|
||||
size :tg-const:`telegram.constants.InputStoryContentLimit.PHOTO_WIDTH`
|
||||
x :tg-const:`telegram.constants.InputStoryContentLimit.PHOTO_HEIGHT` and must not
|
||||
exceed :tg-const:`telegram.constants.InputStoryContentLimit.PHOTOSIZE_UPLOAD` MB.
|
||||
|uploadinputnopath|.
|
||||
|
||||
Attributes:
|
||||
type (:obj:`str`): Type of the content, must be :attr:`~telegram.InputStoryContent.PHOTO`.
|
||||
photo (:class:`telegram.InputFile`): The photo to post as a story. The photo must be of the
|
||||
size :tg-const:`telegram.constants.InputStoryContentLimit.PHOTO_WIDTH`
|
||||
x :tg-const:`telegram.constants.InputStoryContentLimit.PHOTO_HEIGHT` and must not
|
||||
exceed :tg-const:`telegram.constants.InputStoryContentLimit.PHOTOSIZE_UPLOAD` MB.
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ("photo",)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
photo: FileInput,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> None:
|
||||
super().__init__(type=InputStoryContent.PHOTO, api_kwargs=api_kwargs)
|
||||
|
||||
with self._unfrozen():
|
||||
self.photo: Union[str, InputFile] = self._parse_file_input(photo)
|
||||
|
||||
|
||||
class InputStoryContentVideo(InputStoryContent):
|
||||
"""
|
||||
Describes a video to post as a story.
|
||||
|
||||
.. versionadded:: 22.1
|
||||
|
||||
Args:
|
||||
video (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
||||
optional): The video to post as a story. The video must be of
|
||||
the size :tg-const:`telegram.constants.InputStoryContentLimit.VIDEO_WIDTH`
|
||||
x :tg-const:`telegram.constants.InputStoryContentLimit.VIDEO_HEIGHT`,
|
||||
streamable, encoded with ``H.265`` codec, with key frames added
|
||||
each second in the ``MPEG4`` format, and must not exceed
|
||||
:tg-const:`telegram.constants.InputStoryContentLimit.VIDEOSIZE_UPLOAD` MB.
|
||||
|uploadinputnopath|.
|
||||
duration (:class:`datetime.timedelta` | :obj:`int` | :obj:`float`, optional): Precise
|
||||
duration of the video in seconds;
|
||||
0-:tg-const:`telegram.constants.InputStoryContentLimit.MAX_VIDEO_DURATION`
|
||||
cover_frame_timestamp (:class:`datetime.timedelta` | :obj:`int` | :obj:`float`, optional):
|
||||
Timestamp in seconds of the frame that will be used as the static cover for the story.
|
||||
Defaults to ``0.0``.
|
||||
is_animation (:obj:`bool`, optional): Pass :obj:`True` if the video has no sound
|
||||
|
||||
Attributes:
|
||||
type (:obj:`str`): Type of the content, must be :attr:`~telegram.InputStoryContent.VIDEO`.
|
||||
video (:class:`telegram.InputFile`): The video to post as a story. The video must be of
|
||||
the size :tg-const:`telegram.constants.InputStoryContentLimit.VIDEO_WIDTH`
|
||||
x :tg-const:`telegram.constants.InputStoryContentLimit.VIDEO_HEIGHT`,
|
||||
streamable, encoded with ``H.265`` codec, with key frames added
|
||||
each second in the ``MPEG4`` format, and must not exceed
|
||||
:tg-const:`telegram.constants.InputStoryContentLimit.VIDEOSIZE_UPLOAD` MB.
|
||||
duration (:class:`datetime.timedelta`): Optional. Precise duration of the video in seconds;
|
||||
0-:tg-const:`telegram.constants.InputStoryContentLimit.MAX_VIDEO_DURATION`
|
||||
cover_frame_timestamp (:class:`datetime.timedelta`): Optional. Timestamp in seconds of the
|
||||
frame that will be used as the static cover for the story. Defaults to ``0.0``.
|
||||
is_animation (:obj:`bool`): Optional. Pass :obj:`True` if the video has no sound
|
||||
"""
|
||||
|
||||
__slots__ = ("cover_frame_timestamp", "duration", "is_animation", "video")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
video: FileInput,
|
||||
duration: Optional[Union[float, dtm.timedelta]] = None,
|
||||
cover_frame_timestamp: Optional[Union[float, dtm.timedelta]] = None,
|
||||
is_animation: Optional[bool] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> None:
|
||||
super().__init__(type=InputStoryContent.VIDEO, api_kwargs=api_kwargs)
|
||||
|
||||
with self._unfrozen():
|
||||
self.video: Union[str, InputFile] = self._parse_file_input(video)
|
||||
self.duration: Optional[dtm.timedelta] = self._parse_period_arg(duration)
|
||||
self.cover_frame_timestamp: Optional[dtm.timedelta] = self._parse_period_arg(
|
||||
cover_frame_timestamp
|
||||
)
|
||||
self.is_animation: Optional[bool] = is_animation
|
||||
|
||||
# This helper is temporarly here until we can use `argumentparsing.parse_period_arg`
|
||||
# from https://github.com/python-telegram-bot/python-telegram-bot/pull/4750
|
||||
@staticmethod
|
||||
def _parse_period_arg(arg: Optional[Union[float, dtm.timedelta]]) -> Optional[dtm.timedelta]:
|
||||
if arg is None:
|
||||
return None
|
||||
if isinstance(arg, dtm.timedelta):
|
||||
return arg
|
||||
return dtm.timedelta(seconds=arg)
|
||||
@@ -51,13 +51,8 @@ class InputMedia(TelegramObject):
|
||||
|
||||
Args:
|
||||
media_type (:obj:`str`): Type of media that the instance represents.
|
||||
media (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | :obj:`bytes` | \
|
||||
:class:`pathlib.Path` | :class:`telegram.Animation` | :class:`telegram.Audio` | \
|
||||
:class:`telegram.Document` | :class:`telegram.PhotoSize` | \
|
||||
:class:`telegram.Video`): File to send.
|
||||
media (:obj:`str` | :class:`~telegram.InputFile`): File to send.
|
||||
|fileinputnopath|
|
||||
Lastly you can pass an existing telegram media object of the corresponding type
|
||||
to send.
|
||||
caption (:obj:`str`, optional): Caption of the media to be sent,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities
|
||||
parsing.
|
||||
@@ -89,7 +84,7 @@ class InputMedia(TelegramObject):
|
||||
def __init__(
|
||||
self,
|
||||
media_type: str,
|
||||
media: Union[str, InputFile, MediaType],
|
||||
media: Union[str, InputFile],
|
||||
caption: Optional[str] = None,
|
||||
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
||||
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
||||
@@ -98,7 +93,7 @@ class InputMedia(TelegramObject):
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.type: str = enum.get_member(constants.InputMediaType, media_type, media_type)
|
||||
self.media: Union[str, InputFile, Animation, Audio, Document, PhotoSize, Video] = media
|
||||
self.media: Union[str, InputFile] = media
|
||||
self.caption: Optional[str] = caption
|
||||
self.caption_entities: tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
|
||||
self.parse_mode: ODVInput[str] = parse_mode
|
||||
@@ -120,8 +115,8 @@ class InputPaidMedia(TelegramObject):
|
||||
"""
|
||||
Base class for Telegram InputPaidMedia Objects. Currently, it can be one of:
|
||||
|
||||
* :class:`telegram.InputMediaPhoto`
|
||||
* :class:`telegram.InputMediaVideo`
|
||||
* :class:`telegram.InputPaidMediaPhoto`
|
||||
* :class:`telegram.InputPaidMediaVideo`
|
||||
|
||||
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
||||
|
||||
@@ -129,11 +124,8 @@ class InputPaidMedia(TelegramObject):
|
||||
|
||||
Args:
|
||||
type (:obj:`str`): Type of media that the instance represents.
|
||||
media (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | :obj:`bytes` | \
|
||||
:class:`pathlib.Path` | :class:`telegram.PhotoSize` | :class:`telegram.Video`): File
|
||||
media (:obj:`str` | :class:`~telegram.InputFile`): File
|
||||
to send. |fileinputnopath|
|
||||
Lastly you can pass an existing telegram media object of the corresponding type
|
||||
to send.
|
||||
|
||||
Attributes:
|
||||
type (:obj:`str`): Type of the input media.
|
||||
@@ -150,13 +142,13 @@ class InputPaidMedia(TelegramObject):
|
||||
def __init__(
|
||||
self,
|
||||
type: str, # pylint: disable=redefined-builtin
|
||||
media: Union[str, InputFile, PhotoSize, Video],
|
||||
media: Union[str, InputFile],
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.type: str = enum.get_member(constants.InputPaidMediaType, type, type)
|
||||
self.media: Union[str, InputFile, PhotoSize, Video] = media
|
||||
self.media: Union[str, InputFile] = media
|
||||
|
||||
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