Seraph19 commited on
Commit
36367b2
1 Parent(s): 7abc8a8

Upload 117 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.git-blame-ignore-revs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # .git-blame-ignore-revs
2
+ # Use locally as `git blame file.py --ignore-revs-file .git-blame-ignore-revs`
3
+ # or configure git to always use it: `git config blame.ignoreRevsFile .git-blame-ignore-revs`
4
+ # First migration to code style Black (#2122)
5
+ 264b2c9c72691c5937b80e84e061c52dd2d8861a
6
+ # Use Black more extensively (#2972)
7
+ 950d9a0751d79b92d78ea44344ce3e3c5b3948f9
.gitignore ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+
5
+ # C extensions
6
+ *.so
7
+
8
+ # Distribution / packaging
9
+ .Python
10
+ env/
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+ .env
26
+ .pybuild
27
+ debian/tmp
28
+ debian/python3-telegram
29
+ debian/python3-telegram-doc
30
+ debian/.debhelper
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ .pytest_cache
49
+ .mypy_cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *,cover
53
+ .coveralls.yml
54
+ .testmondata
55
+ .testmondata-journal
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+
64
+ # Sphinx documentation
65
+ docs/_build/
66
+
67
+ # PyBuilder
68
+ target/
69
+ .idea/
70
+
71
+ # Sublime Text 2
72
+ *.sublime*
73
+
74
+ # VS Code
75
+ .vscode
76
+
77
+ # unitests files
78
+ game.gif
79
+ telegram.mp3
80
+ telegram.mp4
81
+ telegram2.mp4
82
+ telegram.ogg
83
+ telegram.png
84
+ telegram.webp
85
+ telegram.jpg
86
+
87
+ # original files from merges
88
+ *.orig
89
+
90
+ # Exclude .exrc file for Vim
91
+ .exrc
92
+
93
+ # virtual env
94
+ venv*
95
+
96
+ # environment manager:
97
+ .mise.toml
.pre-commit-config.yaml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Make sure that the additional_dependencies here match pyproject.toml
2
+
3
+ ci:
4
+ autofix_prs: false
5
+ autoupdate_schedule: quarterly
6
+ autoupdate_commit_msg: 'Bump `pre-commit` Hooks to Latest Versions'
7
+
8
+ repos:
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: 'v0.5.6'
11
+ hooks:
12
+ - id: ruff
13
+ name: ruff
14
+ additional_dependencies:
15
+ - httpx~=0.27
16
+ - tornado~=6.4
17
+ - APScheduler~=3.10.4
18
+ - cachetools>=5.3.3,<5.5.0
19
+ - aiolimiter~=1.1.0
20
+ - repo: https://github.com/psf/black-pre-commit-mirror
21
+ rev: 24.4.2
22
+ hooks:
23
+ - id: black
24
+ args:
25
+ - --diff
26
+ - --check
27
+ - repo: https://github.com/PyCQA/flake8
28
+ rev: 7.1.0
29
+ hooks:
30
+ - id: flake8
31
+ - repo: https://github.com/PyCQA/pylint
32
+ rev: v3.2.4
33
+ hooks:
34
+ - id: pylint
35
+ files: ^(?!(tests|docs)).*\.py$
36
+ additional_dependencies:
37
+ - httpx~=0.27
38
+ - tornado~=6.4
39
+ - APScheduler~=3.10.4
40
+ - cachetools>=5.3.3,<5.5.0
41
+ - aiolimiter~=1.1.0
42
+ - . # this basically does `pip install -e .`
43
+ - repo: https://github.com/pre-commit/mirrors-mypy
44
+ rev: v1.10.1
45
+ hooks:
46
+ - id: mypy
47
+ name: mypy-ptb
48
+ files: ^(?!(tests|examples|docs)).*\.py$
49
+ additional_dependencies:
50
+ - types-pytz
51
+ - types-cryptography
52
+ - types-cachetools
53
+ - httpx~=0.27
54
+ - tornado~=6.4
55
+ - APScheduler~=3.10.4
56
+ - cachetools>=5.3.3,<5.5.0
57
+ - aiolimiter~=1.1.0
58
+ - . # this basically does `pip install -e .`
59
+ - id: mypy
60
+ name: mypy-examples
61
+ files: ^examples/.*\.py$
62
+ args:
63
+ - --no-strict-optional
64
+ - --follow-imports=silent
65
+ additional_dependencies:
66
+ - tornado~=6.4
67
+ - APScheduler~=3.10.4
68
+ - cachetools>=5.3.3,<5.5.0
69
+ - . # this basically does `pip install -e .`
70
+ - repo: https://github.com/asottile/pyupgrade
71
+ rev: v3.16.0
72
+ hooks:
73
+ - id: pyupgrade
74
+ args:
75
+ - --py38-plus
76
+ - repo: https://github.com/pycqa/isort
77
+ rev: 5.13.2
78
+ hooks:
79
+ - id: isort
80
+ name: isort
81
+ args:
82
+ - --diff
83
+ - --check
.readthedocs.yml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # .readthedocs.yaml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Build documentation in the docs/ directory with Sphinx
9
+ sphinx:
10
+ configuration: docs/source/conf.py
11
+
12
+ # Optionally build your docs in additional formats such as PDF
13
+ formats:
14
+ - pdf
15
+
16
+ # Optionally set the version of Python and requirements required to build your docs
17
+ python:
18
+ install:
19
+ - method: pip
20
+ path: .
21
+ - requirements: docs/requirements-docs.txt
22
+
23
+ build:
24
+ os: ubuntu-22.04
25
+ tools:
26
+ python: "3" # latest stable cpython version
27
+ jobs:
28
+ post_build:
29
+ # Based on https://github.com/readthedocs/readthedocs.org/issues/3242#issuecomment-1410321534
30
+ # This provides a HTML zip file for download, with the same structure as the hosted website
31
+ - mkdir --parents $READTHEDOCS_OUTPUT/htmlzip
32
+ - cp --recursive $READTHEDOCS_OUTPUT/html $READTHEDOCS_OUTPUT/$READTHEDOCS_PROJECT
33
+ # Hide the "other versions" dropdown. This is a workaround for those versions being shown,
34
+ # but not being accessible, as they are not built. Also, they hide the actual sidebar menu
35
+ # that is relevant only on ReadTheDocs.
36
+ - echo "#furo-readthedocs-versions{display:none}" >> $READTHEDOCS_OUTPUT/$READTHEDOCS_PROJECT/_static/styles/furo-extensions.css
37
+ - cd $READTHEDOCS_OUTPUT ; zip --recurse-path --symlinks htmlzip/$READTHEDOCS_PROJECT.zip $READTHEDOCS_PROJECT
38
+
39
+ search:
40
+ ranking: # bump up rank of commonly searched pages: (default: 0, values range from -10 to 10)
41
+ telegram.bot.html: 7
42
+ telegram.message.html: 3
43
+ telegram.update.html: 3
44
+ telegram.user.html: 2
45
+ telegram.chat.html: 2
46
+ telegram.ext.application.html: 3
47
+ telegram.ext.filters.html: 3
48
+ telegram.ext.callbackcontext.html: 2
49
+ telegram.ext.inlinekeyboardbutton.html: 1
50
+
51
+ telegram.passport*.html: -7
52
+
53
+ ignore:
54
+ - changelog.html
55
+ - coc.html
56
+ - bot_methods.html#
57
+ - bot_methods.html
58
+ # Defaults
59
+ - search.html
60
+ - search/index.html
61
+ - 404.html
62
+ - 404/index.html'
AUTHORS.rst ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Credits
2
+ =======
3
+
4
+ ``python-telegram-bot`` was originally created by
5
+ `Leandro Toledo <https://github.com/leandrotoledo>`_.
6
+ The current development team includes
7
+
8
+ - `Hinrich Mahler <https://github.com/Bibo-Joshi>`_ (maintainer)
9
+ - `Poolitzer <https://github.com/Poolitzer>`_ (community liaison)
10
+ - `Shivam <https://github.com/Starry69>`_
11
+ - `Harshil <https://github.com/harshil21>`_
12
+ - `Dmitry Kolomatskiy <https://github.com/lemontree210>`_
13
+ - `Aditya <https://github.com/clot27>`_
14
+
15
+ Emeritus maintainers include
16
+ `Jannes Höke <https://github.com/jh0ker>`_ (`@jh0ker <https://t.me/jh0ker>`_ on Telegram),
17
+ `Noam Meltzer <https://github.com/tsnoam>`_, `Pieter Schutz <https://github.com/eldinnie>`_ and `Jasmin Bom <https://github.com/jsmnbom>`_.
18
+
19
+ Contributors
20
+ ------------
21
+
22
+ The following wonderful people contributed directly or indirectly to this project:
23
+
24
+ - `Abdelrahman <https://github.com/aelkheir>`_
25
+ - `Abshar <https://github.com/abxhr>`_
26
+ - `Alateas <https://github.com/alateas>`_
27
+ - `Ales Dokshanin <https://github.com/alesdokshanin>`_
28
+ - `Alexandre <https://github.com/xTudoS>`_
29
+ - `Alizia <https://github.com/thefunkycat>`_
30
+ - `Ambro17 <https://github.com/Ambro17>`_
31
+ - `Andrej Zhilenkov <https://github.com/Andrej730>`_
32
+ - `Anton Tagunov <https://github.com/anton-tagunov>`_
33
+ - `Avanatiker <https://github.com/Avanatiker>`_
34
+ - `Balduro <https://github.com/Balduro>`_
35
+ - `Bibo-Joshi <https://github.com/Bibo-Joshi>`_
36
+ - `Biruk Alamirew <https://github.com/BAcode-X>`_
37
+ - `bimmlerd <https://github.com/bimmlerd>`_
38
+ - `cyc8 <https://github.com/cyc8>`_
39
+ - `d-qoi <https://github.com/d-qoi>`_
40
+ - `daimajia <https://github.com/daimajia>`_
41
+ - `Daniel Reed <https://github.com/nmlorg>`_
42
+ - `D David Livingston <https://github.com/daviddl9>`_
43
+ - `DonalDuck004 <https://github.com/DonalDuck004>`_
44
+ - `Eana Hufwe <https://github.com/blueset>`_
45
+ - `Ehsan Online <https://github.com/ehsanonline>`_
46
+ - `Eldad Carin <https://github.com/eldbud>`_
47
+ - `Eli Gao <https://github.com/eligao>`_
48
+ - `Emilio Molinari <https://github.com/xates>`_
49
+ - `ErgoZ Riftbit Vaper <https://github.com/ergoz>`_
50
+ - `Eugene Lisitsky <https://github.com/lisitsky>`_
51
+ - `Eugenio Panadero <https://github.com/azogue>`_
52
+ - `Evan Haberecht <https://github.com/habereet>`_
53
+ - `Evgeny Denisov <https://github.com/eIGato>`_
54
+ - `evgfilim1 <https://github.com/evgfilim1>`_
55
+ - `ExalFabu <https://github.com/ExalFabu>`_
56
+ - `franciscod <https://github.com/franciscod>`_
57
+ - `gamgi <https://github.com/gamgi>`_
58
+ - `Gauthamram Ravichandran <https://github.com/GauthamramRavichandran>`_
59
+ - `Harshil <https://github.com/harshil21>`_
60
+ - `Hugo Damer <https://github.com/HakimusGIT>`_
61
+ - `ihoru <https://github.com/ihoru>`_
62
+ - `Iulian Onofrei <https://github.com/revolter>`_
63
+ - `Jainam Oswal <https://github.com/jainamoswal>`_
64
+ - `Jasmin Bom <https://github.com/jsmnbom>`_
65
+ - `JASON0916 <https://github.com/JASON0916>`_
66
+ - `jeffffc <https://github.com/jeffffc>`_
67
+ - `Jelle Besseling <https://github.com/pingiun>`_
68
+ - `jh0ker <https://github.com/jh0ker>`_
69
+ - `jlmadurga <https://github.com/jlmadurga>`_
70
+ - `John Yong <https://github.com/whipermr5>`_
71
+ - `Joscha Götzer <https://github.com/Rostgnom>`_
72
+ - `jossalgon <https://github.com/jossalgon>`_
73
+ - `JRoot3D <https://github.com/JRoot3D>`_
74
+ - `kenjitagawa <https://github.com/kenjitagawa>`_
75
+ - `kennethcheo <https://github.com/kennethcheo>`_
76
+ - `Kirill Vasin <https://github.com/vasinkd>`_
77
+ - `Kjwon15 <https://github.com/kjwon15>`_
78
+ - `Li-aung Yip <https://github.com/LiaungYip>`_
79
+ - `Loo Zheng Yuan <https://github.com/loozhengyuan>`_
80
+ - `LRezende <https://github.com/lrezende>`_
81
+ - `Luca Bellanti <https://github.com/Trifase>`_
82
+ - `Lucas Molinari <https://github.com/lucasmolinari>`_
83
+ - `macrojames <https://github.com/macrojames>`_
84
+ - `Matheus Lemos <https://github.com/mlemosf>`_
85
+ - `Michael Dix <https://github.com/Eisberge>`_
86
+ - `Michael Elovskikh <https://github.com/wronglink>`_
87
+ - `Miguel C. R. <https://github.com/MiguelX413>`_
88
+ - `miles <https://github.com/miles170>`_
89
+ - `Mischa Krüger <https://github.com/Makman2>`_
90
+ - `Mohd Yusuf <https://github.com/mohdyusuf2312>`_
91
+ - `naveenvhegde <https://github.com/naveenvhegde>`_
92
+ - `neurrone <https://github.com/neurrone>`_
93
+ - `NikitaPirate <https://github.com/NikitaPirate>`_
94
+ - `Nikolai Krivenko <https://github.com/nkrivenko>`_
95
+ - `njittam <https://github.com/njittam>`_
96
+ - `Noam Meltzer <https://github.com/tsnoam>`_
97
+ - `Oleg Shlyazhko <https://github.com/ollmer>`_
98
+ - `Oleg Sushchenko <https://github.com/feuillemorte>`_
99
+ - `Or Bin <https://github.com/OrBin>`_
100
+ - `overquota <https://github.com/overquota>`_
101
+ - `Pablo Martinez <https://github.com/elpekenin>`_
102
+ - `Paradox <https://github.com/paradox70>`_
103
+ - `Patrick Hofmann <https://github.com/PH89>`_
104
+ - `Paul Larsen <https://github.com/PaulSonOfLars>`_
105
+ - `Pawan <https://github.com/pawanrai9999>`_
106
+ - `Pieter Schutz <https://github.com/eldinnie>`_
107
+ - `Piraty <https://github.com/piraty>`_
108
+ - `Poolitzer <https://github.com/Poolitzer>`_
109
+ - `Pranjalya Tiwari <https://github.com/Pranjalya>`_
110
+ - `Rahiel Kasim <https://github.com/rahiel>`_
111
+ - `Riko Naka <https://github.com/rikonaka>`_
112
+ - `Rizlas <https://github.com/rizlas>`_
113
+ - `Sahil Sharma <https://github.com/sahilsharma811>`_
114
+ - `Sam Mosleh <https://github.com/sam-mosleh>`_
115
+ - `Sascha <https://github.com/saschalalala>`_
116
+ - `Shelomentsev D <https://github.com/shelomentsevd>`_
117
+ - `Shivam Saini <https://github.com/shivamsn97>`_
118
+ - `Simon Schürrle <https://github.com/SitiSchu>`_
119
+ - `sooyhwang <https://github.com/sooyhwang>`_
120
+ - `syntx <https://github.com/syntx>`_
121
+ - `thodnev <https://github.com/thodnev>`_
122
+ - `Timur Kushukov <https://github.com/timqsh>`_
123
+ - `Trainer Jono <https://github.com/Tr-Jono>`_
124
+ - `Valentijn <https://github.com/Faalentijn>`_
125
+ - `voider1 <https://github.com/voider1>`_
126
+ - `Vorobjev Simon <https://github.com/simonvorobjev>`_
127
+ - `Wagner Macedo <https://github.com/wagnerluis1982>`_
128
+ - `wjt <https://github.com/wjt>`_
129
+ - `Wonseok Oh <https://github.com/marinelay>`_
130
+ - `Yaw Danso <https://github.com/dglitxh>`_
131
+ - `Yao Kuan <https://github.com/thatguylah>`_
132
+ - `zeroone2numeral2 <https://github.com/zeroone2numeral2>`_
133
+ - `zeshuaro <https://github.com/zeshuaro>`_
134
+ - `zpavloudis <https://github.com/zpavloudis>`_
135
+
136
+
137
+ Please add yourself here alphabetically when you submit your first pull request.
CHANGES.rst ADDED
@@ -0,0 +1,2630 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .. _ptb-changelog:
2
+
3
+ =========
4
+ Changelog
5
+ =========
6
+
7
+ Version 21.5
8
+ ============
9
+
10
+ *Released 2024-09-01*
11
+
12
+ This is the technical changelog for version 21.5. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
13
+
14
+ Major Changes
15
+ -------------
16
+
17
+ - Full Support for Bot API 7.9 (:pr:`4429`)
18
+ - Full Support for Bot API 7.8 (:pr:`4408`)
19
+
20
+ New Features
21
+ ------------
22
+
23
+ - Add ``MessageEntity.shift_entities`` and ``MessageEntity.concatenate`` (:pr:`4376` closes :issue:`4372`)
24
+ - Add Parameter ``game_pattern`` to ``CallbackQueryHandler`` (:pr:`4353` by `jainamoswal <https://github.com/jainamoswal>`_ closes :issue:`4269`)
25
+ - Add Parameter ``read_file_handle`` to ``InputFile`` (:pr:`4388` closes :issue:`4339`)
26
+
27
+ Documentation Improvements
28
+ --------------------------
29
+
30
+ - Bugfix for "Available In" Admonitions (:pr:`4413`)
31
+ - Documentation Improvements (:pr:`4400` closes :issue:`4446`, :pr:`4448` by `Palaptin <https://github.com/Palaptin>`_)
32
+ - Document Return Types of ``RequestData`` Members (:pr:`4396`)
33
+ - Add Introductory Paragraphs to Telegram Types Subsections (:pr:`4389` by `mohdyusuf2312 <https://github.com/mohdyusuf2312>`_ closes :issue:`4380`)
34
+ - Start Adapting to RTD Addons (:pr:`4386`)
35
+
36
+ Minor and Internal Changes
37
+ ---------------------------
38
+
39
+ - Remove Surplus Logging from ``Updater`` Network Loop (:pr:`4432` by `MartinHjelmare <https://github.com/MartinHjelmare>`_)
40
+ - Add Internal Constants for Encodings (:pr:`4378` by `elpekenin <https://github.com/elpekenin>`_)
41
+ - Improve PyPI Automation (:pr:`4375` closes :issue:`4373`)
42
+ - Update Test Suite to New Test Channel Setup (:pr:`4435`)
43
+ - Improve Fixture Usage in ``test_message.py`` (:pr:`4431` by `Palaptin <https://github.com/Palaptin>`_)
44
+ - Update Python 3.13 Test Suite to RC1 (:pr:`4415`)
45
+ - Bump ``ruff`` and Add New Rules (:pr:`4416`)
46
+
47
+ Dependency Updates
48
+ ------------------
49
+
50
+ - Update ``cachetools`` requirement from <5.5.0,>=5.3.3 to >=5.3.3,<5.6.0 (:pr:`4437`)
51
+ - Bump ``sphinx`` from 7.4.7 to 8.0.2 and ``furo`` from 2024.7.18 to 2024.8.6 (:pr:`4412`)
52
+ - Bump ``test-summary/action`` from 2.3 to 2.4 (:pr:`4410`)
53
+ - Bump ``pytest`` from 8.2.2 to 8.3.2 (:pr:`4403`)
54
+ - Bump ``dependabot/fetch-metadata`` from 2.1.0 to 2.2.0 (:pr:`4411`)
55
+ - Update ``cachetools`` requirement from ~=5.3.3 to >=5.3.3,<5.5.0 (:pr:`4390`)
56
+ - Bump ``sphinx`` from 7.3.7 to 7.4.7 (:pr:`4395`)
57
+ - Bump ``furo`` from 2024.5.6 to 2024.7.18 (:pr:`4392`)
58
+
59
+ Version 21.4
60
+ ============
61
+
62
+ *Released 2024-07-12*
63
+
64
+ This is the technical changelog for version 21.4. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
65
+
66
+ Major Changes
67
+ -------------
68
+
69
+ - Full Support for Bot API 7.5 (:pr:`4328`, :pr:`4316`, :pr:`4315`, :pr:`4312` closes :issue:`4310`, :pr:`4311`)
70
+ - Full Support for Bot API 7.6 (:pr:`4333` closes :issue:`4331`, :pr:`4344`, :pr:`4341`, :pr:`4334`, :pr:`4335`, :pr:`4351`, :pr:`4342`, :pr:`4348`)
71
+ - Full Support for Bot API 7.7 (:pr:`4356` closes :issue:`4355`)
72
+ - Drop ``python-telegram-bot-raw`` And Switch to ``pyproject.toml`` Based Packaging (:pr:`4288` closes :issue:`4129` and :issue:`4296`)
73
+ - Deprecate Inclusion of ``successful_payment`` in ``Message.effective_attachment`` (:pr:`4365` closes :issue:`4350`)
74
+
75
+ New Features
76
+ ------------
77
+
78
+ - Add Support for Python 3.13 Beta (:pr:`4253`)
79
+ - Add ``filters.PAID_MEDIA`` (:pr:`4357`)
80
+ - Log Received Data on Deserialization Errors (:pr:`4304`)
81
+ - Add ``MessageEntity.adjust_message_entities_to_utf_16`` Utility Function (:pr:`4323` by `Antares0982 <https://github.com/Antares0982>`_ closes :issue:`4319`)
82
+ - Make Argument ``bot`` of ``TelegramObject.de_json`` Optional (:pr:`4320`)
83
+
84
+ Documentation Improvements
85
+ --------------------------
86
+
87
+ - Documentation Improvements (:pr:`4303` closes :issue:`4301`)
88
+ - Restructure Readme (:pr:`4362`)
89
+ - Fix Link-Check Workflow (:pr:`4332`)
90
+
91
+ Internal Changes
92
+ ----------------
93
+
94
+ - Automate PyPI Releases (:pr:`4364` closes :issue:`4318`)
95
+ - Add ``mise-en-place`` to ``.gitignore`` (:pr:`4300`)
96
+ - Use a Composite Action for Testing Type Completeness (:pr:`4367`)
97
+ - Stabilize Some Concurrency Usages in Test Suite (:pr:`4360`)
98
+ - Add a Test Case for ``MenuButton`` (:pr:`4363`)
99
+ - Extend ``SuccessfulPayment`` Test (:pr:`4349`)
100
+ - Small Fixes for ``test_stars.py`` (:pr:`4347`)
101
+ - Use Python 3.13 Beta 3 in Test Suite (:pr:`4336`)
102
+
103
+ Dependency Updates
104
+ ------------------
105
+
106
+ - Bump ``ruff`` and Add New Rules (:pr:`4329`)
107
+ - Bump ``pre-commit`` Hooks to Latest Versions (:pr:`4337`)
108
+ - Add Lower Bound for ``flaky`` Dependency (:pr:`4322` by `Palaptin <https://github.com/Palaptin>`_)
109
+ - Bump ``pytest`` from 8.2.1 to 8.2.2 (:pr:`4294`)
110
+
111
+ Version 21.3
112
+ ============
113
+ *Released 2024-06-07*
114
+
115
+ This is the technical changelog for version 21.3. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
116
+
117
+ Major Changes
118
+ -------------
119
+
120
+ - Full Support for Bot API 7.4 (:pr:`4286`, :pr:`4276` closes :issue:`4275`, :pr:`4285`, :pr:`4283`, :pr:`4280`, :pr:`4278`, :pr:`4279`)
121
+ - Deprecate ``python-telegram-bot-raw`` (:pr:`4270`)
122
+ - Remove Functionality Deprecated in Bot API 7.3 (:pr:`4266` closes :issue:`4244`)
123
+
124
+ New Features
125
+ ------------
126
+
127
+ - Add Parameter ``chat_id`` to ``ChatMemberHandler`` (:pr:`4290` by `uniquetrij <https://github.com/uniquetrij>`_ closes :issue:`4287`)
128
+
129
+ Documentation Improvements
130
+ --------------------------
131
+
132
+ - Documentation Improvements (:pr:`4264` closes :issue:`4240`)
133
+
134
+ Internal Changes
135
+ ----------------
136
+
137
+ - Add ``setuptools`` to ``requirements-dev.txt`` (:pr:`4282`)
138
+ - Update Settings for pre-commit.ci (:pr:`4265`)
139
+
140
+ Dependency Updates
141
+ ------------------
142
+
143
+ - Bump ``pytest`` from 8.2.0 to 8.2.1 (:pr:`4272`)
144
+
145
+ Version 21.2
146
+ ============
147
+
148
+ *Released 2024-05-20*
149
+
150
+ This is the technical changelog for version 21.2. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
151
+
152
+ Major Changes
153
+ -------------
154
+
155
+ - Full Support for Bot API 7.3 (:pr:`4246`, :pr:`4260`, :pr:`4243`, :pr:`4248`, :pr:`4242` closes :issue:`4236`, :pr:`4247` by `aelkheir <https://github.com/aelkheir>`_)
156
+ - Remove Functionality Deprecated by Bot API 7.2 (:pr:`4245`)
157
+
158
+ New Features
159
+ ------------
160
+
161
+ - Add Version to ``PTBDeprecationWarning`` (:pr:`4262` closes :issue:`4261`)
162
+ - Handle Exceptions in building ``CallbackContext`` (:pr:`4222`)
163
+
164
+ Bug Fixes
165
+ ---------
166
+
167
+ - Call ``Application.post_stop`` Only if ``Application.stop`` was called (:pr:`4211` closes :issue:`4210`)
168
+ - Handle ``SystemExit`` raised in Handlers (:pr:`4157` closes :issue:`4155` and :issue:`4156`)
169
+ - Make ``Birthdate.to_date`` Return a ``datetime.date`` Object (:pr:`4251`)
170
+
171
+ Documentation Improvements
172
+ --------------------------
173
+
174
+ - Documentation Improvements (:pr:`4217`)
175
+
176
+ Internal Changes
177
+ ----------------
178
+
179
+ - Add New Rules to ``ruff`` Config (:pr:`4250`)
180
+ - Adapt Test Suite to Changes in Error Messages (:pr:`4238`)
181
+
182
+ Dependency Updates
183
+ ------------------
184
+
185
+ - Bump ``furo`` from 2024.4.27 to 2024.5.6 (:pr:`4252`)
186
+ - ``pre-commit`` autoupdate (:pr:`4239`)
187
+ - Bump ``pytest`` from 8.1.1 to 8.2.0 (:pr:`4231`)
188
+ - Bump ``dependabot/fetch-metadata`` from 2.0.0 to 2.1.0 (:pr:`4228`)
189
+ - Bump ``pytest-asyncio`` from 0.21.1 to 0.21.2 (:pr:`4232`)
190
+ - Bump ``pytest-xdist`` from 3.6.0 to 3.6.1 (:pr:`4233`)
191
+ - Bump ``furo`` from 2024.1.29 to 2024.4.27 (:pr:`4230`)
192
+ - Bump ``srvaroa/labeler`` from 1.10.0 to 1.10.1 (:pr:`4227`)
193
+ - Bump ``pytest`` from 7.4.4 to 8.1.1 (:pr:`4218`)
194
+ - Bump ``sphinx`` from 7.2.6 to 7.3.7 (:pr:`4215`)
195
+ - Bump ``pytest-xdist`` from 3.5.0 to 3.6.0 (:pr:`4215`)
196
+
197
+ Version 21.1.1
198
+ ==============
199
+
200
+ *Released 2024-04-15*
201
+
202
+ This is the technical changelog for version 21.1.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
203
+
204
+ Bug Fixes
205
+ ---------
206
+
207
+ - Fix Bug With Parameter ``message_thread_id`` of ``Message.reply_*`` (:pr:`4207` closes :issue:`4205`)
208
+
209
+ Minor Changes
210
+ -------------
211
+
212
+ - Remove Deprecation Warning in ``JobQueue.run_daily`` (:pr:`4206` by `@Konano <https://github.com/Konano>`__)
213
+ - Fix Annotation of ``EncryptedCredentials.decrypted_secret`` (:pr:`4199` by `@marinelay <https://github.com/marinelay>`__ closes :issue:`4198`)
214
+
215
+
216
+ Version 21.1
217
+ ==============
218
+
219
+ *Released 2024-04-12*
220
+
221
+ This is the technical changelog for version 21.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
222
+
223
+ Major Changes
224
+ -------------
225
+
226
+ - API 7.2 (:pr:`4180` closes :issue:`4179` and :issue:`4181`, :issue:`4181`)
227
+ - Make ``ChatAdministratorRights/ChatMemberAdministrator.can_*_stories`` Required (API 7.1) (:pr:`4192`)
228
+
229
+ Minor Changes
230
+ -------------
231
+
232
+ - Refactor Debug logging in ``Bot`` to Improve Type Hinting (:pr:`4151` closes :issue:`4010`)
233
+
234
+ New Features
235
+ ------------
236
+
237
+ - Make ``Message.reply_*`` Reply in the Same Topic by Default (:pr:`4170` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`4139`)
238
+ - Accept Socket Objects for Webhooks (:pr:`4161` closes :issue:`4078`)
239
+ - Add ``Update.effective_sender`` (:pr:`4168` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`4085`)
240
+
241
+ Documentation Improvements
242
+ --------------------------
243
+
244
+ - Documentation Improvements (:pr:`4171`, :pr:`4158` by `@teslaedison <https://github.com/teslaedison>`__)
245
+
246
+ Internal Changes
247
+ ----------------
248
+
249
+ - Temporarily Mark Tests with ``get_sticker_set`` as XFAIL due to API 7.2 Update (:pr:`4190`)
250
+
251
+ Dependency Updates
252
+ ------------------
253
+
254
+ - ``pre-commit`` autoupdate (:pr:`4184`)
255
+ - Bump ``dependabot/fetch-metadata`` from 1.6.0 to 2.0.0 (:pr:`4185`)
256
+
257
+
258
+ Version 21.0.1
259
+ ==============
260
+
261
+ *Released 2024-03-06*
262
+
263
+ This is the technical changelog for version 21.0.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
264
+
265
+ Bug Fixes
266
+ ---------
267
+
268
+ - Remove ``docs`` from Package (:pr:`4150`)
269
+
270
+
271
+ Version 21.0
272
+ ============
273
+
274
+ *Released 2024-03-06*
275
+
276
+ This is the technical changelog for version 21.0. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
277
+
278
+ Major Changes
279
+ -------------
280
+
281
+ - Remove Functionality Deprecated in API 7.0 (:pr:`4114` closes :issue:`4099`)
282
+ - API 7.1 (:pr:`4118`)
283
+
284
+ New Features
285
+ ------------
286
+
287
+ - Add Parameter ``media_write_timeout`` to ``HTTPXRequest`` and Method ``ApplicationBuilder.media_write_timeout`` (:pr:`4120` closes :issue:`3864`)
288
+ - Handle Properties in ``TelegramObject.__setstate__`` (:pr:`4134` closes :issue:`4111`)
289
+
290
+ Bug Fixes
291
+ ---------
292
+
293
+ - Add Missing Slot to ``Updater`` (:pr:`4130` closes :issue:`4127`)
294
+
295
+ Documentation Improvements
296
+ --------------------------
297
+
298
+ - Improve HTML Download of Documentation (:pr:`4146` closes :issue:`4050`)
299
+ - Documentation Improvements (:pr:`4109`, :issue:`4116`)
300
+ - Update Copyright to 2024 (:pr:`4121` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`4041`)
301
+
302
+ Internal Changes
303
+ ----------------
304
+
305
+ - Apply ``pre-commit`` Checks More Widely (:pr:`4135`)
306
+ - Refactor and Overhaul ``test_official`` (:pr:`4087` closes :issue:`3874`)
307
+ - Run Unit Tests in PRs on Requirements Changes (:pr:`4144`)
308
+ - Make ``Updater.stop`` Independent of ``CancelledError`` (:pr:`4126`)
309
+
310
+ Dependency Updates
311
+ ------------------
312
+
313
+ - Relax Upper Bound for ``httpx`` Dependency (:pr:`4148`)
314
+ - Bump ``test-summary/action`` from 2.2 to 2.3 (:pr:`4142`)
315
+ - Update ``cachetools`` requirement from ~=5.3.2 to ~=5.3.3 (:pr:`4141`)
316
+ - Update ``httpx`` requirement from ~=0.26.0 to ~=0.27.0 (:pr:`4131`)
317
+
318
+
319
+ Version 20.8
320
+ ============
321
+
322
+ *Released 2024-02-08*
323
+
324
+ This is the technical changelog for version 20.8. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
325
+
326
+ Major Changes
327
+ -------------
328
+
329
+ - API 7.0 (:pr:`4034` closes :issue:`4033`, :pr:`4038` by `@aelkheir <https://github.com/aelkheir>`__)
330
+
331
+ Minor Changes
332
+ -------------
333
+
334
+ - Fix Type Hint for ``filters`` Parameter of ``MessageHandler`` (:pr:`4039` by `@Palaptin <https://github.com/Palaptin>`__)
335
+ - Deprecate ``filters.CHAT`` (:pr:`4083` closes :issue:`4062`)
336
+ - Improve Error Handling in Built-In Webhook Handler (:pr:`3987` closes :issue:`3979`)
337
+
338
+ New Features
339
+ ------------
340
+
341
+ - Add Parameter ``pattern`` to ``PreCheckoutQueryHandler`` and ``filters.SuccessfulPayment`` (:pr:`4005` by `@aelkheir <https://github.com/aelkheir>`__ closes :issue:`3752`)
342
+ - Add Missing Conversions of ``type`` to Corresponding Enum from ``telegram.constants`` (:pr:`4067`)
343
+ - Add Support for Unix Sockets to ``Updater.start_webhook`` (:pr:`3986` closes :issue:`3978`)
344
+ - Add ``Bot.do_api_request`` (:pr:`4084` closes :issue:`4053`)
345
+ - Add ``AsyncContextManager`` as Parent Class to ``BaseUpdateProcessor`` (:pr:`4001`)
346
+
347
+ Documentation Improvements
348
+ --------------------------
349
+
350
+ - Documentation Improvements (:pr:`3919`)
351
+ - Add Docstring to Dunder Methods (:pr:`3929` closes :issue:`3926`)
352
+ - Documentation Improvements (:pr:`4002`, :pr:`4079` by `@kenjitagawa <https://github.com/kenjitagawa>`__, :pr:`4104` by `@xTudoS <https://github.com/xTudoS>`__)
353
+
354
+ Internal Changes
355
+ ----------------
356
+
357
+ - Drop Usage of DeepSource (:pr:`4100`)
358
+ - Improve Type Completeness & Corresponding Workflow (:pr:`4035`)
359
+ - Bump ``ruff`` and Remove ``sort-all`` (:pr:`4075`)
360
+ - Move Handler Files to ``_handlers`` Subdirectory (:pr:`4064` by `@lucasmolinari <https://github.com/lucasmolinari>`__ closes :issue:`4060`)
361
+ - Introduce ``sort-all`` Hook for ``pre-commit`` (:pr:`4052`)
362
+ - Use Recommended ``pre-commit`` Mirror for ``black`` (:pr:`4051`)
363
+ - Remove Unused ``DEFAULT_20`` (:pr:`3997`)
364
+ - Migrate From ``setup.cfg`` to ``pyproject.toml`` Where Possible (:pr:`4088`)
365
+
366
+ Dependency Updates
367
+ ------------------
368
+
369
+ - Bump ``black`` and ``ruff`` (:pr:`4089`)
370
+ - Bump ``srvaroa/labeler`` from 1.8.0 to 1.10.0 (:pr:`4048`)
371
+ - Update ``tornado`` requirement from ~=6.3.3 to ~=6.4 (:pr:`3992`)
372
+ - Bump ``actions/stale`` from 8 to 9 (:pr:`4046`)
373
+ - Bump ``actions/setup-python`` from 4 to 5 (:pr:`4047`)
374
+ - ``pre-commit`` autoupdate (:pr:`4101`)
375
+ - Bump ``actions/upload-artifact`` from 3 to 4 (:pr:`4045`)
376
+ - ``pre-commit`` autoupdate (:pr:`3996`)
377
+ - Bump ``furo`` from 2023.9.10 to 2024.1.29 (:pr:`4094`)
378
+ - ``pre-commit`` autoupdate (:pr:`4043`)
379
+ - Bump ``codecov/codecov-action`` from 3 to 4 (:pr:`4091`)
380
+ - Bump ``EndBug/add-and-commit`` from 9.1.3 to 9.1.4 (:pr:`4090`)
381
+ - Update ``httpx`` requirement from ~=0.25.2 to ~=0.26.0 (:pr:`4024`)
382
+ - Bump ``pytest`` from 7.4.3 to 7.4.4 (:pr:`4056`)
383
+ - Bump ``srvaroa/labeler`` from 1.7.0 to 1.8.0 (:pr:`3993`)
384
+ - Bump ``test-summary/action`` from 2.1 to 2.2 (:pr:`4044`)
385
+ - Bump ``dessant/lock-threads`` from 4.0.1 to 5.0.1 (:pr:`3994`)
386
+
387
+
388
+ Version 20.7
389
+ ============
390
+
391
+ *Released 2023-11-27*
392
+
393
+ This is the technical changelog for version 20.7. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
394
+
395
+ New Features
396
+ ------------
397
+
398
+ - Add ``JobQueue.scheduler_configuration`` and Corresponding Warnings (:pr:`3913` closes :issue:`3837`)
399
+ - Add Parameter ``socket_options`` to ``HTTPXRequest`` (:pr:`3935` closes :issue:`2965`)
400
+ - Add ``ApplicationBuilder.(get_updates_)socket_options`` (:pr:`3943`)
401
+ - Improve ``write_timeout`` Handling for Media Methods (:pr:`3952`)
402
+ - Add ``filters.Mention`` (:pr:`3941` closes :issue:`3799`)
403
+ - Rename ``proxy_url`` to ``proxy`` and Allow ``httpx.{Proxy, URL}`` as Input (:pr:`3939` closes :issue:`3844`)
404
+
405
+ Bug Fixes & Changes
406
+ -------------------
407
+
408
+ - Adjust ``read_timeout`` Behavior for ``Bot.get_updates`` (:pr:`3963` closes :issue:`3893`)
409
+ - Improve ``BaseHandler.__repr__`` for Callbacks without ``__qualname__`` (:pr:`3934`)
410
+ - Fix Persistency Issue with Ended Non-Blocking Conversations (:pr:`3962`)
411
+ - Improve Type Hinting for Arguments with Default Values in ``Bot`` (:pr:`3942`)
412
+
413
+ Documentation Improvements
414
+ --------------------------
415
+
416
+ - Add Documentation for ``__aenter__`` and ``__aexit__`` Methods (:pr:`3907` closes :issue:`3886`)
417
+ - Improve Insertion of Kwargs into ``Bot`` Methods (:pr:`3965`)
418
+
419
+ Internal Changes
420
+ ----------------
421
+
422
+ - Adjust Tests to New Error Messages (:pr:`3970`)
423
+
424
+ Dependency Updates
425
+ ------------------
426
+
427
+ - Bump ``pytest-xdist`` from 3.3.1 to 3.4.0 (:pr:`3975`)
428
+ - ``pre-commit`` autoupdate (:pr:`3967`)
429
+ - Update ``httpx`` requirement from ~=0.25.1 to ~=0.25.2 (:pr:`3983`)
430
+ - Bump ``pytest-xdist`` from 3.4.0 to 3.5.0 (:pr:`3982`)
431
+ - Update ``httpx`` requirement from ~=0.25.0 to ~=0.25.1 (:pr:`3961`)
432
+ - Bump ``srvaroa/labeler`` from 1.6.1 to 1.7.0 (:pr:`3958`)
433
+ - Update ``cachetools`` requirement from ~=5.3.1 to ~=5.3.2 (:pr:`3954`)
434
+ - Bump ``pytest`` from 7.4.2 to 7.4.3 (:pr:`3953`)
435
+
436
+
437
+ Version 20.6
438
+ ============
439
+
440
+ *Released 2023-10-03*
441
+
442
+ This is the technical changelog for version 20.6. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
443
+
444
+ Major Changes
445
+ -------------
446
+
447
+ - Drop Backward Compatibility Layer Introduced in :pr:`3853` (API 6.8) (:pr:`3873`)
448
+ - Full Support for Bot API 6.9 (:pr:`3898`)
449
+
450
+ New Features
451
+ ------------
452
+
453
+ - Add Rich Equality Comparison to ``WriteAccessAllowed`` (:pr:`3911` closes :issue:`3909`)
454
+ - Add ``__repr__`` Methods Added in :pr:`3826` closes :issue:`3770` to Sphinx Documentation (:pr:`3901` closes :issue:`3889`)
455
+ - Add String Representation for Selected Classes (:pr:`3826` closes :issue:`3770`)
456
+
457
+ Minor Changes
458
+ -------------
459
+
460
+ - Add Support Python 3.12 (:pr:`3915`)
461
+ - Documentation Improvements (:pr:`3910`)
462
+
463
+ Internal Changes
464
+ ----------------
465
+
466
+ - Verify Type Hints for Bot Method & Telegram Class Parameters (:pr:`3868`)
467
+ - Move Bot API Tests to Separate Workflow File (:pr:`3912`)
468
+ - Fix Failing ``file_size`` Tests (:pr:`3906`)
469
+ - Set Threshold for DeepSource’s PY-R1000 to High (:pr:`3888`)
470
+ - One-Time Code Formatting Improvement via ``--preview`` Flag of ``black`` (:pr:`3882`)
471
+ - Move Dunder Methods to the Top of Class Bodies (:pr:`3883`)
472
+ - Remove Superfluous ``Defaults.__ne__`` (:pr:`3884`)
473
+
474
+ Dependency Updates
475
+ ------------------
476
+
477
+ - ``pre-commit`` autoupdate (:pr:`3876`)
478
+ - Update ``pre-commit`` Dependencies (:pr:`3916`)
479
+ - Bump ``actions/checkout`` from 3 to 4 (:pr:`3914`)
480
+ - Update ``httpx`` requirement from ~=0.24.1 to ~=0.25.0 (:pr:`3891`)
481
+ - Bump ``furo`` from 2023.8.19 to 2023.9.10 (:pr:`3890`)
482
+ - Bump ``sphinx`` from 7.2.5 to 7.2.6 (:pr:`3892`)
483
+ - Update ``tornado`` requirement from ~=6.2 to ~=6.3.3 (:pr:`3675`)
484
+ - Bump ``pytest`` from 7.4.0 to 7.4.2 (:pr:`3881`)
485
+
486
+
487
+ Version 20.5
488
+ ============
489
+ *Released 2023-09-03*
490
+
491
+ This is the technical changelog for version 20.5. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
492
+
493
+ Major Changes
494
+ -------------
495
+
496
+ - API 6.8 (:pr:`3853`)
497
+ - Remove Functionality Deprecated Since Bot API 6.5, 6.6 or 6.7 (:pr:`3858`)
498
+
499
+ New Features
500
+ ------------
501
+
502
+ - Extend Allowed Values for HTTP Version (:pr:`3823` closes :issue:`3821`)
503
+ - Add ``has_args`` Parameter to ``CommandHandler`` (:pr:`3854` by `@thatguylah <https://github.com/thatguylah>`__ closes :issue:`3798`)
504
+ - Add ``Application.stop_running()`` and Improve Marking Updates as Read on ``Updater.stop()`` (:pr:`3804`)
505
+
506
+ Minor Changes
507
+ -------------
508
+
509
+ - Type Hinting Fixes for ``WebhookInfo`` (:pr:`3871`)
510
+ - Test and Document ``Exception.__cause__`` on ``NetworkError`` (:pr:`3792` closes :issue:`3778`)
511
+ - Add Support for Python 3.12 RC (:pr:`3847`)
512
+
513
+ Documentation Improvements
514
+ --------------------------
515
+
516
+ - Remove Version Check from Examples (:pr:`3846`)
517
+ - Documentation Improvements (:pr:`3803`, :pr:`3797`, :pr:`3816` by `@trim21 <https://github.com/trim21>`__, :pr:`3829` by `@aelkheir <https://github.com/aelkheir>`__)
518
+ - Provide Versions of ``customwebhookbot.py`` with Different Frameworks (:pr:`3820` closes :issue:`3717`)
519
+
520
+ Dependency Updates
521
+ ------------------
522
+
523
+ - ``pre-commit`` autoupdate (:pr:`3824`)
524
+ - Bump ``srvaroa/labeler`` from 1.6.0 to 1.6.1 (:pr:`3870`)
525
+ - Bump ``sphinx`` from 7.0.1 to 7.1.1 (:pr:`3818`)
526
+ - Bump ``sphinx`` from 7.2.3 to 7.2.5 (:pr:`3869`)
527
+ - Bump ``furo`` from 2023.5.20 to 2023.7.26 (:pr:`3817`)
528
+ - Update ``apscheduler`` requirement from ~=3.10.3 to ~=3.10.4 (:pr:`3862`)
529
+ - Bump ``sphinx`` from 7.2.2 to 7.2.3 (:pr:`3861`)
530
+ - Bump ``pytest-asyncio`` from 0.21.0 to 0.21.1 (:pr:`3801`)
531
+ - Bump ``sphinx-paramlinks`` from 0.5.4 to 0.6.0 (:pr:`3840`)
532
+ - Update ``apscheduler`` requirement from ~=3.10.1 to ~=3.10.3 (:pr:`3851`)
533
+ - Bump ``furo`` from 2023.7.26 to 2023.8.19 (:pr:`3850`)
534
+ - Bump ``sphinx`` from 7.1.2 to 7.2.2 (:pr:`3852`)
535
+ - Bump ``sphinx`` from 7.1.1 to 7.1.2 (:pr:`3827`)
536
+
537
+
538
+ Version 20.4
539
+ ============
540
+
541
+ *Released 2023-07-09*
542
+
543
+ This is the technical changelog for version 20.4. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`__.
544
+
545
+ Major Changes
546
+ -------------
547
+
548
+ - Drop Support for Python 3.7 (:pr:`3728`, :pr:`3742` by `@Trifase <https://github.com/Trifase>`__, :pr:`3749` by `@thefunkycat <https://github.com/thefunkycat>`__, :pr:`3740` closes :issue:`3732`, :pr:`3754` closes :issue:`3731`, :pr:`3753`, :pr:`3764`, :pr:`3762`, :pr:`3759` closes :issue:`3733`)
549
+
550
+ New Features
551
+ ------------
552
+
553
+ - Make Integration of ``APScheduler`` into ``JobQueue`` More Explicit (:pr:`3695`)
554
+ - Introduce ``BaseUpdateProcessor`` for Customized Concurrent Handling of Updates (:pr:`3654` closes :issue:`3509`)
555
+
556
+ Minor Changes
557
+ -------------
558
+
559
+ - Fix Inconsistent Type Hints for ``timeout`` Parameter of ``Bot.get_updates`` (:pr:`3709` by `@revolter <https://github.com/revolter>`__)
560
+ - Use Explicit Optionals (:pr:`3692` by `@MiguelX413 <https://github.com/MiguelX413>`__)
561
+
562
+ Bug Fixes
563
+ ---------
564
+
565
+ - Fix Wrong Warning Text in ``KeyboardButton.__eq__`` (:pr:`3768`)
566
+
567
+ Documentation Improvements
568
+ --------------------------
569
+
570
+ - Explicitly set ``allowed_updates`` in Examples (:pr:`3741` by `@Trifase <https://github.com/Trifase>`__ closes :issue:`3726`)
571
+ - Bump ``furo`` and ``sphinx`` (:pr:`3719`)
572
+ - Documentation Improvements (:pr:`3698`, :pr:`3708` by `@revolter <https://github.com/revolter>`__, :pr:`3767`)
573
+ - Add Quotes for Installation Instructions With Optional Dependencies (:pr:`3780`)
574
+ - Exclude Type Hints from Stability Policy (:pr:`3712`)
575
+ - Set ``httpx`` Logging Level to Warning in Examples (:pr:`3746` closes :issue:`3743`)
576
+
577
+ Internal Changes
578
+ ----------------
579
+
580
+ - Drop a Legacy ``pre-commit.ci`` Configuration (:pr:`3697`)
581
+ - Add Python 3.12 Beta to the Test Matrix (:pr:`3751`)
582
+ - Use Temporary Files for Testing File Downloads (:pr:`3777`)
583
+ - Auto-Update Changed Version in Other Files After Dependabot PRs (:pr:`3716`)
584
+ - Add More ``ruff`` Rules (:pr:`3763`)
585
+ - Rename ``_handler.py`` to ``_basehandler.py`` (:pr:`3761`)
586
+ - Automatically Label ``pre-commit-ci`` PRs (:pr:`3713`)
587
+ - Rework ``pytest`` Integration into GitHub Actions (:pr:`3776`)
588
+ - Fix Two Bugs in GitHub Actions Workflows (:pr:`3739`)
589
+
590
+ Dependency Updates
591
+ ------------------
592
+
593
+ - Update ``cachetools`` requirement from ~=5.3.0 to ~=5.3.1 (:pr:`3738`)
594
+ - Update ``aiolimiter`` requirement from ~=1.0.0 to ~=1.1.0 (:pr:`3707`)
595
+ - ``pre-commit`` autoupdate (:pr:`3791`)
596
+ - Bump ``sphinxcontrib-mermaid`` from 0.8.1 to 0.9.2 (:pr:`3737`)
597
+ - Bump ``pytest-xdist`` from 3.2.1 to 3.3.0 (:pr:`3705`)
598
+ - Bump ``srvaroa/labeler`` from 1.5.0 to 1.6.0 (:pr:`3786`)
599
+ - Bump ``dependabot/fetch-metadata`` from 1.5.1 to 1.6.0 (:pr:`3787`)
600
+ - Bump ``dessant/lock-threads`` from 4.0.0 to 4.0.1 (:pr:`3785`)
601
+ - Bump ``pytest`` from 7.3.2 to 7.4.0 (:pr:`3774`)
602
+ - Update ``httpx`` requirement from ~=0.24.0 to ~=0.24.1 (:pr:`3715`)
603
+ - Bump ``pytest-xdist`` from 3.3.0 to 3.3.1 (:pr:`3714`)
604
+ - Bump ``pytest`` from 7.3.1 to 7.3.2 (:pr:`3758`)
605
+ - ``pre-commit`` autoupdate (:pr:`3747`)
606
+
607
+
608
+ Version 20.3
609
+ ============
610
+ *Released 2023-05-07*
611
+
612
+ This is the technical changelog for version 20.3. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
613
+
614
+ Major Changes
615
+ -------------
616
+
617
+ - Full support for API 6.7 (:pr:`3673`)
618
+ - Add a Stability Policy (:pr:`3622`)
619
+
620
+ New Features
621
+ ------------
622
+
623
+ - Add ``Application.mark_data_for_update_persistence`` (:pr:`3607`)
624
+ - Make ``Message.link`` Point to Thread View Where Possible (:pr:`3640`)
625
+ - Localize Received ``datetime`` Objects According to ``Defaults.tzinfo`` (:pr:`3632`)
626
+
627
+ Minor Changes, Documentation Improvements and CI
628
+ ------------------------------------------------
629
+
630
+ - Empower ``ruff`` (:pr:`3594`)
631
+ - Drop Usage of ``sys.maxunicode`` (:pr:`3630`)
632
+ - Add String Representation for ``RequestParameter`` (:pr:`3634`)
633
+ - Stabilize CI by Rerunning Failed Tests (:pr:`3631`)
634
+ - Give Loggers Better Names (:pr:`3623`)
635
+ - Add Logging for Invalid JSON Data in ``BasePersistence.parse_json_payload`` (:pr:`3668`)
636
+ - Improve Warning Categories & Stacklevels (:pr:`3674`)
637
+ - Stabilize ``test_delete_sticker_set`` (:pr:`3685`)
638
+ - Shield Update Fetcher Task in ``Application.start`` (:pr:`3657`)
639
+ - Recover 100% Type Completeness (:pr:`3676`)
640
+ - Documentation Improvements (:pr:`3628`, :pr:`3636`, :pr:`3694`)
641
+
642
+ Dependencies
643
+ ------------
644
+
645
+ - Bump ``actions/stale`` from 7 to 8 (:pr:`3644`)
646
+ - Bump ``furo`` from 2023.3.23 to 2023.3.27 (:pr:`3643`)
647
+ - ``pre-commit`` autoupdate (:pr:`3646`, :pr:`3688`)
648
+ - Remove Deprecated ``codecov`` Package from CI (:pr:`3664`)
649
+ - Bump ``sphinx-copybutton`` from 0.5.1 to 0.5.2 (:pr:`3662`)
650
+ - Update ``httpx`` requirement from ~=0.23.3 to ~=0.24.0 (:pr:`3660`)
651
+ - Bump ``pytest`` from 7.2.2 to 7.3.1 (:pr:`3661`)
652
+
653
+ Version 20.2
654
+ ============
655
+ *Released 2023-03-25*
656
+
657
+ This is the technical changelog for version 20.2. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
658
+
659
+ Major Changes
660
+ -------------
661
+ - Full Support for API 6.6 (:pr:`3584`)
662
+ - Revert to HTTP/1.1 as Default and make HTTP/2 an Optional Dependency (:pr:`3576`)
663
+
664
+ Minor Changes, Documentation Improvements and CI
665
+ ------------------------------------------------
666
+ - Documentation Improvements (:pr:`3565`, :pr:`3600`)
667
+ - Handle Symbolic Links in ``was_called_by`` (:pr:`3552`)
668
+ - Tidy Up Tests Directory (:pr:`3553`)
669
+ - Enhance ``Application.create_task`` (:pr:`3543`)
670
+ - Make Type Completeness Workflow Usable for ``PRs`` from Forks (:pr:`3551`)
671
+ - Refactor and Overhaul the Test Suite (:pr:`3426`)
672
+
673
+ Dependencies
674
+ ------------
675
+ - Bump ``pytest-asyncio`` from 0.20.3 to 0.21.0 (:pr:`3624`)
676
+ - Bump ``furo`` from 2022.12.7 to 2023.3.23 (:pr:`3625`)
677
+ - Bump ``pytest-xdist`` from 3.2.0 to 3.2.1 (:pr:`3606`)
678
+ - ``pre-commit`` autoupdate (:pr:`3577`)
679
+ - Update ``apscheduler`` requirement from ~=3.10.0 to ~=3.10.1 (:pr:`3572`)
680
+ - Bump ``pytest`` from 7.2.1 to 7.2.2 (:pr:`3573`)
681
+ - Bump ``pytest-xdist`` from 3.1.0 to 3.2.0 (:pr:`3550`)
682
+ - Bump ``sphinxcontrib-mermaid`` from 0.7.1 to 0.8 (:pr:`3549`)
683
+
684
+ Version 20.1
685
+ ============
686
+ *Released 2023-02-09*
687
+
688
+ This is the technical changelog for version 20.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
689
+
690
+ Major Changes
691
+ -------------
692
+
693
+ - Full Support for Bot API 6.5 (:pr:`3530`)
694
+
695
+ New Features
696
+ ------------
697
+
698
+ - Add ``Application(Builder).post_stop`` (:pr:`3466`)
699
+ - Add ``Chat.effective_name`` Convenience Property (:pr:`3485`)
700
+ - Allow to Adjust HTTP Version and Use HTTP/2 by Default (:pr:`3506`)
701
+
702
+ Documentation Improvements
703
+ --------------------------
704
+
705
+ - Enhance ``chatmemberbot`` Example (:pr:`3500`)
706
+ - Automatically Generate Cross-Reference Links (:pr:`3501`, :pr:`3529`, :pr:`3523`)
707
+ - Add Some Graphic Elements to Docs (:pr:`3535`)
708
+ - Various Smaller Improvements (:pr:`3464`, :pr:`3483`, :pr:`3484`, :pr:`3497`, :pr:`3512`, :pr:`3515`, :pr:`3498`)
709
+
710
+ Minor Changes, Documentation Improvements and CI
711
+ ------------------------------------------------
712
+
713
+ - Update Copyright to 2023 (:pr:`3459`)
714
+ - Stabilize Tests on Closing and Hiding the General Forum Topic (:pr:`3460`)
715
+ - Fix Dependency Warning Typo (:pr:`3474`)
716
+ - Cache Dependencies on ``GitHub`` Actions (:pr:`3469`)
717
+ - Store Documentation Builts as ``GitHub`` Actions Artifacts (:pr:`3468`)
718
+ - Add ``ruff`` to ``pre-commit`` Hooks (:pr:`3488`)
719
+ - Improve Warning for ``days`` Parameter of ``JobQueue.run_daily`` (:pr:`3503`)
720
+ - Improve Error Message for ``NetworkError`` (:pr:`3505`)
721
+ - Lock Inactive Threads Only Once Each Day (:pr:`3510`)
722
+ - Bump ``pytest`` from 7.2.0 to 7.2.1 (:pr:`3513`)
723
+ - Check for 3D Arrays in ``check_keyboard_type`` (:pr:`3514`)
724
+ - Explicit Type Annotations (:pr:`3508`)
725
+ - Increase Verbosity of Type Completeness CI Job (:pr:`3531`)
726
+ - Fix CI on Python 3.11 + Windows (:pr:`3547`)
727
+
728
+ Dependencies
729
+ ------------
730
+
731
+ - Bump ``actions/stale`` from 6 to 7 (:pr:`3461`)
732
+ - Bump ``dessant/lock-threads`` from 3.0.0 to 4.0.0 (:pr:`3462`)
733
+ - ``pre-commit`` autoupdate (:pr:`3470`)
734
+ - Update ``httpx`` requirement from ~=0.23.1 to ~=0.23.3 (:pr:`3489`)
735
+ - Update ``cachetools`` requirement from ~=5.2.0 to ~=5.2.1 (:pr:`3502`)
736
+ - Improve Config for ``ruff`` and Bump to ``v0.0.222`` (:pr:`3507`)
737
+ - Update ``cachetools`` requirement from ~=5.2.1 to ~=5.3.0 (:pr:`3520`)
738
+ - Bump ``isort`` to 5.12.0 (:pr:`3525`)
739
+ - Update ``apscheduler`` requirement from ~=3.9.1 to ~=3.10.0 (:pr:`3532`)
740
+ - ``pre-commit`` autoupdate (:pr:`3537`)
741
+ - Update ``cryptography`` requirement to >=39.0.1 to address Vulnerability (:pr:`3539`)
742
+
743
+ Version 20.0
744
+ ============
745
+ *Released 2023-01-01*
746
+
747
+ This is the technical changelog for version 20.0. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
748
+
749
+ Major Changes
750
+ -------------
751
+
752
+ - Full Support For Bot API 6.4 (:pr:`3449`)
753
+
754
+ Minor Changes, Documentation Improvements and CI
755
+ ------------------------------------------------
756
+
757
+ - Documentation Improvements (:pr:`3428`, :pr:`3423`, :pr:`3429`, :pr:`3441`, :pr:`3404`, :pr:`3443`)
758
+ - Allow ``Sequence`` Input for Bot Methods (:pr:`3412`)
759
+ - Update Link-Check CI and Replace a Dead Link (:pr:`3456`)
760
+ - Freeze Classes Without Arguments (:pr:`3453`)
761
+ - Add New Constants (:pr:`3444`)
762
+ - Override ``Bot.__deepcopy__`` to Raise ``TypeError`` (:pr:`3446`)
763
+ - Add Log Decorator to ``Bot.get_webhook_info`` (:pr:`3442`)
764
+ - Add Documentation On Verifying Releases (:pr:`3436`)
765
+ - Drop Undocumented ``Job.__lt__`` (:pr:`3432`)
766
+
767
+ Dependencies
768
+ ------------
769
+
770
+ - Downgrade ``sphinx`` to 5.3.0 to Fix Search (:pr:`3457`)
771
+ - Bump ``sphinx`` from 5.3.0 to 6.0.0 (:pr:`3450`)
772
+
773
+ Version 20.0b0
774
+ ==============
775
+ *Released 2022-12-15*
776
+
777
+ This is the technical changelog for version 20.0b0. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
778
+
779
+ Major Changes
780
+ -------------
781
+
782
+ - Make ``TelegramObject`` Immutable (:pr:`3249`)
783
+
784
+ Minor Changes, Documentation Improvements and CI
785
+ ------------------------------------------------
786
+
787
+ - Reduce Code Duplication in Testing ``Defaults`` (:pr:`3419`)
788
+ - Add Notes and Warnings About Optional Dependencies (:pr:`3393`)
789
+ - Simplify Internals of ``Bot`` Methods (:pr:`3396`)
790
+ - Reduce Code Duplication in Several ``Bot`` Methods (:pr:`3385`)
791
+ - Documentation Improvements (:pr:`3386`, :pr:`3395`, :pr:`3398`, :pr:`3403`)
792
+
793
+ Dependencies
794
+ ------------
795
+
796
+ - Bump ``pytest-xdist`` from 3.0.2 to 3.1.0 (:pr:`3415`)
797
+ - Bump ``pytest-asyncio`` from 0.20.2 to 0.20.3 (:pr:`3417`)
798
+ - ``pre-commit`` autoupdate (:pr:`3409`)
799
+
800
+ Version 20.0a6
801
+ ==============
802
+ *Released 2022-11-24*
803
+
804
+ This is the technical changelog for version 20.0a6. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
805
+
806
+ Bug Fixes
807
+ ---------
808
+
809
+ - Only Persist Arbitrary ``callback_data`` if ``ExtBot.callback_data_cache`` is Present (:pr:`3384`)
810
+ - Improve Backwards Compatibility of ``TelegramObjects`` Pickle Behavior (:pr:`3382`)
811
+ - Fix Naming and Keyword Arguments of ``File.download_*`` Methods (:pr:`3380`)
812
+ - Fix Return Value Annotation of ``Chat.create_forum_topic`` (:pr:`3381`)
813
+
814
+ Version 20.0a5
815
+ ==============
816
+ *Released 2022-11-22*
817
+
818
+ This is the technical changelog for version 20.0a5. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
819
+
820
+ Major Changes
821
+ -------------
822
+
823
+ - API 6.3 (:pr:`3346`, :pr:`3343`, :pr:`3342`, :pr:`3360`)
824
+ - Explicit ``local_mode`` Setting (:pr:`3154`)
825
+ - Make Almost All 3rd Party Dependencies Optional (:pr:`3267`)
826
+ - Split ``File.download`` Into ``File.download_to_drive`` And ``File.download_to_memory`` (:pr:`3223`)
827
+
828
+ New Features
829
+ ------------
830
+
831
+ - Add Properties for API Settings of ``Bot`` (:pr:`3247`)
832
+ - Add ``chat_id`` and ``username`` Parameters to ``ChatJoinRequestHandler`` (:pr:`3261`)
833
+ - Introduce ``TelegramObject.api_kwargs`` (:pr:`3233`)
834
+ - Add Two Constants Related to Local Bot API Servers (:pr:`3296`)
835
+ - Add ``recursive`` Parameter to ``TelegramObject.to_dict()`` (:pr:`3276`)
836
+ - Overhaul String Representation of ``TelegramObject`` (:pr:`3234`)
837
+ - Add Methods ``Chat.mention_{html, markdown, markdown_v2}`` (:pr:`3308`)
838
+ - Add ``constants.MessageLimit.DEEP_LINK_LENGTH`` (:pr:`3315`)
839
+ - Add Shortcut Parameters ``caption``, ``parse_mode`` and ``caption_entities`` to ``Bot.send_media_group`` (:pr:`3295`)
840
+ - Add Several New Enums To Constants (:pr:`3351`)
841
+
842
+ Bug Fixes
843
+ ---------
844
+
845
+ - Fix ``CallbackQueryHandler`` Not Handling Non-String Data Correctly With Regex Patterns (:pr:`3252`)
846
+ - Fix Defaults Handling in ``Bot.answer_web_app_query`` (:pr:`3362`)
847
+
848
+ Documentation Improvements
849
+ --------------------------
850
+
851
+ - Update PR Template (:pr:`3361`)
852
+ - Document Dunder Methods of ``TelegramObject`` (:pr:`3319`)
853
+ - Add Several References to Wiki pages (:pr:`3306`)
854
+ - Overhaul Search bar (:pr:`3218`)
855
+ - Unify Documentation of Arguments and Attributes of Telegram Classes (:pr:`3217`, :pr:`3292`, :pr:`3303`, :pr:`3312`, :pr:`3314`)
856
+ - Several Smaller Improvements (:pr:`3214`, :pr:`3271`, :pr:`3289`, :pr:`3326`, :pr:`3370`, :pr:`3376`, :pr:`3366`)
857
+
858
+ Minor Changes, Documentation Improvements and CI
859
+ ------------------------------------------------
860
+
861
+ - Improve Warning About Unknown ``ConversationHandler`` States (:pr:`3242`)
862
+ - Switch from Stale Bot to ``GitHub`` Actions (:pr:`3243`)
863
+ - Bump Python 3.11 to RC2 in Test Matrix (:pr:`3246`)
864
+ - Make ``Job.job`` a Property and Make ``Jobs`` Hashable (:pr:`3250`)
865
+ - Skip ``JobQueue`` Tests on Windows Again (:pr:`3280`)
866
+ - Read-Only ``CallbackDataCache`` (:pr:`3266`)
867
+ - Type Hinting Fix for ``Message.effective_attachment`` (:pr:`3294`)
868
+ - Run Unit Tests in Parallel (:pr:`3283`)
869
+ - Update Test Matrix to Use Stable Python 3.11 (:pr:`3313`)
870
+ - Don't Edit Objects In-Place When Inserting ``ext.Defaults`` (:pr:`3311`)
871
+ - Add a Test for ``MessageAttachmentType`` (:pr:`3335`)
872
+ - Add Three New Test Bots (:pr:`3347`)
873
+ - Improve Unit Tests Regarding ``ChatMemberUpdated.difference`` (:pr:`3352`)
874
+ - Flaky Unit Tests: Use ``pytest`` Marker (:pr:`3354`)
875
+ - Fix ``DeepSource`` Issues (:pr:`3357`)
876
+ - Handle Lists and Tuples and Datetimes Directly in ``TelegramObject.to_dict`` (:pr:`3353`)
877
+ - Update Meta Config (:pr:`3365`)
878
+ - Merge ``ChatDescriptionLimit`` Enum Into ``ChatLimit`` (:pr:`3377`)
879
+
880
+ Dependencies
881
+ ------------
882
+
883
+ - Bump ``pytest`` from 7.1.2 to 7.1.3 (:pr:`3228`)
884
+ - ``pre-commit`` Updates (:pr:`3221`)
885
+ - Bump ``sphinx`` from 5.1.1 to 5.2.3 (:pr:`3269`)
886
+ - Bump ``furo`` from 2022.6.21 to 2022.9.29 (:pr:`3268`)
887
+ - Bump ``actions/stale`` from 5 to 6 (:pr:`3277`)
888
+ - ``pre-commit`` autoupdate (:pr:`3282`)
889
+ - Bump ``sphinx`` from 5.2.3 to 5.3.0 (:pr:`3300`)
890
+ - Bump ``pytest-asyncio`` from 0.19.0 to 0.20.1 (:pr:`3299`)
891
+ - Bump ``pytest`` from 7.1.3 to 7.2.0 (:pr:`3318`)
892
+ - Bump ``pytest-xdist`` from 2.5.0 to 3.0.2 (:pr:`3317`)
893
+ - ``pre-commit`` autoupdate (:pr:`3325`)
894
+ - Bump ``pytest-asyncio`` from 0.20.1 to 0.20.2 (:pr:`3359`)
895
+ - Update ``httpx`` requirement from ~=0.23.0 to ~=0.23.1 (:pr:`3373`)
896
+
897
+ Version 20.0a4
898
+ ==============
899
+ *Released 2022-08-27*
900
+
901
+ This is the technical changelog for version 20.0a4. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
902
+
903
+ Hot Fixes
904
+ ---------
905
+
906
+ * Fix a Bug in ``setup.py`` Regarding Optional Dependencies (:pr:`3209`)
907
+
908
+ Version 20.0a3
909
+ ==============
910
+ *Released 2022-08-27*
911
+
912
+ This is the technical changelog for version 20.0a3. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
913
+
914
+ Major Changes
915
+ -------------
916
+
917
+ - Full Support for API 6.2 (:pr:`3195`)
918
+
919
+ New Features
920
+ ------------
921
+
922
+ - New Rate Limiting Mechanism (:pr:`3148`)
923
+ - Make ``chat/user_data`` Available in Error Handler for Errors in Jobs (:pr:`3152`)
924
+ - Add ``Application.post_shutdown`` (:pr:`3126`)
925
+
926
+ Bug Fixes
927
+ ---------
928
+
929
+ - Fix ``helpers.mention_markdown`` for Markdown V1 and Improve Related Unit Tests (:pr:`3155`)
930
+ - Add ``api_kwargs`` Parameter to ``Bot.log_out`` and Improve Related Unit Tests (:pr:`3147`)
931
+ - Make ``Bot.delete_my_commands`` a Coroutine Function (:pr:`3136`)
932
+ - Fix ``ConversationHandler.check_update`` not respecting ``per_user`` (:pr:`3128`)
933
+
934
+ Minor Changes, Documentation Improvements and CI
935
+ ------------------------------------------------
936
+
937
+ - Add Python 3.11 to Test Suite & Adapt Enum Behaviour (:pr:`3168`)
938
+ - Drop Manual Token Validation (:pr:`3167`)
939
+ - Simplify Unit Tests for ``Bot.send_chat_action`` (:pr:`3151`)
940
+ - Drop ``pre-commit`` Dependencies from ``requirements-dev.txt`` (:pr:`3120`)
941
+ - Change Default Values for ``concurrent_updates`` and ``connection_pool_size`` (:pr:`3127`)
942
+ - Documentation Improvements (:pr:`3139`, :pr:`3153`, :pr:`3135`)
943
+ - Type Hinting Fixes (:pr:`3202`)
944
+
945
+ Dependencies
946
+ ------------
947
+
948
+ - Bump ``sphinx`` from 5.0.2 to 5.1.1 (:pr:`3177`)
949
+ - Update ``pre-commit`` Dependencies (:pr:`3085`)
950
+ - Bump ``pytest-asyncio`` from 0.18.3 to 0.19.0 (:pr:`3158`)
951
+ - Update ``tornado`` requirement from ~=6.1 to ~=6.2 (:pr:`3149`)
952
+ - Bump ``black`` from 22.3.0 to 22.6.0 (:pr:`3132`)
953
+ - Bump ``actions/setup-python`` from 3 to 4 (:pr:`3131`)
954
+
955
+ Version 20.0a2
956
+ ==============
957
+ *Released 2022-06-27*
958
+
959
+ This is the technical changelog for version 20.0a2. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
960
+
961
+ Major Changes
962
+ -------------
963
+
964
+ - Full Support for API 6.1 (:pr:`3112`)
965
+
966
+ New Features
967
+ ------------
968
+
969
+ - Add Additional Shortcut Methods to ``Chat`` (:pr:`3115`)
970
+ - Mermaid-based Example State Diagrams (:pr:`3090`)
971
+
972
+ Minor Changes, Documentation Improvements and CI
973
+ ------------------------------------------------
974
+
975
+ - Documentation Improvements (:pr:`3103`, :pr:`3121`, :pr:`3098`)
976
+ - Stabilize CI (:pr:`3119`)
977
+ - Bump ``pyupgrade`` from 2.32.1 to 2.34.0 (:pr:`3096`)
978
+ - Bump ``furo`` from 2022.6.4 to 2022.6.4.1 (:pr:`3095`)
979
+ - Bump ``mypy`` from 0.960 to 0.961 (:pr:`3093`)
980
+
981
+ Version 20.0a1
982
+ ==============
983
+ *Released 2022-06-09*
984
+
985
+ This is the technical changelog for version 20.0a1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
986
+
987
+ Major Changes:
988
+ --------------
989
+
990
+ - Drop Support for ``ujson`` and instead ``BaseRequest.parse_json_payload`` (:pr:`3037`, :pr:`3072`)
991
+ - Drop ``InputFile.is_image`` (:pr:`3053`)
992
+ - Drop Explicit Type conversions in ``__init__`` s (:pr:`3056`)
993
+ - Handle List-Valued Attributes More Consistently (:pr:`3057`)
994
+ - Split ``{Command, Prefix}Handler`` And Make Attributes Immutable (:pr:`3045`)
995
+ - Align Behavior Of ``JobQueue.run_daily`` With ``cron`` (:pr:`3046`)
996
+ - Make PTB Specific Keyword-Only Arguments for PTB Specific in Bot methods (:pr:`3035`)
997
+ - Adjust Equality Comparisons to Fit Bot API 6.0 (:pr:`3033`)
998
+ - Add Tuple Based Version Info (:pr:`3030`)
999
+ - Improve Type Annotations for ``CallbackContext`` and Move Default Type Alias to ``ContextTypes.DEFAULT_TYPE`` (:pr:`3017`, :pr:`3023`)
1000
+ - Rename ``Job.context`` to ``Job.data`` (:pr:`3028`)
1001
+ - Rename ``Handler`` to ``BaseHandler`` (:pr:`3019`)
1002
+
1003
+ New Features:
1004
+ -------------
1005
+
1006
+ - Add ``Application.post_init`` (:pr:`3078`)
1007
+ - Add Arguments ``chat/user_id`` to ``CallbackContext`` And Example On Custom Webhook Setups (:pr:`3059`)
1008
+ - Add Convenience Property ``Message.id`` (:pr:`3077`)
1009
+ - Add Example for ``WebApp`` (:pr:`3052`)
1010
+ - Rename ``telegram.bot_api_version`` to ``telegram.__bot_api_version__`` (:pr:`3030`)
1011
+
1012
+ Bug Fixes:
1013
+ ----------
1014
+
1015
+ - Fix Non-Blocking Entry Point in ``ConversationHandler`` (:pr:`3068`)
1016
+ - Escape Backslashes in ``escape_markdown`` (:pr:`3055`)
1017
+
1018
+ Dependencies:
1019
+ -------------
1020
+
1021
+ - Update ``httpx`` requirement from ~=0.22.0 to ~=0.23.0 (:pr:`3069`)
1022
+ - Update ``cachetools`` requirement from ~=5.0.0 to ~=5.2.0 (:pr:`3058`, :pr:`3080`)
1023
+
1024
+ Minor Changes, Documentation Improvements and CI:
1025
+ -------------------------------------------------
1026
+
1027
+ - Move Examples To Documentation (:pr:`3089`)
1028
+ - Documentation Improvements and Update Dependencies (:pr:`3010`, :pr:`3007`, :pr:`3012`, :pr:`3067`, :pr:`3081`, :pr:`3082`)
1029
+ - Improve Some Unit Tests (:pr:`3026`)
1030
+ - Update Code Quality dependencies (:pr:`3070`, :pr:`3032`,:pr:`2998`, :pr:`2999`)
1031
+ - Don't Set Signal Handlers On Windows By Default (:pr:`3065`)
1032
+ - Split ``{Command, Prefix}Handler`` And Make Attributes Immutable (:pr:`3045`)
1033
+ - Apply ``isort`` and Update ``pre-commit.ci`` Configuration (:pr:`3049`)
1034
+ - Adjust ``pre-commit`` Settings for ``isort`` (:pr:`3043`)
1035
+ - Add Version Check to Examples (:pr:`3036`)
1036
+ - Use ``Collection`` Instead of ``List`` and ``Tuple`` (:pr:`3025`)
1037
+ - Remove Client-Side Parameter Validation (:pr:`3024`)
1038
+ - Don't Pass Default Values of Optional Parameters to Telegram (:pr:`2978`)
1039
+ - Stabilize ``Application.run_*`` on Python 3.7 (:pr:`3009`)
1040
+ - Ignore Code Style Commits in ``git blame`` (:pr:`3003`)
1041
+ - Adjust Tests to Changed API Behavior (:pr:`3002`)
1042
+
1043
+ Version 20.0a0
1044
+ ==============
1045
+ *Released 2022-05-06*
1046
+
1047
+ This is the technical changelog for version 20.0a0. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1048
+
1049
+ Major Changes:
1050
+ --------------
1051
+
1052
+ - Refactor Initialization of Persistence Classes
1053
+ (:pr:`2604`)
1054
+ - Drop Non-``CallbackContext`` API
1055
+ (:pr:`2617`)
1056
+ - Remove ``__dict__`` from ``__slots__`` and drop Python 3.6
1057
+ (:pr:`2619`,
1058
+ :pr:`2636`)
1059
+ - Move and Rename ``TelegramDecryptionError`` to
1060
+ ``telegram.error.PassportDecryptionError``
1061
+ (:pr:`2621`)
1062
+ - Make ``BasePersistence`` Methods Abstract
1063
+ (:pr:`2624`)
1064
+ - Remove ``day_is_strict`` argument of ``JobQueue.run_monthly``
1065
+ (:pr:`2634`
1066
+ by `iota-008 <https://github.com/iota-008>`__)
1067
+ - Move ``Defaults`` to ``telegram.ext``
1068
+ (:pr:`2648`)
1069
+ - Remove Deprecated Functionality
1070
+ (:pr:`2644`,
1071
+ :pr:`2740`,
1072
+ :pr:`2745`)
1073
+ - Overhaul of Filters
1074
+ (:pr:`2759`,
1075
+ :pr:`2922`)
1076
+ - Switch to ``asyncio`` and Refactor PTBs Architecture
1077
+ (:pr:`2731`)
1078
+ - Improve ``Job.__getattr__``
1079
+ (:pr:`2832`)
1080
+ - Remove ``telegram.ReplyMarkup``
1081
+ (:pr:`2870`)
1082
+ - Persistence of ``Bots``: Refactor Automatic Replacement and
1083
+ Integration with ``TelegramObject``
1084
+ (:pr:`2893`)
1085
+
1086
+ New Features:
1087
+ -------------
1088
+
1089
+ - Introduce Builder Pattern
1090
+ (:pr:`2646`)
1091
+ - Add ``Filters.update.edited``
1092
+ (:pr:`2705`
1093
+ by `PhilippFr <https://github.com/PhilippFr>`__)
1094
+ - Introduce ``Enums`` for ``telegram.constants``
1095
+ (:pr:`2708`)
1096
+ - Accept File Paths for ``private_key``
1097
+ (:pr:`2724`)
1098
+ - Associate ``Jobs`` with ``chat/user_id``
1099
+ (:pr:`2731`)
1100
+ - Convenience Functionality for ``ChatInviteLinks``
1101
+ (:pr:`2782`)
1102
+ - Add ``Dispatcher.add_handlers``
1103
+ (:pr:`2823`)
1104
+ - Improve Error Messages in ``CommandHandler.__init__``
1105
+ (:pr:`2837`)
1106
+ - ``Defaults.protect_content``
1107
+ (:pr:`2840`)
1108
+ - Add ``Dispatcher.migrate_chat_data``
1109
+ (:pr:`2848`
1110
+ by `DonalDuck004 <https://github.com/DonalDuck004>`__)
1111
+ - Add Method ``drop_chat/user_data`` to ``Dispatcher`` and Persistence
1112
+ (:pr:`2852`)
1113
+ - Add methods ``ChatPermissions.{all, no}_permissions`` (:pr:`2948`)
1114
+ - Full Support for API 6.0
1115
+ (:pr:`2956`)
1116
+ - Add Python 3.10 to Test Suite
1117
+ (:pr:`2968`)
1118
+
1119
+ Bug Fixes & Minor Changes:
1120
+ --------------------------
1121
+
1122
+ - Improve Type Hinting for ``CallbackContext``
1123
+ (:pr:`2587`
1124
+ by `revolter <https://github.com/revolter>`__)
1125
+ - Fix Signatures and Improve ``test_official``
1126
+ (:pr:`2643`)
1127
+ - Refine ``Dispatcher.dispatch_error``
1128
+ (:pr:`2660`)
1129
+ - Make ``InlineQuery.answer`` Raise ``ValueError``
1130
+ (:pr:`2675`)
1131
+ - Improve Signature Inspection for Bot Methods
1132
+ (:pr:`2686`)
1133
+ - Introduce ``TelegramObject.set/get_bot``
1134
+ (:pr:`2712`
1135
+ by `zpavloudis <https://github.com/zpavloudis>`__)
1136
+ - Improve Subscription of ``TelegramObject``
1137
+ (:pr:`2719`
1138
+ by `SimonDamberg <https://github.com/SimonDamberg>`__)
1139
+ - Use Enums for Dynamic Types & Rename Two Attributes in ``ChatMember``
1140
+ (:pr:`2817`)
1141
+ - Return Plain Dicts from ``BasePersistence.get_*_data``
1142
+ (:pr:`2873`)
1143
+ - Fix a Bug in ``ChatMemberUpdated.difference``
1144
+ (:pr:`2947`)
1145
+ - Update Dependency Policy
1146
+ (:pr:`2958`)
1147
+
1148
+ Internal Restructurings & Improvements:
1149
+ ---------------------------------------
1150
+
1151
+ - Add User Friendly Type Check For Init Of
1152
+ ``{Inline, Reply}KeyboardMarkup``
1153
+ (:pr:`2657`)
1154
+ - Warnings Overhaul
1155
+ (:pr:`2662`)
1156
+ - Clear Up Import Policy
1157
+ (:pr:`2671`)
1158
+ - Mark Internal Modules As Private
1159
+ (:pr:`2687`
1160
+ by `kencx <https://github.com/kencx>`__)
1161
+ - Handle Filepaths via the ``pathlib`` Module
1162
+ (:pr:`2688`
1163
+ by `eldbud <https://github.com/eldbud>`__)
1164
+ - Refactor MRO of ``InputMedia*`` and Some File-Like Classes
1165
+ (:pr:`2717`
1166
+ by `eldbud <https://github.com/eldbud>`__)
1167
+ - Update Exceptions for Immutable Attributes
1168
+ (:pr:`2749`)
1169
+ - Refactor Warnings in ``ConversationHandler``
1170
+ (:pr:`2755`,
1171
+ :pr:`2784`)
1172
+ - Use ``__all__`` Consistently
1173
+ (:pr:`2805`)
1174
+
1175
+ CI, Code Quality & Test Suite Improvements:
1176
+ -------------------------------------------
1177
+
1178
+ - Add Custom ``pytest`` Marker to Ease Development
1179
+ (:pr:`2628`)
1180
+ - Pass Failing Jobs to Error Handlers
1181
+ (:pr:`2692`)
1182
+ - Update Notification Workflows
1183
+ (:pr:`2695`)
1184
+ - Use Error Messages for ``pylint`` Instead of Codes
1185
+ (:pr:`2700`
1186
+ by `Piraty <https://github.com/Piraty>`__)
1187
+ - Make Tests Agnostic of the CWD
1188
+ (:pr:`2727`
1189
+ by `eldbud <https://github.com/eldbud>`__)
1190
+ - Update Code Quality Dependencies
1191
+ (:pr:`2748`)
1192
+ - Improve Code Quality
1193
+ (:pr:`2783`)
1194
+ - Update ``pre-commit`` Settings & Improve a Test
1195
+ (:pr:`2796`)
1196
+ - Improve Code Quality & Test Suite
1197
+ (:pr:`2843`)
1198
+ - Fix failing animation tests
1199
+ (:pr:`2865`)
1200
+ - Update and Expand Tests & pre-commit Settings and Improve Code
1201
+ Quality
1202
+ (:pr:`2925`)
1203
+ - Extend Code Formatting With Black
1204
+ (:pr:`2972`)
1205
+ - Update Workflow Permissions
1206
+ (:pr:`2984`)
1207
+ - Adapt Tests to Changed ``Bot.get_file`` Behavior
1208
+ (:pr:`2995`)
1209
+
1210
+ Documentation Improvements:
1211
+ ---------------------------
1212
+
1213
+ - Doc Fixes
1214
+ (:pr:`2597`)
1215
+ - Add Code Comment Guidelines to Contribution Guide
1216
+ (:pr:`2612`)
1217
+ - Add Cross-References to External Libraries & Other Documentation
1218
+ Improvements
1219
+ (:pr:`2693`,
1220
+ :pr:`2691`
1221
+ by `joesinghh <https://github.com/joesinghh>`__,
1222
+ :pr:`2739`
1223
+ by `eldbud <https://github.com/eldbud>`__)
1224
+ - Use Furo Theme, Make Parameters Referenceable, Add Documentation
1225
+ Building to CI, Improve Links to Source Code & Other Improvements
1226
+ (:pr:`2856`,
1227
+ :pr:`2798`,
1228
+ :pr:`2854`,
1229
+ :pr:`2841`)
1230
+ - Documentation Fixes & Improvements
1231
+ (:pr:`2822`)
1232
+ - Replace ``git.io`` Links
1233
+ (:pr:`2872`
1234
+ by `murugu-21 <https://github.com/murugu-21>`__)
1235
+ - Overhaul Readmes, Update RTD Startpage & Other Improvements
1236
+ (:pr:`2969`)
1237
+
1238
+ Version 13.11
1239
+ =============
1240
+ *Released 2022-02-02*
1241
+
1242
+ This is the technical changelog for version 13.11. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1243
+
1244
+ **Major Changes:**
1245
+
1246
+ - Full Support for Bot API 5.7 (:pr:`2881`)
1247
+
1248
+ Version 13.10
1249
+ =============
1250
+ *Released 2022-01-03*
1251
+
1252
+ This is the technical changelog for version 13.10. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1253
+
1254
+ **Major Changes:**
1255
+
1256
+ - Full Support for API 5.6 (:pr:`2835`)
1257
+
1258
+ **Minor Changes & Doc fixes:**
1259
+
1260
+ - Update Copyright to 2022 (:pr:`2836`)
1261
+ - Update Documentation of ``BotCommand`` (:pr:`2820`)
1262
+
1263
+ Version 13.9
1264
+ ============
1265
+ *Released 2021-12-11*
1266
+
1267
+ This is the technical changelog for version 13.9. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1268
+
1269
+ **Major Changes:**
1270
+
1271
+ - Full Support for Api 5.5 (:pr:`2809`)
1272
+
1273
+ **Minor Changes**
1274
+
1275
+ - Adjust Automated Locking of Inactive Issues (:pr:`2775`)
1276
+
1277
+ Version 13.8.1
1278
+ ==============
1279
+ *Released 2021-11-08*
1280
+
1281
+ This is the technical changelog for version 13.8.1. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1282
+
1283
+ **Doc fixes:**
1284
+
1285
+ - Add ``ChatJoinRequest(Handler)`` to Docs (:pr:`2771`)
1286
+
1287
+ Version 13.8
1288
+ ============
1289
+ *Released 2021-11-08*
1290
+
1291
+ This is the technical changelog for version 13.8. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1292
+
1293
+ **Major Changes:**
1294
+
1295
+ - Full support for API 5.4 (:pr:`2767`)
1296
+
1297
+ **Minor changes, CI improvements, Doc fixes and Type hinting:**
1298
+
1299
+ - Create Issue Template Forms (:pr:`2689`)
1300
+ - Fix ``camelCase`` Functions in ``ExtBot`` (:pr:`2659`)
1301
+ - Fix Empty Captions not Being Passed by ``Bot.copy_message`` (:pr:`2651`)
1302
+ - Fix Setting Thumbs When Uploading A Single File (:pr:`2583`)
1303
+ - Fix Bug in ``BasePersistence.insert``/``replace_bot`` for Objects with ``__dict__`` not in ``__slots__`` (:pr:`2603`)
1304
+
1305
+ Version 13.7
1306
+ ============
1307
+ *Released 2021-07-01*
1308
+
1309
+ This is the technical changelog for version 13.7. More elaborate release notes can be found in the news channel `@pythontelegrambotchannel <https://t.me/pythontelegrambotchannel>`_.
1310
+
1311
+ **Major Changes:**
1312
+
1313
+ - Full support for Bot API 5.3 (:pr:`2572`)
1314
+
1315
+ **Bug Fixes:**
1316
+
1317
+ - Fix Bug in ``BasePersistence.insert/replace_bot`` for Objects with ``__dict__`` in their slots (:pr:`2561`)
1318
+ - Remove Incorrect Warning About ``Defaults`` and ``ExtBot`` (:pr:`2553`)
1319
+
1320
+ **Minor changes, CI improvements, Doc fixes and Type hinting:**
1321
+
1322
+ - Type Hinting Fixes (:pr:`2552`)
1323
+ - Doc Fixes (:pr:`2551`)
1324
+ - Improve Deprecation Warning for ``__slots__`` (:pr:`2574`)
1325
+ - Stabilize CI (:pr:`2575`)
1326
+ - Fix Coverage Configuration (:pr:`2571`)
1327
+ - Better Exception-Handling for ``BasePersistence.replace/insert_bot`` (:pr:`2564`)
1328
+ - Remove Deprecated ``pass_args`` from Deeplinking Example (:pr:`2550`)
1329
+
1330
+ Version 13.6
1331
+ ============
1332
+ *Released 2021-06-06*
1333
+
1334
+ New Features:
1335
+
1336
+ - Arbitrary ``callback_data`` (:pr:`1844`)
1337
+ - Add ``ContextTypes`` & ``BasePersistence.refresh_user/chat/bot_data`` (:pr:`2262`)
1338
+ - Add ``Filters.attachment`` (:pr:`2528`)
1339
+ - Add ``pattern`` Argument to ``ChosenInlineResultHandler`` (:pr:`2517`)
1340
+
1341
+ Major Changes:
1342
+
1343
+ - Add ``slots`` (:pr:`2345`)
1344
+
1345
+ Minor changes, CI improvements, Doc fixes and Type hinting:
1346
+
1347
+ - Doc Fixes (:pr:`2495`, :pr:`2510`)
1348
+ - Add ``max_connections`` Parameter to ``Updater.start_webhook`` (:pr:`2547`)
1349
+ - Fix for ``Promise.done_callback`` (:pr:`2544`)
1350
+ - Improve Code Quality (:pr:`2536`, :pr:`2454`)
1351
+ - Increase Test Coverage of ``CallbackQueryHandler`` (:pr:`2520`)
1352
+ - Stabilize CI (:pr:`2522`, :pr:`2537`, :pr:`2541`)
1353
+ - Fix ``send_phone_number_to_provider`` argument for ``Bot.send_invoice`` (:pr:`2527`)
1354
+ - Handle Classes as Input for ``BasePersistence.replace/insert_bot`` (:pr:`2523`)
1355
+ - Bump Tornado Version and Remove Workaround from :pr:`2067` (:pr:`2494`)
1356
+
1357
+ Version 13.5
1358
+ ============
1359
+ *Released 2021-04-30*
1360
+
1361
+ **Major Changes:**
1362
+
1363
+ - Full support of Bot API 5.2 (:pr:`2489`).
1364
+
1365
+ .. note::
1366
+ The ``start_parameter`` argument of ``Bot.send_invoice`` and the corresponding shortcuts is now optional, so the order of
1367
+ parameters had to be changed. Make sure to update your method calls accordingly.
1368
+
1369
+ - Update ``ChatActions``, Deprecating ``ChatAction.RECORD_AUDIO`` and ``ChatAction.UPLOAD_AUDIO`` (:pr:`2460`)
1370
+
1371
+ **New Features:**
1372
+
1373
+ - Convenience Utilities & Example for Handling ``ChatMemberUpdated`` (:pr:`2490`)
1374
+ - ``Filters.forwarded_from`` (:pr:`2446`)
1375
+
1376
+ **Minor changes, CI improvements, Doc fixes and Type hinting:**
1377
+
1378
+ - Improve Timeouts in ``ConversationHandler`` (:pr:`2417`)
1379
+ - Stabilize CI (:pr:`2480`)
1380
+ - Doc Fixes (:pr:`2437`)
1381
+ - Improve Type Hints of Data Filters (:pr:`2456`)
1382
+ - Add Two ``UserWarnings`` (:pr:`2464`)
1383
+ - Improve Code Quality (:pr:`2450`)
1384
+ - Update Fallback Test-Bots (:pr:`2451`)
1385
+ - Improve Examples (:pr:`2441`, :pr:`2448`)
1386
+
1387
+ Version 13.4.1
1388
+ ==============
1389
+ *Released 2021-03-14*
1390
+
1391
+ **Hot fix release:**
1392
+
1393
+ - Fixed a bug in ``setup.py`` (:pr:`2431`)
1394
+
1395
+ Version 13.4
1396
+ ============
1397
+ *Released 2021-03-14*
1398
+
1399
+ **Major Changes:**
1400
+
1401
+ - Full support of Bot API 5.1 (:pr:`2424`)
1402
+
1403
+ **Minor changes, CI improvements, doc fixes and type hinting:**
1404
+
1405
+ - Improve ``Updater.set_webhook`` (:pr:`2419`)
1406
+ - Doc Fixes (:pr:`2404`)
1407
+ - Type Hinting Fixes (:pr:`2425`)
1408
+ - Update ``pre-commit`` Settings (:pr:`2415`)
1409
+ - Fix Logging for Vendored ``urllib3`` (:pr:`2427`)
1410
+ - Stabilize Tests (:pr:`2409`)
1411
+
1412
+ Version 13.3
1413
+ ============
1414
+ *Released 2021-02-19*
1415
+
1416
+ **Major Changes:**
1417
+
1418
+ - Make ``cryptography`` Dependency Optional & Refactor Some Tests (:pr:`2386`, :pr:`2370`)
1419
+ - Deprecate ``MessageQueue`` (:pr:`2393`)
1420
+
1421
+ **Bug Fixes:**
1422
+
1423
+ - Refactor ``Defaults`` Integration (:pr:`2363`)
1424
+ - Add Missing ``telegram.SecureValue`` to init and Docs (:pr:`2398`)
1425
+
1426
+ **Minor changes:**
1427
+
1428
+ - Doc Fixes (:pr:`2359`)
1429
+
1430
+ Version 13.2
1431
+ ============
1432
+ *Released 2021-02-02*
1433
+
1434
+ **Major Changes:**
1435
+
1436
+ - Introduce ``python-telegram-bot-raw`` (:pr:`2324`)
1437
+ - Explicit Signatures for Shortcuts (:pr:`2240`)
1438
+
1439
+ **New Features:**
1440
+
1441
+ - Add Missing Shortcuts to ``Message`` (:pr:`2330`)
1442
+ - Rich Comparison for ``Bot`` (:pr:`2320`)
1443
+ - Add ``run_async`` Parameter to ``ConversationHandler`` (:pr:`2292`)
1444
+ - Add New Shortcuts to ``Chat`` (:pr:`2291`)
1445
+ - Add New Constant ``MAX_ANSWER_CALLBACK_QUERY_TEXT_LENGTH`` (:pr:`2282`)
1446
+ - Allow Passing Custom Filename For All Media (:pr:`2249`)
1447
+ - Handle Bytes as File Input (:pr:`2233`)
1448
+
1449
+ **Bug Fixes:**
1450
+
1451
+ - Fix Escaping in Nested Entities in ``Message`` Properties (:pr:`2312`)
1452
+ - Adjust Calling of ``Dispatcher.update_persistence`` (:pr:`2285`)
1453
+ - Add ``quote`` kwarg to ``Message.reply_copy`` (:pr:`2232`)
1454
+ - ``ConversationHandler``: Docs & ``edited_channel_post`` behavior (:pr:`2339`)
1455
+
1456
+ **Minor changes, CI improvements, doc fixes and type hinting:**
1457
+
1458
+ - Doc Fixes (:pr:`2253`, :pr:`2225`)
1459
+ - Reduce Usage of ``typing.Any`` (:pr:`2321`)
1460
+ - Extend Deeplinking Example (:pr:`2335`)
1461
+ - Add pyupgrade to pre-commit Hooks (:pr:`2301`)
1462
+ - Add PR Template (:pr:`2299`)
1463
+ - Drop Nightly Tests & Update Badges (:pr:`2323`)
1464
+ - Update Copyright (:pr:`2289`, :pr:`2287`)
1465
+ - Change Order of Class DocStrings (:pr:`2256`)
1466
+ - Add macOS to Test Matrix (:pr:`2266`)
1467
+ - Start Using Versioning Directives in Docs (:pr:`2252`)
1468
+ - Improve Annotations & Docs of Handlers (:pr:`2243`)
1469
+
1470
+ Version 13.1
1471
+ ============
1472
+ *Released 2020-11-29*
1473
+
1474
+ **Major Changes:**
1475
+
1476
+ - Full support of Bot API 5.0 (:pr:`2181`, :pr:`2186`, :pr:`2190`, :pr:`2189`, :pr:`2183`, :pr:`2184`, :pr:`2188`, :pr:`2185`, :pr:`2192`, :pr:`2196`, :pr:`2193`, :pr:`2223`, :pr:`2199`, :pr:`2187`, :pr:`2147`, :pr:`2205`)
1477
+
1478
+ **New Features:**
1479
+
1480
+ - Add ``Defaults.run_async`` (:pr:`2210`)
1481
+ - Improve and Expand ``CallbackQuery`` Shortcuts (:pr:`2172`)
1482
+ - Add XOR Filters and make ``Filters.name`` a Property (:pr:`2179`)
1483
+ - Add ``Filters.document.file_extension`` (:pr:`2169`)
1484
+ - Add ``Filters.caption_regex`` (:pr:`2163`)
1485
+ - Add ``Filters.chat_type`` (:pr:`2128`)
1486
+ - Handle Non-Binary File Input (:pr:`2202`)
1487
+
1488
+ **Bug Fixes:**
1489
+
1490
+ - Improve Handling of Custom Objects in ``BasePersistence.insert``/``replace_bot`` (:pr:`2151`)
1491
+ - Fix bugs in ``replace/insert_bot`` (:pr:`2218`)
1492
+
1493
+ **Minor changes, CI improvements, doc fixes and type hinting:**
1494
+
1495
+ - Improve Type hinting (:pr:`2204`, :pr:`2118`, :pr:`2167`, :pr:`2136`)
1496
+ - Doc Fixes & Extensions (:pr:`2201`, :pr:`2161`)
1497
+ - Use F-Strings Where Possible (:pr:`2222`)
1498
+ - Rename kwargs to _kwargs where possible (:pr:`2182`)
1499
+ - Comply with PEP561 (:pr:`2168`)
1500
+ - Improve Code Quality (:pr:`2131`)
1501
+ - Switch Code Formatting to Black (:pr:`2122`, :pr:`2159`, :pr:`2158`)
1502
+ - Update Wheel Settings (:pr:`2142`)
1503
+ - Update ``timerbot.py`` to ``v13.0`` (:pr:`2149`)
1504
+ - Overhaul Constants (:pr:`2137`)
1505
+ - Add Python 3.9 to Test Matrix (:pr:`2132`)
1506
+ - Switch Codecov to ``GitHub`` Action (:pr:`2127`)
1507
+ - Specify Required pytz Version (:pr:`2121`)
1508
+
1509
+ Version 13.0
1510
+ ============
1511
+ *Released 2020-10-07*
1512
+
1513
+ **For a detailed guide on how to migrate from v12 to v13, see this** `wiki page <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-13.0>`_.
1514
+
1515
+ **Major Changes:**
1516
+
1517
+ - Deprecate old-style callbacks, i.e. set ``use_context=True`` by default (:pr:`2050`)
1518
+ - Refactor Handling of Message VS Update Filters (:pr:`2032`)
1519
+ - Deprecate ``Message.default_quote`` (:pr:`1965`)
1520
+ - Refactor persistence of Bot instances (:pr:`1994`)
1521
+ - Refactor ``JobQueue`` (:pr:`1981`)
1522
+ - Refactor handling of kwargs in Bot methods (:pr:`1924`)
1523
+ - Refactor ``Dispatcher.run_async``, deprecating the ``@run_async`` decorator (:pr:`2051`)
1524
+
1525
+ **New Features:**
1526
+
1527
+ - Type Hinting (:pr:`1920`)
1528
+ - Automatic Pagination for ``answer_inline_query`` (:pr:`2072`)
1529
+ - ``Defaults.tzinfo`` (:pr:`2042`)
1530
+ - Extend rich comparison of objects (:pr:`1724`)
1531
+ - Add ``Filters.via_bot`` (:pr:`2009`)
1532
+ - Add missing shortcuts (:pr:`2043`)
1533
+ - Allow ``DispatcherHandlerStop`` in ``ConversationHandler`` (:pr:`2059`)
1534
+ - Make Errors picklable (:pr:`2106`)
1535
+
1536
+ **Minor changes, CI improvements, doc fixes or bug fixes:**
1537
+
1538
+ - Fix Webhook not working on Windows with Python 3.8+ (:pr:`2067`)
1539
+ - Fix setting thumbs with ``send_media_group`` (:pr:`2093`)
1540
+ - Make ``MessageHandler`` filter for ``Filters.update`` first (:pr:`2085`)
1541
+ - Fix ``PicklePersistence.flush()`` with only ``bot_data`` (:pr:`2017`)
1542
+ - Add test for clean argument of ``Updater.start_polling/webhook`` (:pr:`2002`)
1543
+ - Doc fixes, refinements and additions (:pr:`2005`, :pr:`2008`, :pr:`2089`, :pr:`2094`, :pr:`2090`)
1544
+ - CI fixes (:pr:`2018`, :pr:`2061`)
1545
+ - Refine ``pollbot.py`` example (:pr:`2047`)
1546
+ - Refine Filters in examples (:pr:`2027`)
1547
+ - Rename ``echobot`` examples (:pr:`2025`)
1548
+ - Use Lock-Bot to lock old threads (:pr:`2048`, :pr:`2052`, :pr:`2049`, :pr:`2053`)
1549
+
1550
+ Version 12.8
1551
+ ============
1552
+ *Released 2020-06-22*
1553
+
1554
+ **Major Changes:**
1555
+
1556
+ - Remove Python 2 support (:pr:`1715`)
1557
+ - Bot API 4.9 support (:pr:`1980`)
1558
+ - IDs/Usernames of ``Filters.user`` and ``Filters.chat`` can now be updated (:pr:`1757`)
1559
+
1560
+ **Minor changes, CI improvements, doc fixes or bug fixes:**
1561
+
1562
+ - Update contribution guide and stale bot (:pr:`1937`)
1563
+ - Remove ``NullHandlers`` (:pr:`1913`)
1564
+ - Improve and expand examples (:pr:`1943`, :pr:`1995`, :pr:`1983`, :pr:`1997`)
1565
+ - Doc fixes (:pr:`1940`, :pr:`1962`)
1566
+ - Add ``User.send_poll()`` shortcut (:pr:`1968`)
1567
+ - Ignore private attributes en ``TelegramObject.to_dict()`` (:pr:`1989`)
1568
+ - Stabilize CI (:pr:`2000`)
1569
+
1570
+ Version 12.7
1571
+ ============
1572
+ *Released 2020-05-02*
1573
+
1574
+ **Major Changes:**
1575
+
1576
+ - Bot API 4.8 support. **Note:** The ``Dice`` object now has a second positional argument ``emoji``. This is relevant, if you instantiate ``Dice`` objects manually. (:pr:`1917`)
1577
+ - Added ``tzinfo`` argument to ``helpers.from_timestamp``. It now returns an timezone aware object. This is relevant for ``Message.{date,forward_date,edit_date}``, ``Poll.close_date`` and ``ChatMember.until_date`` (:pr:`1621`)
1578
+
1579
+ **New Features:**
1580
+
1581
+ - New method ``run_monthly`` for the ``JobQueue`` (:pr:`1705`)
1582
+ - ``Job.next_t`` now gives the datetime of the jobs next execution (:pr:`1685`)
1583
+
1584
+ **Minor changes, CI improvements, doc fixes or bug fixes:**
1585
+
1586
+ - Stabalize CI (:pr:`1919`, :pr:`1931`)
1587
+ - Use ABCs ``@abstractmethod`` instead of raising ``NotImplementedError`` for ``Handler``, ``BasePersistence`` and ``BaseFilter`` (:pr:`1905`)
1588
+ - Doc fixes (:pr:`1914`, :pr:`1902`, :pr:`1910`)
1589
+
1590
+ Version 12.6.1
1591
+ ==============
1592
+ *Released 2020-04-11*
1593
+
1594
+ **Bug fixes:**
1595
+
1596
+ - Fix serialization of ``reply_markup`` in media messages (:pr:`1889`)
1597
+
1598
+ Version 12.6
1599
+ ============
1600
+ *Released 2020-04-10*
1601
+
1602
+ **Major Changes:**
1603
+
1604
+ - Bot API 4.7 support. **Note:** In ``Bot.create_new_sticker_set`` and ``Bot.add_sticker_to_set``, the order of the parameters had be changed, as the ``png_sticker`` parameter is now optional. (:pr:`1858`)
1605
+
1606
+ **Minor changes, CI improvements or bug fixes:**
1607
+
1608
+ - Add tests for ``swtich_inline_query(_current_chat)`` with empty string (:pr:`1635`)
1609
+ - Doc fixes (:pr:`1854`, :pr:`1874`, :pr:`1884`)
1610
+ - Update issue templates (:pr:`1880`)
1611
+ - Favor concrete types over "Iterable" (:pr:`1882`)
1612
+ - Pass last valid ``CallbackContext`` to ``TIMEOUT`` handlers of ``ConversationHandler`` (:pr:`1826`)
1613
+ - Tweak handling of persistence and update persistence after job calls (:pr:`1827`)
1614
+ - Use checkout@v2 for GitHub actions (:pr:`1887`)
1615
+
1616
+ Version 12.5.1
1617
+ ==============
1618
+ *Released 2020-03-30*
1619
+
1620
+ **Minor changes, doc fixes or bug fixes:**
1621
+
1622
+ - Add missing docs for `PollHandler` and `PollAnswerHandler` (:pr:`1853`)
1623
+ - Fix wording in `Filters` docs (:pr:`1855`)
1624
+ - Reorder tests to make them more stable (:pr:`1835`)
1625
+ - Make `ConversationHandler` attributes immutable (:pr:`1756`)
1626
+ - Make `PrefixHandler` attributes `command` and `prefix` editable (:pr:`1636`)
1627
+ - Fix UTC as default `tzinfo` for `Job` (:pr:`1696`)
1628
+
1629
+ Version 12.5
1630
+ ============
1631
+ *Released 2020-03-29*
1632
+
1633
+ **New Features:**
1634
+
1635
+ - `Bot.link` gives the `t.me` link of the bot (:pr:`1770`)
1636
+
1637
+ **Major Changes:**
1638
+
1639
+ - Bot API 4.5 and 4.6 support. (:pr:`1508`, :pr:`1723`)
1640
+
1641
+ **Minor changes, CI improvements or bug fixes:**
1642
+
1643
+ - Remove legacy CI files (:pr:`1783`, :pr:`1791`)
1644
+ - Update pre-commit config file (:pr:`1787`)
1645
+ - Remove builtin names (:pr:`1792`)
1646
+ - CI improvements (:pr:`1808`, :pr:`1848`)
1647
+ - Support Python 3.8 (:pr:`1614`, :pr:`1824`)
1648
+ - Use stale bot for auto closing stale issues (:pr:`1820`, :pr:`1829`, :pr:`1840`)
1649
+ - Doc fixes (:pr:`1778`, :pr:`1818`)
1650
+ - Fix typo in `edit_message_media` (:pr:`1779`)
1651
+ - In examples, answer CallbackQueries and use `edit_message_text` shortcut (:pr:`1721`)
1652
+ - Revert accidental change in vendored urllib3 (:pr:`1775`)
1653
+
1654
+ Version 12.4.2
1655
+ ==============
1656
+ *Released 2020-02-10*
1657
+
1658
+ **Bug Fixes**
1659
+
1660
+ - Pass correct parse_mode to InlineResults if bot.defaults is None (:pr:`1763`)
1661
+ - Make sure PP can read files that dont have bot_data (:pr:`1760`)
1662
+
1663
+ Version 12.4.1
1664
+ ==============
1665
+ *Released 2020-02-08*
1666
+
1667
+ This is a quick release for :pr:`1744` which was accidently left out of v12.4.0 though mentioned in the
1668
+ release notes.
1669
+
1670
+ Version 12.4.0
1671
+ ==============
1672
+ *Released 2020-02-08*
1673
+
1674
+ **New features:**
1675
+
1676
+ - Set default values for arguments appearing repeatedly. We also have a `wiki page for the new defaults`_. (:pr:`1490`)
1677
+ - Store data in ``CallbackContext.bot_data`` to access it in every callback. Also persists. (:pr:`1325`)
1678
+ - ``Filters.poll`` allows only messages containing a poll (:pr:`1673`)
1679
+
1680
+ **Major changes:**
1681
+
1682
+ - ``Filters.text`` now accepts messages that start with a slash, because ``CommandHandler`` checks for ``MessageEntity.BOT_COMMAND`` since v12. This might lead to your MessageHandlers receiving more updates than before (:pr:`1680`).
1683
+ - ``Filters.command`` new checks for ``MessageEntity.BOT_COMMAND`` instead of just a leading slash. Also by ``Filters.command(False)`` you can now filters for messages containing a command `anywhere` in the text (:pr:`1744`).
1684
+
1685
+ **Minor changes, CI improvements or bug fixes:**
1686
+
1687
+ - Add ``disptacher`` argument to ``Updater`` to allow passing a customized ``Dispatcher`` (:pr:`1484`)
1688
+ - Add missing names for ``Filters`` (:pr:`1632`)
1689
+ - Documentation fixes (:pr:`1624`, :pr:`1647`, :pr:`1669`, :pr:`1703`, :pr:`1718`, :pr:`1734`, :pr:`1740`, :pr:`1642`, :pr:`1739`, :pr:`1746`)
1690
+ - CI improvements (:pr:`1716`, :pr:`1731`, :pr:`1738`, :pr:`1748`, :pr:`1749`, :pr:`1750`, :pr:`1752`)
1691
+ - Fix spelling issue for ``encode_conversations_to_json`` (:pr:`1661`)
1692
+ - Remove double assignement of ``Dispatcher.job_queue`` (:pr:`1698`)
1693
+ - Expose dispatcher as property for ``CallbackContext`` (:pr:`1684`)
1694
+ - Fix ``None`` check in ``JobQueue._put()`` (:pr:`1707`)
1695
+ - Log datetimes correctly in ``JobQueue`` (:pr:`1714`)
1696
+ - Fix false ``Message.link`` creation for private groups (:pr:`1741`)
1697
+ - Add option ``--with-upstream-urllib3`` to `setup.py` to allow using non-vendored version (:pr:`1725`)
1698
+ - Fix persistence for nested ``ConversationHandlers`` (:pr:`1679`)
1699
+ - Improve handling of non-decodable server responses (:pr:`1623`)
1700
+ - Fix download for files without ``file_path`` (:pr:`1591`)
1701
+ - test_webhook_invalid_posts is now considered flaky and retried on failure (:pr:`1758`)
1702
+
1703
+ .. _`wiki page for the new defaults`: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Adding-defaults-to-your-bot
1704
+
1705
+ Version 12.3.0
1706
+ ==============
1707
+ *Released 2020-01-11*
1708
+
1709
+ **New features:**
1710
+
1711
+ - `Filters.caption` allows only messages with caption (:pr:`1631`).
1712
+ - Filter for exact messages/captions with new capability of `Filters.text` and `Filters.caption`. Especially useful in combination with ReplyKeyboardMarkup. (:pr:`1631`).
1713
+
1714
+ **Major changes:**
1715
+
1716
+ - Fix inconsistent handling of naive datetimes (:pr:`1506`).
1717
+
1718
+ **Minor changes, CI improvements or bug fixes:**
1719
+
1720
+ - Documentation fixes (:pr:`1558`, :pr:`1569`, :pr:`1579`, :pr:`1572`, :pr:`1566`, :pr:`1577`, :pr:`1656`).
1721
+ - Add mutex protection on `ConversationHandler` (:pr:`1533`).
1722
+ - Add `MAX_PHOTOSIZE_UPLOAD` constant (:pr:`1560`).
1723
+ - Add args and kwargs to `Message.forward()` (:pr:`1574`).
1724
+ - Transfer to GitHub Actions CI (:pr:`1555`, :pr:`1556`, :pr:`1605`, :pr:`1606`, :pr:`1607`, :pr:`1612`, :pr:`1615`, :pr:`1645`).
1725
+ - Fix deprecation warning with Py3.8 by vendored urllib3 (:pr:`1618`).
1726
+ - Simplify assignements for optional arguments (:pr:`1600`)
1727
+ - Allow private groups for `Message.link` (:pr:`1619`).
1728
+ - Fix wrong signature call for `ConversationHandler.TIMEOUT` handlers (:pr:`1653`).
1729
+
1730
+ Version 12.2.0
1731
+ ==============
1732
+ *Released 2019-10-14*
1733
+
1734
+ **New features:**
1735
+
1736
+ - Nested ConversationHandlers (:pr:`1512`).
1737
+
1738
+ **Minor changes, CI improvments or bug fixes:**
1739
+
1740
+ - Fix CI failures due to non-backward compat attrs depndency (:pr:`1540`).
1741
+ - travis.yaml: TEST_OFFICIAL removed from allowed_failures.
1742
+ - Fix typos in examples (:pr:`1537`).
1743
+ - Fix Bot.to_dict to use proper first_name (:pr:`1525`).
1744
+ - Refactor ``test_commandhandler.py`` (:pr:`1408`).
1745
+ - Add Python 3.8 (RC version) to Travis testing matrix (:pr:`1543`).
1746
+ - test_bot.py: Add to_dict test (:pr:`1544`).
1747
+ - Flake config moved into setup.cfg (:pr:`1546`).
1748
+
1749
+ Version 12.1.1
1750
+ ==============
1751
+ *Released 2019-09-18*
1752
+
1753
+ **Hot fix release**
1754
+
1755
+ Fixed regression in the vendored urllib3 (:pr:`1517`).
1756
+
1757
+ Version 12.1.0
1758
+ ================
1759
+ *Released 2019-09-13*
1760
+
1761
+ **Major changes:**
1762
+
1763
+ - Bot API 4.4 support (:pr:`1464`, :pr:`1510`)
1764
+ - Add `get_file` method to `Animation` & `ChatPhoto`. Add, `get_small_file` & `get_big_file`
1765
+ methods to `ChatPhoto` (:pr:`1489`)
1766
+ - Tools for deep linking (:pr:`1049`)
1767
+
1768
+ **Minor changes and/or bug fixes:**
1769
+
1770
+ - Documentation fixes (:pr:`1500`, :pr:`1499`)
1771
+ - Improved examples (:pr:`1502`)
1772
+
1773
+ Version 12.0.0
1774
+ ================
1775
+ *Released 2019-08-29*
1776
+
1777
+ Well... This felt like decades. But here we are with a new release.
1778
+
1779
+ Expect minor releases soon (mainly complete Bot API 4.4 support)
1780
+
1781
+ **Major and/or breaking changes:**
1782
+
1783
+ - Context based callbacks
1784
+ - Persistence
1785
+ - PrefixHandler added (Handler overhaul)
1786
+ - Deprecation of RegexHandler and edited_messages, channel_post, etc. arguments (Filter overhaul)
1787
+ - Various ConversationHandler changes and fixes
1788
+ - Bot API 4.1, 4.2, 4.3 support
1789
+ - Python 3.4 is no longer supported
1790
+ - Error Handler now handles all types of exceptions (:pr:`1485`)
1791
+ - Return UTC from from_timestamp() (:pr:`1485`)
1792
+
1793
+ **See the wiki page at https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-12.0 for a detailed guide on how to migrate from version 11 to version 12.**
1794
+
1795
+ Context based callbacks (:pr:`1100`)
1796
+ ------------------------------------
1797
+
1798
+ - Use of ``pass_`` in handlers is deprecated.
1799
+ - Instead use ``use_context=True`` on ``Updater`` or ``Dispatcher`` and change callback from (bot, update, others...) to (update, context).
1800
+ - This also applies to error handlers ``Dispatcher.add_error_handler`` and JobQueue jobs (change (bot, job) to (context) here).
1801
+ - For users with custom handlers subclassing Handler, this is mostly backwards compatible, but to use the new context based callbacks you need to implement the new collect_additional_context method.
1802
+ - Passing bot to ``JobQueue.__init__`` is deprecated. Use JobQueue.set_dispatcher with a dispatcher instead.
1803
+ - Dispatcher makes sure to use a single `CallbackContext` for a entire update. This means that if an update is handled by multiple handlers (by using the group argument), you can add custom arguments to the `CallbackContext` in a lower group handler and use it in higher group handler. NOTE: Never use with @run_async, see docs for more info. (:pr:`1283`)
1804
+ - If you have custom handlers they will need to be updated to support the changes in this release.
1805
+ - Update all examples to use context based callbacks.
1806
+
1807
+ Persistence (:pr:`1017`)
1808
+ ------------------------
1809
+
1810
+ - Added PicklePersistence and DictPersistence for adding persistence to your bots.
1811
+ - BasePersistence can be subclassed for all your persistence needs.
1812
+ - Add a new example that shows a persistent ConversationHandler bot
1813
+
1814
+ Handler overhaul (:pr:`1114`)
1815
+ -----------------------------
1816
+
1817
+ - CommandHandler now only triggers on actual commands as defined by telegram servers (everything that the clients mark as a tabable link).
1818
+ - PrefixHandler can be used if you need to trigger on prefixes (like all messages starting with a "/" (old CommandHandler behaviour) or even custom prefixes like "#" or "!").
1819
+
1820
+ Filter overhaul (:pr:`1221`)
1821
+ ----------------------------
1822
+
1823
+ - RegexHandler is deprecated and should be replaced with a MessageHandler with a regex filter.
1824
+ - Use update filters to filter update types instead of arguments (message_updates, channel_post_updates and edited_updates) on the handlers.
1825
+ - Completely remove allow_edited argument - it has been deprecated for a while.
1826
+ - data_filters now exist which allows filters that return data into the callback function. This is how the regex filter is implemented.
1827
+ - All this means that it no longer possible to use a list of filters in a handler. Use bitwise operators instead!
1828
+
1829
+ ConversationHandler
1830
+ -------------------
1831
+
1832
+ - Remove ``run_async_timeout`` and ``timed_out_behavior`` arguments (:pr:`1344`)
1833
+ - Replace with ``WAITING`` constant and behavior from states (:pr:`1344`)
1834
+ - Only emit one warning for multiple CallbackQueryHandlers in a ConversationHandler (:pr:`1319`)
1835
+ - Use warnings.warn for ConversationHandler warnings (:pr:`1343`)
1836
+ - Fix unresolvable promises (:pr:`1270`)
1837
+
1838
+ Bug fixes & improvements
1839
+ ------------------------
1840
+
1841
+ - Handlers should be faster due to deduped logic.
1842
+ - Avoid compiling compiled regex in regex filter. (:pr:`1314`)
1843
+ - Add missing ``left_chat_member`` to Message.MESSAGE_TYPES (:pr:`1336`)
1844
+ - Make custom timeouts actually work properly (:pr:`1330`)
1845
+ - Add convenience classmethods (from_button, from_row and from_column) to InlineKeyboardMarkup
1846
+ - Small typo fix in setup.py (:pr:`1306`)
1847
+ - Add Conflict error (HTTP error code 409) (:pr:`1154`)
1848
+ - Change MAX_CAPTION_LENGTH to 1024 (:pr:`1262`)
1849
+ - Remove some unnecessary clauses (:pr:`1247`, :pr:`1239`)
1850
+ - Allow filenames without dots in them when sending files (:pr:`1228`)
1851
+ - Fix uploading files with unicode filenames (:pr:`1214`)
1852
+ - Replace http.server with Tornado (:pr:`1191`)
1853
+ - Allow SOCKSConnection to parse username and password from URL (:pr:`1211`)
1854
+ - Fix for arguments in passport/data.py (:pr:`1213`)
1855
+ - Improve message entity parsing by adding text_mention (:pr:`1206`)
1856
+ - Documentation fixes (:pr:`1348`, :pr:`1397`, :pr:`1436`)
1857
+ - Merged filters short-circuit (:pr:`1350`)
1858
+ - Fix webhook listen with tornado (:pr:`1383`)
1859
+ - Call task_done() on update queue after update processing finished (:pr:`1428`)
1860
+ - Fix send_location() - latitude may be 0 (:pr:`1437`)
1861
+ - Make MessageEntity objects comparable (:pr:`1465`)
1862
+ - Add prefix to thread names (:pr:`1358`)
1863
+
1864
+ Buf fixes since v12.0.0b1
1865
+ -------------------------
1866
+
1867
+ - Fix setting bot on ShippingQuery (:pr:`1355`)
1868
+ - Fix _trigger_timeout() missing 1 required positional argument: 'job' (:pr:`1367`)
1869
+ - Add missing message.text check in PrefixHandler check_update (:pr:`1375`)
1870
+ - Make updates persist even on DispatcherHandlerStop (:pr:`1463`)
1871
+ - Dispatcher force updating persistence object's chat data attribute(:pr:`1462`)
1872
+
1873
+ Internal improvements
1874
+ ---------------------
1875
+
1876
+ - Finally fix our CI builds mostly (too many commits and PRs to list)
1877
+ - Use multiple bots for CI to improve testing times significantly.
1878
+ - Allow pypy to fail in CI.
1879
+ - Remove the last CamelCase CheckUpdate methods from the handlers we missed earlier.
1880
+ - test_official is now executed in a different job
1881
+
1882
+ Version 11.1.0
1883
+ ==============
1884
+ *Released 2018-09-01*
1885
+
1886
+ Fixes and updates for Telegram Passport: (:pr:`1198`)
1887
+
1888
+ - Fix passport decryption failing at random times
1889
+ - Added support for middle names.
1890
+ - Added support for translations for documents
1891
+ - Add errors for translations for documents
1892
+ - Added support for requesting names in the language of the user's country of residence
1893
+ - Replaced the payload parameter with the new parameter nonce
1894
+ - Add hash to EncryptedPassportElement
1895
+
1896
+ Version 11.0.0
1897
+ ==============
1898
+ *Released 2018-08-29*
1899
+
1900
+ Fully support Bot API version 4.0!
1901
+ (also some bugfixes :))
1902
+
1903
+ Telegram Passport (:pr:`1174`):
1904
+
1905
+ - Add full support for telegram passport.
1906
+ - New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
1907
+ - New bot method: set_passport_data_errors
1908
+ - New filter: Filters.passport_data
1909
+ - Field passport_data field on Message
1910
+ - PassportData can be easily decrypted.
1911
+ - PassportFiles are automatically decrypted if originating from decrypted PassportData.
1912
+ - See new passportbot.py example for details on how to use, or go to `our telegram passport wiki page`_ for more info
1913
+ - NOTE: Passport decryption requires new dependency `cryptography`.
1914
+
1915
+ Inputfile rework (:pr:`1184`):
1916
+
1917
+ - Change how Inputfile is handled internally
1918
+ - This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send\_ methods.
1919
+ - Also allows Bot.send_media_group to actually finally send more than one media.
1920
+ - Add thumb to Audio, Video and Videonote
1921
+ - Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
1922
+
1923
+ Other Bot API 4.0 changes:
1924
+
1925
+ - Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (:pr:`1170`)
1926
+ - Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (:pr:`1166`)
1927
+ - Support new message entities: CASHTAG and PHONE_NUMBER. (:pr:`1179`)
1928
+ - Cashtag seems to be things like `$USD` and `$GBP`, but it seems telegram doesn't currently send them to bots.
1929
+ - Phone number also seems to have limited support for now
1930
+ - Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (:pr:`1172`)
1931
+
1932
+ Non Bot API 4.0 changes:
1933
+
1934
+ - Minor integer comparison fix (:pr:`1147`)
1935
+ - Fix Filters.regex failing on non-text message (:pr:`1158`)
1936
+ - Fix ProcessLookupError if process finishes before we kill it (:pr:`1126`)
1937
+ - Add t.me links for User, Chat and Message if available and update User.mention_* (:pr:`1092`)
1938
+ - Fix mention_markdown/html on py2 (:pr:`1112`)
1939
+
1940
+ .. _`our telegram passport wiki page`: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport
1941
+
1942
+ Version 10.1.0
1943
+ ==============
1944
+ *Released 2018-05-02*
1945
+
1946
+ Fixes changing previous behaviour:
1947
+
1948
+ - Add urllib3 fix for socks5h support (:pr:`1085`)
1949
+ - Fix send_sticker() timeout=20 (:pr:`1088`)
1950
+
1951
+ Fixes:
1952
+
1953
+ - Add a caption_entity filter for filtering caption entities (:pr:`1068`)
1954
+ - Inputfile encode filenames (:pr:`1086`)
1955
+ - InputFile: Fix proper naming of file when reading from subprocess.PIPE (:pr:`1079`)
1956
+ - Remove pytest-catchlog from requirements (:pr:`1099`)
1957
+ - Documentation fixes (:pr:`1061`, :pr:`1078`, :pr:`1081`, :pr:`1096`)
1958
+
1959
+ Version 10.0.2
1960
+ ==============
1961
+ *Released 2018-04-17*
1962
+
1963
+ Important fix:
1964
+
1965
+ - Handle utf8 decoding errors (:pr:`1076`)
1966
+
1967
+ New features:
1968
+
1969
+ - Added Filter.regex (:pr:`1028`)
1970
+ - Filters for Category and file types (:pr:`1046`)
1971
+ - Added video note filter (:pr:`1067`)
1972
+
1973
+ Fixes:
1974
+
1975
+ - Fix in telegram.Message (:pr:`1042`)
1976
+ - Make chat_id a positional argument inside shortcut methods of Chat and User classes (:pr:`1050`)
1977
+ - Make Bot.full_name return a unicode object. (:pr:`1063`)
1978
+ - CommandHandler faster check (:pr:`1074`)
1979
+ - Correct documentation of Dispatcher.add_handler (:pr:`1071`)
1980
+ - Various small fixes to documentation.
1981
+
1982
+ Version 10.0.1
1983
+ ==============
1984
+ *Released 2018-03-05*
1985
+
1986
+ Fixes:
1987
+
1988
+ - Fix conversationhandler timeout (PR :pr:`1032`)
1989
+ - Add missing docs utils (PR :pr:`912`)
1990
+
1991
+ Version 10.0.0
1992
+ ==============
1993
+ *Released 2018-03-02*
1994
+
1995
+ Non backward compatabile changes and changed defaults
1996
+
1997
+ - JobQueue: Remove deprecated prevent_autostart & put() (PR :pr:`1012`)
1998
+ - Bot, Updater: Remove deprecated network_delay (PR :pr:`1012`)
1999
+ - Remove deprecated Message.new_chat_member (PR :pr:`1012`)
2000
+ - Retry bootstrap phase indefinitely (by default) on network errors (PR :pr:`1018`)
2001
+
2002
+ New Features
2003
+
2004
+ - Support v3.6 API (PR :pr:`1006`)
2005
+ - User.full_name convinience property (PR :pr:`949`)
2006
+ - Add `send_phone_number_to_provider` and `send_email_to_provider` arguments to send_invoice (PR :pr:`986`)
2007
+ - Bot: Add shortcut methods reply_{markdown,html} (PR :pr:`827`)
2008
+ - Bot: Add shortcut method reply_media_group (PR :pr:`994`)
2009
+ - Added utils.helpers.effective_message_type (PR :pr:`826`)
2010
+ - Bot.get_file now allows passing a file in addition to file_id (PR :pr:`963`)
2011
+ - Add .get_file() to Audio, Document, PhotoSize, Sticker, Video, VideoNote and Voice (PR :pr:`963`)
2012
+ - Add .send_*() methods to User and Chat (PR :pr:`963`)
2013
+ - Get jobs by name (PR :pr:`1011`)
2014
+ - Add Message caption html/markdown methods (PR :pr:`1013`)
2015
+ - File.download_as_bytearray - new method to get a d/led file as bytearray (PR :pr:`1019`)
2016
+ - File.download(): Now returns a meaningful return value (PR :pr:`1019`)
2017
+ - Added conversation timeout in ConversationHandler (PR :pr:`895`)
2018
+
2019
+ Changes
2020
+
2021
+ - Store bot in PreCheckoutQuery (PR :pr:`953`)
2022
+ - Updater: Issue INFO log upon received signal (PR :pr:`951`)
2023
+ - JobQueue: Thread safety fixes (PR :pr:`977`)
2024
+ - WebhookHandler: Fix exception thrown during error handling (PR :pr:`985`)
2025
+ - Explicitly check update.effective_chat in ConversationHandler.check_update (PR :pr:`959`)
2026
+ - Updater: Better handling of timeouts during get_updates (PR :pr:`1007`)
2027
+ - Remove unnecessary to_dict() (PR :pr:`834`)
2028
+ - CommandHandler - ignore strings in entities and "/" followed by whitespace (PR :pr:`1020`)
2029
+ - Documentation & style fixes (PR :pr:`942`, PR :pr:`956`, PR :pr:`962`, PR :pr:`980`, PR :pr:`983`)
2030
+
2031
+ Version 9.0.0
2032
+ =============
2033
+ *Released 2017-12-08*
2034
+
2035
+ Breaking changes (possibly)
2036
+
2037
+ - Drop support for python 3.3 (PR :pr:`930`)
2038
+
2039
+ New Features
2040
+
2041
+ - Support Bot API 3.5 (PR :pr:`920`)
2042
+
2043
+ Changes
2044
+
2045
+ - Fix race condition in dispatcher start/stop (:pr:`887`)
2046
+ - Log error trace if there is no error handler registered (:pr:`694`)
2047
+ - Update examples with consistent string formatting (:pr:`870`)
2048
+ - Various changes and improvements to the docs.
2049
+
2050
+ Version 8.1.1
2051
+ =============
2052
+ *Released 2017-10-15*
2053
+
2054
+ - Fix Commandhandler crashing on single character messages (PR :pr:`873`).
2055
+
2056
+ Version 8.1.0
2057
+ =============
2058
+ *Released 2017-10-14*
2059
+
2060
+ New features
2061
+ - Support Bot API 3.4 (PR :pr:`865`).
2062
+
2063
+ Changes
2064
+ - MessageHandler & RegexHandler now consider channel_updates.
2065
+ - Fix command not recognized if it is directly followed by a newline (PR :pr:`869`).
2066
+ - Removed Bot._message_wrapper (PR :pr:`822`).
2067
+ - Unitests are now also running on AppVeyor (Windows VM).
2068
+ - Various unitest improvements.
2069
+ - Documentation fixes.
2070
+
2071
+ Version 8.0.0
2072
+ =============
2073
+ *Released 2017-09-01*
2074
+
2075
+ New features
2076
+
2077
+ - Fully support Bot Api 3.3 (PR :pr:`806`).
2078
+ - DispatcherHandlerStop (`see docs`_).
2079
+ - Regression fix for text_html & text_markdown (PR :pr:`777`).
2080
+ - Added effective_attachment to message (PR :pr:`766`).
2081
+
2082
+ Non backward compatible changes
2083
+
2084
+ - Removed Botan support from the library (PR :pr:`776`).
2085
+ - Fully support Bot Api 3.3 (PR :pr:`806`).
2086
+ - Remove de_json() (PR :pr:`789`).
2087
+
2088
+ Changes
2089
+
2090
+ - Sane defaults for tcp socket options on linux (PR :pr:`754`).
2091
+ - Add RESTRICTED as constant to ChatMember (PR :pr:`761`).
2092
+ - Add rich comparison to CallbackQuery (PR :pr:`764`).
2093
+ - Fix get_game_high_scores (PR :pr:`771`).
2094
+ - Warn on small con_pool_size during custom initalization of Updater (PR :pr:`793`).
2095
+ - Catch exceptions in error handlerfor errors that happen during polling (PR :pr:`810`).
2096
+ - For testing we switched to pytest (PR :pr:`788`).
2097
+ - Lots of small improvements to our tests and documentation.
2098
+
2099
+ .. _`see docs`: https://docs.python-telegram-bot.org/en/v13.11/telegram.ext.dispatcher.html?highlight=Dispatcher.add_handler#telegram.ext.Dispatcher.add_handler
2100
+
2101
+ Version 7.0.1
2102
+ ===============
2103
+ *Released 2017-07-28*
2104
+
2105
+ - Fix TypeError exception in RegexHandler (PR #751).
2106
+ - Small documentation fix (PR #749).
2107
+
2108
+ Version 7.0.0
2109
+ =============
2110
+ *Released 2017-07-25*
2111
+
2112
+ - Fully support Bot API 3.2.
2113
+ - New filters for handling messages from specific chat/user id (PR #677).
2114
+ - Add the possibility to add objects as arguments to send_* methods (PR #742).
2115
+ - Fixed download of URLs with UTF-8 chars in path (PR #688).
2116
+ - Fixed URL parsing for ``Message`` text properties (PR #689).
2117
+ - Fixed args dispatching in ``MessageQueue``'s decorator (PR #705).
2118
+ - Fixed regression preventing IPv6 only hosts from connnecting to Telegram servers (Issue #720).
2119
+ - ConvesationHandler - check if a user exist before using it (PR #699).
2120
+ - Removed deprecated ``telegram.Emoji``.
2121
+ - Removed deprecated ``Botan`` import from ``utils`` (``Botan`` is still available through ``contrib``).
2122
+ - Removed deprecated ``ReplyKeyboardHide``.
2123
+ - Removed deprecated ``edit_message`` argument of ``bot.set_game_score``.
2124
+ - Internal restructure of files.
2125
+ - Improved documentation.
2126
+ - Improved unitests.
2127
+
2128
+ Pre-version 7.0
2129
+ ===============
2130
+
2131
+ **2017-06-18**
2132
+
2133
+ *Released 6.1.0*
2134
+
2135
+ - Fully support Bot API 3.0
2136
+ - Add more fine-grained filters for status updates
2137
+ - Bug fixes and other improvements
2138
+
2139
+ **2017-05-29**
2140
+
2141
+ *Released 6.0.3*
2142
+
2143
+ - Faulty PyPI release
2144
+
2145
+ **2017-05-29**
2146
+
2147
+ *Released 6.0.2*
2148
+
2149
+ - Avoid confusion with user's ``urllib3`` by renaming vendored ``urllib3`` to ``ptb_urllib3``
2150
+
2151
+ **2017-05-19**
2152
+
2153
+ *Released 6.0.1*
2154
+
2155
+ - Add support for ``User.language_code``
2156
+ - Fix ``Message.text_html`` and ``Message.text_markdown`` for messages with emoji
2157
+
2158
+ **2017-05-19**
2159
+
2160
+ *Released 6.0.0*
2161
+
2162
+ - Add support for Bot API 2.3.1
2163
+ - Add support for ``deleteMessage`` API method
2164
+ - New, simpler API for ``JobQueue`` - :pr:`484`
2165
+ - Download files into file-like objects - :pr:`459`
2166
+ - Use vendor ``urllib3`` to address issues with timeouts
2167
+ - The default timeout for messages is now 5 seconds. For sending media, the default timeout is now 20 seconds.
2168
+ - String attributes that are not set are now ``None`` by default, instead of empty strings
2169
+ - Add ``text_markdown`` and ``text_html`` properties to ``Message`` - :pr:`507`
2170
+ - Add support for Socks5 proxy - :pr:`518`
2171
+ - Add support for filters in ``CommandHandler`` - :pr:`536`
2172
+ - Add the ability to invert (not) filters - :pr:`552`
2173
+ - Add ``Filters.group`` and ``Filters.private``
2174
+ - Compatibility with GAE via ``urllib3.contrib`` package - :pr:`583`
2175
+ - Add equality rich comparision operators to telegram objects - :pr:`604`
2176
+ - Several bugfixes and other improvements
2177
+ - Remove some deprecated code
2178
+
2179
+ **2017-04-17**
2180
+
2181
+ *Released 5.3.1*
2182
+
2183
+ - Hotfix release due to bug introduced by urllib3 version 1.21
2184
+
2185
+ **2016-12-11**
2186
+
2187
+ *Released 5.3*
2188
+
2189
+ - Implement API changes of November 21st (Bot API 2.3)
2190
+ - ``JobQueue`` now supports ``datetime.timedelta`` in addition to seconds
2191
+ - ``JobQueue`` now supports running jobs only on certain days
2192
+ - New ``Filters.reply`` filter
2193
+ - Bugfix for ``Message.edit_reply_markup``
2194
+ - Other bugfixes
2195
+
2196
+ **2016-10-25**
2197
+
2198
+ *Released 5.2*
2199
+
2200
+ - Implement API changes of October 3rd (games update)
2201
+ - Add ``Message.edit_*`` methods
2202
+ - Filters for the ``MessageHandler`` can now be combined using bitwise operators (``& and |``)
2203
+ - Add a way to save user- and chat-related data temporarily
2204
+ - Other bugfixes and improvements
2205
+
2206
+ **2016-09-24**
2207
+
2208
+ *Released 5.1*
2209
+
2210
+ - Drop Python 2.6 support
2211
+ - Deprecate ``telegram.Emoji``
2212
+
2213
+ - Use ``ujson`` if available
2214
+ - Add instance methods to ``Message``, ``Chat``, ``User``, ``InlineQuery`` and ``CallbackQuery``
2215
+ - RegEx filtering for ``CallbackQueryHandler`` and ``InlineQueryHandler``
2216
+ - New ``MessageHandler`` filters: ``forwarded`` and ``entity``
2217
+ - Add ``Message.get_entity`` to correctly handle UTF-16 codepoints and ``MessageEntity`` offsets
2218
+ - Fix bug in ``ConversationHandler`` when first handler ends the conversation
2219
+ - Allow multiple ``Dispatcher`` instances
2220
+ - Add ``ChatMigrated`` Exception
2221
+ - Properly split and handle arguments in ``CommandHandler``
2222
+
2223
+ **2016-07-15**
2224
+
2225
+ *Released 5.0*
2226
+
2227
+ - Rework ``JobQueue``
2228
+ - Introduce ``ConversationHandler``
2229
+ - Introduce ``telegram.constants`` - :pr:`342`
2230
+
2231
+ **2016-07-12**
2232
+
2233
+ *Released 4.3.4*
2234
+
2235
+ - Fix proxy support with ``urllib3`` when proxy requires auth
2236
+
2237
+ **2016-07-08**
2238
+
2239
+ *Released 4.3.3*
2240
+
2241
+ - Fix proxy support with ``urllib3``
2242
+
2243
+ **2016-07-04**
2244
+
2245
+ *Released 4.3.2*
2246
+
2247
+ - Fix: Use ``timeout`` parameter in all API methods
2248
+
2249
+ **2016-06-29**
2250
+
2251
+ *Released 4.3.1*
2252
+
2253
+ - Update wrong requirement: ``urllib3>=1.10``
2254
+
2255
+ **2016-06-28**
2256
+
2257
+ *Released 4.3*
2258
+
2259
+ - Use ``urllib3.PoolManager`` for connection re-use
2260
+ - Rewrite ``run_async`` decorator to re-use threads
2261
+ - New requirements: ``urllib3`` and ``certifi``
2262
+
2263
+ **2016-06-10**
2264
+
2265
+ *Released 4.2.1*
2266
+
2267
+ - Fix ``CallbackQuery.to_dict()`` bug (thanks to @jlmadurga)
2268
+ - Fix ``editMessageText`` exception when receiving a ``CallbackQuery``
2269
+
2270
+ **2016-05-28**
2271
+
2272
+ *Released 4.2*
2273
+
2274
+ - Implement Bot API 2.1
2275
+ - Move ``botan`` module to ``telegram.contrib``
2276
+ - New exception type: ``BadRequest``
2277
+
2278
+ **2016-05-22**
2279
+
2280
+ *Released 4.1.2*
2281
+
2282
+ - Fix ``MessageEntity`` decoding with Bot API 2.1 changes
2283
+
2284
+ **2016-05-16**
2285
+
2286
+ *Released 4.1.1*
2287
+
2288
+ - Fix deprecation warning in ``Dispatcher``
2289
+
2290
+ **2016-05-15**
2291
+
2292
+ *Released 4.1*
2293
+
2294
+ - Implement API changes from May 6, 2016
2295
+ - Fix bug when ``start_polling`` with ``clean=True``
2296
+ - Methods now have snake_case equivalent, for example ``telegram.Bot.send_message`` is the same as ``telegram.Bot.sendMessage``
2297
+
2298
+ **2016-05-01**
2299
+
2300
+ *Released 4.0.3*
2301
+
2302
+ - Add missing attribute ``location`` to ``InlineQuery``
2303
+
2304
+ **2016-04-29**
2305
+
2306
+ *Released 4.0.2*
2307
+
2308
+ - Bugfixes
2309
+ - ``KeyboardReplyMarkup`` now accepts ``str`` again
2310
+
2311
+ **2016-04-27**
2312
+
2313
+ *Released 4.0.1*
2314
+
2315
+ - Implement Bot API 2.0
2316
+ - Almost complete recode of ``Dispatcher``
2317
+ - Please read the `Transition Guide to 4.0 <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-4.0>`_
2318
+ - **Changes from 4.0rc1**
2319
+ - The syntax of filters for ``MessageHandler`` (upper/lower cases)
2320
+ - Handler groups are now identified by ``int`` only, and ordered
2321
+ - **Note:** v4.0 has been skipped due to a PyPI accident
2322
+
2323
+ **2016-04-22**
2324
+
2325
+ *Released 4.0rc1*
2326
+
2327
+ - Implement Bot API 2.0
2328
+ - Almost complete recode of ``Dispatcher``
2329
+ - Please read the `Transistion Guide to 4.0 <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-4.0>`_
2330
+
2331
+ **2016-03-22**
2332
+
2333
+ *Released 3.4*
2334
+
2335
+ - Move ``Updater``, ``Dispatcher`` and ``JobQueue`` to new ``telegram.ext`` submodule (thanks to @rahiel)
2336
+ - Add ``disable_notification`` parameter (thanks to @aidarbiktimirov)
2337
+ - Fix bug where commands sent by Telegram Web would not be recognized (thanks to @shelomentsevd)
2338
+ - Add option to skip old updates on bot startup
2339
+ - Send files from ``BufferedReader``
2340
+
2341
+ **2016-02-28**
2342
+
2343
+ *Released 3.3*
2344
+
2345
+ - Inline bots
2346
+ - Send any file by URL
2347
+ - Specialized exceptions: ``Unauthorized``, ``InvalidToken``, ``NetworkError`` and ``TimedOut``
2348
+ - Integration for botan.io (thanks to @ollmer)
2349
+ - HTML Parsemode (thanks to @jlmadurga)
2350
+ - Bugfixes and under-the-hood improvements
2351
+
2352
+ **Very special thanks to Noam Meltzer (@tsnoam) for all of his work!**
2353
+
2354
+ **2016-01-09**
2355
+
2356
+ *Released 3.3b1*
2357
+
2358
+ - Implement inline bots (beta)
2359
+
2360
+ **2016-01-05**
2361
+
2362
+ *Released 3.2.0*
2363
+
2364
+ - Introducing ``JobQueue`` (original author: @franciscod)
2365
+ - Streamlining all exceptions to ``TelegramError`` (Special thanks to @tsnoam)
2366
+ - Proper locking of ``Updater`` and ``Dispatcher`` ``start`` and ``stop`` methods
2367
+ - Small bugfixes
2368
+
2369
+ **2015-12-29**
2370
+
2371
+ *Released 3.1.2*
2372
+
2373
+ - Fix custom path for file downloads
2374
+ - Don't stop the dispatcher thread on uncaught errors in handlers
2375
+
2376
+ **2015-12-21**
2377
+
2378
+ *Released 3.1.1*
2379
+
2380
+ - Fix a bug where asynchronous handlers could not have additional arguments
2381
+ - Add ``groups`` and ``groupdict`` as additional arguments for regex-based handlers
2382
+
2383
+ **2015-12-16**
2384
+
2385
+ *Released 3.1.0*
2386
+
2387
+ - The ``chat``-field in ``Message`` is now of type ``Chat``. (API update Oct 8 2015)
2388
+ - ``Message`` now contains the optional fields ``supergroup_chat_created``, ``migrate_to_chat_id``, ``migrate_from_chat_id`` and ``channel_chat_created``. (API update Nov 2015)
2389
+
2390
+ **2015-12-08**
2391
+
2392
+ *Released 3.0.0*
2393
+
2394
+ - Introducing the ``Updater`` and ``Dispatcher`` classes
2395
+
2396
+ **2015-11-11**
2397
+
2398
+ *Released 2.9.2*
2399
+
2400
+ - Error handling on request timeouts has been improved
2401
+
2402
+ **2015-11-10**
2403
+
2404
+ *Released 2.9.1*
2405
+
2406
+ - Add parameter ``network_delay`` to Bot.getUpdates for slow connections
2407
+
2408
+ **2015-11-10**
2409
+
2410
+ *Released 2.9*
2411
+
2412
+ - Emoji class now uses ``bytes_to_native_str`` from ``future`` 3rd party lib
2413
+ - Make ``user_from`` optional to work with channels
2414
+ - Raise exception if Telegram times out on long-polling
2415
+
2416
+ *Special thanks to @jh0ker for all hard work*
2417
+
2418
+ **2015-10-08**
2419
+
2420
+ *Released 2.8.7*
2421
+
2422
+ - Type as optional for ``GroupChat`` class
2423
+
2424
+ **2015-10-08**
2425
+
2426
+ *Released 2.8.6*
2427
+
2428
+ - Adds type to ``User`` and ``GroupChat`` classes (pre-release Telegram feature)
2429
+
2430
+ **2015-09-24**
2431
+
2432
+ *Released 2.8.5*
2433
+
2434
+ - Handles HTTP Bad Gateway (503) errors on request
2435
+ - Fixes regression on ``Audio`` and ``Document`` for unicode fields
2436
+
2437
+ **2015-09-20**
2438
+
2439
+ *Released 2.8.4*
2440
+
2441
+ - ``getFile`` and ``File.download`` is now fully supported
2442
+
2443
+ **2015-09-10**
2444
+
2445
+ *Released 2.8.3*
2446
+
2447
+ - Moved ``Bot._requestURL`` to its own class (``telegram.utils.request``)
2448
+ - Much better, such wow, Telegram Objects tests
2449
+ - Add consistency for ``str`` properties on Telegram Objects
2450
+ - Better design to test if ``chat_id`` is invalid
2451
+ - Add ability to set custom filename on ``Bot.sendDocument(..,filename='')``
2452
+ - Fix Sticker as ``InputFile``
2453
+ - Send JSON requests over urlencoded post data
2454
+ - Markdown support for ``Bot.sendMessage(..., parse_mode=ParseMode.MARKDOWN)``
2455
+ - Refactor of ``TelegramError`` class (no more handling ``IOError`` or ``URLError``)
2456
+
2457
+ **2015-09-05**
2458
+
2459
+ *Released 2.8.2*
2460
+
2461
+ - Fix regression on Telegram ReplyMarkup
2462
+ - Add certificate to ``is_inputfile`` method
2463
+
2464
+ **2015-09-05**
2465
+
2466
+ *Released 2.8.1*
2467
+
2468
+ - Fix regression on Telegram objects with thumb properties
2469
+
2470
+ **2015-09-04**
2471
+
2472
+ *Released 2.8*
2473
+
2474
+ - TelegramError when ``chat_id`` is empty for send* methods
2475
+ - ``setWebhook`` now supports sending self-signed certificate
2476
+ - Huge redesign of existing Telegram classes
2477
+ - Added support for PyPy
2478
+ - Added docstring for existing classes
2479
+
2480
+ **2015-08-19**
2481
+
2482
+ *Released 2.7.1*
2483
+
2484
+ - Fixed JSON serialization for ``message``
2485
+
2486
+ **2015-08-17**
2487
+
2488
+ *Released 2.7*
2489
+
2490
+ - Added support for ``Voice`` object and ``sendVoice`` method
2491
+ - Due backward compatibility performer or/and title will be required for ``sendAudio``
2492
+ - Fixed JSON serialization when forwarded message
2493
+
2494
+ **2015-08-15**
2495
+
2496
+ *Released 2.6.1*
2497
+
2498
+ - Fixed parsing image header issue on < Python 2.7.3
2499
+
2500
+ **2015-08-14**
2501
+
2502
+ *Released 2.6.0*
2503
+
2504
+ - Depreciation of ``require_authentication`` and ``clearCredentials`` methods
2505
+ - Giving ``AUTHORS`` the proper credits for their contribution for this project
2506
+ - ``Message.date`` and ``Message.forward_date`` are now ``datetime`` objects
2507
+
2508
+ **2015-08-12**
2509
+
2510
+ *Released 2.5.3*
2511
+
2512
+ - ``telegram.Bot`` now supports to be unpickled
2513
+
2514
+ **2015-08-11**
2515
+
2516
+ *Released 2.5.2*
2517
+
2518
+ - New changes from Telegram Bot API have been applied
2519
+ - ``telegram.Bot`` now supports to be pickled
2520
+ - Return empty ``str`` instead ``None`` when ``message.text`` is empty
2521
+
2522
+ **2015-08-10**
2523
+
2524
+ *Released 2.5.1*
2525
+
2526
+ - Moved from GPLv2 to LGPLv3
2527
+
2528
+ **2015-08-09**
2529
+
2530
+ *Released 2.5*
2531
+
2532
+ - Fixes logging calls in API
2533
+
2534
+ **2015-08-08**
2535
+
2536
+ *Released 2.4*
2537
+
2538
+ - Fixes ``Emoji`` class for Python 3
2539
+ - ``PEP8`` improvements
2540
+
2541
+ **2015-08-08**
2542
+
2543
+ *Released 2.3*
2544
+
2545
+ - Fixes ``ForceReply`` class
2546
+ - Remove ``logging.basicConfig`` from library
2547
+
2548
+ **2015-07-25**
2549
+
2550
+ *Released 2.2*
2551
+
2552
+ - Allows ``debug=True`` when initializing ``telegram.Bot``
2553
+
2554
+ **2015-07-20**
2555
+
2556
+ *Released 2.1*
2557
+
2558
+ - Fix ``to_dict`` for ``Document`` and ``Video``
2559
+
2560
+ **2015-07-19**
2561
+
2562
+ *Released 2.0*
2563
+
2564
+ - Fixes bugs
2565
+ - Improves ``__str__`` over ``to_json()``
2566
+ - Creates abstract class ``TelegramObject``
2567
+
2568
+ **2015-07-15**
2569
+
2570
+ *Released 1.9*
2571
+
2572
+ - Python 3 officially supported
2573
+ - ``PEP8`` improvements
2574
+
2575
+ **2015-07-12**
2576
+
2577
+ *Released 1.8*
2578
+
2579
+ - Fixes crash when replying an unicode text message (special thanks to JRoot3D)
2580
+
2581
+ **2015-07-11**
2582
+
2583
+ *Released 1.7*
2584
+
2585
+ - Fixes crash when ``username`` is not defined on ``chat`` (special thanks to JRoot3D)
2586
+
2587
+ **2015-07-10**
2588
+
2589
+ *Released 1.6*
2590
+
2591
+ - Improvements for GAE support
2592
+
2593
+ **2015-07-10**
2594
+
2595
+ *Released 1.5*
2596
+
2597
+ - Fixes randomly unicode issues when using ``InputFile``
2598
+
2599
+ **2015-07-10**
2600
+
2601
+ *Released 1.4*
2602
+
2603
+ - ``requests`` lib is no longer required
2604
+ - Google App Engine (GAE) is supported
2605
+
2606
+ **2015-07-10**
2607
+
2608
+ *Released 1.3*
2609
+
2610
+ - Added support to ``setWebhook`` (special thanks to macrojames)
2611
+
2612
+ **2015-07-09**
2613
+
2614
+ *Released 1.2*
2615
+
2616
+ - ``CustomKeyboard`` classes now available
2617
+ - Emojis available
2618
+ - ``PEP8`` improvements
2619
+
2620
+ **2015-07-08**
2621
+
2622
+ *Released 1.1*
2623
+
2624
+ - PyPi package now available
2625
+
2626
+ **2015-07-08**
2627
+
2628
+ *Released 1.0*
2629
+
2630
+ - Initial checkin of python-telegram-bot
CODE_OF_CONDUCT.rst ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ====================================
2
+ Contributor Covenant Code of Conduct
3
+ ====================================
4
+
5
+ Our Pledge
6
+ ==========
7
+
8
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
9
+
10
+ Our Standards
11
+ =============
12
+
13
+ Examples of behavior that contributes to creating a positive environment include:
14
+
15
+ * Using welcoming and inclusive language
16
+ * Being respectful of differing viewpoints and experiences
17
+ * Gracefully accepting constructive criticism
18
+ * Focusing on what is best for the community
19
+ * Showing empathy towards other community members
20
+
21
+ Examples of unacceptable behavior by participants include:
22
+
23
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
24
+ * Publication of any content supporting, justifying or otherwise affiliating with terror and/or hate towards others
25
+ * Trolling, insulting/derogatory comments, and personal or political attacks
26
+ * Public or private harassment
27
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
29
+
30
+ Our Responsibilities
31
+ ====================
32
+
33
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
34
+
35
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
36
+
37
+ Scope
38
+ =====
39
+
40
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
41
+
42
+ Enforcement
43
+ ===========
44
+
45
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
46
+
47
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
48
+
49
+ Attribution
50
+ ===========
51
+
52
+ This Code of Conduct is adapted from the `Contributor Covenant <https://www.contributor-covenant.org>`_, version 1.4, available at `https://www.contributor-covenant.org/version/1/4 <https://www.contributor-covenant.org/version/1/4/>`_.
LICENSE ADDED
@@ -0,0 +1,619 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/]
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
LICENSE.dual ADDED
@@ -0,0 +1,792 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NOTICE: You can find here the GPLv3 license and after the Lesser GPLv3 license.
2
+ You may choose either license.
3
+
4
+
5
+ GNU LESSER GENERAL PUBLIC LICENSE
6
+ Version 3, 29 June 2007
7
+
8
+ Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/]
9
+ Everyone is permitted to copy and distribute verbatim copies
10
+ of this license document, but changing it is not allowed.
11
+
12
+
13
+ This version of the GNU Lesser General Public License incorporates
14
+ the terms and conditions of version 3 of the GNU General Public
15
+ License, supplemented by the additional permissions listed below.
16
+
17
+ 0. Additional Definitions.
18
+
19
+ As used herein, "this License" refers to version 3 of the GNU Lesser
20
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
21
+ General Public License.
22
+
23
+ "The Library" refers to a covered work governed by this License,
24
+ other than an Application or a Combined Work as defined below.
25
+
26
+ An "Application" is any work that makes use of an interface provided
27
+ by the Library, but which is not otherwise based on the Library.
28
+ Defining a subclass of a class defined by the Library is deemed a mode
29
+ of using an interface provided by the Library.
30
+
31
+ A "Combined Work" is a work produced by combining or linking an
32
+ Application with the Library. The particular version of the Library
33
+ with which the Combined Work was made is also called the "Linked
34
+ Version".
35
+
36
+ The "Minimal Corresponding Source" for a Combined Work means the
37
+ Corresponding Source for the Combined Work, excluding any source code
38
+ for portions of the Combined Work that, considered in isolation, are
39
+ based on the Application, and not on the Linked Version.
40
+
41
+ The "Corresponding Application Code" for a Combined Work means the
42
+ object code and/or source code for the Application, including any data
43
+ and utility programs needed for reproducing the Combined Work from the
44
+ Application, but excluding the System Libraries of the Combined Work.
45
+
46
+ 1. Exception to Section 3 of the GNU GPL.
47
+
48
+ You may convey a covered work under sections 3 and 4 of this License
49
+ without being bound by section 3 of the GNU GPL.
50
+
51
+ 2. Conveying Modified Versions.
52
+
53
+ If you modify a copy of the Library, and, in your modifications, a
54
+ facility refers to a function or data to be supplied by an Application
55
+ that uses the facility (other than as an argument passed when the
56
+ facility is invoked), then you may convey a copy of the modified
57
+ version:
58
+
59
+ a) under this License, provided that you make a good faith effort to
60
+ ensure that, in the event an Application does not supply the
61
+ function or data, the facility still operates, and performs
62
+ whatever part of its purpose remains meaningful, or
63
+
64
+ b) under the GNU GPL, with none of the additional permissions of
65
+ this License applicable to that copy.
66
+
67
+ 3. Object Code Incorporating Material from Library Header Files.
68
+
69
+ The object code form of an Application may incorporate material from
70
+ a header file that is part of the Library. You may convey such object
71
+ code under terms of your choice, provided that, if the incorporated
72
+ material is not limited to numerical parameters, data structure
73
+ layouts and accessors, or small macros, inline functions and templates
74
+ (ten or fewer lines in length), you do both of the following:
75
+
76
+ a) Give prominent notice with each copy of the object code that the
77
+ Library is used in it and that the Library and its use are
78
+ covered by this License.
79
+
80
+ b) Accompany the object code with a copy of the GNU GPL and this license
81
+ document.
82
+
83
+ 4. Combined Works.
84
+
85
+ You may convey a Combined Work under terms of your choice that,
86
+ taken together, effectively do not restrict modification of the
87
+ portions of the Library contained in the Combined Work and reverse
88
+ engineering for debugging such modifications, if you also do each of
89
+ the following:
90
+
91
+ a) Give prominent notice with each copy of the Combined Work that
92
+ the Library is used in it and that the Library and its use are
93
+ covered by this License.
94
+
95
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
96
+ document.
97
+
98
+ c) For a Combined Work that displays copyright notices during
99
+ execution, include the copyright notice for the Library among
100
+ these notices, as well as a reference directing the user to the
101
+ copies of the GNU GPL and this license document.
102
+
103
+ d) Do one of the following:
104
+
105
+ 0) Convey the Minimal Corresponding Source under the terms of this
106
+ License, and the Corresponding Application Code in a form
107
+ suitable for, and under terms that permit, the user to
108
+ recombine or relink the Application with a modified version of
109
+ the Linked Version to produce a modified Combined Work, in the
110
+ manner specified by section 6 of the GNU GPL for conveying
111
+ Corresponding Source.
112
+
113
+ 1) Use a suitable shared library mechanism for linking with the
114
+ Library. A suitable mechanism is one that (a) uses at run time
115
+ a copy of the Library already present on the user's computer
116
+ system, and (b) will operate properly with a modified version
117
+ of the Library that is interface-compatible with the Linked
118
+ Version.
119
+
120
+ e) Provide Installation Information, but only if you would otherwise
121
+ be required to provide such information under section 6 of the
122
+ GNU GPL, and only to the extent that such information is
123
+ necessary to install and execute a modified version of the
124
+ Combined Work produced by recombining or relinking the
125
+ Application with a modified version of the Linked Version. (If
126
+ you use option 4d0, the Installation Information must accompany
127
+ the Minimal Corresponding Source and Corresponding Application
128
+ Code. If you use option 4d1, you must provide the Installation
129
+ Information in the manner specified by section 6 of the GNU GPL
130
+ for conveying Corresponding Source.)
131
+
132
+ 5. Combined Libraries.
133
+
134
+ You may place library facilities that are a work based on the
135
+ Library side by side in a single library together with other library
136
+ facilities that are not Applications and are not covered by this
137
+ License, and convey such a combined library under terms of your
138
+ choice, if you do both of the following:
139
+
140
+ a) Accompany the combined library with a copy of the same work based
141
+ on the Library, uncombined with any other library facilities,
142
+ conveyed under the terms of this License.
143
+
144
+ b) Give prominent notice with the combined library that part of it
145
+ is a work based on the Library, and explaining where to find the
146
+ accompanying uncombined form of the same work.
147
+
148
+ 6. Revised Versions of the GNU Lesser General Public License.
149
+
150
+ The Free Software Foundation may publish revised and/or new versions
151
+ of the GNU Lesser General Public License from time to time. Such new
152
+ versions will be similar in spirit to the present version, but may
153
+ differ in detail to address new problems or concerns.
154
+
155
+ Each version is given a distinguishing version number. If the
156
+ Library as you received it specifies that a certain numbered version
157
+ of the GNU Lesser General Public License "or any later version"
158
+ applies to it, you have the option of following the terms and
159
+ conditions either of that published version or of any later version
160
+ published by the Free Software Foundation. If the Library as you
161
+ received it does not specify a version number of the GNU Lesser
162
+ General Public License, you may choose any version of the GNU Lesser
163
+ General Public License ever published by the Free Software Foundation.
164
+
165
+ If the Library as you received it specifies that a proxy can decide
166
+ whether future versions of the GNU Lesser General Public License shall
167
+ apply, that proxy's public statement of acceptance of any version is
168
+ permanent authorization for you to choose that version for the
169
+ Library.
170
+
171
+
172
+
173
+
174
+ GNU GENERAL PUBLIC LICENSE
175
+ Version 3, 29 June 2007
176
+
177
+ Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/]
178
+ Everyone is permitted to copy and distribute verbatim copies
179
+ of this license document, but changing it is not allowed.
180
+
181
+ Preamble
182
+
183
+ The GNU General Public License is a free, copyleft license for
184
+ software and other kinds of works.
185
+
186
+ The licenses for most software and other practical works are designed
187
+ to take away your freedom to share and change the works. By contrast,
188
+ the GNU General Public License is intended to guarantee your freedom to
189
+ share and change all versions of a program--to make sure it remains free
190
+ software for all its users. We, the Free Software Foundation, use the
191
+ GNU General Public License for most of our software; it applies also to
192
+ any other work released this way by its authors. You can apply it to
193
+ your programs, too.
194
+
195
+ When we speak of free software, we are referring to freedom, not
196
+ price. Our General Public Licenses are designed to make sure that you
197
+ have the freedom to distribute copies of free software (and charge for
198
+ them if you wish), that you receive source code or can get it if you
199
+ want it, that you can change the software or use pieces of it in new
200
+ free programs, and that you know you can do these things.
201
+
202
+ To protect your rights, we need to prevent others from denying you
203
+ these rights or asking you to surrender the rights. Therefore, you have
204
+ certain responsibilities if you distribute copies of the software, or if
205
+ you modify it: responsibilities to respect the freedom of others.
206
+
207
+ For example, if you distribute copies of such a program, whether
208
+ gratis or for a fee, you must pass on to the recipients the same
209
+ freedoms that you received. You must make sure that they, too, receive
210
+ or can get the source code. And you must show them these terms so they
211
+ know their rights.
212
+
213
+ Developers that use the GNU GPL protect your rights with two steps:
214
+ (1) assert copyright on the software, and (2) offer you this License
215
+ giving you legal permission to copy, distribute and/or modify it.
216
+
217
+ For the developers' and authors' protection, the GPL clearly explains
218
+ that there is no warranty for this free software. For both users' and
219
+ authors' sake, the GPL requires that modified versions be marked as
220
+ changed, so that their problems will not be attributed erroneously to
221
+ authors of previous versions.
222
+
223
+ Some devices are designed to deny users access to install or run
224
+ modified versions of the software inside them, although the manufacturer
225
+ can do so. This is fundamentally incompatible with the aim of
226
+ protecting users' freedom to change the software. The systematic
227
+ pattern of such abuse occurs in the area of products for individuals to
228
+ use, which is precisely where it is most unacceptable. Therefore, we
229
+ have designed this version of the GPL to prohibit the practice for those
230
+ products. If such problems arise substantially in other domains, we
231
+ stand ready to extend this provision to those domains in future versions
232
+ of the GPL, as needed to protect the freedom of users.
233
+
234
+ Finally, every program is threatened constantly by software patents.
235
+ States should not allow patents to restrict development and use of
236
+ software on general-purpose computers, but in those that do, we wish to
237
+ avoid the special danger that patents applied to a free program could
238
+ make it effectively proprietary. To prevent this, the GPL assures that
239
+ patents cannot be used to render the program non-free.
240
+
241
+ The precise terms and conditions for copying, distribution and
242
+ modification follow.
243
+
244
+ TERMS AND CONDITIONS
245
+
246
+ 0. Definitions.
247
+
248
+ "This License" refers to version 3 of the GNU General Public License.
249
+
250
+ "Copyright" also means copyright-like laws that apply to other kinds of
251
+ works, such as semiconductor masks.
252
+
253
+ "The Program" refers to any copyrightable work licensed under this
254
+ License. Each licensee is addressed as "you". "Licensees" and
255
+ "recipients" may be individuals or organizations.
256
+
257
+ To "modify" a work means to copy from or adapt all or part of the work
258
+ in a fashion requiring copyright permission, other than the making of an
259
+ exact copy. The resulting work is called a "modified version" of the
260
+ earlier work or a work "based on" the earlier work.
261
+
262
+ A "covered work" means either the unmodified Program or a work based
263
+ on the Program.
264
+
265
+ To "propagate" a work means to do anything with it that, without
266
+ permission, would make you directly or secondarily liable for
267
+ infringement under applicable copyright law, except executing it on a
268
+ computer or modifying a private copy. Propagation includes copying,
269
+ distribution (with or without modification), making available to the
270
+ public, and in some countries other activities as well.
271
+
272
+ To "convey" a work means any kind of propagation that enables other
273
+ parties to make or receive copies. Mere interaction with a user through
274
+ a computer network, with no transfer of a copy, is not conveying.
275
+
276
+ An interactive user interface displays "Appropriate Legal Notices"
277
+ to the extent that it includes a convenient and prominently visible
278
+ feature that (1) displays an appropriate copyright notice, and (2)
279
+ tells the user that there is no warranty for the work (except to the
280
+ extent that warranties are provided), that licensees may convey the
281
+ work under this License, and how to view a copy of this License. If
282
+ the interface presents a list of user commands or options, such as a
283
+ menu, a prominent item in the list meets this criterion.
284
+
285
+ 1. Source Code.
286
+
287
+ The "source code" for a work means the preferred form of the work
288
+ for making modifications to it. "Object code" means any non-source
289
+ form of a work.
290
+
291
+ A "Standard Interface" means an interface that either is an official
292
+ standard defined by a recognized standards body, or, in the case of
293
+ interfaces specified for a particular programming language, one that
294
+ is widely used among developers working in that language.
295
+
296
+ The "System Libraries" of an executable work include anything, other
297
+ than the work as a whole, that (a) is included in the normal form of
298
+ packaging a Major Component, but which is not part of that Major
299
+ Component, and (b) serves only to enable use of the work with that
300
+ Major Component, or to implement a Standard Interface for which an
301
+ implementation is available to the public in source code form. A
302
+ "Major Component", in this context, means a major essential component
303
+ (kernel, window system, and so on) of the specific operating system
304
+ (if any) on which the executable work runs, or a compiler used to
305
+ produce the work, or an object code interpreter used to run it.
306
+
307
+ The "Corresponding Source" for a work in object code form means all
308
+ the source code needed to generate, install, and (for an executable
309
+ work) run the object code and to modify the work, including scripts to
310
+ control those activities. However, it does not include the work's
311
+ System Libraries, or general-purpose tools or generally available free
312
+ programs which are used unmodified in performing those activities but
313
+ which are not part of the work. For example, Corresponding Source
314
+ includes interface definition files associated with source files for
315
+ the work, and the source code for shared libraries and dynamically
316
+ linked subprograms that the work is specifically designed to require,
317
+ such as by intimate data communication or control flow between those
318
+ subprograms and other parts of the work.
319
+
320
+ The Corresponding Source need not include anything that users
321
+ can regenerate automatically from other parts of the Corresponding
322
+ Source.
323
+
324
+ The Corresponding Source for a work in source code form is that
325
+ same work.
326
+
327
+ 2. Basic Permissions.
328
+
329
+ All rights granted under this License are granted for the term of
330
+ copyright on the Program, and are irrevocable provided the stated
331
+ conditions are met. This License explicitly affirms your unlimited
332
+ permission to run the unmodified Program. The output from running a
333
+ covered work is covered by this License only if the output, given its
334
+ content, constitutes a covered work. This License acknowledges your
335
+ rights of fair use or other equivalent, as provided by copyright law.
336
+
337
+ You may make, run and propagate covered works that you do not
338
+ convey, without conditions so long as your license otherwise remains
339
+ in force. You may convey covered works to others for the sole purpose
340
+ of having them make modifications exclusively for you, or provide you
341
+ with facilities for running those works, provided that you comply with
342
+ the terms of this License in conveying all material for which you do
343
+ not control copyright. Those thus making or running the covered works
344
+ for you must do so exclusively on your behalf, under your direction
345
+ and control, on terms that prohibit them from making any copies of
346
+ your copyrighted material outside their relationship with you.
347
+
348
+ Conveying under any other circumstances is permitted solely under
349
+ the conditions stated below. Sublicensing is not allowed; section 10
350
+ makes it unnecessary.
351
+
352
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
353
+
354
+ No covered work shall be deemed part of an effective technological
355
+ measure under any applicable law fulfilling obligations under article
356
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
357
+ similar laws prohibiting or restricting circumvention of such
358
+ measures.
359
+
360
+ When you convey a covered work, you waive any legal power to forbid
361
+ circumvention of technological measures to the extent such circumvention
362
+ is effected by exercising rights under this License with respect to
363
+ the covered work, and you disclaim any intention to limit operation or
364
+ modification of the work as a means of enforcing, against the work's
365
+ users, your or third parties' legal rights to forbid circumvention of
366
+ technological measures.
367
+
368
+ 4. Conveying Verbatim Copies.
369
+
370
+ You may convey verbatim copies of the Program's source code as you
371
+ receive it, in any medium, provided that you conspicuously and
372
+ appropriately publish on each copy an appropriate copyright notice;
373
+ keep intact all notices stating that this License and any
374
+ non-permissive terms added in accord with section 7 apply to the code;
375
+ keep intact all notices of the absence of any warranty; and give all
376
+ recipients a copy of this License along with the Program.
377
+
378
+ You may charge any price or no price for each copy that you convey,
379
+ and you may offer support or warranty protection for a fee.
380
+
381
+ 5. Conveying Modified Source Versions.
382
+
383
+ You may convey a work based on the Program, or the modifications to
384
+ produce it from the Program, in the form of source code under the
385
+ terms of section 4, provided that you also meet all of these conditions:
386
+
387
+ a) The work must carry prominent notices stating that you modified
388
+ it, and giving a relevant date.
389
+
390
+ b) The work must carry prominent notices stating that it is
391
+ released under this License and any conditions added under section
392
+ 7. This requirement modifies the requirement in section 4 to
393
+ "keep intact all notices".
394
+
395
+ c) You must license the entire work, as a whole, under this
396
+ License to anyone who comes into possession of a copy. This
397
+ License will therefore apply, along with any applicable section 7
398
+ additional terms, to the whole of the work, and all its parts,
399
+ regardless of how they are packaged. This License gives no
400
+ permission to license the work in any other way, but it does not
401
+ invalidate such permission if you have separately received it.
402
+
403
+ d) If the work has interactive user interfaces, each must display
404
+ Appropriate Legal Notices; however, if the Program has interactive
405
+ interfaces that do not display Appropriate Legal Notices, your
406
+ work need not make them do so.
407
+
408
+ A compilation of a covered work with other separate and independent
409
+ works, which are not by their nature extensions of the covered work,
410
+ and which are not combined with it such as to form a larger program,
411
+ in or on a volume of a storage or distribution medium, is called an
412
+ "aggregate" if the compilation and its resulting copyright are not
413
+ used to limit the access or legal rights of the compilation's users
414
+ beyond what the individual works permit. Inclusion of a covered work
415
+ in an aggregate does not cause this License to apply to the other
416
+ parts of the aggregate.
417
+
418
+ 6. Conveying Non-Source Forms.
419
+
420
+ You may convey a covered work in object code form under the terms
421
+ of sections 4 and 5, provided that you also convey the
422
+ machine-readable Corresponding Source under the terms of this License,
423
+ in one of these ways:
424
+
425
+ a) Convey the object code in, or embodied in, a physical product
426
+ (including a physical distribution medium), accompanied by the
427
+ Corresponding Source fixed on a durable physical medium
428
+ customarily used for software interchange.
429
+
430
+ b) Convey the object code in, or embodied in, a physical product
431
+ (including a physical distribution medium), accompanied by a
432
+ written offer, valid for at least three years and valid for as
433
+ long as you offer spare parts or customer support for that product
434
+ model, to give anyone who possesses the object code either (1) a
435
+ copy of the Corresponding Source for all the software in the
436
+ product that is covered by this License, on a durable physical
437
+ medium customarily used for software interchange, for a price no
438
+ more than your reasonable cost of physically performing this
439
+ conveying of source, or (2) access to copy the
440
+ Corresponding Source from a network server at no charge.
441
+
442
+ c) Convey individual copies of the object code with a copy of the
443
+ written offer to provide the Corresponding Source. This
444
+ alternative is allowed only occasionally and noncommercially, and
445
+ only if you received the object code with such an offer, in accord
446
+ with subsection 6b.
447
+
448
+ d) Convey the object code by offering access from a designated
449
+ place (gratis or for a charge), and offer equivalent access to the
450
+ Corresponding Source in the same way through the same place at no
451
+ further charge. You need not require recipients to copy the
452
+ Corresponding Source along with the object code. If the place to
453
+ copy the object code is a network server, the Corresponding Source
454
+ may be on a different server (operated by you or a third party)
455
+ that supports equivalent copying facilities, provided you maintain
456
+ clear directions next to the object code saying where to find the
457
+ Corresponding Source. Regardless of what server hosts the
458
+ Corresponding Source, you remain obligated to ensure that it is
459
+ available for as long as needed to satisfy these requirements.
460
+
461
+ e) Convey the object code using peer-to-peer transmission, provided
462
+ you inform other peers where the object code and Corresponding
463
+ Source of the work are being offered to the general public at no
464
+ charge under subsection 6d.
465
+
466
+ A separable portion of the object code, whose source code is excluded
467
+ from the Corresponding Source as a System Library, need not be
468
+ included in conveying the object code work.
469
+
470
+ A "User Product" is either (1) a "consumer product", which means any
471
+ tangible personal property which is normally used for personal, family,
472
+ or household purposes, or (2) anything designed or sold for incorporation
473
+ into a dwelling. In determining whether a product is a consumer product,
474
+ doubtful cases shall be resolved in favor of coverage. For a particular
475
+ product received by a particular user, "normally used" refers to a
476
+ typical or common use of that class of product, regardless of the status
477
+ of the particular user or of the way in which the particular user
478
+ actually uses, or expects or is expected to use, the product. A product
479
+ is a consumer product regardless of whether the product has substantial
480
+ commercial, industrial or non-consumer uses, unless such uses represent
481
+ the only significant mode of use of the product.
482
+
483
+ "Installation Information" for a User Product means any methods,
484
+ procedures, authorization keys, or other information required to install
485
+ and execute modified versions of a covered work in that User Product from
486
+ a modified version of its Corresponding Source. The information must
487
+ suffice to ensure that the continued functioning of the modified object
488
+ code is in no case prevented or interfered with solely because
489
+ modification has been made.
490
+
491
+ If you convey an object code work under this section in, or with, or
492
+ specifically for use in, a User Product, and the conveying occurs as
493
+ part of a transaction in which the right of possession and use of the
494
+ User Product is transferred to the recipient in perpetuity or for a
495
+ fixed term (regardless of how the transaction is characterized), the
496
+ Corresponding Source conveyed under this section must be accompanied
497
+ by the Installation Information. But this requirement does not apply
498
+ if neither you nor any third party retains the ability to install
499
+ modified object code on the User Product (for example, the work has
500
+ been installed in ROM).
501
+
502
+ The requirement to provide Installation Information does not include a
503
+ requirement to continue to provide support service, warranty, or updates
504
+ for a work that has been modified or installed by the recipient, or for
505
+ the User Product in which it has been modified or installed. Access to a
506
+ network may be denied when the modification itself materially and
507
+ adversely affects the operation of the network or violates the rules and
508
+ protocols for communication across the network.
509
+
510
+ Corresponding Source conveyed, and Installation Information provided,
511
+ in accord with this section must be in a format that is publicly
512
+ documented (and with an implementation available to the public in
513
+ source code form), and must require no special password or key for
514
+ unpacking, reading or copying.
515
+
516
+ 7. Additional Terms.
517
+
518
+ "Additional permissions" are terms that supplement the terms of this
519
+ License by making exceptions from one or more of its conditions.
520
+ Additional permissions that are applicable to the entire Program shall
521
+ be treated as though they were included in this License, to the extent
522
+ that they are valid under applicable law. If additional permissions
523
+ apply only to part of the Program, that part may be used separately
524
+ under those permissions, but the entire Program remains governed by
525
+ this License without regard to the additional permissions.
526
+
527
+ When you convey a copy of a covered work, you may at your option
528
+ remove any additional permissions from that copy, or from any part of
529
+ it. (Additional permissions may be written to require their own
530
+ removal in certain cases when you modify the work.) You may place
531
+ additional permissions on material, added by you to a covered work,
532
+ for which you have or can give appropriate copyright permission.
533
+
534
+ Notwithstanding any other provision of this License, for material you
535
+ add to a covered work, you may (if authorized by the copyright holders of
536
+ that material) supplement the terms of this License with terms:
537
+
538
+ a) Disclaiming warranty or limiting liability differently from the
539
+ terms of sections 15 and 16 of this License; or
540
+
541
+ b) Requiring preservation of specified reasonable legal notices or
542
+ author attributions in that material or in the Appropriate Legal
543
+ Notices displayed by works containing it; or
544
+
545
+ c) Prohibiting misrepresentation of the origin of that material, or
546
+ requiring that modified versions of such material be marked in
547
+ reasonable ways as different from the original version; or
548
+
549
+ d) Limiting the use for publicity purposes of names of licensors or
550
+ authors of the material; or
551
+
552
+ e) Declining to grant rights under trademark law for use of some
553
+ trade names, trademarks, or service marks; or
554
+
555
+ f) Requiring indemnification of licensors and authors of that
556
+ material by anyone who conveys the material (or modified versions of
557
+ it) with contractual assumptions of liability to the recipient, for
558
+ any liability that these contractual assumptions directly impose on
559
+ those licensors and authors.
560
+
561
+ All other non-permissive additional terms are considered "further
562
+ restrictions" within the meaning of section 10. If the Program as you
563
+ received it, or any part of it, contains a notice stating that it is
564
+ governed by this License along with a term that is a further
565
+ restriction, you may remove that term. If a license document contains
566
+ a further restriction but permits relicensing or conveying under this
567
+ License, you may add to a covered work material governed by the terms
568
+ of that license document, provided that the further restriction does
569
+ not survive such relicensing or conveying.
570
+
571
+ If you add terms to a covered work in accord with this section, you
572
+ must place, in the relevant source files, a statement of the
573
+ additional terms that apply to those files, or a notice indicating
574
+ where to find the applicable terms.
575
+
576
+ Additional terms, permissive or non-permissive, may be stated in the
577
+ form of a separately written license, or stated as exceptions;
578
+ the above requirements apply either way.
579
+
580
+ 8. Termination.
581
+
582
+ You may not propagate or modify a covered work except as expressly
583
+ provided under this License. Any attempt otherwise to propagate or
584
+ modify it is void, and will automatically terminate your rights under
585
+ this License (including any patent licenses granted under the third
586
+ paragraph of section 11).
587
+
588
+ However, if you cease all violation of this License, then your
589
+ license from a particular copyright holder is reinstated (a)
590
+ provisionally, unless and until the copyright holder explicitly and
591
+ finally terminates your license, and (b) permanently, if the copyright
592
+ holder fails to notify you of the violation by some reasonable means
593
+ prior to 60 days after the cessation.
594
+
595
+ Moreover, your license from a particular copyright holder is
596
+ reinstated permanently if the copyright holder notifies you of the
597
+ violation by some reasonable means, this is the first time you have
598
+ received notice of violation of this License (for any work) from that
599
+ copyright holder, and you cure the violation prior to 30 days after
600
+ your receipt of the notice.
601
+
602
+ Termination of your rights under this section does not terminate the
603
+ licenses of parties who have received copies or rights from you under
604
+ this License. If your rights have been terminated and not permanently
605
+ reinstated, you do not qualify to receive new licenses for the same
606
+ material under section 10.
607
+
608
+ 9. Acceptance Not Required for Having Copies.
609
+
610
+ You are not required to accept this License in order to receive or
611
+ run a copy of the Program. Ancillary propagation of a covered work
612
+ occurring solely as a consequence of using peer-to-peer transmission
613
+ to receive a copy likewise does not require acceptance. However,
614
+ nothing other than this License grants you permission to propagate or
615
+ modify any covered work. These actions infringe copyright if you do
616
+ not accept this License. Therefore, by modifying or propagating a
617
+ covered work, you indicate your acceptance of this License to do so.
618
+
619
+ 10. Automatic Licensing of Downstream Recipients.
620
+
621
+ Each time you convey a covered work, the recipient automatically
622
+ receives a license from the original licensors, to run, modify and
623
+ propagate that work, subject to this License. You are not responsible
624
+ for enforcing compliance by third parties with this License.
625
+
626
+ An "entity transaction" is a transaction transferring control of an
627
+ organization, or substantially all assets of one, or subdividing an
628
+ organization, or merging organizations. If propagation of a covered
629
+ work results from an entity transaction, each party to that
630
+ transaction who receives a copy of the work also receives whatever
631
+ licenses to the work the party's predecessor in interest had or could
632
+ give under the previous paragraph, plus a right to possession of the
633
+ Corresponding Source of the work from the predecessor in interest, if
634
+ the predecessor has it or can get it with reasonable efforts.
635
+
636
+ You may not impose any further restrictions on the exercise of the
637
+ rights granted or affirmed under this License. For example, you may
638
+ not impose a license fee, royalty, or other charge for exercise of
639
+ rights granted under this License, and you may not initiate litigation
640
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
641
+ any patent claim is infringed by making, using, selling, offering for
642
+ sale, or importing the Program or any portion of it.
643
+
644
+ 11. Patents.
645
+
646
+ A "contributor" is a copyright holder who authorizes use under this
647
+ License of the Program or a work on which the Program is based. The
648
+ work thus licensed is called the contributor's "contributor version".
649
+
650
+ A contributor's "essential patent claims" are all patent claims
651
+ owned or controlled by the contributor, whether already acquired or
652
+ hereafter acquired, that would be infringed by some manner, permitted
653
+ by this License, of making, using, or selling its contributor version,
654
+ but do not include claims that would be infringed only as a
655
+ consequence of further modification of the contributor version. For
656
+ purposes of this definition, "control" includes the right to grant
657
+ patent sublicenses in a manner consistent with the requirements of
658
+ this License.
659
+
660
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
661
+ patent license under the contributor's essential patent claims, to
662
+ make, use, sell, offer for sale, import and otherwise run, modify and
663
+ propagate the contents of its contributor version.
664
+
665
+ In the following three paragraphs, a "patent license" is any express
666
+ agreement or commitment, however denominated, not to enforce a patent
667
+ (such as an express permission to practice a patent or covenant not to
668
+ sue for patent infringement). To "grant" such a patent license to a
669
+ party means to make such an agreement or commitment not to enforce a
670
+ patent against the party.
671
+
672
+ If you convey a covered work, knowingly relying on a patent license,
673
+ and the Corresponding Source of the work is not available for anyone
674
+ to copy, free of charge and under the terms of this License, through a
675
+ publicly available network server or other readily accessible means,
676
+ then you must either (1) cause the Corresponding Source to be so
677
+ available, or (2) arrange to deprive yourself of the benefit of the
678
+ patent license for this particular work, or (3) arrange, in a manner
679
+ consistent with the requirements of this License, to extend the patent
680
+ license to downstream recipients. "Knowingly relying" means you have
681
+ actual knowledge that, but for the patent license, your conveying the
682
+ covered work in a country, or your recipient's use of the covered work
683
+ in a country, would infringe one or more identifiable patents in that
684
+ country that you have reason to believe are valid.
685
+
686
+ If, pursuant to or in connection with a single transaction or
687
+ arrangement, you convey, or propagate by procuring conveyance of, a
688
+ covered work, and grant a patent license to some of the parties
689
+ receiving the covered work authorizing them to use, propagate, modify
690
+ or convey a specific copy of the covered work, then the patent license
691
+ you grant is automatically extended to all recipients of the covered
692
+ work and works based on it.
693
+
694
+ A patent license is "discriminatory" if it does not include within
695
+ the scope of its coverage, prohibits the exercise of, or is
696
+ conditioned on the non-exercise of one or more of the rights that are
697
+ specifically granted under this License. You may not convey a covered
698
+ work if you are a party to an arrangement with a third party that is
699
+ in the business of distributing software, under which you make payment
700
+ to the third party based on the extent of your activity of conveying
701
+ the work, and under which the third party grants, to any of the
702
+ parties who would receive the covered work from you, a discriminatory
703
+ patent license (a) in connection with copies of the covered work
704
+ conveyed by you (or copies made from those copies), or (b) primarily
705
+ for and in connection with specific products or compilations that
706
+ contain the covered work, unless you entered into that arrangement,
707
+ or that patent license was granted, prior to 28 March 2007.
708
+
709
+ Nothing in this License shall be construed as excluding or limiting
710
+ any implied license or other defenses to infringement that may
711
+ otherwise be available to you under applicable patent law.
712
+
713
+ 12. No Surrender of Others' Freedom.
714
+
715
+ If conditions are imposed on you (whether by court order, agreement or
716
+ otherwise) that contradict the conditions of this License, they do not
717
+ excuse you from the conditions of this License. If you cannot convey a
718
+ covered work so as to satisfy simultaneously your obligations under this
719
+ License and any other pertinent obligations, then as a consequence you may
720
+ not convey it at all. For example, if you agree to terms that obligate you
721
+ to collect a royalty for further conveying from those to whom you convey
722
+ the Program, the only way you could satisfy both those terms and this
723
+ License would be to refrain entirely from conveying the Program.
724
+
725
+ 13. Use with the GNU Affero General Public License.
726
+
727
+ Notwithstanding any other provision of this License, you have
728
+ permission to link or combine any covered work with a work licensed
729
+ under version 3 of the GNU Affero General Public License into a single
730
+ combined work, and to convey the resulting work. The terms of this
731
+ License will continue to apply to the part which is the covered work,
732
+ but the special requirements of the GNU Affero General Public License,
733
+ section 13, concerning interaction through a network will apply to the
734
+ combination as such.
735
+
736
+ 14. Revised Versions of this License.
737
+
738
+ The Free Software Foundation may publish revised and/or new versions of
739
+ the GNU General Public License from time to time. Such new versions will
740
+ be similar in spirit to the present version, but may differ in detail to
741
+ address new problems or concerns.
742
+
743
+ Each version is given a distinguishing version number. If the
744
+ Program specifies that a certain numbered version of the GNU General
745
+ Public License "or any later version" applies to it, you have the
746
+ option of following the terms and conditions either of that numbered
747
+ version or of any later version published by the Free Software
748
+ Foundation. If the Program does not specify a version number of the
749
+ GNU General Public License, you may choose any version ever published
750
+ by the Free Software Foundation.
751
+
752
+ If the Program specifies that a proxy can decide which future
753
+ versions of the GNU General Public License can be used, that proxy's
754
+ public statement of acceptance of a version permanently authorizes you
755
+ to choose that version for the Program.
756
+
757
+ Later license versions may give you additional or different
758
+ permissions. However, no additional obligations are imposed on any
759
+ author or copyright holder as a result of your choosing to follow a
760
+ later version.
761
+
762
+ 15. Disclaimer of Warranty.
763
+
764
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
765
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
766
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
767
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
768
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
769
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
770
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
771
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
772
+
773
+ 16. Limitation of Liability.
774
+
775
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
776
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
777
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
778
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
779
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
780
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
781
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
782
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
783
+ SUCH DAMAGES.
784
+
785
+ 17. Interpretation of Sections 15 and 16.
786
+
787
+ If the disclaimer of warranty and limitation of liability provided
788
+ above cannot be given local legal effect according to their terms,
789
+ reviewing courts shall apply local law that most closely approximates
790
+ an absolute waiver of all civil liability in connection with the
791
+ Program, unless a warranty or assumption of liability accompanies a
792
+ copy of the Program in return for a fee.
LICENSE.lesser ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/]
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
README.md CHANGED
@@ -1,13 +1,15 @@
1
  ---
2
- title: Cardiffnlp Twitter Roberta Base Sentiment Latest
3
- emoji: 💬
4
- colorFrom: yellow
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 4.36.1
8
- app_file: app.py
9
- pinned: false
10
  license: mit
11
- ---
12
-
13
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
 
 
 
 
 
 
2
  license: mit
3
+ datasets:
4
+ - HuggingFaceFV/finevideo
5
+ language:
6
+ - en
7
+ metrics:
8
+ - character
9
+ base_model:
10
+ - openai-community/gpt2
11
+ pipeline_tag: text2text-generation
12
+ library_name: transformers
13
+ tags:
14
+ - code
15
+ ---
README.rst ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .. image:: https://raw.githubusercontent.com/python-telegram-bot/logos/master/logo-text/png/ptb-logo-text_768.png
2
+ :align: center
3
+ :target: https://python-telegram-bot.org
4
+ :alt: python-telegram-bot Logo
5
+
6
+ .. image:: https://img.shields.io/pypi/v/python-telegram-bot.svg
7
+ :target: https://pypi.org/project/python-telegram-bot/
8
+ :alt: PyPi Package Version
9
+
10
+ .. image:: https://img.shields.io/pypi/pyversions/python-telegram-bot.svg
11
+ :target: https://pypi.org/project/python-telegram-bot/
12
+ :alt: Supported Python versions
13
+
14
+ .. image:: https://img.shields.io/badge/Bot%20API-7.9-blue?logo=telegram
15
+ :target: https://core.telegram.org/bots/api-changelog
16
+ :alt: Supported Bot API version
17
+
18
+ .. image:: https://img.shields.io/pypi/dm/python-telegram-bot
19
+ :target: https://pypistats.org/packages/python-telegram-bot
20
+ :alt: PyPi Package Monthly Download
21
+
22
+ .. image:: https://readthedocs.org/projects/python-telegram-bot/badge/?version=stable
23
+ :target: https://docs.python-telegram-bot.org/en/stable/
24
+ :alt: Documentation Status
25
+
26
+ .. image:: https://img.shields.io/pypi/l/python-telegram-bot.svg
27
+ :target: https://www.gnu.org/licenses/lgpl-3.0.html
28
+ :alt: LGPLv3 License
29
+
30
+ .. image:: https://github.com/python-telegram-bot/python-telegram-bot/actions/workflows/unit_tests.yml/badge.svg?branch=master
31
+ :target: https://github.com/python-telegram-bot/python-telegram-bot/
32
+ :alt: Github Actions workflow
33
+
34
+ .. image:: https://codecov.io/gh/python-telegram-bot/python-telegram-bot/branch/master/graph/badge.svg
35
+ :target: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot
36
+ :alt: Code coverage
37
+
38
+ .. image:: https://isitmaintained.com/badge/resolution/python-telegram-bot/python-telegram-bot.svg
39
+ :target: https://isitmaintained.com/project/python-telegram-bot/python-telegram-bot
40
+ :alt: Median time to resolve an issue
41
+
42
+ .. image:: https://api.codacy.com/project/badge/Grade/99d901eaa09b44b4819aec05c330c968
43
+ :target: https://app.codacy.com/gh/python-telegram-bot/python-telegram-bot/dashboard
44
+ :alt: Code quality: Codacy
45
+
46
+ .. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
47
+ :target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
48
+ :alt: pre-commit.ci status
49
+
50
+ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
51
+ :target: https://github.com/psf/black
52
+ :alt: Code Style: Black
53
+
54
+ .. image:: https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram
55
+ :target: https://t.me/pythontelegrambotchannel
56
+ :alt: Telegram Channel
57
+
58
+ .. image:: https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram
59
+ :target: https://telegram.me/pythontelegrambotgroup
60
+ :alt: Telegram Group
61
+
62
+ We have made you a wrapper you can't refuse
63
+
64
+ We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
65
+
66
+ *Stay tuned for library updates and new releases on our* `Telegram Channel <https://telegram.me/pythontelegrambotchannel>`_.
67
+
68
+ Introduction
69
+ ------------
70
+
71
+ This library provides a pure Python, asynchronous interface for the
72
+ `Telegram Bot API <https://core.telegram.org/bots/api>`_.
73
+ It's compatible with Python versions **3.8+**.
74
+
75
+ In addition to the pure API implementation, this library features several convenience methods and shortcuts as well as a number of high-level classes to
76
+ make the development of bots easy and straightforward. These classes are contained in the
77
+ ``telegram.ext`` submodule.
78
+
79
+ After installing_ the library, be sure to check out the section on `working with PTB`_.
80
+
81
+ Telegram API support
82
+ ~~~~~~~~~~~~~~~~~~~~
83
+
84
+ All types and methods of the Telegram Bot API **7.9** are natively supported by this library.
85
+ 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>`_.
86
+
87
+ Notable Features
88
+ ~~~~~~~~~~~~~~~~
89
+
90
+ - `Fully asynchronous <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Concurrency>`_
91
+ - Convenient shortcut methods, e.g. `Message.reply_text <https://docs.python-telegram-bot.org/en/stable/telegram.message.html#telegram.Message.reply_text>`_
92
+ - `Fully annotated with static type hints <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Type-Checking>`_
93
+ - `Customizable and extendable interface <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Architecture>`_
94
+ - Seamless integration with `webhooks <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks>`_ and `polling <https://docs.python-telegram-bot.org/en/stable/telegram.ext.application.html#telegram.ext.Application.run_polling>`_
95
+ - `Comprehensive documentation and examples <#working-with-ptb>`_
96
+
97
+ Installing
98
+ ----------
99
+
100
+ You can install or upgrade ``python-telegram-bot`` via
101
+
102
+ .. code:: shell
103
+
104
+ $ pip install python-telegram-bot --upgrade
105
+
106
+ To install a pre-release, use the ``--pre`` `flag <https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-pre>`_ in addition.
107
+
108
+ You can also install ``python-telegram-bot`` from source, though this is usually not necessary.
109
+
110
+ .. code:: shell
111
+
112
+ $ git clone https://github.com/python-telegram-bot/python-telegram-bot
113
+ $ cd python-telegram-bot
114
+ $ pip install build
115
+ $ python -m build
116
+
117
+ Verifying Releases
118
+ ~~~~~~~~~~~~~~~~~~
119
+
120
+ To enable you to verify that a release file that you downloaded was indeed provided by the ``python-telegram-bot`` team, we have taken the following measures.
121
+
122
+ Starting with v21.4, all releases are signed via `sigstore <https://www.sigstore.dev>`_.
123
+ The corresponding signature files are uploaded to the `GitHub releases page`_.
124
+ To verify the signature, please install the `sigstore Python client <https://pypi.org/project/sigstore/>`_ and follow the instructions for `verifying signatures from GitHub Actions <https://github.com/sigstore/sigstore-python#signatures-from-github-actions>`_. As input for the ``--repository`` parameter, please use the value ``python-telegram-bot/python-telegram-bot``.
125
+
126
+ Earlier releases are signed with a GPG key.
127
+ The signatures are uploaded to both the `GitHub releases page`_ and the `PyPI project <https://pypi.org/project/python-telegram-bot/>`_ and end with a suffix ``.asc``.
128
+ Please find the public keys `here <https://github.com/python-telegram-bot/python-telegram-bot/tree/master/public_keys>`_.
129
+ The keys are named in the format ``<first_version>-<last_version>.gpg``.
130
+
131
+ In addition, the GitHub release page also contains the sha1 hashes of the release files in the files with the suffix ``.sha1``.
132
+
133
+ Dependencies & Their Versions
134
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135
+
136
+ ``python-telegram-bot`` tries to use as few 3rd party dependencies as possible.
137
+ However, for some features using a 3rd party library is more sane than implementing the functionality again.
138
+ As these features are *optional*, the corresponding 3rd party dependencies are not installed by default.
139
+ Instead, they are listed as optional dependencies.
140
+ This allows to avoid unnecessary dependency conflicts for users who don't need the optional features.
141
+
142
+ The only required dependency is `httpx ~= 0.27 <https://www.python-httpx.org>`_ for
143
+ ``telegram.request.HTTPXRequest``, the default networking backend.
144
+
145
+ ``python-telegram-bot`` is most useful when used along with additional libraries.
146
+ To minimize dependency conflicts, we try to be liberal in terms of version requirements on the (optional) dependencies.
147
+ On the other hand, we have to ensure stability of ``python-telegram-bot``, which is why we do apply version bounds.
148
+ If you encounter dependency conflicts due to these bounds, feel free to reach out.
149
+
150
+ Optional Dependencies
151
+ #####################
152
+
153
+ PTB can be installed with optional dependencies:
154
+
155
+ * ``pip install "python-telegram-bot[passport]"`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
156
+ * ``pip install "python-telegram-bot[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
157
+ * ``pip install "python-telegram-bot[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
158
+ * ``pip install "python-telegram-bot[rate-limiter]"`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
159
+ * ``pip install "python-telegram-bot[webhooks]"`` installs the `tornado~=6.4 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
160
+ * ``pip install "python-telegram-bot[callback-data]"`` installs the `cachetools>=5.3.3,<5.6.0 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
161
+ * ``pip install "python-telegram-bot[job-queue]"`` installs the `APScheduler~=3.10.4 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``.
162
+
163
+ To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot[socks,webhooks]"``.
164
+
165
+ Additionally, two shortcuts are provided:
166
+
167
+ * ``pip install "python-telegram-bot[all]"`` installs all optional dependencies.
168
+ * ``pip install "python-telegram-bot[ext]"`` installs all optional dependencies that are related to ``telegram.ext``, i.e. ``[rate-limiter, webhooks, callback-data, job-queue]``.
169
+
170
+ Working with PTB
171
+ ----------------
172
+
173
+ Once you have installed the library, you can begin working with it - so let's get started!
174
+
175
+ Quick Start
176
+ ~~~~~~~~~~~
177
+
178
+ Our Wiki contains an `Introduction to the API <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API>`_ explaining how the pure Bot API can be accessed via ``python-telegram-bot``.
179
+ Moreover, the `Tutorial: Your first Bot <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions---Your-first-Bot>`_ gives an introduction on how chatbots can be easily programmed with the help of the ``telegram.ext`` module.
180
+
181
+ Resources
182
+ ~~~~~~~~~
183
+
184
+ - The `package documentation <https://docs.python-telegram-bot.org/>`_ is the technical reference for ``python-telegram-bot``.
185
+ It contains descriptions of all available classes, modules, methods and arguments as well as the `changelog <https://docs.python-telegram-bot.org/changelog.html>`_.
186
+ - The `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ is home to number of more elaborate introductions of the different features of ``python-telegram-bot`` and other useful resources that go beyond the technical documentation.
187
+ - Our `examples section <https://docs.python-telegram-bot.org/examples.html>`_ contains several examples that showcase the different features of both the Bot API and ``python-telegram-bot``.
188
+ Even if it is not your approach for learning, please take a look at ``echobot.py``. It is the de facto base for most of the bots out there.
189
+ The code for these examples is released to the public domain, so you can start by grabbing the code and building on top of it.
190
+ - The `official Telegram Bot API documentation <https://core.telegram.org/bots/api>`_ is of course always worth a read.
191
+
192
+ Getting help
193
+ ~~~~~~~~~~~~
194
+
195
+ If the resources mentioned above don't answer your questions or simply overwhelm you, there are several ways of getting help.
196
+
197
+ 1. We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us! Asking a question here is often the quickest way to get a pointer in the right direction.
198
+
199
+ 2. Ask questions by opening `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
200
+
201
+ 3. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
202
+
203
+ Concurrency
204
+ ~~~~~~~~~~~
205
+
206
+ Since v20.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
207
+ Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.
208
+ Noteworthy parts of ``python-telegram-bots`` API that are likely to cause issues (e.g. race conditions) when used in a multi-threaded setting include:
209
+
210
+ * ``telegram.ext.Application/Updater.update_queue``
211
+ * ``telegram.ext.ConversationHandler.check/handle_update``
212
+ * ``telegram.ext.CallbackDataCache``
213
+ * ``telegram.ext.BasePersistence``
214
+ * all classes in the ``telegram.ext.filters`` module that allow to add/remove allowed users/chats at runtime
215
+
216
+ Contributing
217
+ ------------
218
+
219
+ Contributions of all sizes are welcome.
220
+ Please review our `contribution guidelines <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst>`_ to get started.
221
+ You can also help by `reporting bugs or feature requests <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_.
222
+
223
+ Donating
224
+ --------
225
+ Occasionally we are asked if we accept donations to support the development.
226
+ While we appreciate the thought, maintaining PTB is our hobby, and we have almost no running costs for it. We therefore have nothing set up to accept donations.
227
+ If you still want to donate, we kindly ask you to donate to another open source project/initiative of your choice instead.
228
+
229
+ License
230
+ -------
231
+
232
+ You may copy, distribute and modify the software provided that modifications are described and licensed for free under `LGPL-3 <https://www.gnu.org/licenses/lgpl-3.0.html>`_.
233
+ Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL-3, but applications that use the library don't have to be.
234
+
235
+ .. _`GitHub releases page`: https://github.com/python-telegram-bot/python-telegram-bot/releases>
__init__.py ADDED
File without changes
__main__.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # !/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ # pylint: disable=missing-module-docstring
20
+ # ruff: noqa: T201, D100, S603, S607
21
+ import subprocess
22
+ import sys
23
+ from typing import Optional
24
+
25
+ from . import __version__ as telegram_ver
26
+ from .constants import BOT_API_VERSION
27
+
28
+
29
+ def _git_revision() -> Optional[str]:
30
+ try:
31
+ output = subprocess.check_output(
32
+ ["git", "describe", "--long", "--tags"], stderr=subprocess.STDOUT
33
+ )
34
+ except (subprocess.SubprocessError, OSError):
35
+ return None
36
+ return output.decode().strip()
37
+
38
+
39
+ def print_ver_info() -> None:
40
+ """Prints version information for python-telegram-bot, the Bot API and Python."""
41
+ git_revision = _git_revision()
42
+ print(f"python-telegram-bot {telegram_ver}" + (f" ({git_revision})" if git_revision else ""))
43
+ print(f"Bot API {BOT_API_VERSION}")
44
+ sys_version = sys.version.replace("\n", " ")
45
+ print(f"Python {sys_version}")
46
+
47
+
48
+ def main() -> None:
49
+ """Prints version information for python-telegram-bot, the Bot API and Python."""
50
+ print_ver_info()
51
+
52
+
53
+ if __name__ == "__main__":
54
+ main()
_birthdate.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram Birthday."""
20
+ from datetime import date
21
+ from typing import Optional
22
+
23
+ from telegram._telegramobject import TelegramObject
24
+ from telegram._utils.types import JSONDict
25
+
26
+
27
+ class Birthdate(TelegramObject):
28
+ """
29
+ This object describes the birthdate of a user.
30
+
31
+ Objects of this class are comparable in terms of equality. Two objects of this class are
32
+ considered equal, if their :attr:`day`, and :attr:`month` are equal.
33
+
34
+ .. versionadded:: 21.1
35
+
36
+ Args:
37
+ day (:obj:`int`): Day of the user's birth; 1-31.
38
+ month (:obj:`int`): Month of the user's birth; 1-12.
39
+ year (:obj:`int`, optional): Year of the user's birth.
40
+
41
+ Attributes:
42
+ day (:obj:`int`): Day of the user's birth; 1-31.
43
+ month (:obj:`int`): Month of the user's birth; 1-12.
44
+ year (:obj:`int`): Optional. Year of the user's birth.
45
+
46
+ """
47
+
48
+ __slots__ = ("day", "month", "year")
49
+
50
+ def __init__(
51
+ self,
52
+ day: int,
53
+ month: int,
54
+ year: Optional[int] = None,
55
+ *,
56
+ api_kwargs: Optional[JSONDict] = None,
57
+ ):
58
+ super().__init__(api_kwargs=api_kwargs)
59
+
60
+ # Required
61
+ self.day: int = day
62
+ self.month: int = month
63
+ # Optional
64
+ self.year: Optional[int] = year
65
+
66
+ self._id_attrs = (
67
+ self.day,
68
+ self.month,
69
+ )
70
+
71
+ self._freeze()
72
+
73
+ def to_date(self, year: Optional[int] = None) -> date:
74
+ """Return the birthdate as a date object.
75
+
76
+ .. versionchanged:: 21.2
77
+ Now returns a :obj:`datetime.date` object instead of a :obj:`datetime.datetime` object,
78
+ as was originally intended.
79
+
80
+ Args:
81
+ year (:obj:`int`, optional): The year to use. Required, if the :attr:`year` was not
82
+ present.
83
+
84
+ Returns:
85
+ :obj:`datetime.date`: The birthdate as a date object.
86
+ """
87
+ if self.year is None and year is None:
88
+ raise ValueError(
89
+ "The `year` argument is required if the `year` attribute was not present."
90
+ )
91
+
92
+ return date(year or self.year, self.month, self.day) # type: ignore[arg-type]
_bot.py ADDED
The diff for this file is too large to render. See raw diff
 
_botcommand.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram Bot Command."""
20
+
21
+ from typing import Final, Optional
22
+
23
+ from telegram import constants
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._utils.types import JSONDict
26
+
27
+
28
+ class BotCommand(TelegramObject):
29
+ """
30
+ This object represents a bot command.
31
+
32
+ Objects of this class are comparable in terms of equality. Two objects of this class are
33
+ considered equal, if their :attr:`command` and :attr:`description` are equal.
34
+
35
+ Args:
36
+ command (:obj:`str`): Text of the command; :tg-const:`telegram.BotCommand.MIN_COMMAND`-
37
+ :tg-const:`telegram.BotCommand.MAX_COMMAND` characters. Can contain only lowercase
38
+ English letters, digits and underscores.
39
+ description (:obj:`str`): Description of the command;
40
+ :tg-const:`telegram.BotCommand.MIN_DESCRIPTION`-
41
+ :tg-const:`telegram.BotCommand.MAX_DESCRIPTION` characters.
42
+
43
+ Attributes:
44
+ command (:obj:`str`): Text of the command; :tg-const:`telegram.BotCommand.MIN_COMMAND`-
45
+ :tg-const:`telegram.BotCommand.MAX_COMMAND` characters. Can contain only lowercase
46
+ English letters, digits and underscores.
47
+ description (:obj:`str`): Description of the command;
48
+ :tg-const:`telegram.BotCommand.MIN_DESCRIPTION`-
49
+ :tg-const:`telegram.BotCommand.MAX_DESCRIPTION` characters.
50
+
51
+ """
52
+
53
+ __slots__ = ("command", "description")
54
+
55
+ def __init__(self, command: str, description: str, *, api_kwargs: Optional[JSONDict] = None):
56
+ super().__init__(api_kwargs=api_kwargs)
57
+ self.command: str = command
58
+ self.description: str = description
59
+
60
+ self._id_attrs = (self.command, self.description)
61
+
62
+ self._freeze()
63
+
64
+ MIN_COMMAND: Final[int] = constants.BotCommandLimit.MIN_COMMAND
65
+ """:const:`telegram.constants.BotCommandLimit.MIN_COMMAND`
66
+
67
+ .. versionadded:: 20.0
68
+ """
69
+ MAX_COMMAND: Final[int] = constants.BotCommandLimit.MAX_COMMAND
70
+ """:const:`telegram.constants.BotCommandLimit.MAX_COMMAND`
71
+
72
+ .. versionadded:: 20.0
73
+ """
74
+ MIN_DESCRIPTION: Final[int] = constants.BotCommandLimit.MIN_DESCRIPTION
75
+ """:const:`telegram.constants.BotCommandLimit.MIN_DESCRIPTION`
76
+
77
+ .. versionadded:: 20.0
78
+ """
79
+ MAX_DESCRIPTION: Final[int] = constants.BotCommandLimit.MAX_DESCRIPTION
80
+ """:const:`telegram.constants.BotCommandLimit.MAX_DESCRIPTION`
81
+
82
+ .. versionadded:: 20.0
83
+ """
_botcommandscope.py ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ # pylint: disable=redefined-builtin
20
+ """This module contains objects representing Telegram bot command scopes."""
21
+ from typing import TYPE_CHECKING, Dict, Final, Optional, Type, Union
22
+
23
+ from telegram import constants
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._utils import enum
26
+ from telegram._utils.types import JSONDict
27
+
28
+ if TYPE_CHECKING:
29
+ from telegram import Bot
30
+
31
+
32
+ class BotCommandScope(TelegramObject):
33
+ """Base class for objects that represent the scope to which bot commands are applied.
34
+ Currently, the following 7 scopes are supported:
35
+
36
+ * :class:`telegram.BotCommandScopeDefault`
37
+ * :class:`telegram.BotCommandScopeAllPrivateChats`
38
+ * :class:`telegram.BotCommandScopeAllGroupChats`
39
+ * :class:`telegram.BotCommandScopeAllChatAdministrators`
40
+ * :class:`telegram.BotCommandScopeChat`
41
+ * :class:`telegram.BotCommandScopeChatAdministrators`
42
+ * :class:`telegram.BotCommandScopeChatMember`
43
+
44
+ Objects of this class are comparable in terms of equality. Two objects of this class are
45
+ considered equal, if their :attr:`type` is equal. For subclasses with additional attributes,
46
+ the notion of equality is overridden.
47
+
48
+ Note:
49
+ Please see the `official docs`_ on how Telegram determines which commands to display.
50
+
51
+ .. _`official docs`: https://core.telegram.org/bots/api#determining-list-of-commands
52
+
53
+ .. versionadded:: 13.7
54
+
55
+ Args:
56
+ type (:obj:`str`): Scope type.
57
+
58
+ Attributes:
59
+ type (:obj:`str`): Scope type.
60
+ """
61
+
62
+ __slots__ = ("type",)
63
+
64
+ DEFAULT: Final[str] = constants.BotCommandScopeType.DEFAULT
65
+ """:const:`telegram.constants.BotCommandScopeType.DEFAULT`"""
66
+ ALL_PRIVATE_CHATS: Final[str] = constants.BotCommandScopeType.ALL_PRIVATE_CHATS
67
+ """:const:`telegram.constants.BotCommandScopeType.ALL_PRIVATE_CHATS`"""
68
+ ALL_GROUP_CHATS: Final[str] = constants.BotCommandScopeType.ALL_GROUP_CHATS
69
+ """:const:`telegram.constants.BotCommandScopeType.ALL_GROUP_CHATS`"""
70
+ ALL_CHAT_ADMINISTRATORS: Final[str] = constants.BotCommandScopeType.ALL_CHAT_ADMINISTRATORS
71
+ """:const:`telegram.constants.BotCommandScopeType.ALL_CHAT_ADMINISTRATORS`"""
72
+ CHAT: Final[str] = constants.BotCommandScopeType.CHAT
73
+ """:const:`telegram.constants.BotCommandScopeType.CHAT`"""
74
+ CHAT_ADMINISTRATORS: Final[str] = constants.BotCommandScopeType.CHAT_ADMINISTRATORS
75
+ """:const:`telegram.constants.BotCommandScopeType.CHAT_ADMINISTRATORS`"""
76
+ CHAT_MEMBER: Final[str] = constants.BotCommandScopeType.CHAT_MEMBER
77
+ """:const:`telegram.constants.BotCommandScopeType.CHAT_MEMBER`"""
78
+
79
+ def __init__(self, type: str, *, api_kwargs: Optional[JSONDict] = None):
80
+ super().__init__(api_kwargs=api_kwargs)
81
+ self.type: str = enum.get_member(constants.BotCommandScopeType, type, type)
82
+ self._id_attrs = (self.type,)
83
+
84
+ self._freeze()
85
+
86
+ @classmethod
87
+ def de_json(
88
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
89
+ ) -> Optional["BotCommandScope"]:
90
+ """Converts JSON data to the appropriate :class:`BotCommandScope` object, i.e. takes
91
+ care of selecting the correct subclass.
92
+
93
+ Args:
94
+ data (Dict[:obj:`str`, ...]): The JSON data.
95
+ bot (:class:`telegram.Bot`, optional): The bot associated with this object. Defaults to
96
+ :obj:`None`, in which case shortcut methods will not be available.
97
+
98
+ .. versionchanged:: 21.4
99
+ :paramref:`bot` is now optional and defaults to :obj:`None`
100
+
101
+ Returns:
102
+ The Telegram object.
103
+
104
+ """
105
+ data = cls._parse_data(data)
106
+
107
+ if not data:
108
+ return None
109
+
110
+ _class_mapping: Dict[str, Type[BotCommandScope]] = {
111
+ cls.DEFAULT: BotCommandScopeDefault,
112
+ cls.ALL_PRIVATE_CHATS: BotCommandScopeAllPrivateChats,
113
+ cls.ALL_GROUP_CHATS: BotCommandScopeAllGroupChats,
114
+ cls.ALL_CHAT_ADMINISTRATORS: BotCommandScopeAllChatAdministrators,
115
+ cls.CHAT: BotCommandScopeChat,
116
+ cls.CHAT_ADMINISTRATORS: BotCommandScopeChatAdministrators,
117
+ cls.CHAT_MEMBER: BotCommandScopeChatMember,
118
+ }
119
+
120
+ if cls is BotCommandScope and data.get("type") in _class_mapping:
121
+ return _class_mapping[data.pop("type")].de_json(data=data, bot=bot)
122
+ return super().de_json(data=data, bot=bot)
123
+
124
+
125
+ class BotCommandScopeDefault(BotCommandScope):
126
+ """Represents the default scope of bot commands. Default commands are used if no commands with
127
+ a `narrower scope`_ are specified for the user.
128
+
129
+ .. _`narrower scope`: https://core.telegram.org/bots/api#determining-list-of-commands
130
+
131
+ .. versionadded:: 13.7
132
+ Attributes:
133
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.DEFAULT`.
134
+ """
135
+
136
+ __slots__ = ()
137
+
138
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
139
+ super().__init__(type=BotCommandScope.DEFAULT, api_kwargs=api_kwargs)
140
+ self._freeze()
141
+
142
+
143
+ class BotCommandScopeAllPrivateChats(BotCommandScope):
144
+ """Represents the scope of bot commands, covering all private chats.
145
+
146
+ .. versionadded:: 13.7
147
+
148
+ Attributes:
149
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_PRIVATE_CHATS`.
150
+ """
151
+
152
+ __slots__ = ()
153
+
154
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
155
+ super().__init__(type=BotCommandScope.ALL_PRIVATE_CHATS, api_kwargs=api_kwargs)
156
+ self._freeze()
157
+
158
+
159
+ class BotCommandScopeAllGroupChats(BotCommandScope):
160
+ """Represents the scope of bot commands, covering all group and supergroup chats.
161
+
162
+ .. versionadded:: 13.7
163
+ Attributes:
164
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_GROUP_CHATS`.
165
+ """
166
+
167
+ __slots__ = ()
168
+
169
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
170
+ super().__init__(type=BotCommandScope.ALL_GROUP_CHATS, api_kwargs=api_kwargs)
171
+ self._freeze()
172
+
173
+
174
+ class BotCommandScopeAllChatAdministrators(BotCommandScope):
175
+ """Represents the scope of bot commands, covering all group and supergroup chat administrators.
176
+
177
+ .. versionadded:: 13.7
178
+ Attributes:
179
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_CHAT_ADMINISTRATORS`.
180
+ """
181
+
182
+ __slots__ = ()
183
+
184
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
185
+ super().__init__(type=BotCommandScope.ALL_CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
186
+ self._freeze()
187
+
188
+
189
+ class BotCommandScopeChat(BotCommandScope):
190
+ """Represents the scope of bot commands, covering a specific chat.
191
+
192
+ Objects of this class are comparable in terms of equality. Two objects of this class are
193
+ considered equal, if their :attr:`type` and :attr:`chat_id` are equal.
194
+
195
+ .. versionadded:: 13.7
196
+
197
+ Args:
198
+ chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
199
+
200
+ Attributes:
201
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT`.
202
+ chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
203
+ """
204
+
205
+ __slots__ = ("chat_id",)
206
+
207
+ def __init__(self, chat_id: Union[str, int], *, api_kwargs: Optional[JSONDict] = None):
208
+ super().__init__(type=BotCommandScope.CHAT, api_kwargs=api_kwargs)
209
+ with self._unfrozen():
210
+ self.chat_id: Union[str, int] = (
211
+ chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
212
+ )
213
+ self._id_attrs = (self.type, self.chat_id)
214
+
215
+
216
+ class BotCommandScopeChatAdministrators(BotCommandScope):
217
+ """Represents the scope of bot commands, covering all administrators of a specific group or
218
+ supergroup chat.
219
+
220
+ Objects of this class are comparable in terms of equality. Two objects of this class are
221
+ considered equal, if their :attr:`type` and :attr:`chat_id` are equal.
222
+
223
+ .. versionadded:: 13.7
224
+
225
+ Args:
226
+ chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
227
+ Attributes:
228
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT_ADMINISTRATORS`.
229
+ chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
230
+ """
231
+
232
+ __slots__ = ("chat_id",)
233
+
234
+ def __init__(self, chat_id: Union[str, int], *, api_kwargs: Optional[JSONDict] = None):
235
+ super().__init__(type=BotCommandScope.CHAT_ADMINISTRATORS, api_kwargs=api_kwargs)
236
+ with self._unfrozen():
237
+ self.chat_id: Union[str, int] = (
238
+ chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
239
+ )
240
+ self._id_attrs = (self.type, self.chat_id)
241
+
242
+
243
+ class BotCommandScopeChatMember(BotCommandScope):
244
+ """Represents the scope of bot commands, covering a specific member of a group or supergroup
245
+ chat.
246
+
247
+ Objects of this class are comparable in terms of equality. Two objects of this class are
248
+ considered equal, if their :attr:`type`, :attr:`chat_id` and :attr:`user_id` are equal.
249
+
250
+ .. versionadded:: 13.7
251
+
252
+ Args:
253
+ chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
254
+ user_id (:obj:`int`): Unique identifier of the target user.
255
+
256
+ Attributes:
257
+ type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT_MEMBER`.
258
+ chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
259
+ user_id (:obj:`int`): Unique identifier of the target user.
260
+ """
261
+
262
+ __slots__ = ("chat_id", "user_id")
263
+
264
+ def __init__(
265
+ self, chat_id: Union[str, int], user_id: int, *, api_kwargs: Optional[JSONDict] = None
266
+ ):
267
+ super().__init__(type=BotCommandScope.CHAT_MEMBER, api_kwargs=api_kwargs)
268
+ with self._unfrozen():
269
+ self.chat_id: Union[str, int] = (
270
+ chat_id if isinstance(chat_id, str) and chat_id.startswith("@") else int(chat_id)
271
+ )
272
+ self.user_id: int = user_id
273
+ self._id_attrs = (self.type, self.chat_id, self.user_id)
_botdescription.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains two objects that represent a Telegram bots (short) description."""
20
+ from typing import Optional
21
+
22
+ from telegram._telegramobject import TelegramObject
23
+ from telegram._utils.types import JSONDict
24
+
25
+
26
+ class BotDescription(TelegramObject):
27
+ """This object represents the bot's description.
28
+
29
+ Objects of this class are comparable in terms of equality. Two objects of this class are
30
+ considered equal, if their :attr:`description` is equal.
31
+
32
+ .. versionadded:: 20.2
33
+
34
+ Args:
35
+ description (:obj:`str`): The bot's description.
36
+
37
+ Attributes:
38
+ description (:obj:`str`): The bot's description.
39
+
40
+ """
41
+
42
+ __slots__ = ("description",)
43
+
44
+ def __init__(self, description: str, *, api_kwargs: Optional[JSONDict] = None):
45
+ super().__init__(api_kwargs=api_kwargs)
46
+ self.description: str = description
47
+
48
+ self._id_attrs = (self.description,)
49
+
50
+ self._freeze()
51
+
52
+
53
+ class BotShortDescription(TelegramObject):
54
+ """This object represents the bot's short description.
55
+
56
+ Objects of this class are comparable in terms of equality. Two objects of this class are
57
+ considered equal, if their :attr:`short_description` is equal.
58
+
59
+ .. versionadded:: 20.2
60
+
61
+ Args:
62
+ short_description (:obj:`str`): The bot's short description.
63
+
64
+ Attributes:
65
+ short_description (:obj:`str`): The bot's short description.
66
+
67
+ """
68
+
69
+ __slots__ = ("short_description",)
70
+
71
+ def __init__(self, short_description: str, *, api_kwargs: Optional[JSONDict] = None):
72
+ super().__init__(api_kwargs=api_kwargs)
73
+ self.short_description: str = short_description
74
+
75
+ self._id_attrs = (self.short_description,)
76
+
77
+ self._freeze()
_botname.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represent a Telegram bots name."""
20
+ from typing import Final, Optional
21
+
22
+ from telegram import constants
23
+ from telegram._telegramobject import TelegramObject
24
+ from telegram._utils.types import JSONDict
25
+
26
+
27
+ class BotName(TelegramObject):
28
+ """This object represents the bot's name.
29
+
30
+ Objects of this class are comparable in terms of equality. Two objects of this class are
31
+ considered equal, if their :attr:`name` is equal.
32
+
33
+ .. versionadded:: 20.3
34
+
35
+ Args:
36
+ name (:obj:`str`): The bot's name.
37
+
38
+ Attributes:
39
+ name (:obj:`str`): The bot's name.
40
+
41
+ """
42
+
43
+ __slots__ = ("name",)
44
+
45
+ def __init__(self, name: str, *, api_kwargs: Optional[JSONDict] = None):
46
+ super().__init__(api_kwargs=api_kwargs)
47
+ self.name: str = name
48
+
49
+ self._id_attrs = (self.name,)
50
+
51
+ self._freeze()
52
+
53
+ MAX_LENGTH: Final[int] = constants.BotNameLimit.MAX_NAME_LENGTH
54
+ """:const:`telegram.constants.BotNameLimit.MAX_NAME_LENGTH`"""
_business.py ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # pylint: disable=redefined-builtin
3
+ #
4
+ # A library that provides a Python interface to the Telegram Bot API
5
+ # Copyright (C) 2015-2024
6
+ # Leandro Toledo de Souza <[email protected]>
7
+ #
8
+ # This program is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser Public License
19
+ # along with this program. If not, see [http://www.gnu.org/licenses/]
20
+ """This module contains the Telegram Business related classes."""
21
+
22
+ from datetime import datetime
23
+ from typing import TYPE_CHECKING, Optional, Sequence, Tuple
24
+
25
+ from telegram._chat import Chat
26
+ from telegram._files.location import Location
27
+ from telegram._files.sticker import Sticker
28
+ from telegram._telegramobject import TelegramObject
29
+ from telegram._user import User
30
+ from telegram._utils.argumentparsing import parse_sequence_arg
31
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
32
+ from telegram._utils.types import JSONDict
33
+
34
+ if TYPE_CHECKING:
35
+ from telegram import Bot
36
+
37
+
38
+ class BusinessConnection(TelegramObject):
39
+ """
40
+ Describes the connection of the bot with a business account.
41
+
42
+ Objects of this class are comparable in terms of equality. Two objects of this class are
43
+ considered equal if their :attr:`id`, :attr:`user`, :attr:`user_chat_id`, :attr:`date`,
44
+ :attr:`can_reply`, and :attr:`is_enabled` are equal.
45
+
46
+ .. versionadded:: 21.1
47
+
48
+ Args:
49
+ id (:obj:`str`): Unique identifier of the business connection.
50
+ user (:class:`telegram.User`): Business account user that created the business connection.
51
+ user_chat_id (:obj:`int`): Identifier of a private chat with the user who created the
52
+ business connection.
53
+ date (:obj:`datetime.datetime`): Date the connection was established in Unix time.
54
+ can_reply (:obj:`bool`): True, if the bot can act on behalf of the business account in
55
+ chats that were active in the last 24 hours.
56
+ is_enabled (:obj:`bool`): True, if the connection is active.
57
+
58
+ Attributes:
59
+ id (:obj:`str`): Unique identifier of the business connection.
60
+ user (:class:`telegram.User`): Business account user that created the business connection.
61
+ user_chat_id (:obj:`int`): Identifier of a private chat with the user who created the
62
+ business connection.
63
+ date (:obj:`datetime.datetime`): Date the connection was established in Unix time.
64
+ can_reply (:obj:`bool`): True, if the bot can act on behalf of the business account in
65
+ chats that were active in the last 24 hours.
66
+ is_enabled (:obj:`bool`): True, if the connection is active.
67
+ """
68
+
69
+ __slots__ = (
70
+ "can_reply",
71
+ "date",
72
+ "id",
73
+ "is_enabled",
74
+ "user",
75
+ "user_chat_id",
76
+ )
77
+
78
+ def __init__(
79
+ self,
80
+ id: str,
81
+ user: "User",
82
+ user_chat_id: int,
83
+ date: datetime,
84
+ can_reply: bool,
85
+ is_enabled: bool,
86
+ *,
87
+ api_kwargs: Optional[JSONDict] = None,
88
+ ):
89
+ super().__init__(api_kwargs=api_kwargs)
90
+ self.id: str = id
91
+ self.user: User = user
92
+ self.user_chat_id: int = user_chat_id
93
+ self.date: datetime = date
94
+ self.can_reply: bool = can_reply
95
+ self.is_enabled: bool = is_enabled
96
+
97
+ self._id_attrs = (
98
+ self.id,
99
+ self.user,
100
+ self.user_chat_id,
101
+ self.date,
102
+ self.can_reply,
103
+ self.is_enabled,
104
+ )
105
+
106
+ self._freeze()
107
+
108
+ @classmethod
109
+ def de_json(
110
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
111
+ ) -> Optional["BusinessConnection"]:
112
+ """See :meth:`telegram.TelegramObject.de_json`."""
113
+ data = cls._parse_data(data)
114
+
115
+ if not data:
116
+ return None
117
+
118
+ # Get the local timezone from the bot if it has defaults
119
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
120
+
121
+ data["date"] = from_timestamp(data.get("date"), tzinfo=loc_tzinfo)
122
+ data["user"] = User.de_json(data.get("user"), bot)
123
+
124
+ return super().de_json(data=data, bot=bot)
125
+
126
+
127
+ class BusinessMessagesDeleted(TelegramObject):
128
+ """
129
+ This object is received when messages are deleted from a connected business account.
130
+
131
+ Objects of this class are comparable in terms of equality. Two objects of this class are
132
+ considered equal if their :attr:`business_connection_id`, :attr:`message_ids`, and
133
+ :attr:`chat` are equal.
134
+
135
+ .. versionadded:: 21.1
136
+
137
+ Args:
138
+ business_connection_id (:obj:`str`): Unique identifier of the business connection.
139
+ chat (:class:`telegram.Chat`): Information about a chat in the business account. The bot
140
+ may not have access to the chat or the corresponding user.
141
+ message_ids (Sequence[:obj:`int`]): A list of identifiers of the deleted messages in the
142
+ chat of the business account.
143
+
144
+ Attributes:
145
+ business_connection_id (:obj:`str`): Unique identifier of the business connection.
146
+ chat (:class:`telegram.Chat`): Information about a chat in the business account. The bot
147
+ may not have access to the chat or the corresponding user.
148
+ message_ids (Tuple[:obj:`int`]): A list of identifiers of the deleted messages in the
149
+ chat of the business account.
150
+ """
151
+
152
+ __slots__ = (
153
+ "business_connection_id",
154
+ "chat",
155
+ "message_ids",
156
+ )
157
+
158
+ def __init__(
159
+ self,
160
+ business_connection_id: str,
161
+ chat: Chat,
162
+ message_ids: Sequence[int],
163
+ *,
164
+ api_kwargs: Optional[JSONDict] = None,
165
+ ):
166
+ super().__init__(api_kwargs=api_kwargs)
167
+ self.business_connection_id: str = business_connection_id
168
+ self.chat: Chat = chat
169
+ self.message_ids: Tuple[int, ...] = parse_sequence_arg(message_ids)
170
+
171
+ self._id_attrs = (
172
+ self.business_connection_id,
173
+ self.chat,
174
+ self.message_ids,
175
+ )
176
+
177
+ self._freeze()
178
+
179
+ @classmethod
180
+ def de_json(
181
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
182
+ ) -> Optional["BusinessMessagesDeleted"]:
183
+ """See :meth:`telegram.TelegramObject.de_json`."""
184
+ data = cls._parse_data(data)
185
+
186
+ if not data:
187
+ return None
188
+
189
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
190
+
191
+ return super().de_json(data=data, bot=bot)
192
+
193
+
194
+ class BusinessIntro(TelegramObject):
195
+ """
196
+ This object contains information about the start page settings of a Telegram Business account.
197
+
198
+ Objects of this class are comparable in terms of equality.
199
+ Two objects of this class are considered equal, if their
200
+ :attr:`title`, :attr:`message` and :attr:`sticker` are equal.
201
+
202
+ .. versionadded:: 21.1
203
+
204
+ Args:
205
+ title (:obj:`str`, optional): Title text of the business intro.
206
+ message (:obj:`str`, optional): Message text of the business intro.
207
+ sticker (:class:`telegram.Sticker`, optional): Sticker of the business intro.
208
+
209
+ Attributes:
210
+ title (:obj:`str`): Optional. Title text of the business intro.
211
+ message (:obj:`str`): Optional. Message text of the business intro.
212
+ sticker (:class:`telegram.Sticker`): Optional. Sticker of the business intro.
213
+ """
214
+
215
+ __slots__ = (
216
+ "message",
217
+ "sticker",
218
+ "title",
219
+ )
220
+
221
+ def __init__(
222
+ self,
223
+ title: Optional[str] = None,
224
+ message: Optional[str] = None,
225
+ sticker: Optional[Sticker] = None,
226
+ *,
227
+ api_kwargs: Optional[JSONDict] = None,
228
+ ):
229
+ super().__init__(api_kwargs=api_kwargs)
230
+ self.title: Optional[str] = title
231
+ self.message: Optional[str] = message
232
+ self.sticker: Optional[Sticker] = sticker
233
+
234
+ self._id_attrs = (self.title, self.message, self.sticker)
235
+
236
+ self._freeze()
237
+
238
+ @classmethod
239
+ def de_json(
240
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
241
+ ) -> Optional["BusinessIntro"]:
242
+ """See :meth:`telegram.TelegramObject.de_json`."""
243
+ data = cls._parse_data(data)
244
+
245
+ if not data:
246
+ return None
247
+
248
+ data["sticker"] = Sticker.de_json(data.get("sticker"), bot)
249
+
250
+ return super().de_json(data=data, bot=bot)
251
+
252
+
253
+ class BusinessLocation(TelegramObject):
254
+ """
255
+ This object contains information about the location of a Telegram Business account.
256
+
257
+ Objects of this class are comparable in terms of equality.
258
+ Two objects of this class are considered equal, if their
259
+ :attr:`address` is equal.
260
+
261
+ .. versionadded:: 21.1
262
+
263
+ Args:
264
+ address (:obj:`str`): Address of the business.
265
+ location (:class:`telegram.Location`, optional): Location of the business.
266
+
267
+ Attributes:
268
+ address (:obj:`str`): Address of the business.
269
+ location (:class:`telegram.Location`): Optional. Location of the business.
270
+ """
271
+
272
+ __slots__ = (
273
+ "address",
274
+ "location",
275
+ )
276
+
277
+ def __init__(
278
+ self,
279
+ address: str,
280
+ location: Optional[Location] = None,
281
+ *,
282
+ api_kwargs: Optional[JSONDict] = None,
283
+ ):
284
+ super().__init__(api_kwargs=api_kwargs)
285
+ self.address: str = address
286
+ self.location: Optional[Location] = location
287
+
288
+ self._id_attrs = (self.address,)
289
+
290
+ self._freeze()
291
+
292
+ @classmethod
293
+ def de_json(
294
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
295
+ ) -> Optional["BusinessLocation"]:
296
+ """See :meth:`telegram.TelegramObject.de_json`."""
297
+ data = cls._parse_data(data)
298
+
299
+ if not data:
300
+ return None
301
+
302
+ data["location"] = Location.de_json(data.get("location"), bot)
303
+
304
+ return super().de_json(data=data, bot=bot)
305
+
306
+
307
+ class BusinessOpeningHoursInterval(TelegramObject):
308
+ """
309
+ This object describes an interval of time during which a business is open.
310
+
311
+ Objects of this class are comparable in terms of equality.
312
+ Two objects of this class are considered equal, if their
313
+ :attr:`opening_minute` and :attr:`closing_minute` are equal.
314
+
315
+ .. versionadded:: 21.1
316
+
317
+ Examples:
318
+ A day has (24 * 60 =) 1440 minutes, a week has (7 * 1440 =) 10080 minutes.
319
+ Starting the the minute's sequence from Monday, example values of
320
+ :attr:`opening_minute`, :attr:`closing_minute` will map to the following day times:
321
+
322
+ * Monday - 8am to 8:30pm:
323
+ - ``opening_minute = 480`` :guilabel:`8 * 60`
324
+ - ``closing_minute = 1230`` :guilabel:`20 * 60 + 30`
325
+ * Tuesday - 24 hours:
326
+ - ``opening_minute = 1440`` :guilabel:`24 * 60`
327
+ - ``closing_minute = 2879`` :guilabel:`2 * 24 * 60 - 1`
328
+ * Sunday - 12am - 11:58pm:
329
+ - ``opening_minute = 8640`` :guilabel:`6 * 24 * 60`
330
+ - ``closing_minute = 10078`` :guilabel:`7 * 24 * 60 - 2`
331
+
332
+ Args:
333
+ opening_minute (:obj:`int`): The minute's sequence number in a week, starting on Monday,
334
+ marking the start of the time interval during which the business is open;
335
+ 0 - 7 * 24 * 60.
336
+ closing_minute (:obj:`int`): The minute's
337
+ sequence number in a week, starting on Monday, marking the end of the time interval
338
+ during which the business is open; 0 - 8 * 24 * 60
339
+
340
+ Attributes:
341
+ opening_minute (:obj:`int`): The minute's sequence number in a week, starting on Monday,
342
+ marking the start of the time interval during which the business is open;
343
+ 0 - 7 * 24 * 60.
344
+ closing_minute (:obj:`int`): The minute's
345
+ sequence number in a week, starting on Monday, marking the end of the time interval
346
+ during which the business is open; 0 - 8 * 24 * 60
347
+ """
348
+
349
+ __slots__ = ("_closing_time", "_opening_time", "closing_minute", "opening_minute")
350
+
351
+ def __init__(
352
+ self,
353
+ opening_minute: int,
354
+ closing_minute: int,
355
+ *,
356
+ api_kwargs: Optional[JSONDict] = None,
357
+ ):
358
+ super().__init__(api_kwargs=api_kwargs)
359
+ self.opening_minute: int = opening_minute
360
+ self.closing_minute: int = closing_minute
361
+
362
+ self._opening_time: Optional[Tuple[int, int, int]] = None
363
+ self._closing_time: Optional[Tuple[int, int, int]] = None
364
+
365
+ self._id_attrs = (self.opening_minute, self.closing_minute)
366
+
367
+ self._freeze()
368
+
369
+ def _parse_minute(self, minute: int) -> Tuple[int, int, int]:
370
+ return (minute // 1440, minute % 1440 // 60, minute % 1440 % 60)
371
+
372
+ @property
373
+ def opening_time(self) -> Tuple[int, int, int]:
374
+ """Convenience attribute. A :obj:`tuple` parsed from :attr:`opening_minute`. It contains
375
+ the `weekday`, `hour` and `minute` in the same ranges as :attr:`datetime.datetime.weekday`,
376
+ :attr:`datetime.datetime.hour` and :attr:`datetime.datetime.minute`
377
+
378
+ Returns:
379
+ Tuple[:obj:`int`, :obj:`int`, :obj:`int`]:
380
+ """
381
+ if self._opening_time is None:
382
+ self._opening_time = self._parse_minute(self.opening_minute)
383
+ return self._opening_time
384
+
385
+ @property
386
+ def closing_time(self) -> Tuple[int, int, int]:
387
+ """Convenience attribute. A :obj:`tuple` parsed from :attr:`closing_minute`. It contains
388
+ the `weekday`, `hour` and `minute` in the same ranges as :attr:`datetime.datetime.weekday`,
389
+ :attr:`datetime.datetime.hour` and :attr:`datetime.datetime.minute`
390
+
391
+ Returns:
392
+ Tuple[:obj:`int`, :obj:`int`, :obj:`int`]:
393
+ """
394
+ if self._closing_time is None:
395
+ self._closing_time = self._parse_minute(self.closing_minute)
396
+ return self._closing_time
397
+
398
+
399
+ class BusinessOpeningHours(TelegramObject):
400
+ """
401
+ This object describes the opening hours of a business.
402
+
403
+ Objects of this class are comparable in terms of equality.
404
+ Two objects of this class are considered equal, if their
405
+ :attr:`time_zone_name` and :attr:`opening_hours` are equal.
406
+
407
+ .. versionadded:: 21.1
408
+
409
+ Args:
410
+ time_zone_name (:obj:`str`): Unique name of the time zone for which the opening
411
+ hours are defined.
412
+ opening_hours (Sequence[:class:`telegram.BusinessOpeningHoursInterval`]): List of
413
+ time intervals describing business opening hours.
414
+
415
+ Attributes:
416
+ time_zone_name (:obj:`str`): Unique name of the time zone for which the opening
417
+ hours are defined.
418
+ opening_hours (Sequence[:class:`telegram.BusinessOpeningHoursInterval`]): List of
419
+ time intervals describing business opening hours.
420
+ """
421
+
422
+ __slots__ = ("opening_hours", "time_zone_name")
423
+
424
+ def __init__(
425
+ self,
426
+ time_zone_name: str,
427
+ opening_hours: Sequence[BusinessOpeningHoursInterval],
428
+ *,
429
+ api_kwargs: Optional[JSONDict] = None,
430
+ ):
431
+ super().__init__(api_kwargs=api_kwargs)
432
+ self.time_zone_name: str = time_zone_name
433
+ self.opening_hours: Sequence[BusinessOpeningHoursInterval] = parse_sequence_arg(
434
+ opening_hours
435
+ )
436
+
437
+ self._id_attrs = (self.time_zone_name, self.opening_hours)
438
+
439
+ self._freeze()
440
+
441
+ @classmethod
442
+ def de_json(
443
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
444
+ ) -> Optional["BusinessOpeningHours"]:
445
+ """See :meth:`telegram.TelegramObject.de_json`."""
446
+ data = cls._parse_data(data)
447
+
448
+ if not data:
449
+ return None
450
+
451
+ data["opening_hours"] = BusinessOpeningHoursInterval.de_list(
452
+ data.get("opening_hours"), bot
453
+ )
454
+
455
+ return super().de_json(data=data, bot=bot)
_callbackquery.py ADDED
@@ -0,0 +1,892 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ # pylint: disable=redefined-builtin
20
+ """This module contains an object that represents a Telegram CallbackQuery"""
21
+ from typing import TYPE_CHECKING, Final, Optional, Sequence, Tuple, Union
22
+
23
+ from telegram import constants
24
+ from telegram._files.location import Location
25
+ from telegram._message import MaybeInaccessibleMessage, Message
26
+ from telegram._telegramobject import TelegramObject
27
+ from telegram._user import User
28
+ from telegram._utils.defaultvalue import DEFAULT_NONE
29
+ from telegram._utils.types import JSONDict, ODVInput, ReplyMarkup
30
+
31
+ if TYPE_CHECKING:
32
+ from telegram import (
33
+ Bot,
34
+ GameHighScore,
35
+ InlineKeyboardMarkup,
36
+ InputMedia,
37
+ LinkPreviewOptions,
38
+ MessageEntity,
39
+ MessageId,
40
+ ReplyParameters,
41
+ )
42
+
43
+
44
+ class CallbackQuery(TelegramObject):
45
+ """
46
+ This object represents an incoming callback query from a callback button in an inline keyboard.
47
+
48
+ If the button that originated the query was attached to a message sent by the bot, the field
49
+ :attr:`message` will be present. If the button was attached to a message sent via the bot (in
50
+ inline mode), the field :attr:`inline_message_id` will be present.
51
+
52
+ Objects of this class are comparable in terms of equality. Two objects of this class are
53
+ considered equal, if their :attr:`id` is equal.
54
+
55
+ Note:
56
+ * In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.
57
+ * Exactly one of the fields :attr:`data` or :attr:`game_short_name` will be present.
58
+ * After the user presses an inline button, Telegram clients will display a progress bar
59
+ until you call :attr:`answer`. It is, therefore, necessary to react
60
+ by calling :attr:`telegram.Bot.answer_callback_query` even if no notification to the user
61
+ is needed (e.g., without specifying any of the optional parameters).
62
+ * If you're using :attr:`telegram.ext.ExtBot.callback_data_cache`, :attr:`data` may be
63
+ an instance
64
+ of :class:`telegram.ext.InvalidCallbackData`. This will be the case, if the data
65
+ associated with the button triggering the :class:`telegram.CallbackQuery` was already
66
+ deleted or if :attr:`data` was manipulated by a malicious client.
67
+
68
+ .. versionadded:: 13.6
69
+
70
+ Args:
71
+ id (:obj:`str`): Unique identifier for this query.
72
+ from_user (:class:`telegram.User`): Sender.
73
+ chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
74
+ the message with the callback button was sent. Useful for high scores in games.
75
+ message (:class:`telegram.MaybeInaccessibleMessage`, optional): Message sent by the bot
76
+ with the callback button that originated the query.
77
+
78
+ .. versionchanged:: 20.8
79
+ Accept objects of type :class:`telegram.MaybeInaccessibleMessage` since Bot API 7.0.
80
+ data (:obj:`str`, optional): Data associated with the callback button. Be aware that the
81
+ message, which originated the query, can contain no callback buttons with this data.
82
+ inline_message_id (:obj:`str`, optional): Identifier of the message sent via the bot in
83
+ inline mode, that originated the query.
84
+ game_short_name (:obj:`str`, optional): Short name of a Game to be returned, serves as
85
+ the unique identifier for the game.
86
+
87
+ Attributes:
88
+ id (:obj:`str`): Unique identifier for this query.
89
+ from_user (:class:`telegram.User`): Sender.
90
+ chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
91
+ the message with the callback button was sent. Useful for high scores in games.
92
+ message (:class:`telegram.MaybeInaccessibleMessage`): Optional. Message sent by the bot
93
+ with the callback button that originated the query.
94
+
95
+ .. versionchanged:: 20.8
96
+ Objects may be of type :class:`telegram.MaybeInaccessibleMessage` since Bot API
97
+ 7.0.
98
+ data (:obj:`str` | :obj:`object`): Optional. Data associated with the callback button.
99
+ Be aware that the message, which originated the query, can contain no callback buttons
100
+ with this data.
101
+
102
+ Tip:
103
+ The value here is the same as the value passed in
104
+ :paramref:`telegram.InlineKeyboardButton.callback_data`.
105
+ inline_message_id (:obj:`str`): Optional. Identifier of the message sent via the bot in
106
+ inline mode, that originated the query.
107
+ game_short_name (:obj:`str`): Optional. Short name of a Game to be returned, serves as
108
+ the unique identifier for the game.
109
+
110
+
111
+ """
112
+
113
+ __slots__ = (
114
+ "chat_instance",
115
+ "data",
116
+ "from_user",
117
+ "game_short_name",
118
+ "id",
119
+ "inline_message_id",
120
+ "message",
121
+ )
122
+
123
+ def __init__(
124
+ self,
125
+ id: str,
126
+ from_user: User,
127
+ chat_instance: str,
128
+ message: Optional[MaybeInaccessibleMessage] = None,
129
+ data: Optional[str] = None,
130
+ inline_message_id: Optional[str] = None,
131
+ game_short_name: Optional[str] = None,
132
+ *,
133
+ api_kwargs: Optional[JSONDict] = None,
134
+ ):
135
+ super().__init__(api_kwargs=api_kwargs)
136
+ # Required
137
+ self.id: str = id
138
+ self.from_user: User = from_user
139
+ self.chat_instance: str = chat_instance
140
+ # Optionals
141
+ self.message: Optional[MaybeInaccessibleMessage] = message
142
+ self.data: Optional[str] = data
143
+ self.inline_message_id: Optional[str] = inline_message_id
144
+ self.game_short_name: Optional[str] = game_short_name
145
+
146
+ self._id_attrs = (self.id,)
147
+
148
+ self._freeze()
149
+
150
+ @classmethod
151
+ def de_json(
152
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
153
+ ) -> Optional["CallbackQuery"]:
154
+ """See :meth:`telegram.TelegramObject.de_json`."""
155
+ data = cls._parse_data(data)
156
+
157
+ if not data:
158
+ return None
159
+
160
+ data["from_user"] = User.de_json(data.pop("from", None), bot)
161
+ data["message"] = Message.de_json(data.get("message"), bot)
162
+
163
+ return super().de_json(data=data, bot=bot)
164
+
165
+ async def answer(
166
+ self,
167
+ text: Optional[str] = None,
168
+ show_alert: Optional[bool] = None,
169
+ url: Optional[str] = None,
170
+ cache_time: Optional[int] = None,
171
+ *,
172
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
173
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
174
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
175
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
176
+ api_kwargs: Optional[JSONDict] = None,
177
+ ) -> bool:
178
+ """Shortcut for::
179
+
180
+ await bot.answer_callback_query(update.callback_query.id, *args, **kwargs)
181
+
182
+ For the documentation of the arguments, please see
183
+ :meth:`telegram.Bot.answer_callback_query`.
184
+
185
+ Returns:
186
+ :obj:`bool`: On success, :obj:`True` is returned.
187
+
188
+ """
189
+ return await self.get_bot().answer_callback_query(
190
+ callback_query_id=self.id,
191
+ text=text,
192
+ show_alert=show_alert,
193
+ url=url,
194
+ cache_time=cache_time,
195
+ read_timeout=read_timeout,
196
+ write_timeout=write_timeout,
197
+ connect_timeout=connect_timeout,
198
+ pool_timeout=pool_timeout,
199
+ api_kwargs=api_kwargs,
200
+ )
201
+
202
+ def _get_message(self, action: str = "edit") -> Message:
203
+ """Helper method to get the message for the shortcut methods. Must be called only
204
+ if :attr:`inline_message_id` is *not* set.
205
+ """
206
+ if not isinstance(self.message, Message):
207
+ raise TypeError(f"Cannot {action} an inaccessible message")
208
+ return self.message
209
+
210
+ async def edit_message_text(
211
+ self,
212
+ text: str,
213
+ parse_mode: ODVInput[str] = DEFAULT_NONE,
214
+ reply_markup: Optional["InlineKeyboardMarkup"] = None,
215
+ entities: Optional[Sequence["MessageEntity"]] = None,
216
+ link_preview_options: ODVInput["LinkPreviewOptions"] = DEFAULT_NONE,
217
+ *,
218
+ disable_web_page_preview: Optional[bool] = None,
219
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
220
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
221
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
222
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
223
+ api_kwargs: Optional[JSONDict] = None,
224
+ ) -> Union[Message, bool]:
225
+ """Shortcut for either::
226
+
227
+ await update.callback_query.message.edit_text(*args, **kwargs)
228
+
229
+ or::
230
+
231
+ await bot.edit_message_text(
232
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs,
233
+ )
234
+
235
+ For the documentation of the arguments, please see
236
+ :meth:`telegram.Bot.edit_message_text` and :meth:`telegram.Message.edit_text`.
237
+
238
+ .. versionchanged:: 20.8
239
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
240
+
241
+ Returns:
242
+ :class:`telegram.Message`: On success, if edited message is sent by the bot, the
243
+ edited Message is returned, otherwise :obj:`True` is returned.
244
+
245
+ Raises:
246
+ :exc:`TypeError` if :attr:`message` is not accessible.
247
+
248
+ """
249
+ if self.inline_message_id:
250
+ return await self.get_bot().edit_message_text(
251
+ inline_message_id=self.inline_message_id,
252
+ text=text,
253
+ parse_mode=parse_mode,
254
+ disable_web_page_preview=disable_web_page_preview,
255
+ link_preview_options=link_preview_options,
256
+ reply_markup=reply_markup,
257
+ read_timeout=read_timeout,
258
+ write_timeout=write_timeout,
259
+ connect_timeout=connect_timeout,
260
+ pool_timeout=pool_timeout,
261
+ api_kwargs=api_kwargs,
262
+ entities=entities,
263
+ chat_id=None,
264
+ message_id=None,
265
+ # inline messages can not be sent on behalf of a bcid
266
+ business_connection_id=None,
267
+ )
268
+ return await self._get_message().edit_text(
269
+ text=text,
270
+ parse_mode=parse_mode,
271
+ disable_web_page_preview=disable_web_page_preview,
272
+ link_preview_options=link_preview_options,
273
+ reply_markup=reply_markup,
274
+ read_timeout=read_timeout,
275
+ write_timeout=write_timeout,
276
+ connect_timeout=connect_timeout,
277
+ pool_timeout=pool_timeout,
278
+ api_kwargs=api_kwargs,
279
+ entities=entities,
280
+ )
281
+
282
+ async def edit_message_caption(
283
+ self,
284
+ caption: Optional[str] = None,
285
+ reply_markup: Optional["InlineKeyboardMarkup"] = None,
286
+ parse_mode: ODVInput[str] = DEFAULT_NONE,
287
+ caption_entities: Optional[Sequence["MessageEntity"]] = None,
288
+ show_caption_above_media: Optional[bool] = None,
289
+ *,
290
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
291
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
292
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
293
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
294
+ api_kwargs: Optional[JSONDict] = None,
295
+ ) -> Union[Message, bool]:
296
+ """Shortcut for either::
297
+
298
+ await update.callback_query.message.edit_caption(*args, **kwargs)
299
+
300
+ or::
301
+
302
+ await bot.edit_message_caption(
303
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs,
304
+ )
305
+
306
+ For the documentation of the arguments, please see
307
+ :meth:`telegram.Bot.edit_message_caption` and :meth:`telegram.Message.edit_caption`.
308
+
309
+ .. versionchanged:: 20.8
310
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
311
+
312
+ Returns:
313
+ :class:`telegram.Message`: On success, if edited message is sent by the bot, the
314
+ edited Message is returned, otherwise :obj:`True` is returned.
315
+
316
+ Raises:
317
+ :exc:`TypeError` if :attr:`message` is not accessible.
318
+
319
+ """
320
+ if self.inline_message_id:
321
+ return await self.get_bot().edit_message_caption(
322
+ caption=caption,
323
+ inline_message_id=self.inline_message_id,
324
+ reply_markup=reply_markup,
325
+ read_timeout=read_timeout,
326
+ write_timeout=write_timeout,
327
+ connect_timeout=connect_timeout,
328
+ pool_timeout=pool_timeout,
329
+ parse_mode=parse_mode,
330
+ api_kwargs=api_kwargs,
331
+ caption_entities=caption_entities,
332
+ chat_id=None,
333
+ message_id=None,
334
+ show_caption_above_media=show_caption_above_media,
335
+ # inline messages can not be sent on behalf of a bcid
336
+ business_connection_id=None,
337
+ )
338
+ return await self._get_message().edit_caption(
339
+ caption=caption,
340
+ reply_markup=reply_markup,
341
+ read_timeout=read_timeout,
342
+ write_timeout=write_timeout,
343
+ connect_timeout=connect_timeout,
344
+ pool_timeout=pool_timeout,
345
+ parse_mode=parse_mode,
346
+ api_kwargs=api_kwargs,
347
+ caption_entities=caption_entities,
348
+ show_caption_above_media=show_caption_above_media,
349
+ )
350
+
351
+ async def edit_message_reply_markup(
352
+ self,
353
+ reply_markup: Optional["InlineKeyboardMarkup"] = None,
354
+ *,
355
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
356
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
357
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
358
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
359
+ api_kwargs: Optional[JSONDict] = None,
360
+ ) -> Union[Message, bool]:
361
+ """Shortcut for either::
362
+
363
+ await update.callback_query.message.edit_reply_markup(*args, **kwargs)
364
+
365
+ or::
366
+
367
+ await bot.edit_message_reply_markup(
368
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
369
+ )
370
+
371
+ For the documentation of the arguments, please see
372
+ :meth:`telegram.Bot.edit_message_reply_markup` and
373
+ :meth:`telegram.Message.edit_reply_markup`.
374
+
375
+ .. versionchanged:: 20.8
376
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
377
+
378
+ Returns:
379
+ :class:`telegram.Message`: On success, if edited message is sent by the bot, the
380
+ edited Message is returned, otherwise :obj:`True` is returned.
381
+
382
+ Raises:
383
+ :exc:`TypeError` if :attr:`message` is not accessible.
384
+
385
+ """
386
+ if self.inline_message_id:
387
+ return await self.get_bot().edit_message_reply_markup(
388
+ reply_markup=reply_markup,
389
+ inline_message_id=self.inline_message_id,
390
+ read_timeout=read_timeout,
391
+ write_timeout=write_timeout,
392
+ connect_timeout=connect_timeout,
393
+ pool_timeout=pool_timeout,
394
+ api_kwargs=api_kwargs,
395
+ chat_id=None,
396
+ message_id=None,
397
+ # inline messages can not be sent on behalf of a bcid
398
+ business_connection_id=None,
399
+ )
400
+ return await self._get_message().edit_reply_markup(
401
+ reply_markup=reply_markup,
402
+ read_timeout=read_timeout,
403
+ write_timeout=write_timeout,
404
+ connect_timeout=connect_timeout,
405
+ pool_timeout=pool_timeout,
406
+ api_kwargs=api_kwargs,
407
+ )
408
+
409
+ async def edit_message_media(
410
+ self,
411
+ media: "InputMedia",
412
+ reply_markup: Optional["InlineKeyboardMarkup"] = None,
413
+ *,
414
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
415
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
416
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
417
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
418
+ api_kwargs: Optional[JSONDict] = None,
419
+ ) -> Union[Message, bool]:
420
+ """Shortcut for either::
421
+
422
+ await update.callback_query.message.edit_media(*args, **kwargs)
423
+
424
+ or::
425
+
426
+ await bot.edit_message_media(
427
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
428
+ )
429
+
430
+ For the documentation of the arguments, please see
431
+ :meth:`telegram.Bot.edit_message_media` and :meth:`telegram.Message.edit_media`.
432
+
433
+ .. versionchanged:: 20.8
434
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
435
+
436
+ Returns:
437
+ :class:`telegram.Message`: On success, if edited message is not an inline message, the
438
+ edited Message is returned, otherwise :obj:`True` is returned.
439
+
440
+ Raises:
441
+ :exc:`TypeError` if :attr:`message` is not accessible.
442
+
443
+ """
444
+ if self.inline_message_id:
445
+ return await self.get_bot().edit_message_media(
446
+ inline_message_id=self.inline_message_id,
447
+ media=media,
448
+ reply_markup=reply_markup,
449
+ read_timeout=read_timeout,
450
+ write_timeout=write_timeout,
451
+ connect_timeout=connect_timeout,
452
+ pool_timeout=pool_timeout,
453
+ api_kwargs=api_kwargs,
454
+ chat_id=None,
455
+ message_id=None,
456
+ # inline messages can not be sent on behalf of a bcid
457
+ business_connection_id=None,
458
+ )
459
+ return await self._get_message().edit_media(
460
+ media=media,
461
+ reply_markup=reply_markup,
462
+ read_timeout=read_timeout,
463
+ write_timeout=write_timeout,
464
+ connect_timeout=connect_timeout,
465
+ pool_timeout=pool_timeout,
466
+ api_kwargs=api_kwargs,
467
+ )
468
+
469
+ async def edit_message_live_location(
470
+ self,
471
+ latitude: Optional[float] = None,
472
+ longitude: Optional[float] = None,
473
+ reply_markup: Optional["InlineKeyboardMarkup"] = None,
474
+ horizontal_accuracy: Optional[float] = None,
475
+ heading: Optional[int] = None,
476
+ proximity_alert_radius: Optional[int] = None,
477
+ live_period: Optional[int] = None,
478
+ *,
479
+ location: Optional[Location] = None,
480
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
481
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
482
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
483
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
484
+ api_kwargs: Optional[JSONDict] = None,
485
+ ) -> Union[Message, bool]:
486
+ """Shortcut for either::
487
+
488
+ await update.callback_query.message.edit_live_location(*args, **kwargs)
489
+
490
+ or::
491
+
492
+ await bot.edit_message_live_location(
493
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
494
+ )
495
+
496
+ For the documentation of the arguments, please see
497
+ :meth:`telegram.Bot.edit_message_live_location` and
498
+ :meth:`telegram.Message.edit_live_location`.
499
+
500
+ .. versionchanged:: 20.8
501
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
502
+
503
+ Returns:
504
+ :class:`telegram.Message`: On success, if edited message is sent by the bot, the
505
+ edited Message is returned, otherwise :obj:`True` is returned.
506
+
507
+ Raises:
508
+ :exc:`TypeError` if :attr:`message` is not accessible.
509
+
510
+ """
511
+ if self.inline_message_id:
512
+ return await self.get_bot().edit_message_live_location(
513
+ inline_message_id=self.inline_message_id,
514
+ latitude=latitude,
515
+ longitude=longitude,
516
+ location=location,
517
+ reply_markup=reply_markup,
518
+ read_timeout=read_timeout,
519
+ write_timeout=write_timeout,
520
+ connect_timeout=connect_timeout,
521
+ pool_timeout=pool_timeout,
522
+ api_kwargs=api_kwargs,
523
+ horizontal_accuracy=horizontal_accuracy,
524
+ heading=heading,
525
+ proximity_alert_radius=proximity_alert_radius,
526
+ live_period=live_period,
527
+ chat_id=None,
528
+ message_id=None,
529
+ # inline messages can not be sent on behalf of a bcid
530
+ business_connection_id=None,
531
+ )
532
+ return await self._get_message().edit_live_location(
533
+ latitude=latitude,
534
+ longitude=longitude,
535
+ location=location,
536
+ reply_markup=reply_markup,
537
+ read_timeout=read_timeout,
538
+ write_timeout=write_timeout,
539
+ connect_timeout=connect_timeout,
540
+ pool_timeout=pool_timeout,
541
+ api_kwargs=api_kwargs,
542
+ horizontal_accuracy=horizontal_accuracy,
543
+ heading=heading,
544
+ proximity_alert_radius=proximity_alert_radius,
545
+ live_period=live_period,
546
+ )
547
+
548
+ async def stop_message_live_location(
549
+ self,
550
+ reply_markup: Optional["InlineKeyboardMarkup"] = None,
551
+ *,
552
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
553
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
554
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
555
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
556
+ api_kwargs: Optional[JSONDict] = None,
557
+ ) -> Union[Message, bool]:
558
+ """Shortcut for either::
559
+
560
+ await update.callback_query.message.stop_live_location(*args, **kwargs)
561
+
562
+ or::
563
+
564
+ await bot.stop_message_live_location(
565
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
566
+ )
567
+
568
+ For the documentation of the arguments, please see
569
+ :meth:`telegram.Bot.stop_message_live_location` and
570
+ :meth:`telegram.Message.stop_live_location`.
571
+
572
+ .. versionchanged:: 20.8
573
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
574
+
575
+ Returns:
576
+ :class:`telegram.Message`: On success, if edited message is sent by the bot, the
577
+ edited Message is returned, otherwise :obj:`True` is returned.
578
+
579
+ Raises:
580
+ :exc:`TypeError` if :attr:`message` is not accessible.
581
+
582
+ """
583
+ if self.inline_message_id:
584
+ return await self.get_bot().stop_message_live_location(
585
+ inline_message_id=self.inline_message_id,
586
+ reply_markup=reply_markup,
587
+ read_timeout=read_timeout,
588
+ write_timeout=write_timeout,
589
+ connect_timeout=connect_timeout,
590
+ pool_timeout=pool_timeout,
591
+ api_kwargs=api_kwargs,
592
+ chat_id=None,
593
+ message_id=None,
594
+ # inline messages can not be sent on behalf of a bcid
595
+ business_connection_id=None,
596
+ )
597
+ return await self._get_message().stop_live_location(
598
+ reply_markup=reply_markup,
599
+ read_timeout=read_timeout,
600
+ write_timeout=write_timeout,
601
+ connect_timeout=connect_timeout,
602
+ pool_timeout=pool_timeout,
603
+ api_kwargs=api_kwargs,
604
+ )
605
+
606
+ async def set_game_score(
607
+ self,
608
+ user_id: int,
609
+ score: int,
610
+ force: Optional[bool] = None,
611
+ disable_edit_message: Optional[bool] = None,
612
+ *,
613
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
614
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
615
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
616
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
617
+ api_kwargs: Optional[JSONDict] = None,
618
+ ) -> Union[Message, bool]:
619
+ """Shortcut for either::
620
+
621
+ await update.callback_query.message.set_game_score(*args, **kwargs)
622
+
623
+ or::
624
+
625
+ await bot.set_game_score(
626
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
627
+ )
628
+
629
+ For the documentation of the arguments, please see
630
+ :meth:`telegram.Bot.set_game_score` and :meth:`telegram.Message.set_game_score`.
631
+
632
+ .. versionchanged:: 20.8
633
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
634
+
635
+ Returns:
636
+ :class:`telegram.Message`: On success, if edited message is sent by the bot, the
637
+ edited Message is returned, otherwise :obj:`True` is returned.
638
+
639
+ Raises:
640
+ :exc:`TypeError` if :attr:`message` is not accessible.
641
+
642
+ """
643
+ if self.inline_message_id:
644
+ return await self.get_bot().set_game_score(
645
+ inline_message_id=self.inline_message_id,
646
+ user_id=user_id,
647
+ score=score,
648
+ force=force,
649
+ disable_edit_message=disable_edit_message,
650
+ read_timeout=read_timeout,
651
+ write_timeout=write_timeout,
652
+ connect_timeout=connect_timeout,
653
+ pool_timeout=pool_timeout,
654
+ api_kwargs=api_kwargs,
655
+ chat_id=None,
656
+ message_id=None,
657
+ )
658
+ return await self._get_message().set_game_score(
659
+ user_id=user_id,
660
+ score=score,
661
+ force=force,
662
+ disable_edit_message=disable_edit_message,
663
+ read_timeout=read_timeout,
664
+ write_timeout=write_timeout,
665
+ connect_timeout=connect_timeout,
666
+ pool_timeout=pool_timeout,
667
+ api_kwargs=api_kwargs,
668
+ )
669
+
670
+ async def get_game_high_scores(
671
+ self,
672
+ user_id: int,
673
+ *,
674
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
675
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
676
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
677
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
678
+ api_kwargs: Optional[JSONDict] = None,
679
+ ) -> Tuple["GameHighScore", ...]:
680
+ """Shortcut for either::
681
+
682
+ await update.callback_query.message.get_game_high_score(*args, **kwargs)
683
+
684
+ or::
685
+
686
+ await bot.get_game_high_scores(
687
+ inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
688
+ )
689
+
690
+ For the documentation of the arguments, please see
691
+ :meth:`telegram.Bot.get_game_high_scores` and
692
+ :meth:`telegram.Message.get_game_high_scores`.
693
+
694
+ .. versionchanged:: 20.8
695
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
696
+
697
+ Returns:
698
+ Tuple[:class:`telegram.GameHighScore`]
699
+
700
+ Raises:
701
+ :exc:`TypeError` if :attr:`message` is not accessible.
702
+
703
+ """
704
+ if self.inline_message_id:
705
+ return await self.get_bot().get_game_high_scores(
706
+ inline_message_id=self.inline_message_id,
707
+ user_id=user_id,
708
+ read_timeout=read_timeout,
709
+ write_timeout=write_timeout,
710
+ connect_timeout=connect_timeout,
711
+ pool_timeout=pool_timeout,
712
+ api_kwargs=api_kwargs,
713
+ chat_id=None,
714
+ message_id=None,
715
+ )
716
+ return await self._get_message().get_game_high_scores(
717
+ user_id=user_id,
718
+ read_timeout=read_timeout,
719
+ write_timeout=write_timeout,
720
+ connect_timeout=connect_timeout,
721
+ pool_timeout=pool_timeout,
722
+ api_kwargs=api_kwargs,
723
+ )
724
+
725
+ async def delete_message(
726
+ self,
727
+ *,
728
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
729
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
730
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
731
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
732
+ api_kwargs: Optional[JSONDict] = None,
733
+ ) -> bool:
734
+ """Shortcut for::
735
+
736
+ await update.callback_query.message.delete(*args, **kwargs)
737
+
738
+ For the documentation of the arguments, please see :meth:`telegram.Message.delete`.
739
+
740
+ .. versionchanged:: 20.8
741
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
742
+
743
+ Returns:
744
+ :obj:`bool`: On success, :obj:`True` is returned.
745
+
746
+ Raises:
747
+ :exc:`TypeError` if :attr:`message` is not accessible.
748
+
749
+ """
750
+ return await self._get_message(action="delete").delete(
751
+ read_timeout=read_timeout,
752
+ write_timeout=write_timeout,
753
+ connect_timeout=connect_timeout,
754
+ pool_timeout=pool_timeout,
755
+ api_kwargs=api_kwargs,
756
+ )
757
+
758
+ async def pin_message(
759
+ self,
760
+ disable_notification: ODVInput[bool] = DEFAULT_NONE,
761
+ *,
762
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
763
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
764
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
765
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
766
+ api_kwargs: Optional[JSONDict] = None,
767
+ ) -> bool:
768
+ """Shortcut for::
769
+
770
+ await update.callback_query.message.pin(*args, **kwargs)
771
+
772
+ For the documentation of the arguments, please see :meth:`telegram.Message.pin`.
773
+
774
+ .. versionchanged:: 20.8
775
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
776
+
777
+ Returns:
778
+ :obj:`bool`: On success, :obj:`True` is returned.
779
+
780
+ Raises:
781
+ :exc:`TypeError` if :attr:`message` is not accessible.
782
+ """
783
+ return await self._get_message(action="pin").pin(
784
+ disable_notification=disable_notification,
785
+ read_timeout=read_timeout,
786
+ write_timeout=write_timeout,
787
+ connect_timeout=connect_timeout,
788
+ pool_timeout=pool_timeout,
789
+ api_kwargs=api_kwargs,
790
+ )
791
+
792
+ async def unpin_message(
793
+ self,
794
+ *,
795
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
796
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
797
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
798
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
799
+ api_kwargs: Optional[JSONDict] = None,
800
+ ) -> bool:
801
+ """Shortcut for::
802
+
803
+ await update.callback_query.message.unpin(*args, **kwargs)
804
+
805
+ For the documentation of the arguments, please see :meth:`telegram.Message.unpin`.
806
+
807
+ .. versionchanged:: 20.8
808
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
809
+
810
+ Returns:
811
+ :obj:`bool`: On success, :obj:`True` is returned.
812
+
813
+ Raises:
814
+ :exc:`TypeError` if :attr:`message` is not accessible.
815
+ """
816
+ return await self._get_message(action="unpin").unpin(
817
+ read_timeout=read_timeout,
818
+ write_timeout=write_timeout,
819
+ connect_timeout=connect_timeout,
820
+ pool_timeout=pool_timeout,
821
+ api_kwargs=api_kwargs,
822
+ )
823
+
824
+ async def copy_message(
825
+ self,
826
+ chat_id: Union[int, str],
827
+ caption: Optional[str] = None,
828
+ parse_mode: ODVInput[str] = DEFAULT_NONE,
829
+ caption_entities: Optional[Sequence["MessageEntity"]] = None,
830
+ disable_notification: ODVInput[bool] = DEFAULT_NONE,
831
+ reply_markup: Optional[ReplyMarkup] = None,
832
+ protect_content: ODVInput[bool] = DEFAULT_NONE,
833
+ message_thread_id: Optional[int] = None,
834
+ reply_parameters: Optional["ReplyParameters"] = None,
835
+ show_caption_above_media: Optional[bool] = None,
836
+ *,
837
+ allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
838
+ reply_to_message_id: Optional[int] = None,
839
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
840
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
841
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
842
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
843
+ api_kwargs: Optional[JSONDict] = None,
844
+ ) -> "MessageId":
845
+ """Shortcut for::
846
+
847
+ await update.callback_query.message.copy(
848
+ from_chat_id=update.message.chat_id,
849
+ message_id=update.message.message_id,
850
+ *args,
851
+ **kwargs
852
+ )
853
+
854
+ For the documentation of the arguments, please see :meth:`telegram.Message.copy`.
855
+
856
+ .. versionchanged:: 20.8
857
+ Raises :exc:`TypeError` if :attr:`message` is not accessible.
858
+
859
+ Returns:
860
+ :class:`telegram.MessageId`: On success, returns the MessageId of the sent message.
861
+
862
+ Raises:
863
+ :exc:`TypeError` if :attr:`message` is not accessible.
864
+ """
865
+ return await self._get_message(action="copy").copy(
866
+ chat_id=chat_id,
867
+ caption=caption,
868
+ parse_mode=parse_mode,
869
+ caption_entities=caption_entities,
870
+ disable_notification=disable_notification,
871
+ reply_to_message_id=reply_to_message_id,
872
+ allow_sending_without_reply=allow_sending_without_reply,
873
+ reply_markup=reply_markup,
874
+ read_timeout=read_timeout,
875
+ write_timeout=write_timeout,
876
+ connect_timeout=connect_timeout,
877
+ pool_timeout=pool_timeout,
878
+ api_kwargs=api_kwargs,
879
+ protect_content=protect_content,
880
+ message_thread_id=message_thread_id,
881
+ reply_parameters=reply_parameters,
882
+ show_caption_above_media=show_caption_above_media,
883
+ )
884
+
885
+ MAX_ANSWER_TEXT_LENGTH: Final[int] = (
886
+ constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH
887
+ )
888
+ """
889
+ :const:`telegram.constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH`
890
+
891
+ .. versionadded:: 13.2
892
+ """
_chat.py ADDED
The diff for this file is too large to render. See raw diff
 
_chatadministratorrights.py ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains the class which represents a Telegram ChatAdministratorRights."""
20
+ from typing import Optional
21
+
22
+ from telegram._telegramobject import TelegramObject
23
+ from telegram._utils.types import JSONDict
24
+
25
+
26
+ class ChatAdministratorRights(TelegramObject):
27
+ """Represents the rights of an administrator in a chat.
28
+
29
+ Objects of this class are comparable in terms of equality. Two objects of this class are
30
+ considered equal, if their :attr:`is_anonymous`, :attr:`can_manage_chat`,
31
+ :attr:`can_delete_messages`, :attr:`can_manage_video_chats`, :attr:`can_restrict_members`,
32
+ :attr:`can_promote_members`, :attr:`can_change_info`, :attr:`can_invite_users`,
33
+ :attr:`can_post_messages`, :attr:`can_edit_messages`, :attr:`can_pin_messages`,
34
+ :attr:`can_manage_topics`, :attr:`can_post_stories`, :attr:`can_delete_stories`, and
35
+ :attr:`can_edit_stories` are equal.
36
+
37
+ .. versionadded:: 20.0
38
+
39
+ .. versionchanged:: 20.0
40
+ :attr:`can_manage_topics` is considered as well when comparing objects of
41
+ this type in terms of equality.
42
+
43
+ .. versionchanged:: 20.6
44
+ :attr:`can_post_stories`, :attr:`can_edit_stories`, and :attr:`can_delete_stories` are
45
+ considered as well when comparing objects of this type in terms of equality.
46
+
47
+ .. versionchanged:: 21.1
48
+ As of this version, :attr:`can_post_stories`, :attr:`can_edit_stories`,
49
+ and :attr:`can_delete_stories` is now required. Thus, the order of arguments had to be
50
+ changed.
51
+
52
+ Args:
53
+ is_anonymous (:obj:`bool`): :obj:`True`, if the user's presence in the chat is hidden.
54
+ can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
55
+ log, get boost list, see hidden supergroup and channel members, report spam messages
56
+ and ignore slow mode. Implied by any other administrator privilege.
57
+ can_delete_messages (:obj:`bool`): :obj:`True`, if the administrator can delete messages of
58
+ other users.
59
+ can_manage_video_chats (:obj:`bool`): :obj:`True`, if the administrator can manage video
60
+ chats.
61
+ can_restrict_members (:obj:`bool`): :obj:`True`, if the administrator can restrict, ban or
62
+ unban chat members, or access supergroup statistics.
63
+ can_promote_members (:obj:`bool`): :obj:`True`, if the administrator can add new
64
+ administrators with a subset of their own privileges or demote administrators
65
+ that they have promoted, directly or indirectly (promoted by administrators that
66
+ were appointed by the user).
67
+ can_change_info (:obj:`bool`): :obj:`True`, if the user is allowed to change the chat title
68
+ , photo and other settings.
69
+ can_invite_users (:obj:`bool`): :obj:`True`, if the user is allowed to invite new users to
70
+ the chat.
71
+ can_post_messages (:obj:`bool`, optional): :obj:`True`, if the administrator can post
72
+ messages in the channel, or access channel statistics; for channels only.
73
+ can_edit_messages (:obj:`bool`, optional): :obj:`True`, if the administrator can edit
74
+ messages of other users and can pin messages; for channels only.
75
+ can_pin_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to pin
76
+ messages; for groups and supergroups only.
77
+ can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
78
+ stories to the chat.
79
+
80
+ .. versionadded:: 20.6
81
+ .. versionchanged:: 21.0
82
+ |non_optional_story_argument|
83
+ can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit stories posted
84
+ by other users, post stories to the chat page, pin chat stories, and access the chat's
85
+ story archive
86
+
87
+ .. versionadded:: 20.6
88
+ .. versionchanged:: 21.0
89
+ |non_optional_story_argument|
90
+ can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
91
+ stories posted by other users.
92
+
93
+ .. versionadded:: 20.6
94
+ .. versionchanged:: 21.0
95
+ |non_optional_story_argument|
96
+ can_manage_topics (:obj:`bool`, optional): :obj:`True`, if the user is allowed
97
+ to create, rename, close, and reopen forum topics; for supergroups only.
98
+
99
+ .. versionadded:: 20.0
100
+
101
+ Attributes:
102
+ is_anonymous (:obj:`bool`): :obj:`True`, if the user's presence in the chat is hidden.
103
+ can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
104
+ log, get boost list, see hidden supergroup and channel members, report spam messages
105
+ and ignore slow mode. Implied by any other administrator privilege.
106
+ can_delete_messages (:obj:`bool`): :obj:`True`, if the administrator can delete messages of
107
+ other users.
108
+ can_manage_video_chats (:obj:`bool`): :obj:`True`, if the administrator can manage video
109
+ chats.
110
+ can_restrict_members (:obj:`bool`): :obj:`True`, if the administrator can restrict, ban or
111
+ unban chat members, or access supergroup statistics.
112
+ can_promote_members (:obj:`bool`): :obj:`True`, if the administrator can add new
113
+ administrators with a subset of their own privileges or demote administrators that he
114
+ has promoted, directly or indirectly (promoted by administrators that were appointed by
115
+ the user.)
116
+ can_change_info (:obj:`bool`): :obj:`True`, if the user is allowed to change the chat title
117
+ ,photo and other settings.
118
+ can_invite_users (:obj:`bool`): :obj:`True`, if the user is allowed to invite new users to
119
+ the chat.
120
+ can_post_messages (:obj:`bool`): Optional. :obj:`True`, if the administrator can post
121
+ messages in the channel, or access channel statistics; for channels only.
122
+ can_edit_messages (:obj:`bool`): Optional. :obj:`True`, if the administrator can edit
123
+ messages of other users and can pin messages; for channels only.
124
+ can_pin_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to pin
125
+ messages; for groups and supergroups only.
126
+ can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
127
+ stories to the chat.
128
+
129
+ .. versionadded:: 20.6
130
+ .. versionchanged:: 21.0
131
+ |non_optional_story_argument|
132
+ can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit stories posted
133
+ by other users, post stories to the chat page, pin chat stories, and access the chat's
134
+ story archive
135
+
136
+ .. versionadded:: 20.6
137
+ .. versionchanged:: 21.0
138
+ |non_optional_story_argument|
139
+ can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
140
+ stories posted by other users.
141
+
142
+ .. versionadded:: 20.6
143
+ .. versionchanged:: 21.0
144
+ |non_optional_story_argument|
145
+ can_manage_topics (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
146
+ to create, rename, close, and reopen forum topics; for supergroups only.
147
+
148
+ .. versionadded:: 20.0
149
+ """
150
+
151
+ __slots__ = (
152
+ "can_change_info",
153
+ "can_delete_messages",
154
+ "can_delete_stories",
155
+ "can_edit_messages",
156
+ "can_edit_stories",
157
+ "can_invite_users",
158
+ "can_manage_chat",
159
+ "can_manage_topics",
160
+ "can_manage_video_chats",
161
+ "can_pin_messages",
162
+ "can_post_messages",
163
+ "can_post_stories",
164
+ "can_promote_members",
165
+ "can_restrict_members",
166
+ "is_anonymous",
167
+ )
168
+
169
+ def __init__(
170
+ self,
171
+ is_anonymous: bool,
172
+ can_manage_chat: bool,
173
+ can_delete_messages: bool,
174
+ can_manage_video_chats: bool,
175
+ can_restrict_members: bool,
176
+ can_promote_members: bool,
177
+ can_change_info: bool,
178
+ can_invite_users: bool,
179
+ can_post_stories: bool,
180
+ can_edit_stories: bool,
181
+ can_delete_stories: bool,
182
+ can_post_messages: Optional[bool] = None,
183
+ can_edit_messages: Optional[bool] = None,
184
+ can_pin_messages: Optional[bool] = None,
185
+ can_manage_topics: Optional[bool] = None,
186
+ *,
187
+ api_kwargs: Optional[JSONDict] = None,
188
+ ) -> None:
189
+ super().__init__(api_kwargs=api_kwargs)
190
+ # Required
191
+ self.is_anonymous: bool = is_anonymous
192
+ self.can_manage_chat: bool = can_manage_chat
193
+ self.can_delete_messages: bool = can_delete_messages
194
+ self.can_manage_video_chats: bool = can_manage_video_chats
195
+ self.can_restrict_members: bool = can_restrict_members
196
+ self.can_promote_members: bool = can_promote_members
197
+ self.can_change_info: bool = can_change_info
198
+ self.can_invite_users: bool = can_invite_users
199
+ self.can_post_stories: bool = can_post_stories
200
+ self.can_edit_stories: bool = can_edit_stories
201
+ self.can_delete_stories: bool = can_delete_stories
202
+ # Optionals
203
+ self.can_post_messages: Optional[bool] = can_post_messages
204
+ self.can_edit_messages: Optional[bool] = can_edit_messages
205
+ self.can_pin_messages: Optional[bool] = can_pin_messages
206
+ self.can_manage_topics: Optional[bool] = can_manage_topics
207
+
208
+ self._id_attrs = (
209
+ self.is_anonymous,
210
+ self.can_manage_chat,
211
+ self.can_delete_messages,
212
+ self.can_manage_video_chats,
213
+ self.can_restrict_members,
214
+ self.can_promote_members,
215
+ self.can_change_info,
216
+ self.can_invite_users,
217
+ self.can_post_messages,
218
+ self.can_edit_messages,
219
+ self.can_pin_messages,
220
+ self.can_manage_topics,
221
+ self.can_post_stories,
222
+ self.can_edit_stories,
223
+ self.can_delete_stories,
224
+ )
225
+
226
+ self._freeze()
227
+
228
+ @classmethod
229
+ def all_rights(cls) -> "ChatAdministratorRights":
230
+ """
231
+ This method returns the :class:`ChatAdministratorRights` object with all attributes set to
232
+ :obj:`True`. This is e.g. useful when changing the bot's default administrator rights with
233
+ :meth:`telegram.Bot.set_my_default_administrator_rights`.
234
+
235
+ .. versionadded:: 20.0
236
+ """
237
+ return cls(*(True,) * len(cls.__slots__))
238
+
239
+ @classmethod
240
+ def no_rights(cls) -> "ChatAdministratorRights":
241
+ """
242
+ This method returns the :class:`ChatAdministratorRights` object with all attributes set to
243
+ :obj:`False`.
244
+
245
+ .. versionadded:: 20.0
246
+ """
247
+ return cls(*(False,) * len(cls.__slots__))
_chatbackground.py ADDED
@@ -0,0 +1,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains objects related to chat backgrounds."""
20
+ from typing import TYPE_CHECKING, Dict, Final, Optional, Sequence, Tuple, Type
21
+
22
+ from telegram import constants
23
+ from telegram._files.document import Document
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._utils import enum
26
+ from telegram._utils.argumentparsing import parse_sequence_arg
27
+ from telegram._utils.types import JSONDict
28
+
29
+ if TYPE_CHECKING:
30
+ from telegram import Bot
31
+
32
+
33
+ class BackgroundFill(TelegramObject):
34
+ """Base class for Telegram BackgroundFill Objects. It can be one of:
35
+
36
+ * :class:`telegram.BackgroundFillSolid`
37
+ * :class:`telegram.BackgroundFillGradient`
38
+ * :class:`telegram.BackgroundFillFreeformGradient`
39
+
40
+ Objects of this class are comparable in terms of equality. Two objects of this class are
41
+ considered equal, if their :attr:`type` is equal.
42
+
43
+ .. versionadded:: 21.2
44
+
45
+ Args:
46
+ type (:obj:`str`): Type of the background fill. Can be one of:
47
+ :attr:`~telegram.BackgroundFill.SOLID`, :attr:`~telegram.BackgroundFill.GRADIENT`
48
+ or :attr:`~telegram.BackgroundFill.FREEFORM_GRADIENT`.
49
+
50
+ Attributes:
51
+ type (:obj:`str`): Type of the background fill. Can be one of:
52
+ :attr:`~telegram.BackgroundFill.SOLID`, :attr:`~telegram.BackgroundFill.GRADIENT`
53
+ or :attr:`~telegram.BackgroundFill.FREEFORM_GRADIENT`.
54
+ """
55
+
56
+ __slots__ = ("type",)
57
+
58
+ SOLID: Final[constants.BackgroundFillType] = constants.BackgroundFillType.SOLID
59
+ """:const:`telegram.constants.BackgroundFillType.SOLID`"""
60
+ GRADIENT: Final[constants.BackgroundFillType] = constants.BackgroundFillType.GRADIENT
61
+ """:const:`telegram.constants.BackgroundFillType.GRADIENT`"""
62
+ FREEFORM_GRADIENT: Final[constants.BackgroundFillType] = (
63
+ constants.BackgroundFillType.FREEFORM_GRADIENT
64
+ )
65
+ """:const:`telegram.constants.BackgroundFillType.FREEFORM_GRADIENT`"""
66
+
67
+ def __init__(
68
+ self,
69
+ type: str, # pylint: disable=redefined-builtin
70
+ *,
71
+ api_kwargs: Optional[JSONDict] = None,
72
+ ):
73
+ super().__init__(api_kwargs=api_kwargs)
74
+ # Required by all subclasses
75
+ self.type: str = enum.get_member(constants.BackgroundFillType, type, type)
76
+
77
+ self._id_attrs = (self.type,)
78
+ self._freeze()
79
+
80
+ @classmethod
81
+ def de_json(
82
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
83
+ ) -> Optional["BackgroundFill"]:
84
+ """See :meth:`telegram.TelegramObject.de_json`."""
85
+ data = cls._parse_data(data)
86
+
87
+ if not data:
88
+ return None
89
+
90
+ _class_mapping: Dict[str, Type[BackgroundFill]] = {
91
+ cls.SOLID: BackgroundFillSolid,
92
+ cls.GRADIENT: BackgroundFillGradient,
93
+ cls.FREEFORM_GRADIENT: BackgroundFillFreeformGradient,
94
+ }
95
+
96
+ if cls is BackgroundFill and data.get("type") in _class_mapping:
97
+ return _class_mapping[data.pop("type")].de_json(data=data, bot=bot)
98
+
99
+ return super().de_json(data=data, bot=bot)
100
+
101
+
102
+ class BackgroundFillSolid(BackgroundFill):
103
+ """
104
+ The background is filled using the selected color.
105
+
106
+ Objects of this class are comparable in terms of equality. Two objects of this class are
107
+ considered equal, if their :attr:`color` is equal.
108
+
109
+ .. versionadded:: 21.2
110
+
111
+ Args:
112
+ color (:obj:`int`): The color of the background fill in the `RGB24` format.
113
+
114
+ Attributes:
115
+ type (:obj:`str`): Type of the background fill. Always
116
+ :attr:`~telegram.BackgroundFill.SOLID`.
117
+ color (:obj:`int`): The color of the background fill in the `RGB24` format.
118
+ """
119
+
120
+ __slots__ = ("color",)
121
+
122
+ def __init__(
123
+ self,
124
+ color: int,
125
+ *,
126
+ api_kwargs: Optional[JSONDict] = None,
127
+ ):
128
+ super().__init__(type=self.SOLID, api_kwargs=api_kwargs)
129
+
130
+ with self._unfrozen():
131
+ self.color: int = color
132
+
133
+ self._id_attrs = (self.color,)
134
+
135
+
136
+ class BackgroundFillGradient(BackgroundFill):
137
+ """
138
+ The background is a gradient fill.
139
+
140
+ Objects of this class are comparable in terms of equality. Two objects of this class are
141
+ considered equal, if their :attr:`top_color`, :attr:`bottom_color`
142
+ and :attr:`rotation_angle` are equal.
143
+
144
+ .. versionadded:: 21.2
145
+
146
+ Args:
147
+ top_color (:obj:`int`): Top color of the gradient in the `RGB24` format.
148
+ bottom_color (:obj:`int`): Bottom color of the gradient in the `RGB24` format.
149
+ rotation_angle (:obj:`int`): Clockwise rotation angle of the background
150
+ fill in degrees;
151
+ 0-:tg-const:`telegram.constants.BackgroundFillLimit.MAX_ROTATION_ANGLE`.
152
+
153
+
154
+ Attributes:
155
+ type (:obj:`str`): Type of the background fill. Always
156
+ :attr:`~telegram.BackgroundFill.GRADIENT`.
157
+ top_color (:obj:`int`): Top color of the gradient in the `RGB24` format.
158
+ bottom_color (:obj:`int`): Bottom color of the gradient in the `RGB24` format.
159
+ rotation_angle (:obj:`int`): Clockwise rotation angle of the background
160
+ fill in degrees;
161
+ 0-:tg-const:`telegram.constants.BackgroundFillLimit.MAX_ROTATION_ANGLE`.
162
+ """
163
+
164
+ __slots__ = ("bottom_color", "rotation_angle", "top_color")
165
+
166
+ def __init__(
167
+ self,
168
+ top_color: int,
169
+ bottom_color: int,
170
+ rotation_angle: int,
171
+ *,
172
+ api_kwargs: Optional[JSONDict] = None,
173
+ ):
174
+ super().__init__(type=self.GRADIENT, api_kwargs=api_kwargs)
175
+
176
+ with self._unfrozen():
177
+ self.top_color: int = top_color
178
+ self.bottom_color: int = bottom_color
179
+ self.rotation_angle: int = rotation_angle
180
+
181
+ self._id_attrs = (self.top_color, self.bottom_color, self.rotation_angle)
182
+
183
+
184
+ class BackgroundFillFreeformGradient(BackgroundFill):
185
+ """
186
+ The background is a freeform gradient that rotates after every message in the chat.
187
+
188
+ Objects of this class are comparable in terms of equality. Two objects of this class are
189
+ considered equal, if their :attr:`colors` is equal.
190
+
191
+ .. versionadded:: 21.2
192
+
193
+ Args:
194
+ colors (Sequence[:obj:`int`]): A list of the 3 or 4 base colors that are used to
195
+ generate the freeform gradient in the `RGB24` format
196
+
197
+ Attributes:
198
+ type (:obj:`str`): Type of the background fill. Always
199
+ :attr:`~telegram.BackgroundFill.FREEFORM_GRADIENT`.
200
+ colors (Sequence[:obj:`int`]): A list of the 3 or 4 base colors that are used to
201
+ generate the freeform gradient in the `RGB24` format
202
+ """
203
+
204
+ __slots__ = ("colors",)
205
+
206
+ def __init__(
207
+ self,
208
+ colors: Sequence[int],
209
+ *,
210
+ api_kwargs: Optional[JSONDict] = None,
211
+ ):
212
+ super().__init__(type=self.FREEFORM_GRADIENT, api_kwargs=api_kwargs)
213
+
214
+ with self._unfrozen():
215
+ self.colors: Tuple[int, ...] = parse_sequence_arg(colors)
216
+
217
+ self._id_attrs = (self.colors,)
218
+
219
+
220
+ class BackgroundType(TelegramObject):
221
+ """Base class for Telegram BackgroundType Objects. It can be one of:
222
+
223
+ * :class:`telegram.BackgroundTypeFill`
224
+ * :class:`telegram.BackgroundTypeWallpaper`
225
+ * :class:`telegram.BackgroundTypePattern`
226
+ * :class:`telegram.BackgroundTypeChatTheme`.
227
+
228
+ Objects of this class are comparable in terms of equality. Two objects of this class are
229
+ considered equal, if their :attr:`type` is equal.
230
+
231
+ .. versionadded:: 21.2
232
+
233
+ Args:
234
+ type (:obj:`str`): Type of the background. Can be one of:
235
+ :attr:`~telegram.BackgroundType.FILL`, :attr:`~telegram.BackgroundType.WALLPAPER`
236
+ :attr:`~telegram.BackgroundType.PATTERN` or
237
+ :attr:`~telegram.BackgroundType.CHAT_THEME`.
238
+
239
+ Attributes:
240
+ type (:obj:`str`): Type of the background. Can be one of:
241
+ :attr:`~telegram.BackgroundType.FILL`, :attr:`~telegram.BackgroundType.WALLPAPER`
242
+ :attr:`~telegram.BackgroundType.PATTERN` or
243
+ :attr:`~telegram.BackgroundType.CHAT_THEME`.
244
+
245
+ """
246
+
247
+ __slots__ = ("type",)
248
+
249
+ FILL: Final[constants.BackgroundTypeType] = constants.BackgroundTypeType.FILL
250
+ """:const:`telegram.constants.BackgroundTypeType.FILL`"""
251
+ WALLPAPER: Final[constants.BackgroundTypeType] = constants.BackgroundTypeType.WALLPAPER
252
+ """:const:`telegram.constants.BackgroundTypeType.WALLPAPER`"""
253
+ PATTERN: Final[constants.BackgroundTypeType] = constants.BackgroundTypeType.PATTERN
254
+ """:const:`telegram.constants.BackgroundTypeType.PATTERN`"""
255
+ CHAT_THEME: Final[constants.BackgroundTypeType] = constants.BackgroundTypeType.CHAT_THEME
256
+ """:const:`telegram.constants.BackgroundTypeType.CHAT_THEME`"""
257
+
258
+ def __init__(
259
+ self,
260
+ type: str, # pylint: disable=redefined-builtin
261
+ *,
262
+ api_kwargs: Optional[JSONDict] = None,
263
+ ):
264
+ super().__init__(api_kwargs=api_kwargs)
265
+ # Required by all subclasses
266
+ self.type: str = enum.get_member(constants.BackgroundTypeType, type, type)
267
+
268
+ self._id_attrs = (self.type,)
269
+ self._freeze()
270
+
271
+ @classmethod
272
+ def de_json(
273
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
274
+ ) -> Optional["BackgroundType"]:
275
+ """See :meth:`telegram.TelegramObject.de_json`."""
276
+ data = cls._parse_data(data)
277
+
278
+ if not data:
279
+ return None
280
+
281
+ _class_mapping: Dict[str, Type[BackgroundType]] = {
282
+ cls.FILL: BackgroundTypeFill,
283
+ cls.WALLPAPER: BackgroundTypeWallpaper,
284
+ cls.PATTERN: BackgroundTypePattern,
285
+ cls.CHAT_THEME: BackgroundTypeChatTheme,
286
+ }
287
+
288
+ if cls is BackgroundType and data.get("type") in _class_mapping:
289
+ return _class_mapping[data.pop("type")].de_json(data=data, bot=bot)
290
+
291
+ if "fill" in data:
292
+ data["fill"] = BackgroundFill.de_json(data.get("fill"), bot)
293
+
294
+ if "document" in data:
295
+ data["document"] = Document.de_json(data.get("document"), bot)
296
+
297
+ return super().de_json(data=data, bot=bot)
298
+
299
+
300
+ class BackgroundTypeFill(BackgroundType):
301
+ """
302
+ The background is automatically filled based on the selected colors.
303
+
304
+ Objects of this class are comparable in terms of equality. Two objects of this class are
305
+ considered equal, if their :attr:`fill` and :attr:`dark_theme_dimming` are equal.
306
+
307
+ .. versionadded:: 21.2
308
+
309
+ Args:
310
+ fill (:class:`telegram.BackgroundFill`): The background fill.
311
+ dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
312
+ percentage;
313
+ 0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
314
+
315
+ Attributes:
316
+ type (:obj:`str`): Type of the background. Always
317
+ :attr:`~telegram.BackgroundType.FILL`.
318
+ fill (:class:`telegram.BackgroundFill`): The background fill.
319
+ dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
320
+ percentage;
321
+ 0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
322
+ """
323
+
324
+ __slots__ = ("dark_theme_dimming", "fill")
325
+
326
+ def __init__(
327
+ self,
328
+ fill: BackgroundFill,
329
+ dark_theme_dimming: int,
330
+ *,
331
+ api_kwargs: Optional[JSONDict] = None,
332
+ ):
333
+ super().__init__(type=self.FILL, api_kwargs=api_kwargs)
334
+
335
+ with self._unfrozen():
336
+ self.fill: BackgroundFill = fill
337
+ self.dark_theme_dimming: int = dark_theme_dimming
338
+
339
+ self._id_attrs = (self.fill, self.dark_theme_dimming)
340
+
341
+
342
+ class BackgroundTypeWallpaper(BackgroundType):
343
+ """
344
+ The background is a wallpaper in the `JPEG` format.
345
+
346
+ Objects of this class are comparable in terms of equality. Two objects of this class are
347
+ considered equal, if their :attr:`document` and :attr:`dark_theme_dimming` are equal.
348
+
349
+ .. versionadded:: 21.2
350
+
351
+ Args:
352
+ document (:class:`telegram.Document`): Document with the wallpaper
353
+ dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
354
+ percentage;
355
+ 0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
356
+ is_blurred (:obj:`bool`, optional): :obj:`True`, if the wallpaper is downscaled to fit
357
+ in a 450x450 square and then box-blurred with radius 12
358
+ is_moving (:obj:`bool`, optional): :obj:`True`, if the background moves slightly
359
+ when the device is tilted
360
+
361
+ Attributes:
362
+ type (:obj:`str`): Type of the background. Always
363
+ :attr:`~telegram.BackgroundType.WALLPAPER`.
364
+ document (:class:`telegram.Document`): Document with the wallpaper
365
+ dark_theme_dimming (:obj:`int`): Dimming of the background in dark themes, as a
366
+ percentage;
367
+ 0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_DIMMING`.
368
+ is_blurred (:obj:`bool`): Optional. :obj:`True`, if the wallpaper is downscaled to fit
369
+ in a 450x450 square and then box-blurred with radius 12
370
+ is_moving (:obj:`bool`): Optional. :obj:`True`, if the background moves slightly
371
+ when the device is tilted
372
+ """
373
+
374
+ __slots__ = ("dark_theme_dimming", "document", "is_blurred", "is_moving")
375
+
376
+ def __init__(
377
+ self,
378
+ document: Document,
379
+ dark_theme_dimming: int,
380
+ is_blurred: Optional[bool] = None,
381
+ is_moving: Optional[bool] = None,
382
+ *,
383
+ api_kwargs: Optional[JSONDict] = None,
384
+ ):
385
+ super().__init__(type=self.WALLPAPER, api_kwargs=api_kwargs)
386
+
387
+ with self._unfrozen():
388
+ # Required
389
+ self.document: Document = document
390
+ self.dark_theme_dimming: int = dark_theme_dimming
391
+ # Optionals
392
+ self.is_blurred: Optional[bool] = is_blurred
393
+ self.is_moving: Optional[bool] = is_moving
394
+
395
+ self._id_attrs = (self.document, self.dark_theme_dimming)
396
+
397
+
398
+ class BackgroundTypePattern(BackgroundType):
399
+ """
400
+ The background is a `PNG` or `TGV` (gzipped subset of `SVG` with `MIME` type
401
+ `"application/x-tgwallpattern"`) pattern to be combined with the background fill
402
+ chosen by the user.
403
+
404
+ Objects of this class are comparable in terms of equality. Two objects of this class are
405
+ considered equal, if their :attr:`document` and :attr:`fill` and :attr:`intensity` are equal.
406
+
407
+ .. versionadded:: 21.2
408
+
409
+ Args:
410
+ document (:class:`telegram.Document`): Document with the pattern.
411
+ fill (:class:`telegram.BackgroundFill`): The background fill that is combined with
412
+ the pattern.
413
+ intensity (:obj:`int`): Intensity of the pattern when it is shown above the filled
414
+ background;
415
+ 0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_INTENSITY`.
416
+ is_inverted (:obj:`int`, optional): :obj:`True`, if the background fill must be applied
417
+ only to the pattern itself. All other pixels are black in this case. For dark
418
+ themes only.
419
+ is_moving (:obj:`bool`, optional): :obj:`True`, if the background moves slightly
420
+ when the device is tilted.
421
+
422
+ Attributes:
423
+ type (:obj:`str`): Type of the background. Always
424
+ :attr:`~telegram.BackgroundType.PATTERN`.
425
+ document (:class:`telegram.Document`): Document with the pattern.
426
+ fill (:class:`telegram.BackgroundFill`): The background fill that is combined with
427
+ the pattern.
428
+ intensity (:obj:`int`): Intensity of the pattern when it is shown above the filled
429
+ background;
430
+ 0-:tg-const:`telegram.constants.BackgroundTypeLimit.MAX_INTENSITY`.
431
+ is_inverted (:obj:`int`): Optional. :obj:`True`, if the background fill must be applied
432
+ only to the pattern itself. All other pixels are black in this case. For dark
433
+ themes only.
434
+ is_moving (:obj:`bool`): Optional. :obj:`True`, if the background moves slightly
435
+ when the device is tilted.
436
+ """
437
+
438
+ __slots__ = (
439
+ "document",
440
+ "fill",
441
+ "intensity",
442
+ "is_inverted",
443
+ "is_moving",
444
+ )
445
+
446
+ def __init__(
447
+ self,
448
+ document: Document,
449
+ fill: BackgroundFill,
450
+ intensity: int,
451
+ is_inverted: Optional[bool] = None,
452
+ is_moving: Optional[bool] = None,
453
+ *,
454
+ api_kwargs: Optional[JSONDict] = None,
455
+ ):
456
+ super().__init__(type=self.PATTERN, api_kwargs=api_kwargs)
457
+
458
+ with self._unfrozen():
459
+ # Required
460
+ self.document: Document = document
461
+ self.fill: BackgroundFill = fill
462
+ self.intensity: int = intensity
463
+ # Optionals
464
+ self.is_inverted: Optional[bool] = is_inverted
465
+ self.is_moving: Optional[bool] = is_moving
466
+
467
+ self._id_attrs = (self.document, self.fill, self.intensity)
468
+
469
+
470
+ class BackgroundTypeChatTheme(BackgroundType):
471
+ """
472
+ The background is taken directly from a built-in chat theme.
473
+
474
+ Objects of this class are comparable in terms of equality. Two objects of this class are
475
+ considered equal, if their :attr:`theme_name` is equal.
476
+
477
+ .. versionadded:: 21.2
478
+
479
+ Args:
480
+ theme_name (:obj:`str`): Name of the chat theme, which is usually an emoji.
481
+
482
+ Attributes:
483
+ type (:obj:`str`): Type of the background. Always
484
+ :attr:`~telegram.BackgroundType.CHAT_THEME`.
485
+ theme_name (:obj:`str`): Name of the chat theme, which is usually an emoji.
486
+ """
487
+
488
+ __slots__ = ("theme_name",)
489
+
490
+ def __init__(
491
+ self,
492
+ theme_name: str,
493
+ *,
494
+ api_kwargs: Optional[JSONDict] = None,
495
+ ):
496
+ super().__init__(type=self.CHAT_THEME, api_kwargs=api_kwargs)
497
+
498
+ with self._unfrozen():
499
+ self.theme_name: str = theme_name
500
+
501
+ self._id_attrs = (self.theme_name,)
502
+
503
+
504
+ class ChatBackground(TelegramObject):
505
+ """
506
+ This object represents a chat background.
507
+
508
+ Objects of this class are comparable in terms of equality. Two objects of this class are
509
+ considered equal, if their :attr:`type` is equal.
510
+
511
+ .. versionadded:: 21.2
512
+
513
+ Args:
514
+ type (:class:`telegram.BackgroundType`): Type of the background.
515
+
516
+ Attributes:
517
+ type (:class:`telegram.BackgroundType`): Type of the background.
518
+ """
519
+
520
+ __slots__ = ("type",)
521
+
522
+ def __init__(
523
+ self,
524
+ type: BackgroundType, # pylint: disable=redefined-builtin
525
+ *,
526
+ api_kwargs: Optional[JSONDict] = None,
527
+ ):
528
+ super().__init__(api_kwargs=api_kwargs)
529
+ self.type: BackgroundType = type
530
+
531
+ self._id_attrs = (self.type,)
532
+ self._freeze()
533
+
534
+ @classmethod
535
+ def de_json(
536
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
537
+ ) -> Optional["ChatBackground"]:
538
+ """See :meth:`telegram.TelegramObject.de_json`."""
539
+ data = cls._parse_data(data)
540
+
541
+ if not data:
542
+ return None
543
+
544
+ data["type"] = BackgroundType.de_json(data.get("type"), bot)
545
+
546
+ return super().de_json(data=data, bot=bot)
_chatboost.py ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains the classes that represent Telegram ChatBoosts."""
20
+
21
+ from datetime import datetime
22
+ from typing import TYPE_CHECKING, Dict, Final, Optional, Sequence, Tuple, Type
23
+
24
+ from telegram import constants
25
+ from telegram._chat import Chat
26
+ from telegram._telegramobject import TelegramObject
27
+ from telegram._user import User
28
+ from telegram._utils import enum
29
+ from telegram._utils.argumentparsing import parse_sequence_arg
30
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
31
+ from telegram._utils.types import JSONDict
32
+
33
+ if TYPE_CHECKING:
34
+ from telegram import Bot
35
+
36
+
37
+ class ChatBoostAdded(TelegramObject):
38
+ """
39
+ This object represents a service message about a user boosting a chat.
40
+
41
+ Objects of this class are comparable in terms of equality.
42
+ Two objects of this class are considered equal, if their
43
+ :attr:`boost_count` are equal.
44
+
45
+ .. versionadded:: 21.0
46
+
47
+ Args:
48
+ boost_count (:obj:`int`): Number of boosts added by the user.
49
+
50
+ Attributes:
51
+ boost_count (:obj:`int`): Number of boosts added by the user.
52
+
53
+ """
54
+
55
+ __slots__ = ("boost_count",)
56
+
57
+ def __init__(
58
+ self,
59
+ boost_count: int,
60
+ *,
61
+ api_kwargs: Optional[JSONDict] = None,
62
+ ) -> None:
63
+ super().__init__(api_kwargs=api_kwargs)
64
+ self.boost_count: int = boost_count
65
+ self._id_attrs = (self.boost_count,)
66
+
67
+ self._freeze()
68
+
69
+
70
+ class ChatBoostSource(TelegramObject):
71
+ """
72
+ Base class for Telegram ChatBoostSource objects. It can be one of:
73
+
74
+ * :class:`telegram.ChatBoostSourcePremium`
75
+ * :class:`telegram.ChatBoostSourceGiftCode`
76
+ * :class:`telegram.ChatBoostSourceGiveaway`
77
+
78
+ Objects of this class are comparable in terms of equality. Two objects of this class are
79
+ considered equal, if their :attr:`source` is equal.
80
+
81
+ .. versionadded:: 20.8
82
+
83
+ Args:
84
+ source (:obj:`str`): The source of the chat boost. Can be one of:
85
+ :attr:`~telegram.ChatBoostSource.PREMIUM`, :attr:`~telegram.ChatBoostSource.GIFT_CODE`,
86
+ or :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
87
+
88
+ Attributes:
89
+ source (:obj:`str`): The source of the chat boost. Can be one of:
90
+ :attr:`~telegram.ChatBoostSource.PREMIUM`, :attr:`~telegram.ChatBoostSource.GIFT_CODE`,
91
+ or :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
92
+ """
93
+
94
+ __slots__ = ("source",)
95
+
96
+ PREMIUM: Final[str] = constants.ChatBoostSources.PREMIUM
97
+ """:const:`telegram.constants.ChatBoostSources.PREMIUM`"""
98
+ GIFT_CODE: Final[str] = constants.ChatBoostSources.GIFT_CODE
99
+ """:const:`telegram.constants.ChatBoostSources.GIFT_CODE`"""
100
+ GIVEAWAY: Final[str] = constants.ChatBoostSources.GIVEAWAY
101
+ """:const:`telegram.constants.ChatBoostSources.GIVEAWAY`"""
102
+
103
+ def __init__(self, source: str, *, api_kwargs: Optional[JSONDict] = None):
104
+ super().__init__(api_kwargs=api_kwargs)
105
+
106
+ # Required by all subclasses:
107
+ self.source: str = enum.get_member(constants.ChatBoostSources, source, source)
108
+
109
+ self._id_attrs = (self.source,)
110
+ self._freeze()
111
+
112
+ @classmethod
113
+ def de_json(
114
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
115
+ ) -> Optional["ChatBoostSource"]:
116
+ """See :meth:`telegram.TelegramObject.de_json`."""
117
+ data = cls._parse_data(data)
118
+
119
+ if not data:
120
+ return None
121
+
122
+ _class_mapping: Dict[str, Type[ChatBoostSource]] = {
123
+ cls.PREMIUM: ChatBoostSourcePremium,
124
+ cls.GIFT_CODE: ChatBoostSourceGiftCode,
125
+ cls.GIVEAWAY: ChatBoostSourceGiveaway,
126
+ }
127
+
128
+ if cls is ChatBoostSource and data.get("source") in _class_mapping:
129
+ return _class_mapping[data.pop("source")].de_json(data=data, bot=bot)
130
+
131
+ if "user" in data:
132
+ data["user"] = User.de_json(data.get("user"), bot)
133
+
134
+ return super().de_json(data=data, bot=bot)
135
+
136
+
137
+ class ChatBoostSourcePremium(ChatBoostSource):
138
+ """
139
+ The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium
140
+ subscription to another user.
141
+
142
+ .. versionadded:: 20.8
143
+
144
+ Args:
145
+ user (:class:`telegram.User`): User that boosted the chat.
146
+
147
+ Attributes:
148
+ source (:obj:`str`): The source of the chat boost. Always
149
+ :attr:`~telegram.ChatBoostSource.PREMIUM`.
150
+ user (:class:`telegram.User`): User that boosted the chat.
151
+ """
152
+
153
+ __slots__ = ("user",)
154
+
155
+ def __init__(self, user: User, *, api_kwargs: Optional[JSONDict] = None):
156
+ super().__init__(source=self.PREMIUM, api_kwargs=api_kwargs)
157
+
158
+ with self._unfrozen():
159
+ self.user: User = user
160
+
161
+
162
+ class ChatBoostSourceGiftCode(ChatBoostSource):
163
+ """
164
+ The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each
165
+ such code boosts the chat 4 times for the duration of the corresponding Telegram Premium
166
+ subscription.
167
+
168
+ .. versionadded:: 20.8
169
+
170
+ Args:
171
+ user (:class:`telegram.User`): User for which the gift code was created.
172
+
173
+ Attributes:
174
+ source (:obj:`str`): The source of the chat boost. Always
175
+ :attr:`~telegram.ChatBoostSource.GIFT_CODE`.
176
+ user (:class:`telegram.User`): User for which the gift code was created.
177
+ """
178
+
179
+ __slots__ = ("user",)
180
+
181
+ def __init__(self, user: User, *, api_kwargs: Optional[JSONDict] = None):
182
+ super().__init__(source=self.GIFT_CODE, api_kwargs=api_kwargs)
183
+
184
+ with self._unfrozen():
185
+ self.user: User = user
186
+
187
+
188
+ class ChatBoostSourceGiveaway(ChatBoostSource):
189
+ """
190
+ The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4
191
+ times for the duration of the corresponding Telegram Premium subscription.
192
+
193
+ .. versionadded:: 20.8
194
+
195
+ Args:
196
+ giveaway_message_id (:obj:`int`): Identifier of a message in the chat with the giveaway;
197
+ the message could have been deleted already. May be 0 if the message isn't sent yet.
198
+ user (:class:`telegram.User`, optional): User that won the prize in the giveaway if any.
199
+ is_unclaimed (:obj:`bool`, optional): :obj:`True`, if the giveaway was completed, but
200
+ there was no user to win the prize.
201
+
202
+ Attributes:
203
+ source (:obj:`str`): Source of the boost. Always
204
+ :attr:`~telegram.ChatBoostSource.GIVEAWAY`.
205
+ giveaway_message_id (:obj:`int`): Identifier of a message in the chat with the giveaway;
206
+ the message could have been deleted already. May be 0 if the message isn't sent yet.
207
+ user (:class:`telegram.User`): Optional. User that won the prize in the giveaway if any.
208
+ is_unclaimed (:obj:`bool`): Optional. :obj:`True`, if the giveaway was completed, but
209
+ there was no user to win the prize.
210
+ """
211
+
212
+ __slots__ = ("giveaway_message_id", "is_unclaimed", "user")
213
+
214
+ def __init__(
215
+ self,
216
+ giveaway_message_id: int,
217
+ user: Optional[User] = None,
218
+ is_unclaimed: Optional[bool] = None,
219
+ *,
220
+ api_kwargs: Optional[JSONDict] = None,
221
+ ):
222
+ super().__init__(source=self.GIVEAWAY, api_kwargs=api_kwargs)
223
+
224
+ with self._unfrozen():
225
+ self.giveaway_message_id: int = giveaway_message_id
226
+ self.user: Optional[User] = user
227
+ self.is_unclaimed: Optional[bool] = is_unclaimed
228
+
229
+
230
+ class ChatBoost(TelegramObject):
231
+ """
232
+ This object contains information about a chat boost.
233
+
234
+ Objects of this class are comparable in terms of equality. Two objects of this class are
235
+ considered equal, if their :attr:`boost_id`, :attr:`add_date`, :attr:`expiration_date`,
236
+ and :attr:`source` are equal.
237
+
238
+ .. versionadded:: 20.8
239
+
240
+ Args:
241
+ boost_id (:obj:`str`): Unique identifier of the boost.
242
+ add_date (:obj:`datetime.datetime`): Point in time when the chat was boosted.
243
+ expiration_date (:obj:`datetime.datetime`): Point in time when the boost
244
+ will automatically expire, unless the booster's Telegram Premium subscription is
245
+ prolonged.
246
+ source (:class:`telegram.ChatBoostSource`): Source of the added boost.
247
+
248
+ Attributes:
249
+ boost_id (:obj:`str`): Unique identifier of the boost.
250
+ add_date (:obj:`datetime.datetime`): Point in time when the chat was boosted.
251
+ |datetime_localization|
252
+ expiration_date (:obj:`datetime.datetime`): Point in time when the boost
253
+ will automatically expire, unless the booster's Telegram Premium subscription is
254
+ prolonged. |datetime_localization|
255
+ source (:class:`telegram.ChatBoostSource`): Source of the added boost.
256
+ """
257
+
258
+ __slots__ = ("add_date", "boost_id", "expiration_date", "source")
259
+
260
+ def __init__(
261
+ self,
262
+ boost_id: str,
263
+ add_date: datetime,
264
+ expiration_date: datetime,
265
+ source: ChatBoostSource,
266
+ *,
267
+ api_kwargs: Optional[JSONDict] = None,
268
+ ):
269
+ super().__init__(api_kwargs=api_kwargs)
270
+
271
+ self.boost_id: str = boost_id
272
+ self.add_date: datetime = add_date
273
+ self.expiration_date: datetime = expiration_date
274
+ self.source: ChatBoostSource = source
275
+
276
+ self._id_attrs = (self.boost_id, self.add_date, self.expiration_date, self.source)
277
+ self._freeze()
278
+
279
+ @classmethod
280
+ def de_json(
281
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
282
+ ) -> Optional["ChatBoost"]:
283
+ """See :meth:`telegram.TelegramObject.de_json`."""
284
+ data = cls._parse_data(data)
285
+
286
+ if not data:
287
+ return None
288
+
289
+ data["source"] = ChatBoostSource.de_json(data.get("source"), bot)
290
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
291
+ data["add_date"] = from_timestamp(data["add_date"], tzinfo=loc_tzinfo)
292
+ data["expiration_date"] = from_timestamp(data["expiration_date"], tzinfo=loc_tzinfo)
293
+
294
+ return super().de_json(data=data, bot=bot)
295
+
296
+
297
+ class ChatBoostUpdated(TelegramObject):
298
+ """This object represents a boost added to a chat or changed.
299
+
300
+ Objects of this class are comparable in terms of equality. Two objects of this class are
301
+ considered equal, if their :attr:`chat`, and :attr:`boost` are equal.
302
+
303
+ .. versionadded:: 20.8
304
+
305
+ Args:
306
+ chat (:class:`telegram.Chat`): Chat which was boosted.
307
+ boost (:class:`telegram.ChatBoost`): Information about the chat boost.
308
+
309
+ Attributes:
310
+ chat (:class:`telegram.Chat`): Chat which was boosted.
311
+ boost (:class:`telegram.ChatBoost`): Information about the chat boost.
312
+ """
313
+
314
+ __slots__ = ("boost", "chat")
315
+
316
+ def __init__(
317
+ self,
318
+ chat: Chat,
319
+ boost: ChatBoost,
320
+ *,
321
+ api_kwargs: Optional[JSONDict] = None,
322
+ ):
323
+ super().__init__(api_kwargs=api_kwargs)
324
+
325
+ self.chat: Chat = chat
326
+ self.boost: ChatBoost = boost
327
+
328
+ self._id_attrs = (self.chat.id, self.boost)
329
+ self._freeze()
330
+
331
+ @classmethod
332
+ def de_json(
333
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
334
+ ) -> Optional["ChatBoostUpdated"]:
335
+ """See :meth:`telegram.TelegramObject.de_json`."""
336
+ data = cls._parse_data(data)
337
+
338
+ if not data:
339
+ return None
340
+
341
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
342
+ data["boost"] = ChatBoost.de_json(data.get("boost"), bot)
343
+
344
+ return super().de_json(data=data, bot=bot)
345
+
346
+
347
+ class ChatBoostRemoved(TelegramObject):
348
+ """
349
+ This object represents a boost removed from a chat.
350
+
351
+ Objects of this class are comparable in terms of equality. Two objects of this class are
352
+ considered equal, if their :attr:`chat`, :attr:`boost_id`, :attr:`remove_date`, and
353
+ :attr:`source` are equal.
354
+
355
+ Args:
356
+ chat (:class:`telegram.Chat`): Chat which was boosted.
357
+ boost_id (:obj:`str`): Unique identifier of the boost.
358
+ remove_date (:obj:`datetime.datetime`): Point in time when the boost was removed.
359
+ source (:class:`telegram.ChatBoostSource`): Source of the removed boost.
360
+
361
+ Attributes:
362
+ chat (:class:`telegram.Chat`): Chat which was boosted.
363
+ boost_id (:obj:`str`): Unique identifier of the boost.
364
+ remove_date (:obj:`datetime.datetime`): Point in time when the boost was removed.
365
+ |datetime_localization|
366
+ source (:class:`telegram.ChatBoostSource`): Source of the removed boost.
367
+ """
368
+
369
+ __slots__ = ("boost_id", "chat", "remove_date", "source")
370
+
371
+ def __init__(
372
+ self,
373
+ chat: Chat,
374
+ boost_id: str,
375
+ remove_date: datetime,
376
+ source: ChatBoostSource,
377
+ *,
378
+ api_kwargs: Optional[JSONDict] = None,
379
+ ):
380
+ super().__init__(api_kwargs=api_kwargs)
381
+
382
+ self.chat: Chat = chat
383
+ self.boost_id: str = boost_id
384
+ self.remove_date: datetime = remove_date
385
+ self.source: ChatBoostSource = source
386
+
387
+ self._id_attrs = (self.chat, self.boost_id, self.remove_date, self.source)
388
+ self._freeze()
389
+
390
+ @classmethod
391
+ def de_json(
392
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
393
+ ) -> Optional["ChatBoostRemoved"]:
394
+ """See :meth:`telegram.TelegramObject.de_json`."""
395
+ data = cls._parse_data(data)
396
+
397
+ if not data:
398
+ return None
399
+
400
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
401
+ data["source"] = ChatBoostSource.de_json(data.get("source"), bot)
402
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
403
+ data["remove_date"] = from_timestamp(data["remove_date"], tzinfo=loc_tzinfo)
404
+
405
+ return super().de_json(data=data, bot=bot)
406
+
407
+
408
+ class UserChatBoosts(TelegramObject):
409
+ """This object represents a list of boosts added to a chat by a user.
410
+
411
+ Objects of this class are comparable in terms of equality. Two objects of this class are
412
+ considered equal, if their :attr:`boosts` are equal.
413
+
414
+ .. versionadded:: 20.8
415
+
416
+ Args:
417
+ boosts (Sequence[:class:`telegram.ChatBoost`]): List of boosts added to the chat by the
418
+ user.
419
+
420
+ Attributes:
421
+ boosts (Tuple[:class:`telegram.ChatBoost`]): List of boosts added to the chat by the user.
422
+ """
423
+
424
+ __slots__ = ("boosts",)
425
+
426
+ def __init__(
427
+ self,
428
+ boosts: Sequence[ChatBoost],
429
+ *,
430
+ api_kwargs: Optional[JSONDict] = None,
431
+ ):
432
+ super().__init__(api_kwargs=api_kwargs)
433
+
434
+ self.boosts: Tuple[ChatBoost, ...] = parse_sequence_arg(boosts)
435
+
436
+ self._id_attrs = (self.boosts,)
437
+ self._freeze()
438
+
439
+ @classmethod
440
+ def de_json(
441
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
442
+ ) -> Optional["UserChatBoosts"]:
443
+ """See :meth:`telegram.TelegramObject.de_json`."""
444
+ data = cls._parse_data(data)
445
+
446
+ if not data:
447
+ return None
448
+
449
+ data["boosts"] = ChatBoost.de_list(data.get("boosts"), bot)
450
+
451
+ return super().de_json(data=data, bot=bot)
_chatfullinfo.py ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # pylint: disable=redefined-builtin
3
+ #
4
+ # A library that provides a Python interface to the Telegram Bot API
5
+ # Copyright (C) 2015-2024
6
+ # Leandro Toledo de Souza <[email protected]>
7
+ #
8
+ # This program is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser Public License
19
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
20
+ """This module contains an object that represents a Telegram ChatFullInfo."""
21
+ from datetime import datetime
22
+ from typing import TYPE_CHECKING, Optional, Sequence, Tuple
23
+
24
+ from telegram._birthdate import Birthdate
25
+ from telegram._chat import Chat, _ChatBase
26
+ from telegram._chatlocation import ChatLocation
27
+ from telegram._chatpermissions import ChatPermissions
28
+ from telegram._files.chatphoto import ChatPhoto
29
+ from telegram._reaction import ReactionType
30
+ from telegram._utils.argumentparsing import parse_sequence_arg
31
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
32
+ from telegram._utils.types import JSONDict
33
+
34
+ if TYPE_CHECKING:
35
+ from telegram import Bot, BusinessIntro, BusinessLocation, BusinessOpeningHours, Message
36
+
37
+
38
+ class ChatFullInfo(_ChatBase):
39
+ """
40
+ This object contains full information about a chat.
41
+
42
+ Objects of this class are comparable in terms of equality. Two objects of this class are
43
+ considered equal, if their :attr:`~telegram.Chat.id` is equal.
44
+
45
+ .. versionadded:: 21.2
46
+
47
+ .. versionchanged:: 21.3
48
+ Explicit support for all shortcut methods known from :class:`telegram.Chat` on this
49
+ object. Previously those were only available because this class inherited from
50
+ :class:`telegram.Chat`.
51
+
52
+ Args:
53
+ id (:obj:`int`): Unique identifier for this chat.
54
+ type (:obj:`str`): Type of chat, can be either :attr:`PRIVATE`, :attr:`GROUP`,
55
+ :attr:`SUPERGROUP` or :attr:`CHANNEL`.
56
+ accent_color_id (:obj:`int`, optional): Identifier of the
57
+ :class:`accent color <telegram.constants.AccentColor>` for the chat name and
58
+ backgrounds of the chat photo, reply header, and link preview. See `accent colors`_
59
+ for more details.
60
+
61
+ .. versionadded:: 20.8
62
+ max_reaction_count (:obj:`int`): The maximum number of reactions that can be set on a
63
+ message in the chat.
64
+
65
+ .. versionadded:: 21.2
66
+ title (:obj:`str`, optional): Title, for supergroups, channels and group chats.
67
+ username (:obj:`str`, optional): Username, for private chats, supergroups and channels if
68
+ available.
69
+ first_name (:obj:`str`, optional): First name of the other party in a private chat.
70
+ last_name (:obj:`str`, optional): Last name of the other party in a private chat.
71
+ is_forum (:obj:`bool`, optional): :obj:`True`, if the supergroup chat is a forum
72
+ (has topics_ enabled).
73
+
74
+ .. versionadded:: 20.0
75
+ photo (:class:`telegram.ChatPhoto`, optional): Chat photo.
76
+ active_usernames (Sequence[:obj:`str`], optional): If set, the list of all `active chat
77
+ usernames <https://telegram.org/blog/topics-in-groups-collectible-usernames\
78
+ #collectible-usernames>`_; for private chats, supergroups and channels.
79
+
80
+ .. versionadded:: 20.0
81
+ birthdate (:class:`telegram.Birthdate`, optional): For private chats,
82
+ the date of birth of the user.
83
+
84
+ .. versionadded:: 21.1
85
+ business_intro (:class:`telegram.BusinessIntro`, optional): For private chats with
86
+ business accounts, the intro of the business.
87
+
88
+ .. versionadded:: 21.1
89
+ business_location (:class:`telegram.BusinessLocation`, optional): For private chats with
90
+ business accounts, the location of the business.
91
+
92
+ .. versionadded:: 21.1
93
+ business_opening_hours (:class:`telegram.BusinessOpeningHours`, optional): For private
94
+ chats with business accounts, the opening hours of the business.
95
+
96
+ .. versionadded:: 21.1
97
+ personal_chat (:class:`telegram.Chat`, optional): For private chats, the personal channel
98
+ of the user.
99
+
100
+ .. versionadded:: 21.1
101
+ available_reactions (Sequence[:class:`telegram.ReactionType`], optional): List of available
102
+ reactions allowed in the chat. If omitted, then all of
103
+ :const:`telegram.constants.ReactionEmoji` are allowed.
104
+
105
+ .. versionadded:: 20.8
106
+ background_custom_emoji_id (:obj:`str`, optional): Custom emoji identifier of emoji chosen
107
+ by the chat for the reply header and link preview background.
108
+
109
+ .. versionadded:: 20.8
110
+ profile_accent_color_id (:obj:`int`, optional): Identifier of the
111
+ :class:`accent color <telegram.constants.ProfileAccentColor>` for the chat's profile
112
+ background. See profile `accent colors`_ for more details.
113
+
114
+ .. versionadded:: 20.8
115
+ profile_background_custom_emoji_id (:obj:`str`, optional): Custom emoji identifier of
116
+ the emoji chosen by the chat for its profile background.
117
+
118
+ .. versionadded:: 20.8
119
+ emoji_status_custom_emoji_id (:obj:`str`, optional): Custom emoji identifier of emoji
120
+ status of the chat or the other party in a private chat.
121
+
122
+ .. versionadded:: 20.0
123
+ emoji_status_expiration_date (:class:`datetime.datetime`, optional): Expiration date of
124
+ emoji status of the chat or the other party in a private chat, as a datetime object,
125
+ if any.
126
+
127
+ |datetime_localization|
128
+
129
+ .. versionadded:: 20.5
130
+ bio (:obj:`str`, optional): Bio of the other party in a private chat.
131
+ has_private_forwards (:obj:`bool`, optional): :obj:`True`, if privacy settings of the other
132
+ party in the private chat allows to use ``tg://user?id=<user_id>`` links only in chats
133
+ with the user.
134
+
135
+ .. versionadded:: 13.9
136
+ has_restricted_voice_and_video_messages (:obj:`bool`, optional): :obj:`True`, if the
137
+ privacy settings of the other party restrict sending voice and video note messages
138
+ in the private chat.
139
+
140
+ .. versionadded:: 20.0
141
+ join_to_send_messages (:obj:`bool`, optional): :obj:`True`, if users need to join the
142
+ supergroup before they can send messages.
143
+
144
+ .. versionadded:: 20.0
145
+ join_by_request (:obj:`bool`, optional): :obj:`True`, if all users directly joining the
146
+ supergroup without using an invite link need to be approved by supergroup
147
+ administrators.
148
+
149
+ .. versionadded:: 20.0
150
+ description (:obj:`str`, optional): Description, for groups, supergroups and channel chats.
151
+ invite_link (:obj:`str`, optional): Primary invite link, for groups, supergroups and
152
+ channel.
153
+ pinned_message (:class:`telegram.Message`, optional): The most recent pinned message
154
+ (by sending date).
155
+ permissions (:class:`telegram.ChatPermissions`): Optional. Default chat member permissions,
156
+ for groups and supergroups.
157
+ slow_mode_delay (:obj:`int`, optional): For supergroups, the minimum allowed delay between
158
+ consecutive messages sent by each unprivileged user.
159
+ unrestrict_boost_count (:obj:`int`, optional): For supergroups, the minimum number of
160
+ boosts that a non-administrator user needs to add in order to ignore slow mode and chat
161
+ permissions.
162
+
163
+ .. versionadded:: 21.0
164
+ message_auto_delete_time (:obj:`int`, optional): The time after which all messages sent to
165
+ the chat will be automatically deleted; in seconds.
166
+
167
+ .. versionadded:: 13.4
168
+ has_aggressive_anti_spam_enabled (:obj:`bool`, optional): :obj:`True`, if aggressive
169
+ anti-spam checks are enabled in the supergroup. The field is only available to chat
170
+ administrators.
171
+
172
+ .. versionadded:: 20.0
173
+ has_hidden_members (:obj:`bool`, optional): :obj:`True`, if non-administrators can only
174
+ get the list of bots and administrators in the chat.
175
+
176
+ .. versionadded:: 20.0
177
+ has_protected_content (:obj:`bool`, optional): :obj:`True`, if messages from the chat can't
178
+ be forwarded to other chats.
179
+
180
+ .. versionadded:: 13.9
181
+ has_visible_history (:obj:`bool`, optional): :obj:`True`, if new chat members will have
182
+ access to old messages; available only to chat administrators.
183
+
184
+ .. versionadded:: 20.8
185
+ sticker_set_name (:obj:`str`, optional): For supergroups, name of group sticker set.
186
+ can_set_sticker_set (:obj:`bool`, optional): :obj:`True`, if the bot can change group the
187
+ sticker set.
188
+ custom_emoji_sticker_set_name (:obj:`str`, optional): For supergroups, the name of the
189
+ group's custom emoji sticker set. Custom emoji from this set can be used by all users
190
+ and bots in the group.
191
+
192
+ .. versionadded:: 21.0
193
+ linked_chat_id (:obj:`int`, optional): Unique identifier for the linked chat, i.e. the
194
+ discussion group identifier for a channel and vice versa; for supergroups and channel
195
+ chats.
196
+ location (:class:`telegram.ChatLocation`, optional): For supergroups, the location to which
197
+ the supergroup is connected.
198
+ can_send_paid_media (:obj:`bool`, optional): :obj:`True`, if paid media messages can be
199
+ sent or forwarded to the channel chat. The field is available only for channel chats.
200
+
201
+ .. versionadded:: 21.4
202
+
203
+ Attributes:
204
+ id (:obj:`int`): Unique identifier for this chat.
205
+ type (:obj:`str`): Type of chat, can be either :attr:`PRIVATE`, :attr:`GROUP`,
206
+ :attr:`SUPERGROUP` or :attr:`CHANNEL`.
207
+ accent_color_id (:obj:`int`): Optional. Identifier of the
208
+ :class:`accent color <telegram.constants.AccentColor>` for the chat name and
209
+ backgrounds of the chat photo, reply header, and link preview. See `accent colors`_
210
+ for more details.
211
+
212
+ .. versionadded:: 20.8
213
+ max_reaction_count (:obj:`int`): The maximum number of reactions that can be set on a
214
+ message in the chat.
215
+
216
+ .. versionadded:: 21.2
217
+ title (:obj:`str`, optional): Title, for supergroups, channels and group chats.
218
+ username (:obj:`str`, optional): Username, for private chats, supergroups and channels if
219
+ available.
220
+ first_name (:obj:`str`, optional): First name of the other party in a private chat.
221
+ last_name (:obj:`str`, optional): Last name of the other party in a private chat.
222
+ is_forum (:obj:`bool`, optional): :obj:`True`, if the supergroup chat is a forum
223
+ (has topics_ enabled).
224
+
225
+ .. versionadded:: 20.0
226
+ photo (:class:`telegram.ChatPhoto`): Optional. Chat photo.
227
+ active_usernames (Tuple[:obj:`str`]): Optional. If set, the list of all `active chat
228
+ usernames <https://telegram.org/blog/topics-in-groups-collectible-usernames\
229
+ #collectible-usernames>`_; for private chats, supergroups and channels.
230
+
231
+ This list is empty if the chat has no active usernames or this chat instance was not
232
+ obtained via :meth:`~telegram.Bot.get_chat`.
233
+
234
+ .. versionadded:: 20.0
235
+ birthdate (:class:`telegram.Birthdate`): Optional. For private chats,
236
+ the date of birth of the user.
237
+
238
+ .. versionadded:: 21.1
239
+ business_intro (:class:`telegram.BusinessIntro`): Optional. For private chats with
240
+ business accounts, the intro of the business.
241
+
242
+ .. versionadded:: 21.1
243
+ business_location (:class:`telegram.BusinessLocation`): Optional. For private chats with
244
+ business accounts, the location of the business.
245
+
246
+ .. versionadded:: 21.1
247
+ business_opening_hours (:class:`telegram.BusinessOpeningHours`): Optional. For private
248
+ chats with business accounts, the opening hours of the business.
249
+
250
+ .. versionadded:: 21.1
251
+ personal_chat (:class:`telegram.Chat`): Optional. For private chats, the personal channel
252
+ of the user.
253
+
254
+ .. versionadded:: 21.1
255
+ available_reactions (Tuple[:class:`telegram.ReactionType`]): Optional. List of available
256
+ reactions allowed in the chat. If omitted, then all of
257
+ :const:`telegram.constants.ReactionEmoji` are allowed.
258
+
259
+ .. versionadded:: 20.8
260
+ background_custom_emoji_id (:obj:`str`): Optional. Custom emoji identifier of emoji chosen
261
+ by the chat for the reply header and link preview background.
262
+
263
+ .. versionadded:: 20.8
264
+ profile_accent_color_id (:obj:`int`): Optional. Identifier of the
265
+ :class:`accent color <telegram.constants.ProfileAccentColor>` for the chat's profile
266
+ background. See profile `accent colors`_ for more details.
267
+
268
+ .. versionadded:: 20.8
269
+ profile_background_custom_emoji_id (:obj:`str`): Optional. Custom emoji identifier of
270
+ the emoji chosen by the chat for its profile background.
271
+
272
+ .. versionadded:: 20.8
273
+ emoji_status_custom_emoji_id (:obj:`str`): Optional. Custom emoji identifier of emoji
274
+ status of the chat or the other party in a private chat.
275
+
276
+ .. versionadded:: 20.0
277
+ emoji_status_expiration_date (:class:`datetime.datetime`): Optional. Expiration date of
278
+ emoji status of the chat or the other party in a private chat, as a datetime object,
279
+ if any.
280
+
281
+ |datetime_localization|
282
+
283
+ .. versionadded:: 20.5
284
+ bio (:obj:`str`): Optional. Bio of the other party in a private chat.
285
+ has_private_forwards (:obj:`bool`): Optional. :obj:`True`, if privacy settings of the other
286
+ party in the private chat allows to use ``tg://user?id=<user_id>`` links only in chats
287
+ with the user.
288
+
289
+ .. versionadded:: 13.9
290
+ has_restricted_voice_and_video_messages (:obj:`bool`): Optional. :obj:`True`, if the
291
+ privacy settings of the other party restrict sending voice and video note messages
292
+ in the private chat.
293
+
294
+ .. versionadded:: 20.0
295
+ join_to_send_messages (:obj:`bool`): Optional. :obj:`True`, if users need to join
296
+ the supergroup before they can send messages.
297
+
298
+ .. versionadded:: 20.0
299
+ join_by_request (:obj:`bool`): Optional. :obj:`True`, if all users directly joining the
300
+ supergroup without using an invite link need to be approved by supergroup
301
+ administrators.
302
+
303
+ .. versionadded:: 20.0
304
+ description (:obj:`str`): Optional. Description, for groups, supergroups and channel chats.
305
+ invite_link (:obj:`str`): Optional. Primary invite link, for groups, supergroups and
306
+ channel.
307
+ pinned_message (:class:`telegram.Message`): Optional. The most recent pinned message
308
+ (by sending date).
309
+ permissions (:class:`telegram.ChatPermissions`): Optional. Default chat member permissions,
310
+ for groups and supergroups.
311
+ slow_mode_delay (:obj:`int`): Optional. For supergroups, the minimum allowed delay between
312
+ consecutive messages sent by each unprivileged user.
313
+ unrestrict_boost_count (:obj:`int`): Optional. For supergroups, the minimum number of
314
+ boosts that a non-administrator user needs to add in order to ignore slow mode and chat
315
+ permissions.
316
+
317
+ .. versionadded:: 21.0
318
+ message_auto_delete_time (:obj:`int`): Optional. The time after which all messages sent to
319
+ the chat will be automatically deleted; in seconds.
320
+
321
+ .. versionadded:: 13.4
322
+ has_aggressive_anti_spam_enabled (:obj:`bool`): Optional. :obj:`True`, if aggressive
323
+ anti-spam checks are enabled in the supergroup. The field is only available to chat
324
+ administrators.
325
+
326
+ .. versionadded:: 20.0
327
+ has_hidden_members (:obj:`bool`): Optional. :obj:`True`, if non-administrators can only
328
+ get the list of bots and administrators in the chat.
329
+
330
+ .. versionadded:: 20.0
331
+ has_protected_content (:obj:`bool`): Optional. :obj:`True`, if messages from the chat can't
332
+ be forwarded to other chats.
333
+
334
+ .. versionadded:: 13.9
335
+ has_visible_history (:obj:`bool`): Optional. :obj:`True`, if new chat members will have
336
+ access to old messages; available only to chat administrators.
337
+
338
+ .. versionadded:: 20.8
339
+ sticker_set_name (:obj:`str`): Optional. For supergroups, name of Group sticker set.
340
+ can_set_sticker_set (:obj:`bool`): Optional. :obj:`True`, if the bot can change group the
341
+ sticker set.
342
+ custom_emoji_sticker_set_name (:obj:`str`): Optional. For supergroups, the name of the
343
+ group's custom emoji sticker set. Custom emoji from this set can be used by all users
344
+ and bots in the group.
345
+
346
+ .. versionadded:: 21.0
347
+ linked_chat_id (:obj:`int`): Optional. Unique identifier for the linked chat, i.e. the
348
+ discussion group identifier for a channel and vice versa; for supergroups and channel
349
+ chats.
350
+ location (:class:`telegram.ChatLocation`): Optional. For supergroups, the location to which
351
+ the supergroup is connected.
352
+ can_send_paid_media (:obj:`bool`): Optional. :obj:`True`, if paid media messages can be
353
+ sent or forwarded to the channel chat. The field is available only for channel chats.
354
+
355
+ .. versionadded:: 21.4
356
+
357
+ .. _accent colors: https://core.telegram.org/bots/api#accent-colors
358
+ .. _topics: https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups
359
+ """
360
+
361
+ __slots__ = (
362
+ "accent_color_id",
363
+ "active_usernames",
364
+ "available_reactions",
365
+ "background_custom_emoji_id",
366
+ "bio",
367
+ "birthdate",
368
+ "business_intro",
369
+ "business_location",
370
+ "business_opening_hours",
371
+ "can_send_paid_media",
372
+ "can_set_sticker_set",
373
+ "custom_emoji_sticker_set_name",
374
+ "description",
375
+ "emoji_status_custom_emoji_id",
376
+ "emoji_status_expiration_date",
377
+ "has_aggressive_anti_spam_enabled",
378
+ "has_hidden_members",
379
+ "has_private_forwards",
380
+ "has_protected_content",
381
+ "has_restricted_voice_and_video_messages",
382
+ "has_visible_history",
383
+ "invite_link",
384
+ "join_by_request",
385
+ "join_to_send_messages",
386
+ "linked_chat_id",
387
+ "location",
388
+ "max_reaction_count",
389
+ "message_auto_delete_time",
390
+ "permissions",
391
+ "personal_chat",
392
+ "photo",
393
+ "pinned_message",
394
+ "profile_accent_color_id",
395
+ "profile_background_custom_emoji_id",
396
+ "slow_mode_delay",
397
+ "sticker_set_name",
398
+ "unrestrict_boost_count",
399
+ )
400
+
401
+ def __init__(
402
+ self,
403
+ id: int,
404
+ type: str,
405
+ accent_color_id: int,
406
+ max_reaction_count: int,
407
+ title: Optional[str] = None,
408
+ username: Optional[str] = None,
409
+ first_name: Optional[str] = None,
410
+ last_name: Optional[str] = None,
411
+ is_forum: Optional[bool] = None,
412
+ photo: Optional[ChatPhoto] = None,
413
+ active_usernames: Optional[Sequence[str]] = None,
414
+ birthdate: Optional[Birthdate] = None,
415
+ business_intro: Optional["BusinessIntro"] = None,
416
+ business_location: Optional["BusinessLocation"] = None,
417
+ business_opening_hours: Optional["BusinessOpeningHours"] = None,
418
+ personal_chat: Optional["Chat"] = None,
419
+ available_reactions: Optional[Sequence[ReactionType]] = None,
420
+ background_custom_emoji_id: Optional[str] = None,
421
+ profile_accent_color_id: Optional[int] = None,
422
+ profile_background_custom_emoji_id: Optional[str] = None,
423
+ emoji_status_custom_emoji_id: Optional[str] = None,
424
+ emoji_status_expiration_date: Optional[datetime] = None,
425
+ bio: Optional[str] = None,
426
+ has_private_forwards: Optional[bool] = None,
427
+ has_restricted_voice_and_video_messages: Optional[bool] = None,
428
+ join_to_send_messages: Optional[bool] = None,
429
+ join_by_request: Optional[bool] = None,
430
+ description: Optional[str] = None,
431
+ invite_link: Optional[str] = None,
432
+ pinned_message: Optional["Message"] = None,
433
+ permissions: Optional[ChatPermissions] = None,
434
+ slow_mode_delay: Optional[int] = None,
435
+ unrestrict_boost_count: Optional[int] = None,
436
+ message_auto_delete_time: Optional[int] = None,
437
+ has_aggressive_anti_spam_enabled: Optional[bool] = None,
438
+ has_hidden_members: Optional[bool] = None,
439
+ has_protected_content: Optional[bool] = None,
440
+ has_visible_history: Optional[bool] = None,
441
+ sticker_set_name: Optional[str] = None,
442
+ can_set_sticker_set: Optional[bool] = None,
443
+ custom_emoji_sticker_set_name: Optional[str] = None,
444
+ linked_chat_id: Optional[int] = None,
445
+ location: Optional[ChatLocation] = None,
446
+ can_send_paid_media: Optional[bool] = None,
447
+ *,
448
+ api_kwargs: Optional[JSONDict] = None,
449
+ ):
450
+ super().__init__(
451
+ id=id,
452
+ type=type,
453
+ title=title,
454
+ username=username,
455
+ first_name=first_name,
456
+ last_name=last_name,
457
+ is_forum=is_forum,
458
+ api_kwargs=api_kwargs,
459
+ )
460
+
461
+ # Required and unique to this class-
462
+ with self._unfrozen():
463
+ self.max_reaction_count: int = max_reaction_count
464
+ self.photo: Optional[ChatPhoto] = photo
465
+ self.bio: Optional[str] = bio
466
+ self.has_private_forwards: Optional[bool] = has_private_forwards
467
+ self.description: Optional[str] = description
468
+ self.invite_link: Optional[str] = invite_link
469
+ self.pinned_message: Optional[Message] = pinned_message
470
+ self.permissions: Optional[ChatPermissions] = permissions
471
+ self.slow_mode_delay: Optional[int] = slow_mode_delay
472
+ self.message_auto_delete_time: Optional[int] = (
473
+ int(message_auto_delete_time) if message_auto_delete_time is not None else None
474
+ )
475
+ self.has_protected_content: Optional[bool] = has_protected_content
476
+ self.has_visible_history: Optional[bool] = has_visible_history
477
+ self.sticker_set_name: Optional[str] = sticker_set_name
478
+ self.can_set_sticker_set: Optional[bool] = can_set_sticker_set
479
+ self.linked_chat_id: Optional[int] = linked_chat_id
480
+ self.location: Optional[ChatLocation] = location
481
+ self.join_to_send_messages: Optional[bool] = join_to_send_messages
482
+ self.join_by_request: Optional[bool] = join_by_request
483
+ self.has_restricted_voice_and_video_messages: Optional[bool] = (
484
+ has_restricted_voice_and_video_messages
485
+ )
486
+ self.active_usernames: Tuple[str, ...] = parse_sequence_arg(active_usernames)
487
+ self.emoji_status_custom_emoji_id: Optional[str] = emoji_status_custom_emoji_id
488
+ self.emoji_status_expiration_date: Optional[datetime] = emoji_status_expiration_date
489
+ self.has_aggressive_anti_spam_enabled: Optional[bool] = (
490
+ has_aggressive_anti_spam_enabled
491
+ )
492
+ self.has_hidden_members: Optional[bool] = has_hidden_members
493
+ self.available_reactions: Optional[Tuple[ReactionType, ...]] = parse_sequence_arg(
494
+ available_reactions
495
+ )
496
+ self.accent_color_id: Optional[int] = accent_color_id
497
+ self.background_custom_emoji_id: Optional[str] = background_custom_emoji_id
498
+ self.profile_accent_color_id: Optional[int] = profile_accent_color_id
499
+ self.profile_background_custom_emoji_id: Optional[str] = (
500
+ profile_background_custom_emoji_id
501
+ )
502
+ self.unrestrict_boost_count: Optional[int] = unrestrict_boost_count
503
+ self.custom_emoji_sticker_set_name: Optional[str] = custom_emoji_sticker_set_name
504
+ self.birthdate: Optional[Birthdate] = birthdate
505
+ self.personal_chat: Optional[Chat] = personal_chat
506
+ self.business_intro: Optional[BusinessIntro] = business_intro
507
+ self.business_location: Optional[BusinessLocation] = business_location
508
+ self.business_opening_hours: Optional[BusinessOpeningHours] = business_opening_hours
509
+ self.can_send_paid_media: Optional[bool] = can_send_paid_media
510
+
511
+ @classmethod
512
+ def de_json(
513
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
514
+ ) -> Optional["ChatFullInfo"]:
515
+ """See :meth:`telegram.TelegramObject.de_json`."""
516
+ data = cls._parse_data(data)
517
+
518
+ if not data:
519
+ return None
520
+
521
+ # Get the local timezone from the bot if it has defaults
522
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
523
+
524
+ data["emoji_status_expiration_date"] = from_timestamp(
525
+ data.get("emoji_status_expiration_date"), tzinfo=loc_tzinfo
526
+ )
527
+
528
+ data["photo"] = ChatPhoto.de_json(data.get("photo"), bot)
529
+
530
+ from telegram import ( # pylint: disable=import-outside-toplevel
531
+ BusinessIntro,
532
+ BusinessLocation,
533
+ BusinessOpeningHours,
534
+ Message,
535
+ )
536
+
537
+ data["pinned_message"] = Message.de_json(data.get("pinned_message"), bot)
538
+ data["permissions"] = ChatPermissions.de_json(data.get("permissions"), bot)
539
+ data["location"] = ChatLocation.de_json(data.get("location"), bot)
540
+ data["available_reactions"] = ReactionType.de_list(data.get("available_reactions"), bot)
541
+ data["birthdate"] = Birthdate.de_json(data.get("birthdate"), bot)
542
+ data["personal_chat"] = Chat.de_json(data.get("personal_chat"), bot)
543
+ data["business_intro"] = BusinessIntro.de_json(data.get("business_intro"), bot)
544
+ data["business_location"] = BusinessLocation.de_json(data.get("business_location"), bot)
545
+ data["business_opening_hours"] = BusinessOpeningHours.de_json(
546
+ data.get("business_opening_hours"), bot
547
+ )
548
+
549
+ return super().de_json(data=data, bot=bot)
_chatinvitelink.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents an invite link for a chat."""
20
+ import datetime
21
+ from typing import TYPE_CHECKING, Optional
22
+
23
+ from telegram._telegramobject import TelegramObject
24
+ from telegram._user import User
25
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
26
+ from telegram._utils.types import JSONDict
27
+
28
+ if TYPE_CHECKING:
29
+ from telegram import Bot
30
+
31
+
32
+ class ChatInviteLink(TelegramObject):
33
+ """This object represents an invite link for a chat.
34
+
35
+ Objects of this class are comparable in terms of equality. Two objects of this class are
36
+ considered equal, if their :attr:`invite_link`, :attr:`creator`, :attr:`creates_join_request`,
37
+ :attr:`is_primary` and :attr:`is_revoked` are equal.
38
+
39
+ .. versionadded:: 13.4
40
+ .. versionchanged:: 20.0
41
+
42
+ * The argument & attribute :attr:`creates_join_request` is now required to comply with the
43
+ Bot API.
44
+ * Comparing objects of this class now also takes :attr:`creates_join_request` into account.
45
+
46
+ Args:
47
+ invite_link (:obj:`str`): The invite link.
48
+ creator (:class:`telegram.User`): Creator of the link.
49
+ creates_join_request (:obj:`bool`): :obj:`True`, if users joining the chat via
50
+ the link need to be approved by chat administrators.
51
+
52
+ .. versionadded:: 13.8
53
+ is_primary (:obj:`bool`): :obj:`True`, if the link is primary.
54
+ is_revoked (:obj:`bool`): :obj:`True`, if the link is revoked.
55
+ expire_date (:class:`datetime.datetime`, optional): Date when the link will expire or
56
+ has been expired.
57
+
58
+ .. versionchanged:: 20.3
59
+ |datetime_localization|
60
+ member_limit (:obj:`int`, optional): Maximum number of users that can be members of the
61
+ chat simultaneously after joining the chat via this invite link;
62
+ :tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
63
+ :tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
64
+ name (:obj:`str`, optional): Invite link name.
65
+ 0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
66
+
67
+ .. versionadded:: 13.8
68
+ pending_join_request_count (:obj:`int`, optional): Number of pending join requests
69
+ created using this link.
70
+
71
+ .. versionadded:: 13.8
72
+ subscription_period (:obj:`int`, optional): The number of seconds the subscription will be
73
+ active for before the next payment.
74
+
75
+ .. versionadded:: 21.5
76
+ subscription_price (:obj:`int`, optional): The amount of Telegram Stars a user must pay
77
+ initially and after each subsequent subscription period to be a member of the chat
78
+ using the link.
79
+
80
+ .. versionadded:: 21.5
81
+
82
+ Attributes:
83
+ invite_link (:obj:`str`): The invite link. If the link was created by another chat
84
+ administrator, then the second part of the link will be replaced with ``'…'``.
85
+ creator (:class:`telegram.User`): Creator of the link.
86
+ creates_join_request (:obj:`bool`): :obj:`True`, if users joining the chat via
87
+ the link need to be approved by chat administrators.
88
+
89
+ .. versionadded:: 13.8
90
+ is_primary (:obj:`bool`): :obj:`True`, if the link is primary.
91
+ is_revoked (:obj:`bool`): :obj:`True`, if the link is revoked.
92
+ expire_date (:class:`datetime.datetime`): Optional. Date when the link will expire or
93
+ has been expired.
94
+
95
+ .. versionchanged:: 20.3
96
+ |datetime_localization|
97
+ member_limit (:obj:`int`): Optional. Maximum number of users that can be members
98
+ of the chat simultaneously after joining the chat via this invite link;
99
+ :tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
100
+ :tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
101
+ name (:obj:`str`): Optional. Invite link name.
102
+ 0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
103
+
104
+ .. versionadded:: 13.8
105
+ pending_join_request_count (:obj:`int`): Optional. Number of pending join requests
106
+ created using this link.
107
+
108
+ .. versionadded:: 13.8
109
+ subscription_period (:obj:`int`): Optional. The number of seconds the subscription will be
110
+ active for before the next payment.
111
+
112
+ .. versionadded:: 21.5
113
+ subscription_price (:obj:`int`): Optional. The amount of Telegram Stars a user must pay
114
+ initially and after each subsequent subscription period to be a member of the chat
115
+ using the link.
116
+
117
+ .. versionadded:: 21.5
118
+
119
+ """
120
+
121
+ __slots__ = (
122
+ "creates_join_request",
123
+ "creator",
124
+ "expire_date",
125
+ "invite_link",
126
+ "is_primary",
127
+ "is_revoked",
128
+ "member_limit",
129
+ "name",
130
+ "pending_join_request_count",
131
+ "subscription_period",
132
+ "subscription_price",
133
+ )
134
+
135
+ def __init__(
136
+ self,
137
+ invite_link: str,
138
+ creator: User,
139
+ creates_join_request: bool,
140
+ is_primary: bool,
141
+ is_revoked: bool,
142
+ expire_date: Optional[datetime.datetime] = None,
143
+ member_limit: Optional[int] = None,
144
+ name: Optional[str] = None,
145
+ pending_join_request_count: Optional[int] = None,
146
+ subscription_period: Optional[int] = None,
147
+ subscription_price: Optional[int] = None,
148
+ *,
149
+ api_kwargs: Optional[JSONDict] = None,
150
+ ):
151
+ super().__init__(api_kwargs=api_kwargs)
152
+ # Required
153
+ self.invite_link: str = invite_link
154
+ self.creator: User = creator
155
+ self.creates_join_request: bool = creates_join_request
156
+ self.is_primary: bool = is_primary
157
+ self.is_revoked: bool = is_revoked
158
+
159
+ # Optionals
160
+ self.expire_date: Optional[datetime.datetime] = expire_date
161
+ self.member_limit: Optional[int] = member_limit
162
+ self.name: Optional[str] = name
163
+ self.pending_join_request_count: Optional[int] = (
164
+ int(pending_join_request_count) if pending_join_request_count is not None else None
165
+ )
166
+ self.subscription_period: Optional[int] = subscription_period
167
+ self.subscription_price: Optional[int] = subscription_price
168
+
169
+ self._id_attrs = (
170
+ self.invite_link,
171
+ self.creates_join_request,
172
+ self.creator,
173
+ self.is_primary,
174
+ self.is_revoked,
175
+ )
176
+
177
+ self._freeze()
178
+
179
+ @classmethod
180
+ def de_json(
181
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
182
+ ) -> Optional["ChatInviteLink"]:
183
+ """See :meth:`telegram.TelegramObject.de_json`."""
184
+ data = cls._parse_data(data)
185
+
186
+ if not data:
187
+ return None
188
+
189
+ # Get the local timezone from the bot if it has defaults
190
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
191
+
192
+ data["creator"] = User.de_json(data.get("creator"), bot)
193
+ data["expire_date"] = from_timestamp(data.get("expire_date", None), tzinfo=loc_tzinfo)
194
+
195
+ return super().de_json(data=data, bot=bot)
_chatjoinrequest.py ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram ChatJoinRequest."""
20
+ import datetime
21
+ from typing import TYPE_CHECKING, Optional
22
+
23
+ from telegram._chat import Chat
24
+ from telegram._chatinvitelink import ChatInviteLink
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._user import User
27
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
28
+ from telegram._utils.defaultvalue import DEFAULT_NONE
29
+ from telegram._utils.types import JSONDict, ODVInput
30
+
31
+ if TYPE_CHECKING:
32
+ from telegram import Bot
33
+
34
+
35
+ class ChatJoinRequest(TelegramObject):
36
+ """This object represents a join request sent to a chat.
37
+
38
+ Objects of this class are comparable in terms of equality. Two objects of this class are
39
+ considered equal, if their :attr:`chat`, :attr:`from_user` and :attr:`date` are equal.
40
+
41
+ Note:
42
+ * Since Bot API 5.5, bots are allowed to contact users who sent a join request to a chat
43
+ where the bot is an administrator with the
44
+ :attr:`~telegram.ChatMemberAdministrator.can_invite_users` administrator right - even
45
+ if the user never interacted with the bot before.
46
+ * Telegram does not guarantee that :attr:`from_user.id <from_user>` coincides with the
47
+ ``chat_id`` of the user. Please use :attr:`user_chat_id` to contact the user in
48
+ response to their join request.
49
+
50
+ .. versionadded:: 13.8
51
+ .. versionchanged:: 20.1
52
+ In Bot API 6.5 the argument :paramref:`user_chat_id` was added, which changes the position
53
+ of the optional arguments :paramref:`bio` and :paramref:`invite_link`.
54
+
55
+ Args:
56
+ chat (:class:`telegram.Chat`): Chat to which the request was sent.
57
+ from_user (:class:`telegram.User`): User that sent the join request.
58
+ date (:class:`datetime.datetime`): Date the request was sent.
59
+
60
+ .. versionchanged:: 20.3
61
+ |datetime_localization|
62
+ user_chat_id (:obj:`int`): Identifier of a private chat with the user who sent the join
63
+ request. This number may have more than 32 significant bits and some programming
64
+ languages may have difficulty/silent defects in interpreting it. But it has at most 52
65
+ significant bits, so a 64-bit integer or double-precision float type are safe for
66
+ storing this identifier. The bot can use this identifier for 5 minutes to send messages
67
+ until the join request is processed, assuming no other administrator contacted the
68
+ user.
69
+
70
+ .. versionadded:: 20.1
71
+ bio (:obj:`str`, optional): Bio of the user.
72
+ invite_link (:class:`telegram.ChatInviteLink`, optional): Chat invite link that was used
73
+ by the user to send the join request.
74
+
75
+ Attributes:
76
+ chat (:class:`telegram.Chat`): Chat to which the request was sent.
77
+ from_user (:class:`telegram.User`): User that sent the join request.
78
+ date (:class:`datetime.datetime`): Date the request was sent.
79
+
80
+ .. versionchanged:: 20.3
81
+ |datetime_localization|
82
+ user_chat_id (:obj:`int`): Identifier of a private chat with the user who sent the join
83
+ request. This number may have more than 32 significant bits and some programming
84
+ languages may have difficulty/silent defects in interpreting it. But it has at most 52
85
+ significant bits, so a 64-bit integer or double-precision float type are safe for
86
+ storing this identifier. The bot can use this identifier for 24 hours to send messages
87
+ until the join request is processed, assuming no other administrator contacted the
88
+ user.
89
+
90
+ .. versionadded:: 20.1
91
+ bio (:obj:`str`): Optional. Bio of the user.
92
+ invite_link (:class:`telegram.ChatInviteLink`): Optional. Chat invite link that was used
93
+ by the user to send the join request.
94
+
95
+ Note:
96
+ When a user joins a *public* group via an invite link, this attribute may not
97
+ be present. However, this behavior is undocument and may be subject to change.
98
+ See `this GitHub thread <https://github.com/tdlib/telegram-bot-api/issues/428>`_
99
+ for some discussion.
100
+
101
+ """
102
+
103
+ __slots__ = ("bio", "chat", "date", "from_user", "invite_link", "user_chat_id")
104
+
105
+ def __init__(
106
+ self,
107
+ chat: Chat,
108
+ from_user: User,
109
+ date: datetime.datetime,
110
+ user_chat_id: int,
111
+ bio: Optional[str] = None,
112
+ invite_link: Optional[ChatInviteLink] = None,
113
+ *,
114
+ api_kwargs: Optional[JSONDict] = None,
115
+ ):
116
+ super().__init__(api_kwargs=api_kwargs)
117
+ # Required
118
+ self.chat: Chat = chat
119
+ self.from_user: User = from_user
120
+ self.date: datetime.datetime = date
121
+ self.user_chat_id: int = user_chat_id
122
+
123
+ # Optionals
124
+ self.bio: Optional[str] = bio
125
+ self.invite_link: Optional[ChatInviteLink] = invite_link
126
+
127
+ self._id_attrs = (self.chat, self.from_user, self.date)
128
+
129
+ self._freeze()
130
+
131
+ @classmethod
132
+ def de_json(
133
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
134
+ ) -> Optional["ChatJoinRequest"]:
135
+ """See :meth:`telegram.TelegramObject.de_json`."""
136
+ data = cls._parse_data(data)
137
+
138
+ if not data:
139
+ return None
140
+
141
+ # Get the local timezone from the bot if it has defaults
142
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
143
+
144
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
145
+ data["from_user"] = User.de_json(data.pop("from", None), bot)
146
+ data["date"] = from_timestamp(data.get("date", None), tzinfo=loc_tzinfo)
147
+ data["invite_link"] = ChatInviteLink.de_json(data.get("invite_link"), bot)
148
+
149
+ return super().de_json(data=data, bot=bot)
150
+
151
+ async def approve(
152
+ self,
153
+ *,
154
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
155
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
156
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
157
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
158
+ api_kwargs: Optional[JSONDict] = None,
159
+ ) -> bool:
160
+ """Shortcut for::
161
+
162
+ await bot.approve_chat_join_request(
163
+ chat_id=update.effective_chat.id, user_id=update.effective_user.id, *args, **kwargs
164
+ )
165
+
166
+ For the documentation of the arguments, please see
167
+ :meth:`telegram.Bot.approve_chat_join_request`.
168
+
169
+ Returns:
170
+ :obj:`bool`: On success, :obj:`True` is returned.
171
+
172
+ """
173
+ return await self.get_bot().approve_chat_join_request(
174
+ chat_id=self.chat.id,
175
+ user_id=self.from_user.id,
176
+ read_timeout=read_timeout,
177
+ write_timeout=write_timeout,
178
+ connect_timeout=connect_timeout,
179
+ pool_timeout=pool_timeout,
180
+ api_kwargs=api_kwargs,
181
+ )
182
+
183
+ async def decline(
184
+ self,
185
+ *,
186
+ read_timeout: ODVInput[float] = DEFAULT_NONE,
187
+ write_timeout: ODVInput[float] = DEFAULT_NONE,
188
+ connect_timeout: ODVInput[float] = DEFAULT_NONE,
189
+ pool_timeout: ODVInput[float] = DEFAULT_NONE,
190
+ api_kwargs: Optional[JSONDict] = None,
191
+ ) -> bool:
192
+ """Shortcut for::
193
+
194
+ await bot.decline_chat_join_request(
195
+ chat_id=update.effective_chat.id, user_id=update.effective_user.id, *args, **kwargs
196
+ )
197
+
198
+ For the documentation of the arguments, please see
199
+ :meth:`telegram.Bot.decline_chat_join_request`.
200
+
201
+ Returns:
202
+ :obj:`bool`: On success, :obj:`True` is returned.
203
+
204
+ """
205
+ return await self.get_bot().decline_chat_join_request(
206
+ chat_id=self.chat.id,
207
+ user_id=self.from_user.id,
208
+ read_timeout=read_timeout,
209
+ write_timeout=write_timeout,
210
+ connect_timeout=connect_timeout,
211
+ pool_timeout=pool_timeout,
212
+ api_kwargs=api_kwargs,
213
+ )
_chatlocation.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a location to which a chat is connected."""
20
+
21
+ from typing import TYPE_CHECKING, Final, Optional
22
+
23
+ from telegram import constants
24
+ from telegram._files.location import Location
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._utils.types import JSONDict
27
+
28
+ if TYPE_CHECKING:
29
+ from telegram import Bot
30
+
31
+
32
+ class ChatLocation(TelegramObject):
33
+ """This object represents a location to which a chat is connected.
34
+
35
+ Objects of this class are comparable in terms of equality. Two objects of this class are
36
+ considered equal, if their :attr:`location` is equal.
37
+
38
+ Args:
39
+ location (:class:`telegram.Location`): The location to which the supergroup is connected.
40
+ Can't be a live location.
41
+ address (:obj:`str`): Location address;
42
+ :tg-const:`telegram.ChatLocation.MIN_ADDRESS`-
43
+ :tg-const:`telegram.ChatLocation.MAX_ADDRESS` characters, as defined by the chat owner.
44
+ Attributes:
45
+ location (:class:`telegram.Location`): The location to which the supergroup is connected.
46
+ Can't be a live location.
47
+ address (:obj:`str`): Location address;
48
+ :tg-const:`telegram.ChatLocation.MIN_ADDRESS`-
49
+ :tg-const:`telegram.ChatLocation.MAX_ADDRESS` characters, as defined by the chat owner.
50
+
51
+ """
52
+
53
+ __slots__ = ("address", "location")
54
+
55
+ def __init__(
56
+ self,
57
+ location: Location,
58
+ address: str,
59
+ *,
60
+ api_kwargs: Optional[JSONDict] = None,
61
+ ):
62
+ super().__init__(api_kwargs=api_kwargs)
63
+ self.location: Location = location
64
+ self.address: str = address
65
+
66
+ self._id_attrs = (self.location,)
67
+
68
+ self._freeze()
69
+
70
+ @classmethod
71
+ def de_json(
72
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
73
+ ) -> Optional["ChatLocation"]:
74
+ """See :meth:`telegram.TelegramObject.de_json`."""
75
+ data = cls._parse_data(data)
76
+
77
+ if not data:
78
+ return None
79
+
80
+ data["location"] = Location.de_json(data.get("location"), bot)
81
+
82
+ return super().de_json(data=data, bot=bot)
83
+
84
+ MIN_ADDRESS: Final[int] = constants.LocationLimit.MIN_CHAT_LOCATION_ADDRESS
85
+ """:const:`telegram.constants.LocationLimit.MIN_CHAT_LOCATION_ADDRESS`
86
+
87
+ .. versionadded:: 20.0
88
+ """
89
+ MAX_ADDRESS: Final[int] = constants.LocationLimit.MAX_CHAT_LOCATION_ADDRESS
90
+ """:const:`telegram.constants.LocationLimit.MAX_CHAT_LOCATION_ADDRESS`
91
+
92
+ .. versionadded:: 20.0
93
+ """
_chatmember.py ADDED
@@ -0,0 +1,665 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram ChatMember."""
20
+
21
+ import datetime
22
+ from typing import TYPE_CHECKING, Dict, Final, Optional, Type
23
+
24
+ from telegram import constants
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._user import User
27
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
28
+ from telegram._utils.types import JSONDict
29
+
30
+ if TYPE_CHECKING:
31
+ from telegram import Bot
32
+
33
+
34
+ class ChatMember(TelegramObject):
35
+ """Base class for Telegram ChatMember Objects.
36
+ Currently, the following 6 types of chat members are supported:
37
+
38
+ * :class:`telegram.ChatMemberOwner`
39
+ * :class:`telegram.ChatMemberAdministrator`
40
+ * :class:`telegram.ChatMemberMember`
41
+ * :class:`telegram.ChatMemberRestricted`
42
+ * :class:`telegram.ChatMemberLeft`
43
+ * :class:`telegram.ChatMemberBanned`
44
+
45
+ Objects of this class are comparable in terms of equality. Two objects of this class are
46
+ considered equal, if their :attr:`user` and :attr:`status` are equal.
47
+
48
+ Examples:
49
+ :any:`Chat Member Bot <examples.chatmemberbot>`
50
+
51
+ .. versionchanged:: 20.0
52
+
53
+ * As of Bot API 5.3, :class:`ChatMember` is nothing but the base class for the subclasses
54
+ listed above and is no longer returned directly by :meth:`~telegram.Bot.get_chat`.
55
+ Therefore, most of the arguments and attributes were removed and you should no longer
56
+ use :class:`ChatMember` directly.
57
+ * The constant ``ChatMember.CREATOR`` was replaced by :attr:`~telegram.ChatMember.OWNER`
58
+ * The constant ``ChatMember.KICKED`` was replaced by :attr:`~telegram.ChatMember.BANNED`
59
+
60
+ Args:
61
+ user (:class:`telegram.User`): Information about the user.
62
+ status (:obj:`str`): The member's status in the chat. Can be
63
+ :attr:`~telegram.ChatMember.ADMINISTRATOR`, :attr:`~telegram.ChatMember.OWNER`,
64
+ :attr:`~telegram.ChatMember.BANNED`, :attr:`~telegram.ChatMember.LEFT`,
65
+ :attr:`~telegram.ChatMember.MEMBER` or :attr:`~telegram.ChatMember.RESTRICTED`.
66
+
67
+ Attributes:
68
+ user (:class:`telegram.User`): Information about the user.
69
+ status (:obj:`str`): The member's status in the chat. Can be
70
+ :attr:`~telegram.ChatMember.ADMINISTRATOR`, :attr:`~telegram.ChatMember.OWNER`,
71
+ :attr:`~telegram.ChatMember.BANNED`, :attr:`~telegram.ChatMember.LEFT`,
72
+ :attr:`~telegram.ChatMember.MEMBER` or :attr:`~telegram.ChatMember.RESTRICTED`.
73
+
74
+ """
75
+
76
+ __slots__ = ("status", "user")
77
+
78
+ ADMINISTRATOR: Final[str] = constants.ChatMemberStatus.ADMINISTRATOR
79
+ """:const:`telegram.constants.ChatMemberStatus.ADMINISTRATOR`"""
80
+ OWNER: Final[str] = constants.ChatMemberStatus.OWNER
81
+ """:const:`telegram.constants.ChatMemberStatus.OWNER`"""
82
+ BANNED: Final[str] = constants.ChatMemberStatus.BANNED
83
+ """:const:`telegram.constants.ChatMemberStatus.BANNED`"""
84
+ LEFT: Final[str] = constants.ChatMemberStatus.LEFT
85
+ """:const:`telegram.constants.ChatMemberStatus.LEFT`"""
86
+ MEMBER: Final[str] = constants.ChatMemberStatus.MEMBER
87
+ """:const:`telegram.constants.ChatMemberStatus.MEMBER`"""
88
+ RESTRICTED: Final[str] = constants.ChatMemberStatus.RESTRICTED
89
+ """:const:`telegram.constants.ChatMemberStatus.RESTRICTED`"""
90
+
91
+ def __init__(
92
+ self,
93
+ user: User,
94
+ status: str,
95
+ *,
96
+ api_kwargs: Optional[JSONDict] = None,
97
+ ):
98
+ super().__init__(api_kwargs=api_kwargs)
99
+ # Required by all subclasses
100
+ self.user: User = user
101
+ self.status: str = status
102
+
103
+ self._id_attrs = (self.user, self.status)
104
+
105
+ self._freeze()
106
+
107
+ @classmethod
108
+ def de_json(
109
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
110
+ ) -> Optional["ChatMember"]:
111
+ """See :meth:`telegram.TelegramObject.de_json`."""
112
+ data = cls._parse_data(data)
113
+
114
+ if not data:
115
+ return None
116
+
117
+ _class_mapping: Dict[str, Type[ChatMember]] = {
118
+ cls.OWNER: ChatMemberOwner,
119
+ cls.ADMINISTRATOR: ChatMemberAdministrator,
120
+ cls.MEMBER: ChatMemberMember,
121
+ cls.RESTRICTED: ChatMemberRestricted,
122
+ cls.LEFT: ChatMemberLeft,
123
+ cls.BANNED: ChatMemberBanned,
124
+ }
125
+
126
+ if cls is ChatMember and data.get("status") in _class_mapping:
127
+ return _class_mapping[data.pop("status")].de_json(data=data, bot=bot)
128
+
129
+ data["user"] = User.de_json(data.get("user"), bot)
130
+ if "until_date" in data:
131
+ # Get the local timezone from the bot if it has defaults
132
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
133
+
134
+ data["until_date"] = from_timestamp(data["until_date"], tzinfo=loc_tzinfo)
135
+
136
+ # This is a deprecated field that TG still returns for backwards compatibility
137
+ # Let's filter it out to speed up the de-json process
138
+ if cls is ChatMemberRestricted and data.get("can_send_media_messages") is not None:
139
+ api_kwargs = {"can_send_media_messages": data.pop("can_send_media_messages")}
140
+ return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
141
+
142
+ return super().de_json(data=data, bot=bot)
143
+
144
+
145
+ class ChatMemberOwner(ChatMember):
146
+ """
147
+ Represents a chat member that owns the chat
148
+ and has all administrator privileges.
149
+
150
+ .. versionadded:: 13.7
151
+
152
+ Args:
153
+ user (:class:`telegram.User`): Information about the user.
154
+ is_anonymous (:obj:`bool`): :obj:`True`, if the
155
+ user's presence in the chat is hidden.
156
+ custom_title (:obj:`str`, optional): Custom title for this user.
157
+
158
+ Attributes:
159
+ status (:obj:`str`): The member's status in the chat,
160
+ always :tg-const:`telegram.ChatMember.OWNER`.
161
+ user (:class:`telegram.User`): Information about the user.
162
+ is_anonymous (:obj:`bool`): :obj:`True`, if the user's
163
+ presence in the chat is hidden.
164
+ custom_title (:obj:`str`): Optional. Custom title for
165
+ this user.
166
+ """
167
+
168
+ __slots__ = ("custom_title", "is_anonymous")
169
+
170
+ def __init__(
171
+ self,
172
+ user: User,
173
+ is_anonymous: bool,
174
+ custom_title: Optional[str] = None,
175
+ *,
176
+ api_kwargs: Optional[JSONDict] = None,
177
+ ):
178
+ super().__init__(status=ChatMember.OWNER, user=user, api_kwargs=api_kwargs)
179
+ with self._unfrozen():
180
+ self.is_anonymous: bool = is_anonymous
181
+ self.custom_title: Optional[str] = custom_title
182
+
183
+
184
+ class ChatMemberAdministrator(ChatMember):
185
+ """
186
+ Represents a chat member that has some additional privileges.
187
+
188
+ .. versionadded:: 13.7
189
+ .. versionchanged:: 20.0
190
+
191
+ * Argument and attribute ``can_manage_voice_chats`` were renamed to
192
+ :paramref:`can_manage_video_chats` and :attr:`can_manage_video_chats` in accordance to
193
+ Bot API 6.0.
194
+ * The argument :paramref:`can_manage_topics` was added, which changes the position of the
195
+ optional argument :paramref:`custom_title`.
196
+
197
+ .. versionchanged:: 21.1
198
+ As of this version, :attr:`can_post_stories`, :attr:`can_edit_stories`,
199
+ and :attr:`can_delete_stories` is now required. Thus, the order of arguments had to be
200
+ changed.
201
+
202
+ Args:
203
+ user (:class:`telegram.User`): Information about the user.
204
+ can_be_edited (:obj:`bool`): :obj:`True`, if the bot
205
+ is allowed to edit administrator privileges of that user.
206
+ is_anonymous (:obj:`bool`): :obj:`True`, if the user's
207
+ presence in the chat is hidden.
208
+ can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
209
+ log, get boost list, see hidden supergroup and channel members, report spam messages
210
+ and ignore slow mode. Implied by any other administrator privilege.
211
+ can_delete_messages (:obj:`bool`): :obj:`True`, if the
212
+ administrator can delete messages of other users.
213
+ can_manage_video_chats (:obj:`bool`): :obj:`True`, if the
214
+ administrator can manage video chats.
215
+
216
+ .. versionadded:: 20.0
217
+ can_restrict_members (:obj:`bool`): :obj:`True`, if the
218
+ administrator can restrict, ban or unban chat members.
219
+ can_promote_members (:obj:`bool`): :obj:`True`, if the administrator
220
+ can add new administrators with a subset of his own privileges or demote
221
+ administrators that he has promoted, directly or indirectly (promoted by
222
+ administrators that were appointed by the user).
223
+ can_change_info (:obj:`bool`): :obj:`True`, if the user can change
224
+ the chat title, photo and other settings.
225
+ can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
226
+ new users to the chat.
227
+ can_post_messages (:obj:`bool`, optional): :obj:`True`, if the
228
+ administrator can post messages in the channel, or access channel statistics;
229
+ for channels only.
230
+ can_edit_messages (:obj:`bool`, optional): :obj:`True`, if the
231
+ administrator can edit messages of other users and can pin
232
+ messages; for channels only.
233
+ can_pin_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed
234
+ to pin messages; for groups and supergroups only.
235
+ can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
236
+ stories to the chat.
237
+
238
+ .. versionadded:: 20.6
239
+ .. versionchanged:: 21.0
240
+ |non_optional_story_argument|
241
+ can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit stories posted
242
+ by other users, post stories to the chat page, pin chat stories, and access the chat's
243
+ story archive
244
+
245
+ .. versionadded:: 20.6
246
+ .. versionchanged:: 21.0
247
+ |non_optional_story_argument|
248
+ can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
249
+ stories posted by other users.
250
+
251
+ .. versionadded:: 20.6
252
+ .. versionchanged:: 21.0
253
+ |non_optional_story_argument|
254
+ can_manage_topics (:obj:`bool`, optional): :obj:`True`, if the user is allowed
255
+ to create, rename, close, and reopen forum topics; for supergroups only.
256
+
257
+ .. versionadded:: 20.0
258
+ custom_title (:obj:`str`, optional): Custom title for this user.
259
+
260
+ Attributes:
261
+ status (:obj:`str`): The member's status in the chat,
262
+ always :tg-const:`telegram.ChatMember.ADMINISTRATOR`.
263
+ user (:class:`telegram.User`): Information about the user.
264
+ can_be_edited (:obj:`bool`): :obj:`True`, if the bot
265
+ is allowed to edit administrator privileges of that user.
266
+ is_anonymous (:obj:`bool`): :obj:`True`, if the user's
267
+ presence in the chat is hidden.
268
+ can_manage_chat (:obj:`bool`): :obj:`True`, if the administrator can access the chat event
269
+ log, get boost list, see hidden supergroup and channel members, report spam messages
270
+ and ignore slow mode. Implied by any other administrator privilege.
271
+ can_delete_messages (:obj:`bool`): :obj:`True`, if the
272
+ administrator can delete messages of other users.
273
+ can_manage_video_chats (:obj:`bool`): :obj:`True`, if the
274
+ administrator can manage video chats.
275
+
276
+ .. versionadded:: 20.0
277
+ can_restrict_members (:obj:`bool`): :obj:`True`, if the
278
+ administrator can restrict, ban or unban chat members, or access supergroup statistics.
279
+ can_promote_members (:obj:`bool`): :obj:`True`, if the administrator can add new
280
+ administrators with a subset of their own privileges or demote administrators
281
+ that they have promoted, directly or indirectly (promoted by administrators that
282
+ were appointed by the user).
283
+ can_change_info (:obj:`bool`): :obj:`True`, if the user can change
284
+ the chat title, photo and other settings.
285
+ can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
286
+ new users to the chat.
287
+ can_post_messages (:obj:`bool`): Optional. :obj:`True`, if the
288
+ administrator can post messages in the channel or access channel statistics;
289
+ for channels only.
290
+ can_edit_messages (:obj:`bool`): Optional. :obj:`True`, if the
291
+ administrator can edit messages of other users and can pin
292
+ messages; for channels only.
293
+ can_pin_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
294
+ to pin messages; for groups and supergroups only.
295
+ can_post_stories (:obj:`bool`): :obj:`True`, if the administrator can post
296
+ stories to the chat.
297
+
298
+ .. versionadded:: 20.6
299
+ .. versionchanged:: 21.0
300
+ |non_optional_story_argument|
301
+ can_edit_stories (:obj:`bool`): :obj:`True`, if the administrator can edit stories posted
302
+ by other users, post stories to the chat page, pin chat stories, and access the chat's
303
+ story archive
304
+
305
+ .. versionadded:: 20.6
306
+ .. versionchanged:: 21.0
307
+ |non_optional_story_argument|
308
+ can_delete_stories (:obj:`bool`): :obj:`True`, if the administrator can delete
309
+ stories posted by other users.
310
+
311
+ .. versionadded:: 20.6
312
+ .. versionchanged:: 21.0
313
+ |non_optional_story_argument|
314
+ can_manage_topics (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
315
+ to create, rename, close, and reopen forum topics; for supergroups only
316
+
317
+ .. versionadded:: 20.0
318
+ custom_title (:obj:`str`): Optional. Custom title for this user.
319
+ """
320
+
321
+ __slots__ = (
322
+ "can_be_edited",
323
+ "can_change_info",
324
+ "can_delete_messages",
325
+ "can_delete_stories",
326
+ "can_edit_messages",
327
+ "can_edit_stories",
328
+ "can_invite_users",
329
+ "can_manage_chat",
330
+ "can_manage_topics",
331
+ "can_manage_video_chats",
332
+ "can_pin_messages",
333
+ "can_post_messages",
334
+ "can_post_stories",
335
+ "can_promote_members",
336
+ "can_restrict_members",
337
+ "custom_title",
338
+ "is_anonymous",
339
+ )
340
+
341
+ def __init__(
342
+ self,
343
+ user: User,
344
+ can_be_edited: bool,
345
+ is_anonymous: bool,
346
+ can_manage_chat: bool,
347
+ can_delete_messages: bool,
348
+ can_manage_video_chats: bool,
349
+ can_restrict_members: bool,
350
+ can_promote_members: bool,
351
+ can_change_info: bool,
352
+ can_invite_users: bool,
353
+ can_post_stories: bool,
354
+ can_edit_stories: bool,
355
+ can_delete_stories: bool,
356
+ can_post_messages: Optional[bool] = None,
357
+ can_edit_messages: Optional[bool] = None,
358
+ can_pin_messages: Optional[bool] = None,
359
+ can_manage_topics: Optional[bool] = None,
360
+ custom_title: Optional[str] = None,
361
+ *,
362
+ api_kwargs: Optional[JSONDict] = None,
363
+ ):
364
+ super().__init__(status=ChatMember.ADMINISTRATOR, user=user, api_kwargs=api_kwargs)
365
+ with self._unfrozen():
366
+ self.can_be_edited: bool = can_be_edited
367
+ self.is_anonymous: bool = is_anonymous
368
+ self.can_manage_chat: bool = can_manage_chat
369
+ self.can_delete_messages: bool = can_delete_messages
370
+ self.can_manage_video_chats: bool = can_manage_video_chats
371
+ self.can_restrict_members: bool = can_restrict_members
372
+ self.can_promote_members: bool = can_promote_members
373
+ self.can_change_info: bool = can_change_info
374
+ self.can_invite_users: bool = can_invite_users
375
+ self.can_post_stories: bool = can_post_stories
376
+ self.can_edit_stories: bool = can_edit_stories
377
+ self.can_delete_stories: bool = can_delete_stories
378
+ # Optionals
379
+ self.can_post_messages: Optional[bool] = can_post_messages
380
+ self.can_edit_messages: Optional[bool] = can_edit_messages
381
+ self.can_pin_messages: Optional[bool] = can_pin_messages
382
+ self.can_manage_topics: Optional[bool] = can_manage_topics
383
+ self.custom_title: Optional[str] = custom_title
384
+
385
+
386
+ class ChatMemberMember(ChatMember):
387
+ """
388
+ Represents a chat member that has no additional
389
+ privileges or restrictions.
390
+
391
+ .. versionadded:: 13.7
392
+
393
+ Args:
394
+ user (:class:`telegram.User`): Information about the user.
395
+ until_date (:class:`datetime.datetime`, optional): Date when the user's subscription will
396
+ expire.
397
+
398
+ .. versionadded:: 21.5
399
+
400
+ Attributes:
401
+ status (:obj:`str`): The member's status in the chat,
402
+ always :tg-const:`telegram.ChatMember.MEMBER`.
403
+ user (:class:`telegram.User`): Information about the user.
404
+ until_date (:class:`datetime.datetime`): Optional. Date when the user's subscription will
405
+ expire.
406
+
407
+ .. versionadded:: 21.5
408
+
409
+ """
410
+
411
+ __slots__ = ("until_date",)
412
+
413
+ def __init__(
414
+ self,
415
+ user: User,
416
+ until_date: Optional[datetime.datetime] = None,
417
+ *,
418
+ api_kwargs: Optional[JSONDict] = None,
419
+ ):
420
+ super().__init__(status=ChatMember.MEMBER, user=user, api_kwargs=api_kwargs)
421
+ with self._unfrozen():
422
+ self.until_date: Optional[datetime.datetime] = until_date
423
+
424
+
425
+ class ChatMemberRestricted(ChatMember):
426
+ """
427
+ Represents a chat member that is under certain restrictions
428
+ in the chat. Supergroups only.
429
+
430
+ .. versionadded:: 13.7
431
+ .. versionchanged:: 20.0
432
+ All arguments were made positional and their order was changed.
433
+ The argument can_manage_topics was added.
434
+
435
+ .. versionchanged:: 20.5
436
+ Removed deprecated argument and attribute ``can_send_media_messages``.
437
+
438
+ Args:
439
+ user (:class:`telegram.User`): Information about the user.
440
+ is_member (:obj:`bool`): :obj:`True`, if the user is a
441
+ member of the chat at the moment of the request.
442
+ can_change_info (:obj:`bool`): :obj:`True`, if the user can change
443
+ the chat title, photo and other settings.
444
+ can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
445
+ new users to the chat.
446
+ can_pin_messages (:obj:`bool`): :obj:`True`, if the user is allowed
447
+ to pin messages; groups and supergroups only.
448
+ can_send_messages (:obj:`bool`): :obj:`True`, if the user is allowed
449
+ to send text messages, contacts, invoices, locations and venues.
450
+ can_send_polls (:obj:`bool`): :obj:`True`, if the user is allowed
451
+ to send polls.
452
+ can_send_other_messages (:obj:`bool`): :obj:`True`, if the user is allowed
453
+ to send animations, games, stickers and use inline bots.
454
+ can_add_web_page_previews (:obj:`bool`): :obj:`True`, if the user is
455
+ allowed to add web page previews to their messages.
456
+ can_manage_topics (:obj:`bool`): :obj:`True`, if the user is allowed to create
457
+ forum topics.
458
+
459
+ .. versionadded:: 20.0
460
+ until_date (:class:`datetime.datetime`): Date when restrictions
461
+ will be lifted for this user.
462
+
463
+ .. versionchanged:: 20.3
464
+ |datetime_localization|
465
+ can_send_audios (:obj:`bool`): :obj:`True`, if the user is allowed to send audios.
466
+
467
+ .. versionadded:: 20.1
468
+ can_send_documents (:obj:`bool`): :obj:`True`, if the user is allowed to send documents.
469
+
470
+ .. versionadded:: 20.1
471
+ can_send_photos (:obj:`bool`): :obj:`True`, if the user is allowed to send photos.
472
+
473
+ .. versionadded:: 20.1
474
+ can_send_videos (:obj:`bool`): :obj:`True`, if the user is allowed to send videos.
475
+
476
+ .. versionadded:: 20.1
477
+ can_send_video_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send video
478
+ notes.
479
+
480
+ .. versionadded:: 20.1
481
+ can_send_voice_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send voice
482
+ notes.
483
+
484
+ .. versionadded:: 20.1
485
+
486
+ Attributes:
487
+ status (:obj:`str`): The member's status in the chat,
488
+ always :tg-const:`telegram.ChatMember.RESTRICTED`.
489
+ user (:class:`telegram.User`): Information about the user.
490
+ is_member (:obj:`bool`): :obj:`True`, if the user is a
491
+ member of the chat at the moment of the request.
492
+ can_change_info (:obj:`bool`): :obj:`True`, if the user can change
493
+ the chat title, photo and other settings.
494
+ can_invite_users (:obj:`bool`): :obj:`True`, if the user can invite
495
+ new users to the chat.
496
+ can_pin_messages (:obj:`bool`): :obj:`True`, if the user is allowed
497
+ to pin messages; groups and supergroups only.
498
+ can_send_messages (:obj:`bool`): :obj:`True`, if the user is allowed
499
+ to send text messages, contacts, locations and venues.
500
+ can_send_polls (:obj:`bool`): :obj:`True`, if the user is allowed
501
+ to send polls.
502
+ can_send_other_messages (:obj:`bool`): :obj:`True`, if the user is allowed
503
+ to send animations, games, stickers and use inline bots.
504
+ can_add_web_page_previews (:obj:`bool`): :obj:`True`, if the user is
505
+ allowed to add web page previews to their messages.
506
+ can_manage_topics (:obj:`bool`): :obj:`True`, if the user is allowed to create
507
+ forum topics.
508
+
509
+ .. versionadded:: 20.0
510
+ until_date (:class:`datetime.datetime`): Date when restrictions
511
+ will be lifted for this user.
512
+
513
+ .. versionchanged:: 20.3
514
+ |datetime_localization|
515
+ can_send_audios (:obj:`bool`): :obj:`True`, if the user is allowed to send audios.
516
+
517
+ .. versionadded:: 20.1
518
+ can_send_documents (:obj:`bool`): :obj:`True`, if the user is allowed to send documents.
519
+
520
+ .. versionadded:: 20.1
521
+ can_send_photos (:obj:`bool`): :obj:`True`, if the user is allowed to send photos.
522
+
523
+ .. versionadded:: 20.1
524
+ can_send_videos (:obj:`bool`): :obj:`True`, if the user is allowed to send videos.
525
+
526
+ .. versionadded:: 20.1
527
+ can_send_video_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send video
528
+ notes.
529
+
530
+ .. versionadded:: 20.1
531
+ can_send_voice_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send voice
532
+ notes.
533
+
534
+ .. versionadded:: 20.1
535
+
536
+ """
537
+
538
+ __slots__ = (
539
+ "can_add_web_page_previews",
540
+ "can_change_info",
541
+ "can_invite_users",
542
+ "can_manage_topics",
543
+ "can_pin_messages",
544
+ "can_send_audios",
545
+ "can_send_documents",
546
+ "can_send_messages",
547
+ "can_send_other_messages",
548
+ "can_send_photos",
549
+ "can_send_polls",
550
+ "can_send_video_notes",
551
+ "can_send_videos",
552
+ "can_send_voice_notes",
553
+ "is_member",
554
+ "until_date",
555
+ )
556
+
557
+ def __init__(
558
+ self,
559
+ user: User,
560
+ is_member: bool,
561
+ can_change_info: bool,
562
+ can_invite_users: bool,
563
+ can_pin_messages: bool,
564
+ can_send_messages: bool,
565
+ can_send_polls: bool,
566
+ can_send_other_messages: bool,
567
+ can_add_web_page_previews: bool,
568
+ can_manage_topics: bool,
569
+ until_date: datetime.datetime,
570
+ can_send_audios: bool,
571
+ can_send_documents: bool,
572
+ can_send_photos: bool,
573
+ can_send_videos: bool,
574
+ can_send_video_notes: bool,
575
+ can_send_voice_notes: bool,
576
+ *,
577
+ api_kwargs: Optional[JSONDict] = None,
578
+ ):
579
+ super().__init__(status=ChatMember.RESTRICTED, user=user, api_kwargs=api_kwargs)
580
+ with self._unfrozen():
581
+ self.is_member: bool = is_member
582
+ self.can_change_info: bool = can_change_info
583
+ self.can_invite_users: bool = can_invite_users
584
+ self.can_pin_messages: bool = can_pin_messages
585
+ self.can_send_messages: bool = can_send_messages
586
+ self.can_send_polls: bool = can_send_polls
587
+ self.can_send_other_messages: bool = can_send_other_messages
588
+ self.can_add_web_page_previews: bool = can_add_web_page_previews
589
+ self.can_manage_topics: bool = can_manage_topics
590
+ self.until_date: datetime.datetime = until_date
591
+ self.can_send_audios: bool = can_send_audios
592
+ self.can_send_documents: bool = can_send_documents
593
+ self.can_send_photos: bool = can_send_photos
594
+ self.can_send_videos: bool = can_send_videos
595
+ self.can_send_video_notes: bool = can_send_video_notes
596
+ self.can_send_voice_notes: bool = can_send_voice_notes
597
+
598
+
599
+ class ChatMemberLeft(ChatMember):
600
+ """
601
+ Represents a chat member that isn't currently a member of the chat,
602
+ but may join it themselves.
603
+
604
+ .. versionadded:: 13.7
605
+
606
+ Args:
607
+ user (:class:`telegram.User`): Information about the user.
608
+
609
+ Attributes:
610
+ status (:obj:`str`): The member's status in the chat,
611
+ always :tg-const:`telegram.ChatMember.LEFT`.
612
+ user (:class:`telegram.User`): Information about the user.
613
+ """
614
+
615
+ __slots__ = ()
616
+
617
+ def __init__(
618
+ self,
619
+ user: User,
620
+ *,
621
+ api_kwargs: Optional[JSONDict] = None,
622
+ ):
623
+ super().__init__(status=ChatMember.LEFT, user=user, api_kwargs=api_kwargs)
624
+ self._freeze()
625
+
626
+
627
+ class ChatMemberBanned(ChatMember):
628
+ """
629
+ Represents a chat member that was banned in the chat and
630
+ can't return to the chat or view chat messages.
631
+
632
+ .. versionadded:: 13.7
633
+
634
+ Args:
635
+ user (:class:`telegram.User`): Information about the user.
636
+ until_date (:class:`datetime.datetime`): Date when restrictions
637
+ will be lifted for this user.
638
+
639
+ .. versionchanged:: 20.3
640
+ |datetime_localization|
641
+
642
+ Attributes:
643
+ status (:obj:`str`): The member's status in the chat,
644
+ always :tg-const:`telegram.ChatMember.BANNED`.
645
+ user (:class:`telegram.User`): Information about the user.
646
+ until_date (:class:`datetime.datetime`): Date when restrictions
647
+ will be lifted for this user.
648
+
649
+ .. versionchanged:: 20.3
650
+ |datetime_localization|
651
+
652
+ """
653
+
654
+ __slots__ = ("until_date",)
655
+
656
+ def __init__(
657
+ self,
658
+ user: User,
659
+ until_date: datetime.datetime,
660
+ *,
661
+ api_kwargs: Optional[JSONDict] = None,
662
+ ):
663
+ super().__init__(status=ChatMember.BANNED, user=user, api_kwargs=api_kwargs)
664
+ with self._unfrozen():
665
+ self.until_date: datetime.datetime = until_date
_chatmemberupdated.py ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram ChatMemberUpdated."""
20
+ import datetime
21
+ from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union
22
+
23
+ from telegram._chat import Chat
24
+ from telegram._chatinvitelink import ChatInviteLink
25
+ from telegram._chatmember import ChatMember
26
+ from telegram._telegramobject import TelegramObject
27
+ from telegram._user import User
28
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
29
+ from telegram._utils.types import JSONDict
30
+
31
+ if TYPE_CHECKING:
32
+ from telegram import Bot
33
+
34
+
35
+ class ChatMemberUpdated(TelegramObject):
36
+ """This object represents changes in the status of a chat member.
37
+
38
+ Objects of this class are comparable in terms of equality. Two objects of this class are
39
+ considered equal, if their :attr:`chat`, :attr:`from_user`, :attr:`date`,
40
+ :attr:`old_chat_member` and :attr:`new_chat_member` are equal.
41
+
42
+ .. versionadded:: 13.4
43
+
44
+ Note:
45
+ In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.
46
+
47
+ Examples:
48
+ :any:`Chat Member Bot <examples.chatmemberbot>`
49
+
50
+ Args:
51
+ chat (:class:`telegram.Chat`): Chat the user belongs to.
52
+ from_user (:class:`telegram.User`): Performer of the action, which resulted in the change.
53
+ date (:class:`datetime.datetime`): Date the change was done in Unix time. Converted to
54
+ :class:`datetime.datetime`.
55
+
56
+ .. versionchanged:: 20.3
57
+ |datetime_localization|
58
+ old_chat_member (:class:`telegram.ChatMember`): Previous information about the chat member.
59
+ new_chat_member (:class:`telegram.ChatMember`): New information about the chat member.
60
+ invite_link (:class:`telegram.ChatInviteLink`, optional): Chat invite link, which was used
61
+ by the user to join the chat. For joining by invite link events only.
62
+ via_chat_folder_invite_link (:obj:`bool`, optional): :obj:`True`, if the user joined the
63
+ chat via a chat folder invite link
64
+
65
+ .. versionadded:: 20.3
66
+ via_join_request (:obj:`bool`, optional): :obj:`True`, if the user joined the chat after
67
+ sending a direct join request without using an invite link and being approved by
68
+ an administrator
69
+
70
+ .. versionadded:: 21.2
71
+
72
+ Attributes:
73
+ chat (:class:`telegram.Chat`): Chat the user belongs to.
74
+ from_user (:class:`telegram.User`): Performer of the action, which resulted in the change.
75
+ date (:class:`datetime.datetime`): Date the change was done in Unix time. Converted to
76
+ :class:`datetime.datetime`.
77
+
78
+ .. versionchanged:: 20.3
79
+ |datetime_localization|
80
+ old_chat_member (:class:`telegram.ChatMember`): Previous information about the chat member.
81
+ new_chat_member (:class:`telegram.ChatMember`): New information about the chat member.
82
+ invite_link (:class:`telegram.ChatInviteLink`): Optional. Chat invite link, which was used
83
+ by the user to join the chat. For joining by invite link events only.
84
+ via_chat_folder_invite_link (:obj:`bool`): Optional. :obj:`True`, if the user joined the
85
+ chat via a chat folder invite link
86
+
87
+ .. versionadded:: 20.3
88
+ via_join_request (:obj:`bool`): Optional. :obj:`True`, if the user joined the chat after
89
+ sending a direct join request without using an invite link and being approved
90
+ by an administrator
91
+
92
+ .. versionadded:: 21.2
93
+
94
+ """
95
+
96
+ __slots__ = (
97
+ "chat",
98
+ "date",
99
+ "from_user",
100
+ "invite_link",
101
+ "new_chat_member",
102
+ "old_chat_member",
103
+ "via_chat_folder_invite_link",
104
+ "via_join_request",
105
+ )
106
+
107
+ def __init__(
108
+ self,
109
+ chat: Chat,
110
+ from_user: User,
111
+ date: datetime.datetime,
112
+ old_chat_member: ChatMember,
113
+ new_chat_member: ChatMember,
114
+ invite_link: Optional[ChatInviteLink] = None,
115
+ via_chat_folder_invite_link: Optional[bool] = None,
116
+ via_join_request: Optional[bool] = None,
117
+ *,
118
+ api_kwargs: Optional[JSONDict] = None,
119
+ ):
120
+ super().__init__(api_kwargs=api_kwargs)
121
+ # Required
122
+ self.chat: Chat = chat
123
+ self.from_user: User = from_user
124
+ self.date: datetime.datetime = date
125
+ self.old_chat_member: ChatMember = old_chat_member
126
+ self.new_chat_member: ChatMember = new_chat_member
127
+ self.via_chat_folder_invite_link: Optional[bool] = via_chat_folder_invite_link
128
+
129
+ # Optionals
130
+ self.invite_link: Optional[ChatInviteLink] = invite_link
131
+ self.via_join_request: Optional[bool] = via_join_request
132
+
133
+ self._id_attrs = (
134
+ self.chat,
135
+ self.from_user,
136
+ self.date,
137
+ self.old_chat_member,
138
+ self.new_chat_member,
139
+ )
140
+
141
+ self._freeze()
142
+
143
+ @classmethod
144
+ def de_json(
145
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
146
+ ) -> Optional["ChatMemberUpdated"]:
147
+ """See :meth:`telegram.TelegramObject.de_json`."""
148
+ data = cls._parse_data(data)
149
+
150
+ if not data:
151
+ return None
152
+
153
+ # Get the local timezone from the bot if it has defaults
154
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
155
+
156
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
157
+ data["from_user"] = User.de_json(data.pop("from", None), bot)
158
+ data["date"] = from_timestamp(data.get("date"), tzinfo=loc_tzinfo)
159
+ data["old_chat_member"] = ChatMember.de_json(data.get("old_chat_member"), bot)
160
+ data["new_chat_member"] = ChatMember.de_json(data.get("new_chat_member"), bot)
161
+ data["invite_link"] = ChatInviteLink.de_json(data.get("invite_link"), bot)
162
+
163
+ return super().de_json(data=data, bot=bot)
164
+
165
+ def _get_attribute_difference(self, attribute: str) -> Tuple[object, object]:
166
+ try:
167
+ old = self.old_chat_member[attribute]
168
+ except KeyError:
169
+ old = None
170
+
171
+ try:
172
+ new = self.new_chat_member[attribute]
173
+ except KeyError:
174
+ new = None
175
+
176
+ return old, new
177
+
178
+ def difference(
179
+ self,
180
+ ) -> Dict[
181
+ str,
182
+ Tuple[
183
+ Union[str, bool, datetime.datetime, User], Union[str, bool, datetime.datetime, User]
184
+ ],
185
+ ]:
186
+ """Computes the difference between :attr:`old_chat_member` and :attr:`new_chat_member`.
187
+
188
+ Example:
189
+ .. code:: pycon
190
+
191
+ >>> chat_member_updated.difference()
192
+ {'custom_title': ('old title', 'new title')}
193
+
194
+ Note:
195
+ To determine, if the :attr:`telegram.ChatMember.user` attribute has changed, *every*
196
+ attribute of the user will be checked.
197
+
198
+ .. versionadded:: 13.5
199
+
200
+ Returns:
201
+ Dict[:obj:`str`, Tuple[:class:`object`, :class:`object`]]: A dictionary mapping
202
+ attribute names to tuples of the form ``(old_value, new_value)``
203
+ """
204
+ # we first get the names of the attributes that have changed
205
+ # user.to_dict() is unhashable, so that needs some special casing further down
206
+ old_dict = self.old_chat_member.to_dict()
207
+ old_user_dict = old_dict.pop("user")
208
+ new_dict = self.new_chat_member.to_dict()
209
+ new_user_dict = new_dict.pop("user")
210
+
211
+ # Generator for speed: we only need to iterate over it once
212
+ # we can't directly use the values from old_dict ^ new_dict b/c that set is unordered
213
+ attributes = (entry[0] for entry in set(old_dict.items()) ^ set(new_dict.items()))
214
+
215
+ result = {attribute: self._get_attribute_difference(attribute) for attribute in attributes}
216
+ if old_user_dict != new_user_dict:
217
+ result["user"] = (self.old_chat_member.user, self.new_chat_member.user)
218
+
219
+ return result # type: ignore[return-value]
_chatpermissions.py ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram ChatPermission."""
20
+ from typing import TYPE_CHECKING, Optional
21
+
22
+ from telegram._telegramobject import TelegramObject
23
+ from telegram._utils.types import JSONDict
24
+
25
+ if TYPE_CHECKING:
26
+ from telegram import Bot
27
+
28
+
29
+ class ChatPermissions(TelegramObject):
30
+ """Describes actions that a non-administrator user is allowed to take in a chat.
31
+
32
+ Objects of this class are comparable in terms of equality. Two objects of this class are
33
+ considered equal, if their :attr:`can_send_messages`,
34
+ :attr:`can_send_polls`, :attr:`can_send_other_messages`, :attr:`can_add_web_page_previews`,
35
+ :attr:`can_change_info`, :attr:`can_invite_users`, :attr:`can_pin_messages`,
36
+ :attr:`can_send_audios`, :attr:`can_send_documents`, :attr:`can_send_photos`,
37
+ :attr:`can_send_videos`, :attr:`can_send_video_notes`, :attr:`can_send_voice_notes`, and
38
+ :attr:`can_manage_topics` are equal.
39
+
40
+ .. versionchanged:: 20.0
41
+ :attr:`can_manage_topics` is considered as well when comparing objects of
42
+ this type in terms of equality.
43
+ .. versionchanged:: 20.5
44
+
45
+ * :attr:`can_send_audios`, :attr:`can_send_documents`, :attr:`can_send_photos`,
46
+ :attr:`can_send_videos`, :attr:`can_send_video_notes` and :attr:`can_send_voice_notes`
47
+ are considered as well when comparing objects of this type in terms of equality.
48
+ * Removed deprecated argument and attribute ``can_send_media_messages``.
49
+
50
+
51
+ Note:
52
+ Though not stated explicitly in the official docs, Telegram changes not only the
53
+ permissions that are set, but also sets all the others to :obj:`False`. However, since not
54
+ documented, this behavior may change unbeknown to PTB.
55
+
56
+ Args:
57
+ can_send_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to send text
58
+ messages, contacts, locations and venues.
59
+ can_send_polls (:obj:`bool`, optional): :obj:`True`, if the user is allowed to send polls.
60
+ can_send_other_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to
61
+ send animations, games, stickers and use inline bots.
62
+ can_add_web_page_previews (:obj:`bool`, optional): :obj:`True`, if the user is allowed to
63
+ add web page previews to their messages.
64
+ can_change_info (:obj:`bool`, optional): :obj:`True`, if the user is allowed to change the
65
+ chat title, photo and other settings. Ignored in public supergroups.
66
+ can_invite_users (:obj:`bool`, optional): :obj:`True`, if the user is allowed to invite new
67
+ users to the chat.
68
+ can_pin_messages (:obj:`bool`, optional): :obj:`True`, if the user is allowed to pin
69
+ messages. Ignored in public supergroups.
70
+ can_manage_topics (:obj:`bool`, optional): :obj:`True`, if the user is allowed
71
+ to create forum topics. If omitted defaults to the value of
72
+ :attr:`can_pin_messages`.
73
+
74
+ .. versionadded:: 20.0
75
+ can_send_audios (:obj:`bool`): :obj:`True`, if the user is allowed to send audios.
76
+
77
+ .. versionadded:: 20.1
78
+ can_send_documents (:obj:`bool`): :obj:`True`, if the user is allowed to send documents.
79
+
80
+ .. versionadded:: 20.1
81
+ can_send_photos (:obj:`bool`): :obj:`True`, if the user is allowed to send photos.
82
+
83
+ .. versionadded:: 20.1
84
+ can_send_videos (:obj:`bool`): :obj:`True`, if the user is allowed to send videos.
85
+
86
+ .. versionadded:: 20.1
87
+ can_send_video_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send video
88
+ notes.
89
+
90
+ .. versionadded:: 20.1
91
+ can_send_voice_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send voice
92
+ notes.
93
+
94
+ .. versionadded:: 20.1
95
+
96
+ Attributes:
97
+ can_send_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to send text
98
+ messages, contacts, locations and venues.
99
+ can_send_polls (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to send polls,
100
+ implies :attr:`can_send_messages`.
101
+ can_send_other_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to
102
+ send animations, games, stickers and use inline bots.
103
+ can_add_web_page_previews (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to
104
+ add web page previews to their messages.
105
+ can_change_info (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to change the
106
+ chat title, photo and other settings. Ignored in public supergroups.
107
+ can_invite_users (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to invite
108
+ new users to the chat.
109
+ can_pin_messages (:obj:`bool`): Optional. :obj:`True`, if the user is allowed to pin
110
+ messages. Ignored in public supergroups.
111
+ can_manage_topics (:obj:`bool`): Optional. :obj:`True`, if the user is allowed
112
+ to create forum topics. If omitted defaults to the value of
113
+ :attr:`can_pin_messages`.
114
+
115
+ .. versionadded:: 20.0
116
+ can_send_audios (:obj:`bool`): :obj:`True`, if the user is allowed to send audios.
117
+
118
+ .. versionadded:: 20.1
119
+ can_send_documents (:obj:`bool`): :obj:`True`, if the user is allowed to send documents.
120
+
121
+ .. versionadded:: 20.1
122
+ can_send_photos (:obj:`bool`): :obj:`True`, if the user is allowed to send photos.
123
+
124
+ .. versionadded:: 20.1
125
+ can_send_videos (:obj:`bool`): :obj:`True`, if the user is allowed to send videos.
126
+
127
+ .. versionadded:: 20.1
128
+ can_send_video_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send video
129
+ notes.
130
+
131
+ .. versionadded:: 20.1
132
+ can_send_voice_notes (:obj:`bool`): :obj:`True`, if the user is allowed to send voice
133
+ notes.
134
+
135
+ .. versionadded:: 20.1
136
+
137
+ """
138
+
139
+ __slots__ = (
140
+ "can_add_web_page_previews",
141
+ "can_change_info",
142
+ "can_invite_users",
143
+ "can_manage_topics",
144
+ "can_pin_messages",
145
+ "can_send_audios",
146
+ "can_send_documents",
147
+ "can_send_messages",
148
+ "can_send_other_messages",
149
+ "can_send_photos",
150
+ "can_send_polls",
151
+ "can_send_video_notes",
152
+ "can_send_videos",
153
+ "can_send_voice_notes",
154
+ )
155
+
156
+ def __init__(
157
+ self,
158
+ can_send_messages: Optional[bool] = None,
159
+ can_send_polls: Optional[bool] = None,
160
+ can_send_other_messages: Optional[bool] = None,
161
+ can_add_web_page_previews: Optional[bool] = None,
162
+ can_change_info: Optional[bool] = None,
163
+ can_invite_users: Optional[bool] = None,
164
+ can_pin_messages: Optional[bool] = None,
165
+ can_manage_topics: Optional[bool] = None,
166
+ can_send_audios: Optional[bool] = None,
167
+ can_send_documents: Optional[bool] = None,
168
+ can_send_photos: Optional[bool] = None,
169
+ can_send_videos: Optional[bool] = None,
170
+ can_send_video_notes: Optional[bool] = None,
171
+ can_send_voice_notes: Optional[bool] = None,
172
+ *,
173
+ api_kwargs: Optional[JSONDict] = None,
174
+ ):
175
+ super().__init__(api_kwargs=api_kwargs)
176
+ # Required
177
+ self.can_send_messages: Optional[bool] = can_send_messages
178
+ self.can_send_polls: Optional[bool] = can_send_polls
179
+ self.can_send_other_messages: Optional[bool] = can_send_other_messages
180
+ self.can_add_web_page_previews: Optional[bool] = can_add_web_page_previews
181
+ self.can_change_info: Optional[bool] = can_change_info
182
+ self.can_invite_users: Optional[bool] = can_invite_users
183
+ self.can_pin_messages: Optional[bool] = can_pin_messages
184
+ self.can_manage_topics: Optional[bool] = can_manage_topics
185
+ self.can_send_audios: Optional[bool] = can_send_audios
186
+ self.can_send_documents: Optional[bool] = can_send_documents
187
+ self.can_send_photos: Optional[bool] = can_send_photos
188
+ self.can_send_videos: Optional[bool] = can_send_videos
189
+ self.can_send_video_notes: Optional[bool] = can_send_video_notes
190
+ self.can_send_voice_notes: Optional[bool] = can_send_voice_notes
191
+
192
+ self._id_attrs = (
193
+ self.can_send_messages,
194
+ self.can_send_polls,
195
+ self.can_send_other_messages,
196
+ self.can_add_web_page_previews,
197
+ self.can_change_info,
198
+ self.can_invite_users,
199
+ self.can_pin_messages,
200
+ self.can_manage_topics,
201
+ self.can_send_audios,
202
+ self.can_send_documents,
203
+ self.can_send_photos,
204
+ self.can_send_videos,
205
+ self.can_send_video_notes,
206
+ self.can_send_voice_notes,
207
+ )
208
+
209
+ self._freeze()
210
+
211
+ @classmethod
212
+ def all_permissions(cls) -> "ChatPermissions":
213
+ """
214
+ This method returns an :class:`ChatPermissions` instance with all attributes
215
+ set to :obj:`True`. This is e.g. useful when unrestricting a chat member with
216
+ :meth:`telegram.Bot.restrict_chat_member`.
217
+
218
+ .. versionadded:: 20.0
219
+
220
+ """
221
+ return cls(*(14 * (True,)))
222
+
223
+ @classmethod
224
+ def no_permissions(cls) -> "ChatPermissions":
225
+ """
226
+ This method returns an :class:`ChatPermissions` instance
227
+ with all attributes set to :obj:`False`.
228
+
229
+ .. versionadded:: 20.0
230
+ """
231
+ return cls(*(14 * (False,)))
232
+
233
+ @classmethod
234
+ def de_json(
235
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
236
+ ) -> Optional["ChatPermissions"]:
237
+ """See :meth:`telegram.TelegramObject.de_json`."""
238
+ data = cls._parse_data(data)
239
+
240
+ if not data:
241
+ return None
242
+
243
+ api_kwargs = {}
244
+ # This is a deprecated field that TG still returns for backwards compatibility
245
+ # Let's filter it out to speed up the de-json process
246
+ if data.get("can_send_media_messages") is not None:
247
+ api_kwargs["can_send_media_messages"] = data.pop("can_send_media_messages")
248
+
249
+ return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
_choseninlineresult.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # pylint: disable=too-many-arguments
3
+ #
4
+ # A library that provides a Python interface to the Telegram Bot API
5
+ # Copyright (C) 2015-2024
6
+ # Leandro Toledo de Souza <[email protected]>
7
+ #
8
+ # This program is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser Public License
19
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
20
+ """This module contains an object that represents a Telegram ChosenInlineResult."""
21
+
22
+ from typing import TYPE_CHECKING, Optional
23
+
24
+ from telegram._files.location import Location
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._user import User
27
+ from telegram._utils.types import JSONDict
28
+
29
+ if TYPE_CHECKING:
30
+ from telegram import Bot
31
+
32
+
33
+ class ChosenInlineResult(TelegramObject):
34
+ """
35
+ Represents a result of an inline query that was chosen by the user and sent to their chat
36
+ partner.
37
+
38
+ Objects of this class are comparable in terms of equality. Two objects of this class are
39
+ considered equal, if their :attr:`result_id` is equal.
40
+
41
+ Note:
42
+ * In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.
43
+ * It is necessary to enable inline feedback via `@Botfather <https://t.me/BotFather>`_ in
44
+ order to receive these objects in updates.
45
+
46
+ Args:
47
+ result_id (:obj:`str`): The unique identifier for the result that was chosen.
48
+ from_user (:class:`telegram.User`): The user that chose the result.
49
+ location (:class:`telegram.Location`, optional): Sender location, only for bots that
50
+ require user location.
51
+ inline_message_id (:obj:`str`, optional): Identifier of the sent inline message. Available
52
+ only if there is an inline keyboard attached to the message. Will be also received in
53
+ callback queries and can be used to edit the message.
54
+ query (:obj:`str`): The query that was used to obtain the result.
55
+
56
+ Attributes:
57
+ result_id (:obj:`str`): The unique identifier for the result that was chosen.
58
+ from_user (:class:`telegram.User`): The user that chose the result.
59
+ location (:class:`telegram.Location`): Optional. Sender location, only for bots that
60
+ require user location.
61
+ inline_message_id (:obj:`str`): Optional. Identifier of the sent inline message. Available
62
+ only if there is an inline keyboard attached to the message. Will be also received in
63
+ callback queries and can be used to edit the message.
64
+ query (:obj:`str`): The query that was used to obtain the result.
65
+
66
+ """
67
+
68
+ __slots__ = ("from_user", "inline_message_id", "location", "query", "result_id")
69
+
70
+ def __init__(
71
+ self,
72
+ result_id: str,
73
+ from_user: User,
74
+ query: str,
75
+ location: Optional[Location] = None,
76
+ inline_message_id: Optional[str] = None,
77
+ *,
78
+ api_kwargs: Optional[JSONDict] = None,
79
+ ):
80
+ super().__init__(api_kwargs=api_kwargs)
81
+
82
+ # Required
83
+ self.result_id: str = result_id
84
+ self.from_user: User = from_user
85
+ self.query: str = query
86
+ # Optionals
87
+ self.location: Optional[Location] = location
88
+ self.inline_message_id: Optional[str] = inline_message_id
89
+
90
+ self._id_attrs = (self.result_id,)
91
+
92
+ self._freeze()
93
+
94
+ @classmethod
95
+ def de_json(
96
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
97
+ ) -> Optional["ChosenInlineResult"]:
98
+ """See :meth:`telegram.TelegramObject.de_json`."""
99
+ data = cls._parse_data(data)
100
+
101
+ if not data:
102
+ return None
103
+
104
+ # Required
105
+ data["from_user"] = User.de_json(data.pop("from", None), bot)
106
+ # Optionals
107
+ data["location"] = Location.de_json(data.get("location"), bot)
108
+
109
+ return super().de_json(data=data, bot=bot)
_dice.py ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram Dice."""
20
+ from typing import Final, List, Optional
21
+
22
+ from telegram import constants
23
+ from telegram._telegramobject import TelegramObject
24
+ from telegram._utils.types import JSONDict
25
+
26
+
27
+ class Dice(TelegramObject):
28
+ """
29
+ This object represents an animated emoji with a random value for currently supported base
30
+ emoji. (The singular form of "dice" is "die". However, PTB mimics the Telegram API, which uses
31
+ the term "dice".)
32
+
33
+ Objects of this class are comparable in terms of equality. Two objects of this class are
34
+ considered equal, if their :attr:`value` and :attr:`emoji` are equal.
35
+
36
+ Note:
37
+ If :attr:`emoji` is :tg-const:`telegram.Dice.DARTS`, a value of 6 currently
38
+ represents a bullseye, while a value of 1 indicates that the dartboard was missed.
39
+ However, this behaviour is undocumented and might be changed by Telegram.
40
+
41
+ If :attr:`emoji` is :tg-const:`telegram.Dice.BASKETBALL`, a value of 4 or 5
42
+ currently score a basket, while a value of 1 to 3 indicates that the basket was missed.
43
+ However, this behaviour is undocumented and might be changed by Telegram.
44
+
45
+ If :attr:`emoji` is :tg-const:`telegram.Dice.FOOTBALL`, a value of 4 to 5
46
+ currently scores a goal, while a value of 1 to 3 indicates that the goal was missed.
47
+ However, this behaviour is undocumented and might be changed by Telegram.
48
+
49
+ If :attr:`emoji` is :tg-const:`telegram.Dice.BOWLING`, a value of 6 knocks
50
+ all the pins, while a value of 1 means all the pins were missed.
51
+ However, this behaviour is undocumented and might be changed by Telegram.
52
+
53
+ If :attr:`emoji` is :tg-const:`telegram.Dice.SLOT_MACHINE`, each value
54
+ corresponds to a unique combination of symbols, which
55
+ can be found in our
56
+ :wiki:`wiki <Code-snippets#map-a-slot-machine-dice-value-to-the-corresponding-symbols>`.
57
+ However, this behaviour is undocumented and might be changed by Telegram.
58
+
59
+ ..
60
+ In args, some links for limits of `value` intentionally point to constants for only
61
+ one emoji of a group to avoid duplication. For example, maximum value for Dice, Darts and
62
+ Bowling is linked to a constant for Bowling.
63
+
64
+ Args:
65
+ value (:obj:`int`): Value of the dice.
66
+ :tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BOWLING`
67
+ for :tg-const:`telegram.Dice.DICE`, :tg-const:`telegram.Dice.DARTS` and
68
+ :tg-const:`telegram.Dice.BOWLING` base emoji,
69
+ :tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BASKETBALL`
70
+ for :tg-const:`telegram.Dice.BASKETBALL` and :tg-const:`telegram.Dice.FOOTBALL`
71
+ base emoji,
72
+ :tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_SLOT_MACHINE`
73
+ for :tg-const:`telegram.Dice.SLOT_MACHINE` base emoji.
74
+ emoji (:obj:`str`): Emoji on which the dice throw animation is based.
75
+
76
+ Attributes:
77
+ value (:obj:`int`): Value of the dice.
78
+ :tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BOWLING`
79
+ for :tg-const:`telegram.Dice.DICE`, :tg-const:`telegram.Dice.DARTS` and
80
+ :tg-const:`telegram.Dice.BOWLING` base emoji,
81
+ :tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BASKETBALL`
82
+ for :tg-const:`telegram.Dice.BASKETBALL` and :tg-const:`telegram.Dice.FOOTBALL`
83
+ base emoji,
84
+ :tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_SLOT_MACHINE`
85
+ for :tg-const:`telegram.Dice.SLOT_MACHINE` base emoji.
86
+ emoji (:obj:`str`): Emoji on which the dice throw animation is based.
87
+
88
+ """
89
+
90
+ __slots__ = ("emoji", "value")
91
+
92
+ def __init__(self, value: int, emoji: str, *, api_kwargs: Optional[JSONDict] = None):
93
+ super().__init__(api_kwargs=api_kwargs)
94
+ self.value: int = value
95
+ self.emoji: str = emoji
96
+
97
+ self._id_attrs = (self.value, self.emoji)
98
+
99
+ self._freeze()
100
+
101
+ DICE: Final[str] = constants.DiceEmoji.DICE
102
+ """:const:`telegram.constants.DiceEmoji.DICE`"""
103
+ DARTS: Final[str] = constants.DiceEmoji.DARTS
104
+ """:const:`telegram.constants.DiceEmoji.DARTS`"""
105
+ BASKETBALL: Final[str] = constants.DiceEmoji.BASKETBALL
106
+ """:const:`telegram.constants.DiceEmoji.BASKETBALL`"""
107
+ FOOTBALL: Final[str] = constants.DiceEmoji.FOOTBALL
108
+ """:const:`telegram.constants.DiceEmoji.FOOTBALL`"""
109
+ SLOT_MACHINE: Final[str] = constants.DiceEmoji.SLOT_MACHINE
110
+ """:const:`telegram.constants.DiceEmoji.SLOT_MACHINE`"""
111
+ BOWLING: Final[str] = constants.DiceEmoji.BOWLING
112
+ """
113
+ :const:`telegram.constants.DiceEmoji.BOWLING`
114
+
115
+ .. versionadded:: 13.4
116
+ """
117
+ ALL_EMOJI: Final[List[str]] = list(constants.DiceEmoji)
118
+ """List[:obj:`str`]: A list of all available dice emoji."""
119
+
120
+ MIN_VALUE: Final[int] = constants.DiceLimit.MIN_VALUE
121
+ """:const:`telegram.constants.DiceLimit.MIN_VALUE`
122
+
123
+ .. versionadded:: 20.0
124
+ """
125
+
126
+ MAX_VALUE_BOWLING: Final[int] = constants.DiceLimit.MAX_VALUE_BOWLING
127
+ """:const:`telegram.constants.DiceLimit.MAX_VALUE_BOWLING`
128
+
129
+ .. versionadded:: 20.0
130
+ """
131
+
132
+ MAX_VALUE_DARTS: Final[int] = constants.DiceLimit.MAX_VALUE_DARTS
133
+ """:const:`telegram.constants.DiceLimit.MAX_VALUE_DARTS`
134
+
135
+ .. versionadded:: 20.0
136
+ """
137
+
138
+ MAX_VALUE_DICE: Final[int] = constants.DiceLimit.MAX_VALUE_DICE
139
+ """:const:`telegram.constants.DiceLimit.MAX_VALUE_DICE`
140
+
141
+ .. versionadded:: 20.0
142
+ """
143
+
144
+ MAX_VALUE_BASKETBALL: Final[int] = constants.DiceLimit.MAX_VALUE_BASKETBALL
145
+ """:const:`telegram.constants.DiceLimit.MAX_VALUE_BASKETBALL`
146
+
147
+ .. versionadded:: 20.0
148
+ """
149
+
150
+ MAX_VALUE_FOOTBALL: Final[int] = constants.DiceLimit.MAX_VALUE_FOOTBALL
151
+ """:const:`telegram.constants.DiceLimit.MAX_VALUE_FOOTBALL`
152
+
153
+ .. versionadded:: 20.0
154
+ """
155
+
156
+ MAX_VALUE_SLOT_MACHINE: Final[int] = constants.DiceLimit.MAX_VALUE_SLOT_MACHINE
157
+ """:const:`telegram.constants.DiceLimit.MAX_VALUE_SLOT_MACHINE`
158
+
159
+ .. versionadded:: 20.0
160
+ """
_forcereply.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram ForceReply."""
20
+
21
+ from typing import Final, Optional
22
+
23
+ from telegram import constants
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._utils.types import JSONDict
26
+
27
+
28
+ class ForceReply(TelegramObject):
29
+ """
30
+ Upon receiving a message with this object, Telegram clients will display a reply interface to
31
+ the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be
32
+ extremely useful if you want to create user-friendly step-by-step interfaces without having
33
+ to sacrifice `privacy mode <https://core.telegram.org/bots/features#privacy-mode>`_. Not
34
+ supported in channels and for messages sent on behalf of a Telegram Business account.
35
+
36
+ Objects of this class are comparable in terms of equality. Two objects of this class are
37
+ considered equal, if their :attr:`selective` is equal.
38
+
39
+ .. versionchanged:: 20.0
40
+ The (undocumented) argument ``force_reply`` was removed and instead :attr:`force_reply`
41
+ is now always set to :obj:`True` as expected by the Bot API.
42
+
43
+ Args:
44
+ selective (:obj:`bool`, optional): Use this parameter if you want to force reply from
45
+ specific users only. Targets:
46
+
47
+ 1) Users that are @mentioned in the :attr:`~telegram.Message.text` of the
48
+ :class:`telegram.Message` object.
49
+ 2) If the bot's message is a reply to a message in the same chat and forum topic,
50
+ sender of the original message.
51
+
52
+ input_field_placeholder (:obj:`str`, optional): The placeholder to be shown in the input
53
+ field when the reply is active;
54
+ :tg-const:`telegram.ForceReply.MIN_INPUT_FIELD_PLACEHOLDER`-
55
+ :tg-const:`telegram.ForceReply.MAX_INPUT_FIELD_PLACEHOLDER`
56
+ characters.
57
+
58
+ .. versionadded:: 13.7
59
+
60
+ Attributes:
61
+ force_reply (:obj:`True`): Shows reply interface to the user, as if they manually selected
62
+ the bots message and tapped 'Reply'.
63
+ selective (:obj:`bool`): Optional. Force reply from specific users only. Targets:
64
+
65
+ 1) Users that are @mentioned in the :attr:`~telegram.Message.text` of the
66
+ :class:`telegram.Message` object.
67
+ 2) If the bot's message is a reply to a message in the same chat and forum topic,
68
+ sender of the original message.
69
+ input_field_placeholder (:obj:`str`): Optional. The placeholder to be shown in the input
70
+ field when the reply is active;
71
+ :tg-const:`telegram.ForceReply.MIN_INPUT_FIELD_PLACEHOLDER`-
72
+ :tg-const:`telegram.ForceReply.MAX_INPUT_FIELD_PLACEHOLDER`
73
+ characters.
74
+
75
+ .. versionadded:: 13.7
76
+
77
+ """
78
+
79
+ __slots__ = ("force_reply", "input_field_placeholder", "selective")
80
+
81
+ def __init__(
82
+ self,
83
+ selective: Optional[bool] = None,
84
+ input_field_placeholder: Optional[str] = None,
85
+ *,
86
+ api_kwargs: Optional[JSONDict] = None,
87
+ ):
88
+ super().__init__(api_kwargs=api_kwargs)
89
+ self.force_reply: bool = True
90
+ self.selective: Optional[bool] = selective
91
+ self.input_field_placeholder: Optional[str] = input_field_placeholder
92
+
93
+ self._id_attrs = (self.selective,)
94
+
95
+ self._freeze()
96
+
97
+ MIN_INPUT_FIELD_PLACEHOLDER: Final[int] = constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER
98
+ """:const:`telegram.constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER`
99
+
100
+ .. versionadded:: 20.0
101
+ """
102
+ MAX_INPUT_FIELD_PLACEHOLDER: Final[int] = constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER
103
+ """:const:`telegram.constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER`
104
+
105
+ .. versionadded:: 20.0
106
+ """
_forumtopic.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains objects related to Telegram forum topics."""
20
+ from typing import Optional
21
+
22
+ from telegram._telegramobject import TelegramObject
23
+ from telegram._utils.types import JSONDict
24
+
25
+
26
+ class ForumTopic(TelegramObject):
27
+ """
28
+ This object represents a forum topic.
29
+
30
+ Objects of this class are comparable in terms of equality. Two objects of this class are
31
+ considered equal, if their :attr:`message_thread_id`, :attr:`name` and :attr:`icon_color`
32
+ are equal.
33
+
34
+ .. versionadded:: 20.0
35
+
36
+ Args:
37
+ message_thread_id (:obj:`int`): Unique identifier of the forum topic
38
+ name (:obj:`str`): Name of the topic
39
+ icon_color (:obj:`int`): Color of the topic icon in RGB format
40
+ icon_custom_emoji_id (:obj:`str`, optional): Unique identifier of the custom emoji shown
41
+ as the topic icon.
42
+
43
+ Attributes:
44
+ message_thread_id (:obj:`int`): Unique identifier of the forum topic
45
+ name (:obj:`str`): Name of the topic
46
+ icon_color (:obj:`int`): Color of the topic icon in RGB format
47
+ icon_custom_emoji_id (:obj:`str`): Optional. Unique identifier of the custom emoji shown
48
+ as the topic icon.
49
+ """
50
+
51
+ __slots__ = ("icon_color", "icon_custom_emoji_id", "message_thread_id", "name")
52
+
53
+ def __init__(
54
+ self,
55
+ message_thread_id: int,
56
+ name: str,
57
+ icon_color: int,
58
+ icon_custom_emoji_id: Optional[str] = None,
59
+ *,
60
+ api_kwargs: Optional[JSONDict] = None,
61
+ ):
62
+ super().__init__(api_kwargs=api_kwargs)
63
+ self.message_thread_id: int = message_thread_id
64
+ self.name: str = name
65
+ self.icon_color: int = icon_color
66
+ self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
67
+
68
+ self._id_attrs = (self.message_thread_id, self.name, self.icon_color)
69
+
70
+ self._freeze()
71
+
72
+
73
+ class ForumTopicCreated(TelegramObject):
74
+ """
75
+ This object represents the content of a service message about a new forum topic created in
76
+ the chat.
77
+
78
+ Objects of this class are comparable in terms of equality. Two objects of this class are
79
+ considered equal, if their :attr:`name` and :attr:`icon_color` are equal.
80
+
81
+ .. versionadded:: 20.0
82
+
83
+ Args:
84
+ name (:obj:`str`): Name of the topic
85
+ icon_color (:obj:`int`): Color of the topic icon in RGB format
86
+ icon_custom_emoji_id (:obj:`str`, optional): Unique identifier of the custom emoji shown
87
+ as the topic icon.
88
+
89
+ Attributes:
90
+ name (:obj:`str`): Name of the topic
91
+ icon_color (:obj:`int`): Color of the topic icon in RGB format
92
+ icon_custom_emoji_id (:obj:`str`): Optional. Unique identifier of the custom emoji shown
93
+ as the topic icon.
94
+ """
95
+
96
+ __slots__ = ("icon_color", "icon_custom_emoji_id", "name")
97
+
98
+ def __init__(
99
+ self,
100
+ name: str,
101
+ icon_color: int,
102
+ icon_custom_emoji_id: Optional[str] = None,
103
+ *,
104
+ api_kwargs: Optional[JSONDict] = None,
105
+ ):
106
+ super().__init__(api_kwargs=api_kwargs)
107
+ self.name: str = name
108
+ self.icon_color: int = icon_color
109
+ self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
110
+
111
+ self._id_attrs = (self.name, self.icon_color)
112
+
113
+ self._freeze()
114
+
115
+
116
+ class ForumTopicClosed(TelegramObject):
117
+ """
118
+ This object represents a service message about a forum topic closed in the chat.
119
+ Currently holds no information.
120
+
121
+ .. versionadded:: 20.0
122
+ """
123
+
124
+ __slots__ = ()
125
+
126
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None) -> None:
127
+ super().__init__(api_kwargs=api_kwargs)
128
+
129
+ self._freeze()
130
+
131
+
132
+ class ForumTopicReopened(TelegramObject):
133
+ """
134
+ This object represents a service message about a forum topic reopened in the chat.
135
+ Currently holds no information.
136
+
137
+ .. versionadded:: 20.0
138
+ """
139
+
140
+ __slots__ = ()
141
+
142
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None) -> None:
143
+ super().__init__(api_kwargs=api_kwargs)
144
+
145
+ self._freeze()
146
+
147
+
148
+ class ForumTopicEdited(TelegramObject):
149
+ """
150
+ This object represents a service message about an edited forum topic.
151
+
152
+ Objects of this class are comparable in terms of equality. Two objects of this class are
153
+ considered equal, if their :attr:`name` and :attr:`icon_custom_emoji_id` are equal.
154
+
155
+ .. versionadded:: 20.0
156
+
157
+ Args:
158
+ name (:obj:`str`, optional): New name of the topic, if it was edited.
159
+ icon_custom_emoji_id (:obj:`str`, optional): New identifier of the custom emoji shown as
160
+ the topic icon, if it was edited; an empty string if the icon was removed.
161
+
162
+ Attributes:
163
+ name (:obj:`str`): Optional. New name of the topic, if it was edited.
164
+ icon_custom_emoji_id (:obj:`str`): Optional. New identifier of the custom emoji shown as
165
+ the topic icon, if it was edited; an empty string if the icon was removed.
166
+ """
167
+
168
+ __slots__ = ("icon_custom_emoji_id", "name")
169
+
170
+ def __init__(
171
+ self,
172
+ name: Optional[str] = None,
173
+ icon_custom_emoji_id: Optional[str] = None,
174
+ *,
175
+ api_kwargs: Optional[JSONDict] = None,
176
+ ):
177
+ super().__init__(api_kwargs=api_kwargs)
178
+ self.name: Optional[str] = name
179
+ self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
180
+
181
+ self._id_attrs = (self.name, self.icon_custom_emoji_id)
182
+
183
+ self._freeze()
184
+
185
+
186
+ class GeneralForumTopicHidden(TelegramObject):
187
+ """
188
+ This object represents a service message about General forum topic hidden in the chat.
189
+ Currently holds no information.
190
+
191
+ .. versionadded:: 20.0
192
+ """
193
+
194
+ __slots__ = ()
195
+
196
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
197
+ super().__init__(api_kwargs=api_kwargs)
198
+
199
+ self._freeze()
200
+
201
+
202
+ class GeneralForumTopicUnhidden(TelegramObject):
203
+ """
204
+ This object represents a service message about General forum topic unhidden in the chat.
205
+ Currently holds no information.
206
+
207
+ .. versionadded:: 20.0
208
+ """
209
+
210
+ __slots__ = ()
211
+
212
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
213
+ super().__init__(api_kwargs=api_kwargs)
214
+
215
+ self._freeze()
_giveaway.py ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an objects that are related to Telegram giveaways."""
20
+ import datetime
21
+ from typing import TYPE_CHECKING, Optional, Sequence, Tuple
22
+
23
+ from telegram._chat import Chat
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._user import User
26
+ from telegram._utils.argumentparsing import parse_sequence_arg
27
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
28
+ from telegram._utils.types import JSONDict
29
+
30
+ if TYPE_CHECKING:
31
+ from telegram import Bot, Message
32
+
33
+
34
+ class Giveaway(TelegramObject):
35
+ """This object represents a message about a scheduled giveaway.
36
+
37
+ Objects of this class are comparable in terms of equality. Two objects of this class are
38
+ considered equal, if their :attr:`chats`, :attr:`winners_selection_date` and
39
+ :attr:`winner_count` are equal.
40
+
41
+ .. versionadded:: 20.8
42
+
43
+ Args:
44
+ chats (Tuple[:class:`telegram.Chat`]): The list of chats which the user must join to
45
+ participate in the giveaway.
46
+ winners_selection_date (:class:`datetime.datetime`): The date when the giveaway winner will
47
+ be selected. |datetime_localization|
48
+ winner_count (:obj:`int`): The number of users which are supposed to be selected as winners
49
+ of the giveaway.
50
+ only_new_members (:obj:`True`, optional): If :obj:`True`, only users who join the chats
51
+ after the giveaway started should be eligible to win.
52
+ has_public_winners (:obj:`True`, optional): :obj:`True`, if the list of giveaway winners
53
+ will be visible to everyone
54
+ prize_description (:obj:`str`, optional): Description of additional giveaway prize
55
+ country_codes (Sequence[:obj:`str`]): A list of two-letter ISO 3166-1 alpha-2
56
+ country codes indicating the countries from which eligible users for the giveaway must
57
+ come. If empty, then all users can participate in the giveaway. Users with a phone
58
+ number that was bought on Fragment can always participate in giveaways.
59
+ premium_subscription_month_count (:obj:`int`, optional): The number of months the Telegram
60
+ Premium subscription won from the giveaway will be active for.
61
+
62
+ Attributes:
63
+ chats (Sequence[:class:`telegram.Chat`]): The list of chats which the user must join to
64
+ participate in the giveaway.
65
+ winners_selection_date (:class:`datetime.datetime`): The date when the giveaway winner will
66
+ be selected. |datetime_localization|
67
+ winner_count (:obj:`int`): The number of users which are supposed to be selected as winners
68
+ of the giveaway.
69
+ only_new_members (:obj:`True`): Optional. If :obj:`True`, only users who join the chats
70
+ after the giveaway started should be eligible to win.
71
+ has_public_winners (:obj:`True`): Optional. :obj:`True`, if the list of giveaway winners
72
+ will be visible to everyone
73
+ prize_description (:obj:`str`): Optional. Description of additional giveaway prize
74
+ country_codes (Tuple[:obj:`str`]): Optional. A tuple of two-letter ISO 3166-1 alpha-2
75
+ country codes indicating the countries from which eligible users for the giveaway must
76
+ come. If empty, then all users can participate in the giveaway. Users with a phone
77
+ number that was bought on Fragment can always participate in giveaways.
78
+ premium_subscription_month_count (:obj:`int`): Optional. The number of months the Telegram
79
+ Premium subscription won from the giveaway will be active for.
80
+ """
81
+
82
+ __slots__ = (
83
+ "chats",
84
+ "country_codes",
85
+ "has_public_winners",
86
+ "only_new_members",
87
+ "premium_subscription_month_count",
88
+ "prize_description",
89
+ "winner_count",
90
+ "winners_selection_date",
91
+ )
92
+
93
+ def __init__(
94
+ self,
95
+ chats: Sequence[Chat],
96
+ winners_selection_date: datetime.datetime,
97
+ winner_count: int,
98
+ only_new_members: Optional[bool] = None,
99
+ has_public_winners: Optional[bool] = None,
100
+ prize_description: Optional[str] = None,
101
+ country_codes: Optional[Sequence[str]] = None,
102
+ premium_subscription_month_count: Optional[int] = None,
103
+ *,
104
+ api_kwargs: Optional[JSONDict] = None,
105
+ ):
106
+ super().__init__(api_kwargs=api_kwargs)
107
+
108
+ self.chats: Tuple[Chat, ...] = tuple(chats)
109
+ self.winners_selection_date: datetime.datetime = winners_selection_date
110
+ self.winner_count: int = winner_count
111
+ self.only_new_members: Optional[bool] = only_new_members
112
+ self.has_public_winners: Optional[bool] = has_public_winners
113
+ self.prize_description: Optional[str] = prize_description
114
+ self.country_codes: Tuple[str, ...] = parse_sequence_arg(country_codes)
115
+ self.premium_subscription_month_count: Optional[int] = premium_subscription_month_count
116
+
117
+ self._id_attrs = (
118
+ self.chats,
119
+ self.winners_selection_date,
120
+ self.winner_count,
121
+ )
122
+
123
+ self._freeze()
124
+
125
+ @classmethod
126
+ def de_json(
127
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
128
+ ) -> Optional["Giveaway"]:
129
+ """See :meth:`telegram.TelegramObject.de_json`."""
130
+ data = cls._parse_data(data)
131
+
132
+ if data is None:
133
+ return None
134
+
135
+ # Get the local timezone from the bot if it has defaults
136
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
137
+
138
+ data["chats"] = tuple(Chat.de_list(data.get("chats"), bot))
139
+ data["winners_selection_date"] = from_timestamp(
140
+ data.get("winners_selection_date"), tzinfo=loc_tzinfo
141
+ )
142
+
143
+ return super().de_json(data=data, bot=bot)
144
+
145
+
146
+ class GiveawayCreated(TelegramObject):
147
+ """This object represents a service message about the creation of a scheduled giveaway.
148
+ Currently holds no information.
149
+ """
150
+
151
+ __slots__ = ()
152
+
153
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
154
+ super().__init__(api_kwargs=api_kwargs)
155
+
156
+ self._freeze()
157
+
158
+
159
+ class GiveawayWinners(TelegramObject):
160
+ """This object represents a message about the completion of a giveaway with public winners.
161
+
162
+ Objects of this class are comparable in terms of equality. Two objects of this class are
163
+ considered equal, if their :attr:`chat`, :attr:`giveaway_message_id`,
164
+ :attr:`winners_selection_date`, :attr:`winner_count` and :attr:`winners` are equal.
165
+
166
+ .. versionadded:: 20.8
167
+
168
+ Args:
169
+ chat (:class:`telegram.Chat`): The chat that created the giveaway
170
+ giveaway_message_id (:obj:`int`): Identifier of the message with the giveaway in the chat
171
+ winners_selection_date (:class:`datetime.datetime`): Point in time when winners of the
172
+ giveaway were selected. |datetime_localization|
173
+ winner_count (:obj:`int`): Total number of winners in the giveaway
174
+ winners (Sequence[:class:`telegram.User`]): List of up to
175
+ :tg-const:`telegram.constants.GiveawayLimit.MAX_WINNERS` winners of the giveaway
176
+ additional_chat_count (:obj:`int`, optional): The number of other chats the user had to
177
+ join in order to be eligible for the giveaway
178
+ premium_subscription_month_count (:obj:`int`, optional): The number of months the Telegram
179
+ Premium subscription won from the giveaway will be active for
180
+ unclaimed_prize_count (:obj:`int`, optional): Number of undistributed prizes
181
+ only_new_members (:obj:`True`, optional): :obj:`True`, if only users who had joined the
182
+ chats after the giveaway started were eligible to win
183
+ was_refunded (:obj:`True`, optional): :obj:`True`, if the giveaway was canceled because the
184
+ payment for it was refunded
185
+ prize_description (:obj:`str`, optional): Description of additional giveaway prize
186
+
187
+ Attributes:
188
+ chat (:class:`telegram.Chat`): The chat that created the giveaway
189
+ giveaway_message_id (:obj:`int`): Identifier of the message with the giveaway in the chat
190
+ winners_selection_date (:class:`datetime.datetime`): Point in time when winners of the
191
+ giveaway were selected. |datetime_localization|
192
+ winner_count (:obj:`int`): Total number of winners in the giveaway
193
+ winners (Tuple[:class:`telegram.User`]): tuple of up to
194
+ :tg-const:`telegram.constants.GiveawayLimit.MAX_WINNERS` winners of the giveaway
195
+ additional_chat_count (:obj:`int`): Optional. The number of other chats the user had to
196
+ join in order to be eligible for the giveaway
197
+ premium_subscription_month_count (:obj:`int`): Optional. The number of months the Telegram
198
+ Premium subscription won from the giveaway will be active for
199
+ unclaimed_prize_count (:obj:`int`): Optional. Number of undistributed prizes
200
+ only_new_members (:obj:`True`): Optional. :obj:`True`, if only users who had joined the
201
+ chats after the giveaway started were eligible to win
202
+ was_refunded (:obj:`True`): Optional. :obj:`True`, if the giveaway was canceled because the
203
+ payment for it was refunded
204
+ prize_description (:obj:`str`): Optional. Description of additional giveaway prize
205
+ """
206
+
207
+ __slots__ = (
208
+ "additional_chat_count",
209
+ "chat",
210
+ "giveaway_message_id",
211
+ "only_new_members",
212
+ "premium_subscription_month_count",
213
+ "prize_description",
214
+ "unclaimed_prize_count",
215
+ "was_refunded",
216
+ "winner_count",
217
+ "winners",
218
+ "winners_selection_date",
219
+ )
220
+
221
+ def __init__(
222
+ self,
223
+ chat: Chat,
224
+ giveaway_message_id: int,
225
+ winners_selection_date: datetime.datetime,
226
+ winner_count: int,
227
+ winners: Sequence[User],
228
+ additional_chat_count: Optional[int] = None,
229
+ premium_subscription_month_count: Optional[int] = None,
230
+ unclaimed_prize_count: Optional[int] = None,
231
+ only_new_members: Optional[bool] = None,
232
+ was_refunded: Optional[bool] = None,
233
+ prize_description: Optional[str] = None,
234
+ *,
235
+ api_kwargs: Optional[JSONDict] = None,
236
+ ):
237
+ super().__init__(api_kwargs=api_kwargs)
238
+
239
+ self.chat: Chat = chat
240
+ self.giveaway_message_id: int = giveaway_message_id
241
+ self.winners_selection_date: datetime.datetime = winners_selection_date
242
+ self.winner_count: int = winner_count
243
+ self.winners: Tuple[User, ...] = tuple(winners)
244
+ self.additional_chat_count: Optional[int] = additional_chat_count
245
+ self.premium_subscription_month_count: Optional[int] = premium_subscription_month_count
246
+ self.unclaimed_prize_count: Optional[int] = unclaimed_prize_count
247
+ self.only_new_members: Optional[bool] = only_new_members
248
+ self.was_refunded: Optional[bool] = was_refunded
249
+ self.prize_description: Optional[str] = prize_description
250
+
251
+ self._id_attrs = (
252
+ self.chat,
253
+ self.giveaway_message_id,
254
+ self.winners_selection_date,
255
+ self.winner_count,
256
+ self.winners,
257
+ )
258
+
259
+ self._freeze()
260
+
261
+ @classmethod
262
+ def de_json(
263
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
264
+ ) -> Optional["GiveawayWinners"]:
265
+ """See :meth:`telegram.TelegramObject.de_json`."""
266
+ data = cls._parse_data(data)
267
+
268
+ if data is None:
269
+ return None
270
+
271
+ # Get the local timezone from the bot if it has defaults
272
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
273
+
274
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
275
+ data["winners"] = tuple(User.de_list(data.get("winners"), bot))
276
+ data["winners_selection_date"] = from_timestamp(
277
+ data.get("winners_selection_date"), tzinfo=loc_tzinfo
278
+ )
279
+
280
+ return super().de_json(data=data, bot=bot)
281
+
282
+
283
+ class GiveawayCompleted(TelegramObject):
284
+ """This object represents a service message about the completion of a giveaway without public
285
+ winners.
286
+
287
+ Objects of this class are comparable in terms of equality. Two objects of this class are
288
+ considered equal, if their :attr:`winner_count` and :attr:`unclaimed_prize_count` are equal.
289
+
290
+ .. versionadded:: 20.8
291
+
292
+
293
+ Args:
294
+ winner_count (:obj:`int`): Number of winners in the giveaway
295
+ unclaimed_prize_count (:obj:`int`, optional): Number of undistributed prizes
296
+ giveaway_message (:class:`telegram.Message`, optional): Message with the giveaway that was
297
+ completed, if it wasn't deleted
298
+
299
+ Attributes:
300
+ winner_count (:obj:`int`): Number of winners in the giveaway
301
+ unclaimed_prize_count (:obj:`int`): Optional. Number of undistributed prizes
302
+ giveaway_message (:class:`telegram.Message`): Optional. Message with the giveaway that was
303
+ completed, if it wasn't deleted
304
+ """
305
+
306
+ __slots__ = ("giveaway_message", "unclaimed_prize_count", "winner_count")
307
+
308
+ def __init__(
309
+ self,
310
+ winner_count: int,
311
+ unclaimed_prize_count: Optional[int] = None,
312
+ giveaway_message: Optional["Message"] = None,
313
+ *,
314
+ api_kwargs: Optional[JSONDict] = None,
315
+ ):
316
+ super().__init__(api_kwargs=api_kwargs)
317
+
318
+ self.winner_count: int = winner_count
319
+ self.unclaimed_prize_count: Optional[int] = unclaimed_prize_count
320
+ self.giveaway_message: Optional[Message] = giveaway_message
321
+
322
+ self._id_attrs = (
323
+ self.winner_count,
324
+ self.unclaimed_prize_count,
325
+ )
326
+
327
+ self._freeze()
328
+
329
+ @classmethod
330
+ def de_json(
331
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
332
+ ) -> Optional["GiveawayCompleted"]:
333
+ """See :meth:`telegram.TelegramObject.de_json`."""
334
+ data = cls._parse_data(data)
335
+
336
+ if data is None:
337
+ return None
338
+
339
+ # Unfortunately, this needs to be here due to cyclic imports
340
+ from telegram._message import Message # pylint: disable=import-outside-toplevel
341
+
342
+ data["giveaway_message"] = Message.de_json(data.get("giveaway_message"), bot)
343
+
344
+ return super().de_json(data=data, bot=bot)
_keyboardbutton.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram KeyboardButton."""
20
+
21
+ from typing import TYPE_CHECKING, Optional
22
+
23
+ from telegram._keyboardbuttonpolltype import KeyboardButtonPollType
24
+ from telegram._keyboardbuttonrequest import KeyboardButtonRequestChat, KeyboardButtonRequestUsers
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._utils.types import JSONDict
27
+ from telegram._webappinfo import WebAppInfo
28
+
29
+ if TYPE_CHECKING:
30
+ from telegram import Bot
31
+
32
+
33
+ class KeyboardButton(TelegramObject):
34
+ """
35
+ This object represents one button of the reply keyboard. At most one of the optional fields
36
+ must be used to specify type of the button. For simple text buttons, :obj:`str`
37
+ can be used instead of this object to specify text of the button.
38
+
39
+ Objects of this class are comparable in terms of equality. Two objects of this class are
40
+ considered equal, if their :attr:`text`, :attr:`request_contact`, :attr:`request_location`,
41
+ :attr:`request_poll`, :attr:`web_app`, :attr:`request_users` and :attr:`request_chat` are
42
+ equal.
43
+
44
+ Note:
45
+ * Optional fields are mutually exclusive.
46
+ * :attr:`request_contact` and :attr:`request_location` options will only work in Telegram
47
+ versions released after 9 April, 2016. Older clients will display unsupported message.
48
+ * :attr:`request_poll` option will only work in Telegram versions released after 23
49
+ January, 2020. Older clients will display unsupported message.
50
+ * :attr:`web_app` option will only work in Telegram versions released after 16 April, 2022.
51
+ Older clients will display unsupported message.
52
+ * :attr:`request_users` and :attr:`request_chat` options will only work in Telegram
53
+ versions released after 3 February, 2023. Older clients will display unsupported
54
+ message.
55
+
56
+ .. versionchanged:: 21.0
57
+ Removed deprecated argument and attribute ``request_user``.
58
+ .. versionchanged:: 20.0
59
+ :attr:`web_app` is considered as well when comparing objects of this type in terms of
60
+ equality.
61
+ .. versionchanged:: 20.5
62
+ :attr:`request_users` and :attr:`request_chat` are considered as well when
63
+ comparing objects of this type in terms of equality.
64
+
65
+ Args:
66
+ text (:obj:`str`): Text of the button. If none of the optional fields are used, it will be
67
+ sent to the bot as a message when the button is pressed.
68
+ request_contact (:obj:`bool`, optional): If :obj:`True`, the user's phone number will be
69
+ sent as a contact when the button is pressed. Available in private chats only.
70
+ request_location (:obj:`bool`, optional): If :obj:`True`, the user's current location will
71
+ be sent when the button is pressed. Available in private chats only.
72
+ request_poll (:class:`~telegram.KeyboardButtonPollType`, optional): If specified, the user
73
+ will be asked to create a poll and send it to the bot when the button is pressed.
74
+ Available in private chats only.
75
+ web_app (:class:`~telegram.WebAppInfo`, optional): If specified, the described `Web App
76
+ <https://core.telegram.org/bots/webapps>`_ will be launched when the button is pressed.
77
+ The Web App will be able to send a :attr:`Message.web_app_data` service message.
78
+ Available in private chats only.
79
+
80
+ .. versionadded:: 20.0
81
+
82
+ request_users (:class:`KeyboardButtonRequestUsers`, optional): If specified, pressing the
83
+ button will open a list of suitable users. Tapping on any user will send its
84
+ identifier to the bot in a :attr:`telegram.Message.users_shared` service message.
85
+ Available in private chats only.
86
+
87
+ .. versionadded:: 20.8
88
+ request_chat (:class:`KeyboardButtonRequestChat`, optional): If specified, pressing the
89
+ button will open a list of suitable chats. Tapping on a chat will send its
90
+ identifier to the bot in a :attr:`telegram.Message.chat_shared` service message.
91
+ Available in private chats only.
92
+
93
+ .. versionadded:: 20.1
94
+ Attributes:
95
+ text (:obj:`str`): Text of the button. If none of the optional fields are used, it will be
96
+ sent to the bot as a message when the button is pressed.
97
+ request_contact (:obj:`bool`): Optional. If :obj:`True`, the user's phone number will be
98
+ sent as a contact when the button is pressed. Available in private chats only.
99
+ request_location (:obj:`bool`): Optional. If :obj:`True`, the user's current location will
100
+ be sent when the button is pressed. Available in private chats only.
101
+ request_poll (:class:`~telegram.KeyboardButtonPollType`): Optional. If specified,
102
+ the user will be asked to create a poll and send it to the bot when the button is
103
+ pressed. Available in private chats only.
104
+ web_app (:class:`~telegram.WebAppInfo`): Optional. If specified, the described `Web App
105
+ <https://core.telegram.org/bots/webapps>`_ will be launched when the button is pressed.
106
+ The Web App will be able to send a :attr:`Message.web_app_data` service message.
107
+ Available in private chats only.
108
+
109
+ .. versionadded:: 20.0
110
+ request_users (:class:`KeyboardButtonRequestUsers`): Optional. If specified, pressing the
111
+ button will open a list of suitable users. Tapping on any user will send its
112
+ identifier to the bot in a :attr:`telegram.Message.users_shared` service message.
113
+ Available in private chats only.
114
+
115
+ .. versionadded:: 20.8
116
+ request_chat (:class:`KeyboardButtonRequestChat`): Optional. If specified, pressing the
117
+ button will open a list of suitable chats. Tapping on a chat will send its
118
+ identifier to the bot in a :attr:`telegram.Message.chat_shared` service message.
119
+ Available in private chats only.
120
+
121
+ .. versionadded:: 20.1
122
+ """
123
+
124
+ __slots__ = (
125
+ "request_chat",
126
+ "request_contact",
127
+ "request_location",
128
+ "request_poll",
129
+ "request_users",
130
+ "text",
131
+ "web_app",
132
+ )
133
+
134
+ def __init__(
135
+ self,
136
+ text: str,
137
+ request_contact: Optional[bool] = None,
138
+ request_location: Optional[bool] = None,
139
+ request_poll: Optional[KeyboardButtonPollType] = None,
140
+ web_app: Optional[WebAppInfo] = None,
141
+ request_chat: Optional[KeyboardButtonRequestChat] = None,
142
+ request_users: Optional[KeyboardButtonRequestUsers] = None,
143
+ *,
144
+ api_kwargs: Optional[JSONDict] = None,
145
+ ):
146
+ super().__init__(api_kwargs=api_kwargs)
147
+
148
+ # Required
149
+ self.text: str = text
150
+ # Optionals
151
+ self.request_contact: Optional[bool] = request_contact
152
+ self.request_location: Optional[bool] = request_location
153
+ self.request_poll: Optional[KeyboardButtonPollType] = request_poll
154
+ self.web_app: Optional[WebAppInfo] = web_app
155
+ self.request_users: Optional[KeyboardButtonRequestUsers] = request_users
156
+ self.request_chat: Optional[KeyboardButtonRequestChat] = request_chat
157
+
158
+ self._id_attrs = (
159
+ self.text,
160
+ self.request_contact,
161
+ self.request_location,
162
+ self.request_poll,
163
+ self.web_app,
164
+ self.request_users,
165
+ self.request_chat,
166
+ )
167
+
168
+ self._freeze()
169
+
170
+ @classmethod
171
+ def de_json(
172
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
173
+ ) -> Optional["KeyboardButton"]:
174
+ """See :meth:`telegram.TelegramObject.de_json`."""
175
+ data = cls._parse_data(data)
176
+
177
+ if not data:
178
+ return None
179
+
180
+ data["request_poll"] = KeyboardButtonPollType.de_json(data.get("request_poll"), bot)
181
+ data["request_users"] = KeyboardButtonRequestUsers.de_json(data.get("request_users"), bot)
182
+ data["request_chat"] = KeyboardButtonRequestChat.de_json(data.get("request_chat"), bot)
183
+ data["web_app"] = WebAppInfo.de_json(data.get("web_app"), bot)
184
+
185
+ api_kwargs = {}
186
+ # This is a deprecated field that TG still returns for backwards compatibility
187
+ # Let's filter it out to speed up the de-json process
188
+ if request_user := data.get("request_user"):
189
+ api_kwargs = {"request_user": request_user}
190
+
191
+ return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
_keyboardbuttonpolltype.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a type of a Telegram Poll."""
20
+ from typing import Optional
21
+
22
+ from telegram._telegramobject import TelegramObject
23
+ from telegram._utils import enum
24
+ from telegram._utils.types import JSONDict
25
+ from telegram.constants import PollType
26
+
27
+
28
+ class KeyboardButtonPollType(TelegramObject):
29
+ """This object represents type of a poll, which is allowed to be created
30
+ and sent when the corresponding button is pressed.
31
+
32
+ Objects of this class are comparable in terms of equality. Two objects of this class are
33
+ considered equal, if their :attr:`type` is equal.
34
+
35
+ Examples:
36
+ :any:`Poll Bot <examples.pollbot>`
37
+
38
+ Args:
39
+ type (:obj:`str`, optional): If :tg-const:`telegram.Poll.QUIZ` is passed, the user will be
40
+ allowed to create only polls in the quiz mode. If :tg-const:`telegram.Poll.REGULAR` is
41
+ passed, only regular polls will be allowed. Otherwise, the user will be allowed to
42
+ create a poll of any type.
43
+ Attributes:
44
+ type (:obj:`str`): Optional. If equals :tg-const:`telegram.Poll.QUIZ`, the user will
45
+ be allowed to create only polls in the quiz mode. If equals
46
+ :tg-const:`telegram.Poll.REGULAR`, only regular polls will be allowed.
47
+ Otherwise, the user will be allowed to create a poll of any type.
48
+ """
49
+
50
+ __slots__ = ("type",)
51
+
52
+ def __init__(
53
+ self,
54
+ type: Optional[str] = None, # pylint: disable=redefined-builtin
55
+ *,
56
+ api_kwargs: Optional[JSONDict] = None,
57
+ ):
58
+ super().__init__(api_kwargs=api_kwargs)
59
+ self.type: Optional[str] = enum.get_member(PollType, type, type)
60
+
61
+ self._id_attrs = (self.type,)
62
+
63
+ self._freeze()
_keyboardbuttonrequest.py ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains two objects to request chats/users."""
20
+
21
+ from typing import TYPE_CHECKING, Optional
22
+
23
+ from telegram._chatadministratorrights import ChatAdministratorRights
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._utils.types import JSONDict
26
+
27
+ if TYPE_CHECKING:
28
+ from telegram import Bot
29
+
30
+
31
+ class KeyboardButtonRequestUsers(TelegramObject):
32
+ """This object defines the criteria used to request a suitable user. The identifier of the
33
+ selected user will be shared with the bot when the corresponding button is pressed. `More
34
+ about requesting users » <https://core.telegram.org/bots/features#chat-and-user-selection>`_.
35
+
36
+ Objects of this class are comparable in terms of equality. Two objects of this class are
37
+ considered equal, if their :attr:`request_id` is equal.
38
+
39
+ .. versionadded:: 20.8
40
+ This class was previously named ``KeyboardButtonRequestUser``.
41
+
42
+ Args:
43
+ request_id (:obj:`int`): Signed 32-bit identifier of the request, which will be received
44
+ back in the :class:`telegram.UsersShared` object. Must be unique within the message.
45
+ user_is_bot (:obj:`bool`, optional): Pass :obj:`True` to request a bot, pass :obj:`False`
46
+ to request a regular user. If not specified, no additional restrictions are applied.
47
+ user_is_premium (:obj:`bool`, optional): Pass :obj:`True` to request a premium user, pass
48
+ :obj:`False` to request a non-premium user. If not specified, no additional
49
+ restrictions are applied.
50
+ max_quantity (:obj:`int`, optional): The maximum number of users to be selected;
51
+ :tg-const:`telegram.constants.KeyboardButtonRequestUsersLimit.MIN_QUANTITY` -
52
+ :tg-const:`telegram.constants.KeyboardButtonRequestUsersLimit.MAX_QUANTITY`.
53
+ Defaults to :tg-const:`telegram.constants.KeyboardButtonRequestUsersLimit.MIN_QUANTITY`
54
+ .
55
+
56
+ .. versionadded:: 20.8
57
+ request_name (:obj:`bool`, optional): Pass :obj:`True` to request the users' first and last
58
+ name.
59
+
60
+ .. versionadded:: 21.1
61
+ request_username (:obj:`bool`, optional): Pass :obj:`True` to request the users' username.
62
+
63
+ .. versionadded:: 21.1
64
+ request_photo (:obj:`bool`, optional): Pass :obj:`True` to request the users' photo.
65
+
66
+ .. versionadded:: 21.1
67
+
68
+ Attributes:
69
+ request_id (:obj:`int`): Identifier of the request.
70
+ user_is_bot (:obj:`bool`): Optional. Pass :obj:`True` to request a bot, pass :obj:`False`
71
+ to request a regular user. If not specified, no additional restrictions are applied.
72
+ user_is_premium (:obj:`bool`): Optional. Pass :obj:`True` to request a premium user, pass
73
+ :obj:`False` to request a non-premium user. If not specified, no additional
74
+ restrictions are applied.
75
+ max_quantity (:obj:`int`): Optional. The maximum number of users to be selected;
76
+ :tg-const:`telegram.constants.KeyboardButtonRequestUsersLimit.MIN_QUANTITY` -
77
+ :tg-const:`telegram.constants.KeyboardButtonRequestUsersLimit.MAX_QUANTITY`.
78
+ Defaults to :tg-const:`telegram.constants.KeyboardButtonRequestUsersLimit.MIN_QUANTITY`
79
+ .
80
+
81
+ .. versionadded:: 20.8
82
+ request_name (:obj:`bool`): Optional. Pass :obj:`True` to request the users' first and last
83
+ name.
84
+
85
+ .. versionadded:: 21.1
86
+ request_username (:obj:`bool`): Optional. Pass :obj:`True` to request the users' username.
87
+
88
+ .. versionadded:: 21.1
89
+ request_photo (:obj:`bool`): Optional. Pass :obj:`True` to request the users' photo.
90
+
91
+ .. versionadded:: 21.1
92
+
93
+ """
94
+
95
+ __slots__ = (
96
+ "max_quantity",
97
+ "request_id",
98
+ "request_name",
99
+ "request_photo",
100
+ "request_username",
101
+ "user_is_bot",
102
+ "user_is_premium",
103
+ )
104
+
105
+ def __init__(
106
+ self,
107
+ request_id: int,
108
+ user_is_bot: Optional[bool] = None,
109
+ user_is_premium: Optional[bool] = None,
110
+ max_quantity: Optional[int] = None,
111
+ request_name: Optional[bool] = None,
112
+ request_username: Optional[bool] = None,
113
+ request_photo: Optional[bool] = None,
114
+ *,
115
+ api_kwargs: Optional[JSONDict] = None,
116
+ ):
117
+ super().__init__(api_kwargs=api_kwargs)
118
+ # Required
119
+ self.request_id: int = request_id
120
+
121
+ # Optionals
122
+ self.user_is_bot: Optional[bool] = user_is_bot
123
+ self.user_is_premium: Optional[bool] = user_is_premium
124
+ self.max_quantity: Optional[int] = max_quantity
125
+ self.request_name: Optional[bool] = request_name
126
+ self.request_username: Optional[bool] = request_username
127
+ self.request_photo: Optional[bool] = request_photo
128
+
129
+ self._id_attrs = (self.request_id,)
130
+
131
+ self._freeze()
132
+
133
+
134
+ class KeyboardButtonRequestChat(TelegramObject):
135
+ """This object defines the criteria used to request a suitable chat. The identifier of the
136
+ selected user will be shared with the bot when the corresponding button is pressed. `More
137
+ about requesting users » <https://core.telegram.org/bots/features#chat-and-user-selection>`_.
138
+
139
+ Objects of this class are comparable in terms of equality. Two objects of this class are
140
+ considered equal, if their :attr:`request_id` is equal.
141
+
142
+ .. versionadded:: 20.1
143
+
144
+ Args:
145
+ request_id (:obj:`int`): Signed 32-bit identifier of the request, which will be received
146
+ back in the :class:`telegram.ChatShared` object. Must be unique within the message.
147
+ chat_is_channel (:obj:`bool`): Pass :obj:`True` to request a channel chat, pass
148
+ :obj:`False` to request a group or a supergroup chat.
149
+ chat_is_forum (:obj:`bool`, optional): Pass :obj:`True` to request a forum supergroup, pass
150
+ :obj:`False` to request a non-forum chat. If not specified, no additional
151
+ restrictions are applied.
152
+ chat_has_username (:obj:`bool`, optional): Pass :obj:`True` to request a supergroup or a
153
+ channel with a username, pass :obj:`False` to request a chat without a username. If
154
+ not specified, no additional restrictions are applied.
155
+ chat_is_created (:obj:`bool`, optional): Pass :obj:`True` to request a chat owned by the
156
+ user. Otherwise, no additional restrictions are applied.
157
+ user_administrator_rights (:class:`ChatAdministratorRights`, optional): Specifies the
158
+ required administrator rights of the user in the chat. If not specified, no additional
159
+ restrictions are applied.
160
+ bot_administrator_rights (:class:`ChatAdministratorRights`, optional): Specifies the
161
+ required administrator rights of the bot in the chat. The rights must be a subset of
162
+ :paramref:`user_administrator_rights`. If not specified, no additional restrictions are
163
+ applied.
164
+ bot_is_member (:obj:`bool`, optional): Pass :obj:`True` to request a chat with the bot
165
+ as a member. Otherwise, no additional restrictions are applied.
166
+ request_title (:obj:`bool`, optional): Pass :obj:`True` to request the chat's title.
167
+
168
+ .. versionadded:: 21.1
169
+ request_username (:obj:`bool`, optional): Pass :obj:`True` to request the chat's username.
170
+
171
+ .. versionadded:: 21.1
172
+ request_photo (:obj:`bool`, optional): Pass :obj:`True` to request the chat's photo.
173
+
174
+ .. versionadded:: 21.1
175
+ Attributes:
176
+ request_id (:obj:`int`): Identifier of the request.
177
+ chat_is_channel (:obj:`bool`): Pass :obj:`True` to request a channel chat, pass
178
+ :obj:`False` to request a group or a supergroup chat.
179
+ chat_is_forum (:obj:`bool`): Optional. Pass :obj:`True` to request a forum supergroup, pass
180
+ :obj:`False` to request a non-forum chat. If not specified, no additional
181
+ restrictions are applied.
182
+ chat_has_username (:obj:`bool`): Optional. Pass :obj:`True` to request a supergroup or a
183
+ channel with a username, pass :obj:`False` to request a chat without a username. If
184
+ not specified, no additional restrictions are applied.
185
+ chat_is_created (:obj:`bool`) Optional. Pass :obj:`True` to request a chat owned by the
186
+ user. Otherwise, no additional restrictions are applied.
187
+ user_administrator_rights (:class:`ChatAdministratorRights`) Optional. Specifies the
188
+ required administrator rights of the user in the chat. If not specified, no additional
189
+ restrictions are applied.
190
+ bot_administrator_rights (:class:`ChatAdministratorRights`) Optional. Specifies the
191
+ required administrator rights of the bot in the chat. The rights must be a subset of
192
+ :attr:`user_administrator_rights`. If not specified, no additional restrictions are
193
+ applied.
194
+ bot_is_member (:obj:`bool`) Optional. Pass :obj:`True` to request a chat with the bot
195
+ as a member. Otherwise, no additional restrictions are applied.
196
+ request_title (:obj:`bool`): Optional. Pass :obj:`True` to request the chat's title.
197
+
198
+ .. versionadded:: 21.1
199
+ request_username (:obj:`bool`): Optional. Pass :obj:`True` to request the chat's username.
200
+
201
+ .. versionadded:: 21.1
202
+ request_photo (:obj:`bool`): Optional. Pass :obj:`True` to request the chat's photo.
203
+
204
+ .. versionadded:: 21.1
205
+ """
206
+
207
+ __slots__ = (
208
+ "bot_administrator_rights",
209
+ "bot_is_member",
210
+ "chat_has_username",
211
+ "chat_is_channel",
212
+ "chat_is_created",
213
+ "chat_is_forum",
214
+ "request_id",
215
+ "request_photo",
216
+ "request_title",
217
+ "request_username",
218
+ "user_administrator_rights",
219
+ )
220
+
221
+ def __init__(
222
+ self,
223
+ request_id: int,
224
+ chat_is_channel: bool,
225
+ chat_is_forum: Optional[bool] = None,
226
+ chat_has_username: Optional[bool] = None,
227
+ chat_is_created: Optional[bool] = None,
228
+ user_administrator_rights: Optional[ChatAdministratorRights] = None,
229
+ bot_administrator_rights: Optional[ChatAdministratorRights] = None,
230
+ bot_is_member: Optional[bool] = None,
231
+ request_title: Optional[bool] = None,
232
+ request_username: Optional[bool] = None,
233
+ request_photo: Optional[bool] = None,
234
+ *,
235
+ api_kwargs: Optional[JSONDict] = None,
236
+ ):
237
+ super().__init__(api_kwargs=api_kwargs)
238
+ # required
239
+ self.request_id: int = request_id
240
+ self.chat_is_channel: bool = chat_is_channel
241
+
242
+ # optional
243
+ self.chat_is_forum: Optional[bool] = chat_is_forum
244
+ self.chat_has_username: Optional[bool] = chat_has_username
245
+ self.chat_is_created: Optional[bool] = chat_is_created
246
+ self.user_administrator_rights: Optional[ChatAdministratorRights] = (
247
+ user_administrator_rights
248
+ )
249
+ self.bot_administrator_rights: Optional[ChatAdministratorRights] = bot_administrator_rights
250
+ self.bot_is_member: Optional[bool] = bot_is_member
251
+ self.request_title: Optional[bool] = request_title
252
+ self.request_username: Optional[bool] = request_username
253
+ self.request_photo: Optional[bool] = request_photo
254
+
255
+ self._id_attrs = (self.request_id,)
256
+
257
+ self._freeze()
258
+
259
+ @classmethod
260
+ def de_json(
261
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
262
+ ) -> Optional["KeyboardButtonRequestChat"]:
263
+ """See :meth:`telegram.TelegramObject.de_json`."""
264
+ data = cls._parse_data(data)
265
+
266
+ if not data:
267
+ return None
268
+
269
+ data["user_administrator_rights"] = ChatAdministratorRights.de_json(
270
+ data.get("user_administrator_rights"), bot
271
+ )
272
+ data["bot_administrator_rights"] = ChatAdministratorRights.de_json(
273
+ data.get("bot_administrator_rights"), bot
274
+ )
275
+
276
+ return super().de_json(data=data, bot=bot)
_linkpreviewoptions.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains the LinkPreviewOptions class."""
20
+
21
+
22
+ from typing import Optional
23
+
24
+ from telegram._telegramobject import TelegramObject
25
+ from telegram._utils.defaultvalue import DEFAULT_NONE
26
+ from telegram._utils.types import JSONDict, ODVInput
27
+
28
+
29
+ class LinkPreviewOptions(TelegramObject):
30
+ """
31
+ Describes the options used for link preview generation.
32
+
33
+ Objects of this class are comparable in terms of equality. Two objects of this class are
34
+ considered equal, if their :attr:`is_disabled`, :attr:`url`, :attr:`prefer_small_media`,
35
+ :attr:`prefer_large_media`, and :attr:`show_above_text` are equal.
36
+
37
+ .. versionadded:: 20.8
38
+
39
+ Args:
40
+ is_disabled (:obj:`bool`, optional): :obj:`True`, if the link preview is disabled.
41
+ url (:obj:`str`, optional): The URL to use for the link preview. If empty, then the first
42
+ URL found in the message text will be used.
43
+ prefer_small_media (:obj:`bool`, optional): :obj:`True`, if the media in the link preview
44
+ is supposed to be shrunk; ignored if the URL isn't explicitly specified or media size
45
+ change isn't supported for the preview.
46
+ prefer_large_media (:obj:`bool`, optional): :obj:`True`, if the media in the link preview
47
+ is supposed to be enlarged; ignored if the URL isn't explicitly specified or media
48
+ size change isn't supported for the preview.
49
+ show_above_text (:obj:`bool`, optional): :obj:`True`, if the link preview must be shown
50
+ above the message text; otherwise, the link preview will be shown below the message
51
+ text.
52
+
53
+ Attributes:
54
+ is_disabled (:obj:`bool`): Optional. :obj:`True`, if the link preview is disabled.
55
+ url (:obj:`str`): Optional. The URL to use for the link preview. If empty, then the first
56
+ URL found in the message text will be used.
57
+ prefer_small_media (:obj:`bool`): Optional. :obj:`True`, if the media in the link preview
58
+ is supposed to be shrunk; ignored if the URL isn't explicitly specified or media size
59
+ change isn't supported for the preview.
60
+ prefer_large_media (:obj:`bool`): Optional. :obj:`True`, if the media in the link preview
61
+ is supposed to be enlarged; ignored if the URL isn't explicitly specified or media size
62
+ change isn't supported for the preview.
63
+ show_above_text (:obj:`bool`): Optional. :obj:`True`, if the link preview must be shown
64
+ above the message text; otherwise, the link preview will be shown below the message
65
+ text.
66
+ """
67
+
68
+ __slots__ = (
69
+ "is_disabled",
70
+ "prefer_large_media",
71
+ "prefer_small_media",
72
+ "show_above_text",
73
+ "url",
74
+ )
75
+
76
+ def __init__(
77
+ self,
78
+ is_disabled: ODVInput[bool] = DEFAULT_NONE,
79
+ url: ODVInput[str] = DEFAULT_NONE,
80
+ prefer_small_media: ODVInput[bool] = DEFAULT_NONE,
81
+ prefer_large_media: ODVInput[bool] = DEFAULT_NONE,
82
+ show_above_text: ODVInput[bool] = DEFAULT_NONE,
83
+ *,
84
+ api_kwargs: Optional[JSONDict] = None,
85
+ ):
86
+ super().__init__(api_kwargs=api_kwargs)
87
+
88
+ # Optionals
89
+
90
+ self.is_disabled: ODVInput[bool] = is_disabled
91
+ self.url: ODVInput[str] = url
92
+ self.prefer_small_media: ODVInput[bool] = prefer_small_media
93
+ self.prefer_large_media: ODVInput[bool] = prefer_large_media
94
+ self.show_above_text: ODVInput[bool] = show_above_text
95
+
96
+ self._id_attrs = (
97
+ self.is_disabled,
98
+ self.url,
99
+ self.prefer_small_media,
100
+ self.prefer_large_media,
101
+ self.show_above_text,
102
+ )
103
+ self._freeze()
_loginurl.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram LoginUrl."""
20
+ from typing import Optional
21
+
22
+ from telegram._telegramobject import TelegramObject
23
+ from telegram._utils.types import JSONDict
24
+
25
+
26
+ class LoginUrl(TelegramObject):
27
+ """This object represents a parameter of the inline keyboard button used to automatically
28
+ authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is
29
+ coming from Telegram. All the user needs to do is tap/click a button and confirm that they want
30
+ to log in. Telegram apps support these buttons as of version 5.7.
31
+
32
+ Sample bot: `@discussbot <https://t.me/discussbot>`_
33
+
34
+ Objects of this class are comparable in terms of equality. Two objects of this class are
35
+ considered equal, if their :attr:`url` is equal.
36
+
37
+ Note:
38
+ You must always check the hash of the received data to verify the authentication
39
+ and the integrity of the data as described in
40
+ `Checking authorization <https://core.telegram.org/widgets/login#checking-authorization>`_
41
+
42
+ Args:
43
+ url (:obj:`str`): An HTTPS URL to be opened with user authorization data added to the query
44
+ string when the button is pressed. If the user refuses to provide authorization data,
45
+ the original URL without information about the user will be opened. The data added is
46
+ the same as described in
47
+ `Receiving authorization data
48
+ <https://core.telegram.org/widgets/login#receiving-authorization-data>`_.
49
+ forward_text (:obj:`str`, optional): New text of the button in forwarded messages.
50
+ bot_username (:obj:`str`, optional): Username of a bot, which will be used for user
51
+ authorization. See
52
+ `Setting up a bot <https://core.telegram.org/widgets/login#setting-up-a-bot>`_
53
+ for more details. If not specified, the current
54
+ bot's username will be assumed. The url's domain must be the same as the domain linked
55
+ with the bot. See
56
+ `Linking your domain to the bot
57
+ <https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot>`_
58
+ for more details.
59
+ request_write_access (:obj:`bool`, optional): Pass :obj:`True` to request the permission
60
+ for your bot to send messages to the user.
61
+
62
+ Attributes:
63
+ url (:obj:`str`): An HTTPS URL to be opened with user authorization data added to the query
64
+ string when the button is pressed. If the user refuses to provide authorization data,
65
+ the original URL without information about the user will be opened. The data added is
66
+ the same as described in
67
+ `Receiving authorization data
68
+ <https://core.telegram.org/widgets/login#receiving-authorization-data>`_.
69
+ forward_text (:obj:`str`): Optional. New text of the button in forwarded messages.
70
+ bot_username (:obj:`str`): Optional. Username of a bot, which will be used for user
71
+ authorization. See
72
+ `Setting up a bot <https://core.telegram.org/widgets/login#setting-up-a-bot>`_
73
+ for more details. If not specified, the current
74
+ bot's username will be assumed. The url's domain must be the same as the domain linked
75
+ with the bot. See
76
+ `Linking your domain to the bot
77
+ <https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot>`_
78
+ for more details.
79
+ request_write_access (:obj:`bool`): Optional. Pass :obj:`True` to request the permission
80
+ for your bot to send messages to the user.
81
+
82
+ """
83
+
84
+ __slots__ = ("bot_username", "forward_text", "request_write_access", "url")
85
+
86
+ def __init__(
87
+ self,
88
+ url: str,
89
+ forward_text: Optional[str] = None,
90
+ bot_username: Optional[str] = None,
91
+ request_write_access: Optional[bool] = None,
92
+ *,
93
+ api_kwargs: Optional[JSONDict] = None,
94
+ ):
95
+ super().__init__(api_kwargs=api_kwargs)
96
+ # Required
97
+ self.url: str = url
98
+ # Optional
99
+ self.forward_text: Optional[str] = forward_text
100
+ self.bot_username: Optional[str] = bot_username
101
+ self.request_write_access: Optional[bool] = request_write_access
102
+
103
+ self._id_attrs = (self.url,)
104
+
105
+ self._freeze()
_menubutton.py ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains objects related to Telegram menu buttons."""
20
+ from typing import TYPE_CHECKING, Dict, Final, Optional, Type
21
+
22
+ from telegram import constants
23
+ from telegram._telegramobject import TelegramObject
24
+ from telegram._utils import enum
25
+ from telegram._utils.types import JSONDict
26
+ from telegram._webappinfo import WebAppInfo
27
+
28
+ if TYPE_CHECKING:
29
+ from telegram import Bot
30
+
31
+
32
+ class MenuButton(TelegramObject):
33
+ """This object describes the bot's menu button in a private chat. It should be one of
34
+
35
+ * :class:`telegram.MenuButtonCommands`
36
+ * :class:`telegram.MenuButtonWebApp`
37
+ * :class:`telegram.MenuButtonDefault`
38
+
39
+ If a menu button other than :class:`telegram.MenuButtonDefault` is set for a private chat,
40
+ then it is applied in the chat. Otherwise the default menu button is applied. By default, the
41
+ menu button opens the list of bot commands.
42
+
43
+ Objects of this class are comparable in terms of equality. Two objects of this class are
44
+ considered equal, if their :attr:`type` is equal. For subclasses with additional attributes,
45
+ the notion of equality is overridden.
46
+
47
+ .. versionadded:: 20.0
48
+
49
+ Args:
50
+ type (:obj:`str`): Type of menu button that the instance represents.
51
+
52
+ Attributes:
53
+ type (:obj:`str`): Type of menu button that the instance represents.
54
+ """
55
+
56
+ __slots__ = ("type",)
57
+
58
+ def __init__(
59
+ self,
60
+ type: str,
61
+ *,
62
+ api_kwargs: Optional[JSONDict] = None,
63
+ ): # pylint: disable=redefined-builtin
64
+ super().__init__(api_kwargs=api_kwargs)
65
+ self.type: str = enum.get_member(constants.MenuButtonType, type, type)
66
+
67
+ self._id_attrs = (self.type,)
68
+
69
+ self._freeze()
70
+
71
+ @classmethod
72
+ def de_json(
73
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
74
+ ) -> Optional["MenuButton"]:
75
+ """Converts JSON data to the appropriate :class:`MenuButton` object, i.e. takes
76
+ care of selecting the correct subclass.
77
+
78
+ Args:
79
+ data (Dict[:obj:`str`, ...]): The JSON data.
80
+ bot (:class:`telegram.Bot`, optional): The bot associated with this object. Defaults to
81
+ :obj:`None`, in which case shortcut methods will not be available.
82
+
83
+ .. versionchanged:: 21.4
84
+ :paramref:`bot` is now optional and defaults to :obj:`None`
85
+
86
+ Returns:
87
+ The Telegram object.
88
+
89
+ """
90
+ data = cls._parse_data(data)
91
+
92
+ if data is None:
93
+ return None
94
+
95
+ if not data and cls is MenuButton:
96
+ return None
97
+
98
+ _class_mapping: Dict[str, Type[MenuButton]] = {
99
+ cls.COMMANDS: MenuButtonCommands,
100
+ cls.WEB_APP: MenuButtonWebApp,
101
+ cls.DEFAULT: MenuButtonDefault,
102
+ }
103
+
104
+ if cls is MenuButton and data.get("type") in _class_mapping:
105
+ return _class_mapping[data.pop("type")].de_json(data, bot=bot)
106
+ return super().de_json(data=data, bot=bot)
107
+
108
+ COMMANDS: Final[str] = constants.MenuButtonType.COMMANDS
109
+ """:const:`telegram.constants.MenuButtonType.COMMANDS`"""
110
+ WEB_APP: Final[str] = constants.MenuButtonType.WEB_APP
111
+ """:const:`telegram.constants.MenuButtonType.WEB_APP`"""
112
+ DEFAULT: Final[str] = constants.MenuButtonType.DEFAULT
113
+ """:const:`telegram.constants.MenuButtonType.DEFAULT`"""
114
+
115
+
116
+ class MenuButtonCommands(MenuButton):
117
+ """Represents a menu button, which opens the bot's list of commands.
118
+
119
+ .. include:: inclusions/menu_button_command_video.rst
120
+
121
+ .. versionadded:: 20.0
122
+ Attributes:
123
+ type (:obj:`str`): :tg-const:`telegram.constants.MenuButtonType.COMMANDS`.
124
+ """
125
+
126
+ __slots__ = ()
127
+
128
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
129
+ super().__init__(type=constants.MenuButtonType.COMMANDS, api_kwargs=api_kwargs)
130
+ self._freeze()
131
+
132
+
133
+ class MenuButtonWebApp(MenuButton):
134
+ """Represents a menu button, which launches a
135
+ `Web App <https://core.telegram.org/bots/webapps>`_.
136
+
137
+ Objects of this class are comparable in terms of equality. Two objects of this class are
138
+ considered equal, if their :attr:`type`, :attr:`text` and :attr:`web_app`
139
+ are equal.
140
+
141
+ .. versionadded:: 20.0
142
+
143
+ Args:
144
+ text (:obj:`str`): Text of the button.
145
+ web_app (:class:`telegram.WebAppInfo`): Description of the Web App that will be launched
146
+ when the user presses the button. The Web App will be able to send an arbitrary
147
+ message on behalf of the user using the method :meth:`~telegram.Bot.answerWebAppQuery`
148
+ of :class:`~telegram.Bot`. Alternatively, a ``t.me`` link to a Web App of the bot can
149
+ be specified in the object instead of the Web App's URL, in which case the Web App
150
+ will be opened as if the user pressed the link.
151
+
152
+
153
+ Attributes:
154
+ type (:obj:`str`): :tg-const:`telegram.constants.MenuButtonType.WEB_APP`.
155
+ text (:obj:`str`): Text of the button.
156
+ web_app (:class:`telegram.WebAppInfo`): Description of the Web App that will be launched
157
+ when the user presses the button. The Web App will be able to send an arbitrary
158
+ message on behalf of the user using the method :meth:`~telegram.Bot.answerWebAppQuery`
159
+ of :class:`~telegram.Bot`. Alternatively, a ``t.me`` link to a Web App of the bot can
160
+ be specified in the object instead of the Web App's URL, in which case the Web App
161
+ will be opened as if the user pressed the link.
162
+ """
163
+
164
+ __slots__ = ("text", "web_app")
165
+
166
+ def __init__(self, text: str, web_app: WebAppInfo, *, api_kwargs: Optional[JSONDict] = None):
167
+ super().__init__(type=constants.MenuButtonType.WEB_APP, api_kwargs=api_kwargs)
168
+ with self._unfrozen():
169
+ self.text: str = text
170
+ self.web_app: WebAppInfo = web_app
171
+
172
+ self._id_attrs = (self.type, self.text, self.web_app)
173
+
174
+ @classmethod
175
+ def de_json(
176
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
177
+ ) -> Optional["MenuButtonWebApp"]:
178
+ """See :meth:`telegram.TelegramObject.de_json`."""
179
+ data = cls._parse_data(data)
180
+
181
+ if not data:
182
+ return None
183
+
184
+ data["web_app"] = WebAppInfo.de_json(data.get("web_app"), bot)
185
+
186
+ return super().de_json(data=data, bot=bot) # type: ignore[return-value]
187
+
188
+
189
+ class MenuButtonDefault(MenuButton):
190
+ """Describes that no specific value for the menu button was set.
191
+
192
+ .. versionadded:: 20.0
193
+ Attributes:
194
+ type (:obj:`str`): :tg-const:`telegram.constants.MenuButtonType.DEFAULT`.
195
+ """
196
+
197
+ __slots__ = ()
198
+
199
+ def __init__(self, *, api_kwargs: Optional[JSONDict] = None):
200
+ super().__init__(type=constants.MenuButtonType.DEFAULT, api_kwargs=api_kwargs)
201
+ self._freeze()
_message.py ADDED
The diff for this file is too large to render. See raw diff
 
_messageautodeletetimerchanged.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a change in the Telegram message auto
20
+ deletion.
21
+ """
22
+
23
+ from typing import Optional
24
+
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._utils.types import JSONDict
27
+
28
+
29
+ class MessageAutoDeleteTimerChanged(TelegramObject):
30
+ """This object represents a service message about a change in auto-delete timer settings.
31
+
32
+ Objects of this class are comparable in terms of equality. Two objects of this class are
33
+ considered equal, if their :attr:`message_auto_delete_time` is equal.
34
+
35
+ .. versionadded:: 13.4
36
+
37
+ Args:
38
+ message_auto_delete_time (:obj:`int`): New auto-delete time for messages in the
39
+ chat.
40
+
41
+ Attributes:
42
+ message_auto_delete_time (:obj:`int`): New auto-delete time for messages in the
43
+ chat.
44
+
45
+ """
46
+
47
+ __slots__ = ("message_auto_delete_time",)
48
+
49
+ def __init__(
50
+ self,
51
+ message_auto_delete_time: int,
52
+ *,
53
+ api_kwargs: Optional[JSONDict] = None,
54
+ ):
55
+ super().__init__(api_kwargs=api_kwargs)
56
+ self.message_auto_delete_time: int = message_auto_delete_time
57
+
58
+ self._id_attrs = (self.message_auto_delete_time,)
59
+
60
+ self._freeze()
_messageentity.py ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram MessageEntity."""
20
+
21
+ import copy
22
+ import itertools
23
+ from typing import TYPE_CHECKING, Dict, Final, List, Optional, Sequence, Tuple, Union
24
+
25
+ from telegram import constants
26
+ from telegram._telegramobject import TelegramObject
27
+ from telegram._user import User
28
+ from telegram._utils import enum
29
+ from telegram._utils.strings import TextEncoding
30
+ from telegram._utils.types import JSONDict
31
+
32
+ if TYPE_CHECKING:
33
+ from telegram import Bot
34
+
35
+ _SEM = Sequence["MessageEntity"]
36
+
37
+
38
+ class MessageEntity(TelegramObject):
39
+ """
40
+ This object represents one special entity in a text message. For example, hashtags,
41
+ usernames, URLs, etc.
42
+
43
+ Objects of this class are comparable in terms of equality. Two objects of this class are
44
+ considered equal, if their :attr:`type`, :attr:`offset` and :attr:`length` are equal.
45
+
46
+ Args:
47
+ type (:obj:`str`): Type of the entity. Can be :attr:`MENTION` (@username),
48
+ :attr:`HASHTAG` (#hashtag), :attr:`CASHTAG` ($USD), :attr:`BOT_COMMAND`
49
+ (/start@jobs_bot), :attr:`URL` (https://telegram.org),
50
+ :attr:`EMAIL` ([email protected]), :attr:`PHONE_NUMBER` (+1-212-555-0123),
51
+ :attr:`BOLD` (**bold text**), :attr:`ITALIC` (*italic text*), :attr:`UNDERLINE`
52
+ (underlined text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
53
+ :attr:`BLOCKQUOTE` (block quotation), :attr:`CODE` (monowidth string), :attr:`PRE`
54
+ (monowidth block), :attr:`TEXT_LINK` (for clickable text URLs), :attr:`TEXT_MENTION`
55
+ (for users without usernames), :attr:`CUSTOM_EMOJI` (for inline custom emoji stickers).
56
+
57
+ .. versionadded:: 20.0
58
+ Added inline custom emoji
59
+
60
+ .. versionadded:: 20.8
61
+ Added block quotation
62
+ offset (:obj:`int`): Offset in UTF-16 code units to the start of the entity.
63
+ length (:obj:`int`): Length of the entity in UTF-16 code units.
64
+ url (:obj:`str`, optional): For :attr:`TEXT_LINK` only, url that will be opened after
65
+ user taps on the text.
66
+ user (:class:`telegram.User`, optional): For :attr:`TEXT_MENTION` only, the mentioned
67
+ user.
68
+ language (:obj:`str`, optional): For :attr:`PRE` only, the programming language of
69
+ the entity text.
70
+ custom_emoji_id (:obj:`str`, optional): For :attr:`CUSTOM_EMOJI` only, unique identifier
71
+ of the custom emoji. Use :meth:`telegram.Bot.get_custom_emoji_stickers` to get full
72
+ information about the sticker.
73
+
74
+ .. versionadded:: 20.0
75
+ Attributes:
76
+ type (:obj:`str`): Type of the entity. Can be :attr:`MENTION` (@username),
77
+ :attr:`HASHTAG` (#hashtag), :attr:`CASHTAG` ($USD), :attr:`BOT_COMMAND`
78
+ (/start@jobs_bot), :attr:`URL` (https://telegram.org),
79
+ :attr:`EMAIL` ([email protected]), :attr:`PHONE_NUMBER` (+1-212-555-0123),
80
+ :attr:`BOLD` (**bold text**), :attr:`ITALIC` (*italic text*), :attr:`UNDERLINE`
81
+ (underlined text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
82
+ :attr:`BLOCKQUOTE` (block quotation), :attr:`CODE` (monowidth string), :attr:`PRE`
83
+ (monowidth block), :attr:`TEXT_LINK` (for clickable text URLs), :attr:`TEXT_MENTION`
84
+ (for users without usernames), :attr:`CUSTOM_EMOJI` (for inline custom emoji stickers).
85
+
86
+ .. versionadded:: 20.0
87
+ Added inline custom emoji
88
+
89
+ .. versionadded:: 20.8
90
+ Added block quotation
91
+ offset (:obj:`int`): Offset in UTF-16 code units to the start of the entity.
92
+ length (:obj:`int`): Length of the entity in UTF-16 code units.
93
+ url (:obj:`str`): Optional. For :attr:`TEXT_LINK` only, url that will be opened after
94
+ user taps on the text.
95
+ user (:class:`telegram.User`): Optional. For :attr:`TEXT_MENTION` only, the mentioned
96
+ user.
97
+ language (:obj:`str`): Optional. For :attr:`PRE` only, the programming language of
98
+ the entity text.
99
+ custom_emoji_id (:obj:`str`): Optional. For :attr:`CUSTOM_EMOJI` only, unique identifier
100
+ of the custom emoji. Use :meth:`telegram.Bot.get_custom_emoji_stickers` to get full
101
+ information about the sticker.
102
+
103
+ .. versionadded:: 20.0
104
+
105
+ """
106
+
107
+ __slots__ = ("custom_emoji_id", "language", "length", "offset", "type", "url", "user")
108
+
109
+ def __init__(
110
+ self,
111
+ type: str, # pylint: disable=redefined-builtin
112
+ offset: int,
113
+ length: int,
114
+ url: Optional[str] = None,
115
+ user: Optional[User] = None,
116
+ language: Optional[str] = None,
117
+ custom_emoji_id: Optional[str] = None,
118
+ *,
119
+ api_kwargs: Optional[JSONDict] = None,
120
+ ):
121
+ super().__init__(api_kwargs=api_kwargs)
122
+ # Required
123
+ self.type: str = enum.get_member(constants.MessageEntityType, type, type)
124
+ self.offset: int = offset
125
+ self.length: int = length
126
+ # Optionals
127
+ self.url: Optional[str] = url
128
+ self.user: Optional[User] = user
129
+ self.language: Optional[str] = language
130
+ self.custom_emoji_id: Optional[str] = custom_emoji_id
131
+
132
+ self._id_attrs = (self.type, self.offset, self.length)
133
+
134
+ self._freeze()
135
+
136
+ @classmethod
137
+ def de_json(
138
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
139
+ ) -> Optional["MessageEntity"]:
140
+ """See :meth:`telegram.TelegramObject.de_json`."""
141
+ data = cls._parse_data(data)
142
+
143
+ if not data:
144
+ return None
145
+
146
+ data["user"] = User.de_json(data.get("user"), bot)
147
+
148
+ return super().de_json(data=data, bot=bot)
149
+
150
+ @staticmethod
151
+ def adjust_message_entities_to_utf_16(text: str, entities: _SEM) -> _SEM:
152
+ """Utility functionality for converting the offset and length of entities from
153
+ Unicode (:obj:`str`) to UTF-16 (``utf-16-le`` encoded :obj:`bytes`).
154
+
155
+ Tip:
156
+ Only the offsets and lengths calulated in UTF-16 is acceptable by the Telegram Bot API.
157
+ If they are calculated using the Unicode string (:obj:`str` object), errors may occur
158
+ when the text contains characters that are not in the Basic Multilingual Plane (BMP).
159
+ For more information, see `Unicode <https://en.wikipedia.org/wiki/Unicode>`_ and
160
+ `Plane (Unicode) <https://en.wikipedia.org/wiki/Plane_(Unicode)>`_.
161
+
162
+ .. versionadded:: 21.4
163
+
164
+ Examples:
165
+ Below is a snippet of code that demonstrates how to use this function to convert
166
+ entities from Unicode to UTF-16 space. The ``unicode_entities`` are calculated in
167
+ Unicode and the `utf_16_entities` are calculated in UTF-16.
168
+
169
+ .. code-block:: python
170
+
171
+ text = "𠌕 bold 𝄢 italic underlined: 𝛙𝌢𑁍"
172
+ unicode_entities = [
173
+ MessageEntity(offset=2, length=4, type=MessageEntity.BOLD),
174
+ MessageEntity(offset=9, length=6, type=MessageEntity.ITALIC),
175
+ MessageEntity(offset=28, length=3, type=MessageEntity.UNDERLINE),
176
+ ]
177
+ utf_16_entities = MessageEntity.adjust_message_entities_to_utf_16(
178
+ text, unicode_entities
179
+ )
180
+ await bot.send_message(
181
+ chat_id=123,
182
+ text=text,
183
+ entities=utf_16_entities,
184
+ )
185
+ # utf_16_entities[0]: offset=3, length=4
186
+ # utf_16_entities[1]: offset=11, length=6
187
+ # utf_16_entities[2]: offset=30, length=6
188
+
189
+ Args:
190
+ text (:obj:`str`): The text that the entities belong to
191
+ entities (Sequence[:class:`telegram.MessageEntity`]): Sequence of entities
192
+ with offset and length calculated in Unicode
193
+
194
+ Returns:
195
+ Sequence[:class:`telegram.MessageEntity`]: Sequence of entities
196
+ with offset and length calculated in UTF-16 encoding
197
+ """
198
+ # get sorted positions
199
+ positions = sorted(itertools.chain(*((x.offset, x.offset + x.length) for x in entities)))
200
+ accumulated_length = 0
201
+ # calculate the length of each slice text[:position] in utf-16 accordingly,
202
+ # store the position translations
203
+ position_translation: Dict[int, int] = {}
204
+ for i, position in enumerate(positions):
205
+ last_position = positions[i - 1] if i > 0 else 0
206
+ text_slice = text[last_position:position]
207
+ accumulated_length += len(text_slice.encode(TextEncoding.UTF_16_LE)) // 2
208
+ position_translation[position] = accumulated_length
209
+ # get the final output entities
210
+ out = []
211
+ for entity in entities:
212
+ translated_positions = position_translation[entity.offset]
213
+ translated_length = (
214
+ position_translation[entity.offset + entity.length] - translated_positions
215
+ )
216
+ new_entity = copy.copy(entity)
217
+ with new_entity._unfrozen():
218
+ new_entity.offset = translated_positions
219
+ new_entity.length = translated_length
220
+ out.append(new_entity)
221
+ return out
222
+
223
+ @staticmethod
224
+ def shift_entities(by: Union[str, int], entities: _SEM) -> _SEM:
225
+ """Utility functionality for shifting the offset of entities by a given amount.
226
+
227
+ Examples:
228
+ Shifting by an integer amount:
229
+
230
+ .. code-block:: python
231
+
232
+ text = "Hello, world!"
233
+ entities = [
234
+ MessageEntity(offset=0, length=5, type=MessageEntity.BOLD),
235
+ MessageEntity(offset=7, length=5, type=MessageEntity.ITALIC),
236
+ ]
237
+ shifted_entities = MessageEntity.shift_entities(1, entities)
238
+ await bot.send_message(
239
+ chat_id=123,
240
+ text="!" + text,
241
+ entities=shifted_entities,
242
+ )
243
+
244
+ Shifting using a string:
245
+
246
+ .. code-block:: python
247
+
248
+ text = "Hello, world!"
249
+ prefix = "𝄢"
250
+ entities = [
251
+ MessageEntity(offset=0, length=5, type=MessageEntity.BOLD),
252
+ MessageEntity(offset=7, length=5, type=MessageEntity.ITALIC),
253
+ ]
254
+ shifted_entities = MessageEntity.shift_entities(prefix, entities)
255
+ await bot.send_message(
256
+ chat_id=123,
257
+ text=prefix + text,
258
+ entities=shifted_entities,
259
+ )
260
+
261
+ Tip:
262
+ The :paramref:`entities` are *not* modified in place. The function returns a sequence
263
+ of new objects.
264
+
265
+ .. versionadded:: 21.5
266
+
267
+ Args:
268
+ by (:obj:`str` | :obj:`int`): Either the amount to shift the offset by or
269
+ a string whose length will be used as the amount to shift the offset by. In this
270
+ case, UTF-16 encoding will be used to calculate the length.
271
+ entities (Sequence[:class:`telegram.MessageEntity`]): Sequence of entities
272
+
273
+ Returns:
274
+ Sequence[:class:`telegram.MessageEntity`]: Sequence of entities with the offset shifted
275
+ """
276
+ effective_shift = by if isinstance(by, int) else len(by.encode("utf-16-le")) // 2
277
+
278
+ out = []
279
+ for entity in entities:
280
+ new_entity = copy.copy(entity)
281
+ with new_entity._unfrozen():
282
+ new_entity.offset += effective_shift
283
+ out.append(new_entity)
284
+ return out
285
+
286
+ @classmethod
287
+ def concatenate(
288
+ cls,
289
+ *args: Union[Tuple[str, _SEM], Tuple[str, _SEM, bool]],
290
+ ) -> Tuple[str, _SEM]:
291
+ """Utility functionality for concatenating two text along with their formatting entities.
292
+
293
+ Tip:
294
+ This function is useful for prefixing an already formatted text with a new text and its
295
+ formatting entities. In particular, it automatically correctly handles UTF-16 encoding.
296
+
297
+ Examples:
298
+ This example shows a callback function that can be used to add a prefix and suffix to
299
+ the message in a :class:`~telegram.ext.CallbackQueryHandler`:
300
+
301
+ .. code-block:: python
302
+
303
+ async def prefix_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
304
+ prefix = "𠌕 bold 𝄢 italic underlined: 𝛙𝌢𑁍 | "
305
+ prefix_entities = [
306
+ MessageEntity(offset=2, length=4, type=MessageEntity.BOLD),
307
+ MessageEntity(offset=9, length=6, type=MessageEntity.ITALIC),
308
+ MessageEntity(offset=28, length=3, type=MessageEntity.UNDERLINE),
309
+ ]
310
+ suffix = " | 𠌕 bold 𝄢 italic underlined: 𝛙𝌢𑁍"
311
+ suffix_entities = [
312
+ MessageEntity(offset=5, length=4, type=MessageEntity.BOLD),
313
+ MessageEntity(offset=12, length=6, type=MessageEntity.ITALIC),
314
+ MessageEntity(offset=31, length=3, type=MessageEntity.UNDERLINE),
315
+ ]
316
+
317
+ message = update.effective_message
318
+ first = (prefix, prefix_entities, True)
319
+ second = (message.text, message.entities)
320
+ third = (suffix, suffix_entities, True)
321
+
322
+ new_text, new_entities = MessageEntity.concatenate(first, second, third)
323
+ await update.callback_query.edit_message_text(
324
+ text=new_text,
325
+ entities=new_entities,
326
+ )
327
+
328
+ Hint:
329
+ The entities are *not* modified in place. The function returns a
330
+ new sequence of objects.
331
+
332
+ .. versionadded:: 21.5
333
+
334
+ Args:
335
+ *args (Tuple[:obj:`str`, Sequence[:class:`telegram.MessageEntity`]] | \
336
+ Tuple[:obj:`str`, Sequence[:class:`telegram.MessageEntity`], :obj:`bool`]):
337
+ Arbitrary number of tuples containing the text and its entities to concatenate.
338
+ If the last element of the tuple is a :obj:`bool`, it is used to determine whether
339
+ to adjust the entities to UTF-16 via
340
+ :meth:`adjust_message_entities_to_utf_16`. UTF-16 adjustment is disabled by
341
+ default.
342
+
343
+ Returns:
344
+ Tuple[:obj:`str`, Sequence[:class:`telegram.MessageEntity`]]: The concatenated text
345
+ and its entities
346
+ """
347
+ output_text = ""
348
+ output_entities: List[MessageEntity] = []
349
+ for arg in args:
350
+ text, entities = arg[0], arg[1]
351
+
352
+ if len(arg) > 2 and arg[2] is True:
353
+ entities = cls.adjust_message_entities_to_utf_16(text, entities)
354
+
355
+ output_entities.extend(cls.shift_entities(output_text, entities))
356
+ output_text += text
357
+
358
+ return output_text, output_entities
359
+
360
+ ALL_TYPES: Final[List[str]] = list(constants.MessageEntityType)
361
+ """List[:obj:`str`]: A list of all available message entity types."""
362
+ BLOCKQUOTE: Final[str] = constants.MessageEntityType.BLOCKQUOTE
363
+ """:const:`telegram.constants.MessageEntityType.BLOCKQUOTE`
364
+
365
+ .. versionadded:: 20.8
366
+ """
367
+ BOLD: Final[str] = constants.MessageEntityType.BOLD
368
+ """:const:`telegram.constants.MessageEntityType.BOLD`"""
369
+ BOT_COMMAND: Final[str] = constants.MessageEntityType.BOT_COMMAND
370
+ """:const:`telegram.constants.MessageEntityType.BOT_COMMAND`"""
371
+ CASHTAG: Final[str] = constants.MessageEntityType.CASHTAG
372
+ """:const:`telegram.constants.MessageEntityType.CASHTAG`"""
373
+ CODE: Final[str] = constants.MessageEntityType.CODE
374
+ """:const:`telegram.constants.MessageEntityType.CODE`"""
375
+ CUSTOM_EMOJI: Final[str] = constants.MessageEntityType.CUSTOM_EMOJI
376
+ """:const:`telegram.constants.MessageEntityType.CUSTOM_EMOJI`
377
+
378
+ .. versionadded:: 20.0
379
+ """
380
+ EMAIL: Final[str] = constants.MessageEntityType.EMAIL
381
+ """:const:`telegram.constants.MessageEntityType.EMAIL`"""
382
+ EXPANDABLE_BLOCKQUOTE: Final[str] = constants.MessageEntityType.EXPANDABLE_BLOCKQUOTE
383
+ """:const:`telegram.constants.MessageEntityType.EXPANDABLE_BLOCKQUOTE`
384
+
385
+ .. versionadded:: 21.3
386
+ """
387
+ HASHTAG: Final[str] = constants.MessageEntityType.HASHTAG
388
+ """:const:`telegram.constants.MessageEntityType.HASHTAG`"""
389
+ ITALIC: Final[str] = constants.MessageEntityType.ITALIC
390
+ """:const:`telegram.constants.MessageEntityType.ITALIC`"""
391
+ MENTION: Final[str] = constants.MessageEntityType.MENTION
392
+ """:const:`telegram.constants.MessageEntityType.MENTION`"""
393
+ PHONE_NUMBER: Final[str] = constants.MessageEntityType.PHONE_NUMBER
394
+ """:const:`telegram.constants.MessageEntityType.PHONE_NUMBER`"""
395
+ PRE: Final[str] = constants.MessageEntityType.PRE
396
+ """:const:`telegram.constants.MessageEntityType.PRE`"""
397
+ SPOILER: Final[str] = constants.MessageEntityType.SPOILER
398
+ """:const:`telegram.constants.MessageEntityType.SPOILER`
399
+
400
+ .. versionadded:: 13.10
401
+ """
402
+ STRIKETHROUGH: Final[str] = constants.MessageEntityType.STRIKETHROUGH
403
+ """:const:`telegram.constants.MessageEntityType.STRIKETHROUGH`"""
404
+ TEXT_LINK: Final[str] = constants.MessageEntityType.TEXT_LINK
405
+ """:const:`telegram.constants.MessageEntityType.TEXT_LINK`"""
406
+ TEXT_MENTION: Final[str] = constants.MessageEntityType.TEXT_MENTION
407
+ """:const:`telegram.constants.MessageEntityType.TEXT_MENTION`"""
408
+ UNDERLINE: Final[str] = constants.MessageEntityType.UNDERLINE
409
+ """:const:`telegram.constants.MessageEntityType.UNDERLINE`"""
410
+ URL: Final[str] = constants.MessageEntityType.URL
411
+ """:const:`telegram.constants.MessageEntityType.URL`"""
_messageid.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents an instance of a Telegram MessageId."""
20
+
21
+ from typing import Optional
22
+
23
+ from telegram._telegramobject import TelegramObject
24
+ from telegram._utils.types import JSONDict
25
+
26
+
27
+ class MessageId(TelegramObject):
28
+ """This object represents a unique message identifier.
29
+
30
+ Objects of this class are comparable in terms of equality. Two objects of this class are
31
+ considered equal, if their :attr:`message_id` is equal.
32
+
33
+ Args:
34
+ message_id (:obj:`int`): Unique message identifier.
35
+
36
+ Attributes:
37
+ message_id (:obj:`int`): Unique message identifier.
38
+ """
39
+
40
+ __slots__ = ("message_id",)
41
+
42
+ def __init__(self, message_id: int, *, api_kwargs: Optional[JSONDict] = None):
43
+ super().__init__(api_kwargs=api_kwargs)
44
+ self.message_id: int = message_id
45
+
46
+ self._id_attrs = (self.message_id,)
47
+
48
+ self._freeze()
_messageorigin.py ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains the classes that represent Telegram MessageOigin."""
20
+ import datetime
21
+ from typing import TYPE_CHECKING, Dict, Final, Optional, Type
22
+
23
+ from telegram import constants
24
+ from telegram._chat import Chat
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._user import User
27
+ from telegram._utils import enum
28
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
29
+ from telegram._utils.types import JSONDict
30
+
31
+ if TYPE_CHECKING:
32
+ from telegram import Bot
33
+
34
+
35
+ class MessageOrigin(TelegramObject):
36
+ """
37
+ Base class for telegram MessageOrigin object, it can be one of:
38
+
39
+ * :class:`MessageOriginUser`
40
+ * :class:`MessageOriginHiddenUser`
41
+ * :class:`MessageOriginChat`
42
+ * :class:`MessageOriginChannel`
43
+
44
+ Objects of this class are comparable in terms of equality. Two objects of this class are
45
+ considered equal, if their :attr:`type` and :attr:`date` are equal.
46
+
47
+ .. versionadded:: 20.8
48
+
49
+ Args:
50
+ type (:obj:`str`): Type of the message origin, can be on of:
51
+ :attr:`~telegram.MessageOrigin.USER`, :attr:`~telegram.MessageOrigin.HIDDEN_USER`,
52
+ :attr:`~telegram.MessageOrigin.CHAT`, or :attr:`~telegram.MessageOrigin.CHANNEL`.
53
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
54
+ |datetime_localization|
55
+
56
+ Attributes:
57
+ type (:obj:`str`): Type of the message origin, can be on of:
58
+ :attr:`~telegram.MessageOrigin.USER`, :attr:`~telegram.MessageOrigin.HIDDEN_USER`,
59
+ :attr:`~telegram.MessageOrigin.CHAT`, or :attr:`~telegram.MessageOrigin.CHANNEL`.
60
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
61
+ |datetime_localization|
62
+ """
63
+
64
+ __slots__ = (
65
+ "date",
66
+ "type",
67
+ )
68
+
69
+ USER: Final[str] = constants.MessageOriginType.USER
70
+ """:const:`telegram.constants.MessageOriginType.USER`"""
71
+ HIDDEN_USER: Final[str] = constants.MessageOriginType.HIDDEN_USER
72
+ """:const:`telegram.constants.MessageOriginType.HIDDEN_USER`"""
73
+ CHAT: Final[str] = constants.MessageOriginType.CHAT
74
+ """:const:`telegram.constants.MessageOriginType.CHAT`"""
75
+ CHANNEL: Final[str] = constants.MessageOriginType.CHANNEL
76
+ """:const:`telegram.constants.MessageOriginType.CHANNEL`"""
77
+
78
+ def __init__(
79
+ self,
80
+ type: str, # pylint: disable=W0622
81
+ date: datetime.datetime,
82
+ *,
83
+ api_kwargs: Optional[JSONDict] = None,
84
+ ):
85
+ super().__init__(api_kwargs=api_kwargs)
86
+ # Required by all subclasses
87
+ self.type: str = enum.get_member(constants.MessageOriginType, type, type)
88
+ self.date: datetime.datetime = date
89
+
90
+ self._id_attrs = (
91
+ self.type,
92
+ self.date,
93
+ )
94
+ self._freeze()
95
+
96
+ @classmethod
97
+ def de_json(
98
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
99
+ ) -> Optional["MessageOrigin"]:
100
+ """Converts JSON data to the appropriate :class:`MessageOrigin` object, i.e. takes
101
+ care of selecting the correct subclass.
102
+ """
103
+ data = cls._parse_data(data)
104
+
105
+ if not data:
106
+ return None
107
+
108
+ _class_mapping: Dict[str, Type[MessageOrigin]] = {
109
+ cls.USER: MessageOriginUser,
110
+ cls.HIDDEN_USER: MessageOriginHiddenUser,
111
+ cls.CHAT: MessageOriginChat,
112
+ cls.CHANNEL: MessageOriginChannel,
113
+ }
114
+ if cls is MessageOrigin and data.get("type") in _class_mapping:
115
+ return _class_mapping[data.pop("type")].de_json(data=data, bot=bot)
116
+
117
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
118
+ data["date"] = from_timestamp(data.get("date"), tzinfo=loc_tzinfo)
119
+
120
+ if "sender_user" in data:
121
+ data["sender_user"] = User.de_json(data.get("sender_user"), bot)
122
+
123
+ if "sender_chat" in data:
124
+ data["sender_chat"] = Chat.de_json(data.get("sender_chat"), bot)
125
+
126
+ if "chat" in data:
127
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
128
+
129
+ return super().de_json(data=data, bot=bot)
130
+
131
+
132
+ class MessageOriginUser(MessageOrigin):
133
+ """
134
+ The message was originally sent by a known user.
135
+
136
+ .. versionadded:: 20.8
137
+
138
+ Args:
139
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
140
+ |datetime_localization|
141
+ sender_user (:class:`telegram.User`): User that sent the message originally.
142
+
143
+ Attributes:
144
+ type (:obj:`str`): Type of the message origin. Always
145
+ :tg-const:`~telegram.MessageOrigin.USER`.
146
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
147
+ |datetime_localization|
148
+ sender_user (:class:`telegram.User`): User that sent the message originally.
149
+ """
150
+
151
+ __slots__ = ("sender_user",)
152
+
153
+ def __init__(
154
+ self,
155
+ date: datetime.datetime,
156
+ sender_user: User,
157
+ *,
158
+ api_kwargs: Optional[JSONDict] = None,
159
+ ):
160
+ super().__init__(type=self.USER, date=date, api_kwargs=api_kwargs)
161
+
162
+ with self._unfrozen():
163
+ self.sender_user: User = sender_user
164
+
165
+
166
+ class MessageOriginHiddenUser(MessageOrigin):
167
+ """
168
+ The message was originally sent by an unknown user.
169
+
170
+ .. versionadded:: 20.8
171
+
172
+ Args:
173
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
174
+ |datetime_localization|
175
+ sender_user_name (:obj:`str`): Name of the user that sent the message originally.
176
+
177
+ Attributes:
178
+ type (:obj:`str`): Type of the message origin. Always
179
+ :tg-const:`~telegram.MessageOrigin.HIDDEN_USER`.
180
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
181
+ |datetime_localization|
182
+ sender_user_name (:obj:`str`): Name of the user that sent the message originally.
183
+ """
184
+
185
+ __slots__ = ("sender_user_name",)
186
+
187
+ def __init__(
188
+ self,
189
+ date: datetime.datetime,
190
+ sender_user_name: str,
191
+ *,
192
+ api_kwargs: Optional[JSONDict] = None,
193
+ ):
194
+ super().__init__(type=self.HIDDEN_USER, date=date, api_kwargs=api_kwargs)
195
+
196
+ with self._unfrozen():
197
+ self.sender_user_name: str = sender_user_name
198
+
199
+
200
+ class MessageOriginChat(MessageOrigin):
201
+ """
202
+ The message was originally sent on behalf of a chat to a group chat.
203
+
204
+ .. versionadded:: 20.8
205
+
206
+ Args:
207
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
208
+ |datetime_localization|
209
+ sender_chat (:class:`telegram.Chat`): Chat that sent the message originally.
210
+ author_signature (:obj:`str`, optional): For messages originally sent by an anonymous chat
211
+ administrator, original message author signature
212
+
213
+ Attributes:
214
+ type (:obj:`str`): Type of the message origin. Always
215
+ :tg-const:`~telegram.MessageOrigin.CHAT`.
216
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
217
+ |datetime_localization|
218
+ sender_chat (:class:`telegram.Chat`): Chat that sent the message originally.
219
+ author_signature (:obj:`str`): Optional. For messages originally sent by an anonymous chat
220
+ administrator, original message author signature
221
+ """
222
+
223
+ __slots__ = (
224
+ "author_signature",
225
+ "sender_chat",
226
+ )
227
+
228
+ def __init__(
229
+ self,
230
+ date: datetime.datetime,
231
+ sender_chat: Chat,
232
+ author_signature: Optional[str] = None,
233
+ *,
234
+ api_kwargs: Optional[JSONDict] = None,
235
+ ):
236
+ super().__init__(type=self.CHAT, date=date, api_kwargs=api_kwargs)
237
+
238
+ with self._unfrozen():
239
+ self.sender_chat: Chat = sender_chat
240
+ self.author_signature: Optional[str] = author_signature
241
+
242
+
243
+ class MessageOriginChannel(MessageOrigin):
244
+ """
245
+ The message was originally sent to a channel chat.
246
+
247
+ .. versionadded:: 20.8
248
+
249
+ Args:
250
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
251
+ |datetime_localization|
252
+ chat (:class:`telegram.Chat`): Channel chat to which the message was originally sent.
253
+ message_id (:obj:`int`): Unique message identifier inside the chat.
254
+ author_signature (:obj:`str`, optional): Signature of the original post author.
255
+
256
+ Attributes:
257
+ type (:obj:`str`): Type of the message origin. Always
258
+ :tg-const:`~telegram.MessageOrigin.CHANNEL`.
259
+ date (:obj:`datetime.datetime`): Date the message was sent originally.
260
+ |datetime_localization|
261
+ chat (:class:`telegram.Chat`): Channel chat to which the message was originally sent.
262
+ message_id (:obj:`int`): Unique message identifier inside the chat.
263
+ author_signature (:obj:`str`): Optional. Signature of the original post author.
264
+ """
265
+
266
+ __slots__ = (
267
+ "author_signature",
268
+ "chat",
269
+ "message_id",
270
+ )
271
+
272
+ def __init__(
273
+ self,
274
+ date: datetime.datetime,
275
+ chat: Chat,
276
+ message_id: int,
277
+ author_signature: Optional[str] = None,
278
+ *,
279
+ api_kwargs: Optional[JSONDict] = None,
280
+ ):
281
+ super().__init__(type=self.CHANNEL, date=date, api_kwargs=api_kwargs)
282
+
283
+ with self._unfrozen():
284
+ self.chat: Chat = chat
285
+ self.message_id: int = message_id
286
+ self.author_signature: Optional[str] = author_signature
_messagereactionupdated.py ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # A library that provides a Python interface to the Telegram Bot API
4
+ # Copyright (C) 2015-2024
5
+ # Leandro Toledo de Souza <[email protected]>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser Public License
18
+ # along with this program. If not, see [http://www.gnu.org/licenses/].
19
+ """This module contains an object that represents a Telegram MessageReaction Update."""
20
+ from datetime import datetime
21
+ from typing import TYPE_CHECKING, Optional, Sequence, Tuple
22
+
23
+ from telegram._chat import Chat
24
+ from telegram._reaction import ReactionCount, ReactionType
25
+ from telegram._telegramobject import TelegramObject
26
+ from telegram._user import User
27
+ from telegram._utils.argumentparsing import parse_sequence_arg
28
+ from telegram._utils.datetime import extract_tzinfo_from_defaults, from_timestamp
29
+ from telegram._utils.types import JSONDict
30
+
31
+ if TYPE_CHECKING:
32
+ from telegram import Bot
33
+
34
+
35
+ class MessageReactionCountUpdated(TelegramObject):
36
+ """This class represents reaction changes on a message with anonymous reactions.
37
+
38
+ Objects of this class are comparable in terms of equality. Two objects of this class are
39
+ considered equal, if the :attr:`chat`, :attr:`message_id`, :attr:`date` and :attr:`reactions`
40
+ is equal.
41
+
42
+ .. versionadded:: 20.8
43
+
44
+ Args:
45
+ chat (:class:`telegram.Chat`): The chat containing the message.
46
+ message_id (:obj:`int`): Unique message identifier inside the chat.
47
+ date (:class:`datetime.datetime`): Date of the change in Unix time
48
+ |datetime_localization|
49
+ reactions (Sequence[:class:`telegram.ReactionCount`]): List of reactions that are present
50
+ on the message
51
+
52
+ Attributes:
53
+ chat (:class:`telegram.Chat`): The chat containing the message.
54
+ message_id (:obj:`int`): Unique message identifier inside the chat.
55
+ date (:class:`datetime.datetime`): Date of the change in Unix time
56
+ |datetime_localization|
57
+ reactions (Tuple[:class:`telegram.ReactionCount`]): List of reactions that are present on
58
+ the message
59
+ """
60
+
61
+ __slots__ = (
62
+ "chat",
63
+ "date",
64
+ "message_id",
65
+ "reactions",
66
+ )
67
+
68
+ def __init__(
69
+ self,
70
+ chat: Chat,
71
+ message_id: int,
72
+ date: datetime,
73
+ reactions: Sequence[ReactionCount],
74
+ *,
75
+ api_kwargs: Optional[JSONDict] = None,
76
+ ):
77
+ super().__init__(api_kwargs=api_kwargs)
78
+ # Required
79
+ self.chat: Chat = chat
80
+ self.message_id: int = message_id
81
+ self.date: datetime = date
82
+ self.reactions: Tuple[ReactionCount, ...] = parse_sequence_arg(reactions)
83
+
84
+ self._id_attrs = (self.chat, self.message_id, self.date, self.reactions)
85
+ self._freeze()
86
+
87
+ @classmethod
88
+ def de_json(
89
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
90
+ ) -> Optional["MessageReactionCountUpdated"]:
91
+ """See :meth:`telegram.TelegramObject.de_json`."""
92
+ data = cls._parse_data(data)
93
+
94
+ if not data:
95
+ return None
96
+
97
+ # Get the local timezone from the bot if it has defaults
98
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
99
+
100
+ data["date"] = from_timestamp(data.get("date"), tzinfo=loc_tzinfo)
101
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
102
+ data["reactions"] = ReactionCount.de_list(data.get("reactions"), bot)
103
+
104
+ return super().de_json(data=data, bot=bot)
105
+
106
+
107
+ class MessageReactionUpdated(TelegramObject):
108
+ """This class represents a change of a reaction on a message performed by a user.
109
+
110
+ Objects of this class are comparable in terms of equality. Two objects of this class are
111
+ considered equal, if the :attr:`chat`, :attr:`message_id`, :attr:`date`, :attr:`old_reaction`
112
+ and :attr:`new_reaction` is equal.
113
+
114
+ .. versionadded:: 20.8
115
+
116
+ Args:
117
+ chat (:class:`telegram.Chat`): The chat containing the message.
118
+ message_id (:obj:`int`): Unique message identifier inside the chat.
119
+ date (:class:`datetime.datetime`): Date of the change in Unix time.
120
+ |datetime_localization|
121
+ old_reaction (Sequence[:class:`telegram.ReactionType`]): Previous list of reaction types
122
+ that were set by the user.
123
+ new_reaction (Sequence[:class:`telegram.ReactionType`]): New list of reaction types that
124
+ were set by the user.
125
+ user (:class:`telegram.User`, optional): The user that changed the reaction, if the user
126
+ isn't anonymous.
127
+ actor_chat (:class:`telegram.Chat`, optional): The chat on behalf of which the reaction was
128
+ changed, if the user is anonymous.
129
+
130
+ Attributes:
131
+ chat (:class:`telegram.Chat`): The chat containing the message.
132
+ message_id (:obj:`int`): Unique message identifier inside the chat.
133
+ date (:class:`datetime.datetime`): Date of the change in Unix time.
134
+ |datetime_localization|
135
+ old_reaction (Tuple[:class:`telegram.ReactionType`]): Previous list of reaction types
136
+ that were set by the user.
137
+ new_reaction (Tuple[:class:`telegram.ReactionType`]): New list of reaction types that
138
+ were set by the user.
139
+ user (:class:`telegram.User`): Optional. The user that changed the reaction, if the user
140
+ isn't anonymous.
141
+ actor_chat (:class:`telegram.Chat`): Optional. The chat on behalf of which the reaction was
142
+ changed, if the user is anonymous.
143
+ """
144
+
145
+ __slots__ = (
146
+ "actor_chat",
147
+ "chat",
148
+ "date",
149
+ "message_id",
150
+ "new_reaction",
151
+ "old_reaction",
152
+ "user",
153
+ )
154
+
155
+ def __init__(
156
+ self,
157
+ chat: Chat,
158
+ message_id: int,
159
+ date: datetime,
160
+ old_reaction: Sequence[ReactionType],
161
+ new_reaction: Sequence[ReactionType],
162
+ user: Optional[User] = None,
163
+ actor_chat: Optional[Chat] = None,
164
+ *,
165
+ api_kwargs: Optional[JSONDict] = None,
166
+ ):
167
+ super().__init__(api_kwargs=api_kwargs)
168
+ # Required
169
+ self.chat: Chat = chat
170
+ self.message_id: int = message_id
171
+ self.date: datetime = date
172
+ self.old_reaction: Tuple[ReactionType, ...] = parse_sequence_arg(old_reaction)
173
+ self.new_reaction: Tuple[ReactionType, ...] = parse_sequence_arg(new_reaction)
174
+
175
+ # Optional
176
+ self.user: Optional[User] = user
177
+ self.actor_chat: Optional[Chat] = actor_chat
178
+
179
+ self._id_attrs = (
180
+ self.chat,
181
+ self.message_id,
182
+ self.date,
183
+ self.old_reaction,
184
+ self.new_reaction,
185
+ )
186
+ self._freeze()
187
+
188
+ @classmethod
189
+ def de_json(
190
+ cls, data: Optional[JSONDict], bot: Optional["Bot"] = None
191
+ ) -> Optional["MessageReactionUpdated"]:
192
+ """See :meth:`telegram.TelegramObject.de_json`."""
193
+ data = cls._parse_data(data)
194
+
195
+ if not data:
196
+ return None
197
+
198
+ # Get the local timezone from the bot if it has defaults
199
+ loc_tzinfo = extract_tzinfo_from_defaults(bot)
200
+
201
+ data["date"] = from_timestamp(data.get("date"), tzinfo=loc_tzinfo)
202
+ data["chat"] = Chat.de_json(data.get("chat"), bot)
203
+ data["old_reaction"] = ReactionType.de_list(data.get("old_reaction"), bot)
204
+ data["new_reaction"] = ReactionType.de_list(data.get("new_reaction"), bot)
205
+ data["user"] = User.de_json(data.get("user"), bot)
206
+ data["actor_chat"] = Chat.de_json(data.get("actor_chat"), bot)
207
+
208
+ return super().de_json(data=data, bot=bot)