Compare commits

...

506 Commits

Author SHA1 Message Date
Hinrich Mahler 59105b240f Bump Version to v20.4 2023-07-09 12:18:32 +02:00
Bibo-Joshi db6030ea83 Documentation Improvements (#3698, #3708, #3767)
Co-authored-by: Iulian Onofrei <5748627+revolter@users.noreply.github.com>
Co-authored-by: Poolitzer <github@poolitzer.eu>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Aditya <clot27@apx_managed.vanilla>
2023-07-09 11:22:08 +02:00
pre-commit-ci[bot] 7d52ead228 pre-commit autoupdate (#3791)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2023-07-06 18:57:51 +02:00
Harshil 589047ddbf Add Python 3.12 Beta to the Test Matrix (#3751) 2023-07-05 21:58:57 +02:00
Bibo-Joshi 5534ddfaa0 Use Temporary Files for Testing File Downloads (#3777) 2023-07-03 10:06:16 +02:00
dependabot[bot] 1d27a0fadb Bump srvaroa/labeler from 1.5.0 to 1.6.0 (#3786)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 18:07:30 +02:00
dependabot[bot] 79cda7582e Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0 (#3787)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 17:56:58 +02:00
dependabot[bot] dccf62eb1c Bump dessant/lock-threads from 4.0.0 to 4.0.1 (#3785)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 17:56:21 +02:00
Bibo-Joshi fb86bb3417 Drop Support for Python 3.7 (#3728, #3742, #3749, #3740, #3754, #3753, #3764, #3762, #3759)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Luca Bellanti <luca.bellanti@gmail.com>
Co-authored-by: thefunkycat <104379699+thefunkycat@users.noreply.github.com>
Co-authored-by: Aditya Yadav <69784758+clot27@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2023-06-29 18:17:47 +02:00
Harshil 58b89cf0e9 Add More ruff Rules (#3763) 2023-06-29 11:38:09 +02:00
Bibo-Joshi 4a6e0fd7a6 Add Quotes for Installation Instructions With Optional Dependencies (#3780) 2023-06-29 07:46:00 +02:00
dependabot[bot] 623d2f7f0b Bump pytest from 7.3.2 to 7.4.0 (#3774)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2023-06-26 22:14:19 +02:00
Bibo-Joshi 62a8cfc395 Rework pytest Integration into GitHub Actions (#3776) 2023-06-26 19:48:38 +02:00
Harshil b0cff31fc1 Rename _handler.py to _basehandler.py (#3761) 2023-06-25 15:08:26 +02:00
Harshil 3c87e450fb Fix Wrong Warning Text in KeyboardButton.__eq__ (#3768) 2023-06-22 10:21:53 +02:00
dependabot[bot] 8e91a6adba Bump pytest from 7.3.1 to 7.3.2 (#3758) 2023-06-17 09:16:31 +02:00
Dmitry Kolomatskiy 63fd846233 Set httpx Logging Level to Warning in Examples (#3746) 2023-06-07 22:32:04 +02:00
pre-commit-ci[bot] 814c72052f pre-commit autoupdate (#3747)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-06-07 21:51:40 +02:00
Luca Bellanti 1a7edd7a5d Explicitly set allowed_updates in Examples (#3741) 2023-06-04 17:11:58 +02:00
dependabot[bot] f0e71216fe Update cachetools requirement from ~=5.3.0 to ~=5.3.1 (#3738) 2023-06-03 08:44:14 +02:00
Bibo-Joshi ca37219a68 Fix Two Bugs in GitHub Actions Workflows (#3739) 2023-06-03 08:28:08 +02:00
dependabot[bot] c9636726f7 Bump sphinxcontrib-mermaid from 0.8.1 to 0.9.2 (#3737) 2023-06-03 07:48:17 +02:00
Bibo-Joshi 9c8d6efe7a Make Integration of APScheduler into JobQueue More Explicit (#3695) 2023-06-02 22:17:46 +02:00
Aditya Yadav bf54599618 Introduce BaseUpdateProcessor for Customized Concurrent Handling of Updates (#3654)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-06-02 18:17:08 +02:00
Bibo-Joshi 4c8d7332db Auto-Update Changed Version in Other Files After Dependabot PRs (#3716) 2023-05-31 22:19:56 +02:00
Harshil c185137c9e Bump furo and sphinx 7 (#3719) 2023-05-25 22:47:05 +02:00
Bibo-Joshi 3c5a16be1c Exclude Type Hints from Stability Policy (#3712) 2023-05-24 21:42:30 +02:00
dependabot[bot] cd25964419 Update httpx requirement from ~=0.24.0 to ~=0.24.1 (#3715)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-05-20 14:23:40 +02:00
Bibo-Joshi 5309cf6555 Automatically Label pre-commit-ci PRs (#3713) 2023-05-20 10:27:51 +02:00
dependabot[bot] bb8b508a22 Bump pytest-xdist from 3.3.0 to 3.3.1 (#3714)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-20 10:15:57 +02:00
Iulian Onofrei 4f15a7feee Fix Inconsistent Type Hints for timeout Parameter of Bot.get_updates (#3709) 2023-05-19 22:09:16 +02:00
dependabot[bot] 57c780c62f Update aiolimiter requirement from ~=1.0.0 to ~=1.1.0 (#3707)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-05-18 07:59:44 +02:00
MiguelX413 99fd4432db Use Explicit Optionals (#3692)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2023-05-18 07:57:59 +02:00
dependabot[bot] e432c296a9 Bump pytest-xdist from 3.2.1 to 3.3.0 (#3705) 2023-05-15 18:20:50 +02:00
Bibo-Joshi 1fdccd7bf9 Drop a Legacy pre-commit.ci Configuration (#3697) 2023-05-12 22:36:52 +02:00
Hinrich Mahler bfbf6d3f94 Bump Version to v20.3 2023-05-07 15:31:23 +02:00
Bibo-Joshi 0c4180c74b Documentation Improvements (#3628, #3636, #3694)
Co-authored-by: Yossi Rafelson <yossi.rafelson@gmail.com>
Co-authored-by: Aditya <clot27@apx_managed.vanilla>
Co-authored-by: ibragimovgeorge <103066850+ibragimovgeorge@users.noreply.github.com>
2023-05-07 14:51:22 +02:00
Bibo-Joshi 1c6ae435bf Add a Stability Policy (#3622)
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2023-05-07 14:50:41 +02:00
Bibo-Joshi 66b6d3c497 Recover 100% Type Completeness (#3676) 2023-05-07 14:10:20 +02:00
Bibo-Joshi 8c252c9822 API 6.7 (#3673)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Harshil Mehta <37377066+harshil21@users.noreply.github.com>
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Aditya <clot27@apx_managed.vanilla>
2023-05-07 13:44:34 +02:00
Bibo-Joshi 450dc2115c Shield Update Fetcher Task in Application.start (#3657) 2023-05-06 21:10:12 +02:00
pre-commit-ci[bot] 87a6890900 pre-commit autoupdate (#3688) 2023-05-06 20:52:58 +02:00
Bibo-Joshi 83ab12c387 Stabilize test_delete_sticker_set (#3685)
Co-authored-by: poolitzer <github@poolitzer.eu>
2023-04-30 11:03:00 +02:00
Bibo-Joshi 3f444dad8d Improve Warning Categories & Stacklevels (#3674) 2023-04-27 22:36:04 +02:00
Bibo-Joshi f23315d08b Add Logging for Invalid JSON Data in BasePersistence.parse_json_payload (#3668) 2023-04-18 16:17:20 +02:00
Luca Bellanti 7b116be344 Localize Received datetime Objects According to Defaults.tzinfo (#3632) 2023-04-18 16:16:23 +02:00
dependabot[bot] 934e4c9bd4 Bump pytest from 7.2.2 to 7.3.1 (#3661)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2023-04-16 11:24:50 +02:00
dependabot[bot] 1966fb25c5 Update httpx requirement from ~=0.23.3 to ~=0.24.0 (#3660)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2023-04-16 11:20:36 +02:00
dependabot[bot] a333d8514a Bump sphinx-copybutton from 0.5.1 to 0.5.2 (#3662)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2023-04-16 11:15:06 +02:00
Bibo-Joshi b146c7131e Remove Deprecated codecov Package from CI (#3664) 2023-04-16 10:54:49 +02:00
Bibo-Joshi 53093ebceb Give Loggers Better Names (#3623) 2023-04-10 17:01:35 +02:00
Luca Bellanti 401b2decce Make Message.link Point to Thread View Where Possible (#3640) 2023-04-07 17:13:45 +02:00
pre-commit-ci[bot] 83a164e5ef pre-commit autoupdate (#3646)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Harshil Mehta <37377066+harshil21@users.noreply.github.com>
2023-04-05 20:52:52 +02:00
Bibo-Joshi d91bc45cdc Add Application.mark_data_for_update_persistence (#3607) 2023-04-02 22:29:16 +02:00
dependabot[bot] 8967912f46 Bump furo from 2023.3.23 to 2023.3.27 (#3643) 2023-04-02 21:42:57 +02:00
dependabot[bot] 7ab2cafbee Bump actions/stale from 7 to 8 (#3644) 2023-04-02 21:41:37 +02:00
Harshil 7e0ed2235e Stabilize CI by Rerunning Failed Tests (#3631)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2023-04-01 22:35:20 +02:00
Harshil 53abb7b4bd Add String Representation for RequestParameter (#3634) 2023-03-27 22:03:02 +02:00
Harshil 11f86b8813 Drop Usage of sys.maxunicode (#3630) 2023-03-26 21:58:23 +02:00
Harshil 9997a9f47e Empower ruff (#3594) 2023-03-25 19:18:04 +01:00
Hinrich Mahler 4aedb33d37 Bump version to v20.2 2023-03-25 13:25:59 +01:00
Bibo-Joshi 4ddc36c625 Documentation Improvements (#3565, #3600)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Louis Wang <beiluonever@users.noreply.github.com>
2023-03-25 12:48:34 +01:00
dependabot[bot] 311f88a716 Bump pytest-asyncio from 0.20.3 to 0.21.0 (#3624) 2023-03-25 12:25:57 +01:00
dependabot[bot] 179cb49dbc Bump furo from 2022.12.7 to 2023.3.23 (#3625) 2023-03-25 12:25:36 +01:00
Bibo-Joshi 512e390738 API 6.6 (#3584)
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2023-03-25 11:47:26 +01:00
dependabot[bot] 33b677aeb4 Bump pytest-xdist from 3.2.0 to 3.2.1 (#3606) 2023-03-19 10:54:03 +01:00
Poolitzer 800598ced4 Revert to HTTP/1.1 as Default and make HTTP/2 an Optional Dependency (#3576)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2023-03-12 16:30:39 +01:00
pre-commit-ci[bot] ec20f27a82 pre-commit autoupdate (#3577)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-03-08 20:46:51 +01:00
Bibo-Joshi cd59c1c075 Handle Symbolic Links in was_called_by (#3552)
Co-authored-by: hyfc <myloxyloto2012@gmail.com>
2023-03-06 21:59:01 +01:00
dependabot[bot] 52b0f2c3c9 Update apscheduler requirement from ~=3.10.0 to ~=3.10.1 (#3572)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-03-06 21:09:29 +01:00
dependabot[bot] 598f44f4c2 Bump pytest from 7.2.1 to 7.2.2 (#3573) 2023-03-05 16:21:57 +01:00
Bibo-Joshi 22d0dd1301 Tidy Up Tests Directory (#3553) 2023-02-22 20:19:46 +01:00
sam-mosleh c6b6b0a370 Enhance Application.create_task (#3543) 2023-02-20 19:53:27 +01:00
Bibo-Joshi ee6c8a5995 Make Type Completeness Workflow Usable for PRs from Forks (#3551) 2023-02-13 20:39:12 +01:00
dependabot[bot] d5a1a48145 Bump pytest-xdist from 3.1.0 to 3.2.0 (#3550) 2023-02-11 17:42:10 +01:00
Harshil 963edbf191 Refactor and Overhaul the Test Suite (#3426) 2023-02-11 10:45:17 +01:00
dependabot[bot] 43c3c8f568 Bump sphinxcontrib-mermaid from 0.7.1 to 0.8 (#3549) 2023-02-11 10:43:38 +01:00
Hinrich Mahler 49ea8d39fb Bump version to v20.1 2023-02-09 20:58:22 +01:00
Harshil 7e86e8be14 Update cryptography requirement to >=39.0.1 to address Vulnerability (#3539) 2023-02-09 19:32:50 +01:00
Bibo-Joshi 5cff9adb55 Fix CI on Python 3.11 + Windows (#3547) 2023-02-09 18:58:36 +01:00
Harshil 217a5f929e Add Some Graphic Elements to Docs (#3535)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2023-02-08 17:43:14 +01:00
pre-commit-ci[bot] 007f432ee4 pre-commit autoupdate (#3537)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2023-02-08 17:41:10 +01:00
Poolitzer 23a685335b API 6.5 (#3530)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2023-02-08 11:47:21 +01:00
Bibo-Joshi 9953216980 Documentation Improvements (#3464, #3483, #3484, #3497, #3512, #3501, #3515, #3523, #3498, #3529)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Shivam Saini <51438830+shivamsn97@users.noreply.github.com>
Co-authored-by: Aditya Yadav <adityayadav11082@gmail.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Crsi <47722349+CrsiX@users.noreply.github.com>
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Aditya <clot27@apx_managed.vanilla>
2023-02-05 18:09:55 +01:00
Bibo-Joshi bacdeb37fd Increase Verbosity of Type Completeness CI Job (#3531) 2023-02-04 16:45:47 +01:00
dependabot[bot] a0f98b241e Update apscheduler requirement from ~=3.9.1 to ~=3.10.0 (#3532)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-02-04 09:21:28 +01:00
Bibo-Joshi 23d0bd8fe3 Explicit Type Annotations (#3508) 2023-02-02 18:55:07 +01:00
Poolitzer 1701950a1d Bump isort to 5.12.0 (#3525) 2023-02-01 22:11:56 +01:00
dependabot[bot] 851f7ff0b3 Update cachetools requirement from ~=5.2.1 to ~=5.3.0 (#3520)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-01-28 12:36:11 +01:00
Aditya 359232e6c7 Check for 3D Arrays in check_keyboard_type (#3514) 2023-01-22 12:11:52 +01:00
dependabot[bot] 9782510779 Bump pytest from 7.2.0 to 7.2.1 (#3513) 2023-01-21 11:01:25 +01:00
Harshil deb6cb19b3 Allow to Adjust HTTP Version and Use HTTP/2 by Default (#3506) 2023-01-20 21:15:02 +01:00
Bibo-Joshi 21ebdbc973 Lock Inactive Threads Only Once Each Day (#3510) 2023-01-20 20:49:20 +01:00
Dmitry Kolomatskiy 54d0294f92 Enhance chatmemberbot Example (#3500) 2023-01-19 21:33:16 +01:00
Harshil 5693add136 Improve Config for ruff and Bump to v0.0.222 (#3507) 2023-01-15 16:17:02 +01:00
Bibo-Joshi 3dd7d84fa5 Improve Error Message for NetworkError (#3505) 2023-01-15 13:40:20 +01:00
Harshil 4ebcec2b91 Improve Warning for days Parameter of JobQueue.run_daily (#3503) 2023-01-14 18:57:08 +01:00
dependabot[bot] 200b623263 Update cachetools requirement from ~=5.2.0 to ~=5.2.1 (#3502)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-01-14 17:41:47 +01:00
dependabot[bot] c64bd7a715 Update httpx requirement from ~=0.23.1 to ~=0.23.3 (#3489)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-01-07 13:39:23 +01:00
Aditya bbb9fcaaa5 Add ruff to pre-commit Hooks (#3488) 2023-01-06 16:19:49 +01:00
Viicos d48fa71ec5 Add Chat.effective_name Convenience Property (#3485) 2023-01-06 08:15:56 +01:00
Harshil f9cbddd10a Store Documentation Builts as GitHub Actions Artifacts (#3468) 2023-01-06 08:14:09 +01:00
Harshil 2797d9d305 Cache Dependencies on GitHub Actions (#3469) 2023-01-06 08:13:20 +01:00
Aditya 19302bce25 Add Application(Builder).post_stop (#3466) 2023-01-04 16:48:48 +01:00
Aditya 3507cb13e6 Fix Dependency Warning Typo (#3474) 2023-01-03 18:50:06 +01:00
pre-commit-ci[bot] 6b59365464 pre-commit autoupdate (#3470) 2023-01-03 13:27:56 +01:00
dependabot[bot] 74da17153b Bump dessant/lock-threads from 3.0.0 to 4.0.0 (#3462) 2023-01-02 21:55:21 +01:00
dependabot[bot] 97e6e7e206 Bump actions/stale from 6 to 7 (#3461) 2023-01-02 21:53:44 +01:00
Bibo-Joshi d1159cd5ac Stabilize Tests on Closing and Hiding the General Forum Topic (#3460) 2023-01-02 19:45:07 +01:00
Bibo-Joshi 51ad4d76d0 Update Copyright to 2023 (#3459) 2023-01-01 21:31:29 +01:00
Hinrich Mahler 171953f109 Bump version to v20.0 2023-01-01 17:20:54 +01:00
Harshil 606773d8f0 API 6.4 (#3449)
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-01-01 17:00:49 +01:00
Bibo-Joshi f408b1a2dd Documentation Improvements (#3428, #3423, #3429, #3441, #3404, #3443)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Viicos <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Eisberge <22561095+Eisberge@users.noreply.github.com>
Co-authored-by: Joshua Tang <joshuaystang@gmail.com>
2023-01-01 16:24:00 +01:00
Harshil 3e7ab7e7af Downgrade sphinx to 5.3.0 to Fix Search (#3457) 2023-01-01 15:48:48 +01:00
Aditya 456b81d22a Allow Sequence Input for Bot Methods (#3412)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2023-01-01 14:24:30 +01:00
Bibo-Joshi cb90814829 Update Link-Check CI and Replace a Dead Link (#3456) 2023-01-01 13:48:24 +01:00
Bibo-Joshi 7b61a30fb1 Freeze Classes Without Arguments (#3453) 2023-01-01 13:04:37 +01:00
dependabot[bot] f3a9b74445 Bump sphinx from 5.3.0 to 6.0.0 (#3450)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-12-31 16:59:49 +01:00
Dmitry Kolomatskiy d996e8f9c9 Add New Constants (#3444) 2022-12-30 14:09:06 +01:00
Bibo-Joshi 0a6725852f Override Bot.__deepcopy__ to Raise TypeError (#3446) 2022-12-30 10:50:49 +01:00
Bibo-Joshi b8fbb89fae Add Log Decorator to Bot.get_webhook_info (#3442) 2022-12-27 19:02:50 +01:00
Bibo-Joshi f3650364b9 Add Documention On Verifying Releases (#3436) 2022-12-21 16:55:58 +01:00
Bibo-Joshi 5b629ede56 Drop Undocumented Job.__lt__ (#3432) 2022-12-19 18:32:53 +01:00
Hinrich Mahler 28afeccf70 Bump version to v20.0b0 2022-12-15 15:54:00 +01:00
Bibo-Joshi 9467847d74 Documentation Improvements (#3386)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Viicos <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-12-15 15:20:04 +01:00
Bibo-Joshi b11a0c7778 Make TelegramObject Immutable (#3249) 2022-12-15 15:00:36 +01:00
Bibo-Joshi ff645c6fe2 Reduce Code Duplication in Testing Defaults (#3419) 2022-12-12 10:51:33 +01:00
dependabot[bot] 9c3053b3f9 Bump pytest-xdist from 3.0.2 to 3.1.0 (#3415) 2022-12-11 15:28:12 +01:00
dependabot[bot] 5a6c9cc777 Bump pytest-asyncio from 0.20.2 to 0.20.3 (#3417) 2022-12-11 15:27:51 +01:00
pre-commit-ci[bot] 6e4a1f0a21 pre-commit autoupdate (#3409)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-12-06 11:28:47 +01:00
Aditya f8be97c12c Add Notes and Warnings About Optional Dependencies (#3393) 2022-12-02 12:08:11 +01:00
Harshil 4123e7aa57 Simplify Internals of Bot Methods (#3396) 2022-12-01 19:26:01 +01:00
Dmitry Kolomatskiy 637cc574ab Reduce Code Duplication in Several Bot Methods (#3385) 2022-11-26 19:05:44 +01:00
Hinrich Mahler 3042f187ed Bump version to v20.0a6 2022-11-24 12:32:43 +01:00
Bibo-Joshi 867f742d08 Only Persist Arbitrary callback_data if ExtBot.callback_data_cache is Present (#3384) 2022-11-24 12:13:54 +01:00
Harshil 1724212458 Improve Backwards Compatibility of TelegramObjects Pickle Behavior (#3382)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-11-24 12:11:37 +01:00
Bibo-Joshi 05c6ca06f8 Fix Naming and Keyword Arguments of File.download_* Methods (#3380) 2022-11-24 12:09:51 +01:00
Poolitzer 8c03f0e2eb Fix Return Value Annotation of Chat.create_forum_topic (#3381)
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-23 13:21:10 +01:00
Hinrich Mahler 20c3532e01 Bump version to v20.0a5 2022-11-22 12:51:57 +01:00
Dmitry Kolomatskiy 6cba7f164e Merge ChatDescriptionLimit Enum Into ChatLimit (#3377) 2022-11-22 12:09:44 +01:00
Dmitry Kolomatskiy c3f8fcd7b7 Add Several New Enums To Constants (#3351) 2022-11-22 11:07:42 +01:00
Harshil caacafa090 API 6.3 (#3346)
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
Co-authored-by: Clot <69784758+clot27@users.noreply.github.com>
2022-11-22 10:43:50 +01:00
Bibo-Joshi 0a614e4bab Documentation Improvements (#3370, #3376, #3366)
Co-authored-by: Viicos <65306057+Viicos@users.noreply.github.com>
2022-11-22 10:39:20 +01:00
dependabot[bot] c12a04c224 Update httpx requirement from ~=0.23.0 to ~=0.23.1 (#3373) 2022-11-20 18:00:52 +01:00
Bibo-Joshi 5c3b06f015 Update Meta Config (#3365) 2022-11-15 17:47:24 +01:00
Bibo-Joshi 9520c6eeba Documentation Improvements (#3214, #3217, #3218, #3271, #3289, #3292, #3303, #3312, #3306, #3319, #3326, #3314)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Simon Fong <44134941+simonfongnt@users.noreply.github.com>
Co-authored-by: Piotr Rogulski <rivinek@gmail.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Or Bin <or@raftt.io>
Co-authored-by: Sandro <j32g7f67hb@liamekaens.com>
Co-authored-by: Hatim Zahid <63000127+HatimZ@users.noreply.github.com>
Co-authored-by: Robi <53259730+RobiMez@users.noreply.github.com>
Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
2022-11-15 09:06:23 +01:00
dependabot[bot] 70aa674226 Bump pytest-asyncio from 0.20.1 to 0.20.2 (#3359) 2022-11-14 20:19:00 +01:00
Bibo-Joshi 422aa86874 Fix Defaults Handling in Bot.answer_web_app_query (#3362) 2022-11-14 20:08:16 +01:00
Harshil b44af136e7 Update PR Template (#3361) 2022-11-13 21:37:20 +01:00
Harshil e54c6a04de Handle Lists and Tuples and Datetimes Directly in TelegramObject.to_dict (#3353) 2022-11-13 21:28:41 +01:00
Harshil e1d56178c8 Fix DeepSource Issues (#3357) 2022-11-11 18:18:42 +01:00
Harshil 1d1d774d9f Flaky Unit Tests: Use pytest Marker (#3354) 2022-11-09 20:43:27 +01:00
Bibo-Joshi 8dead11a25 Improve Unit Tests Regarding ChatMemberUpdated.difference (#3352) 2022-11-08 17:56:39 +01:00
Bibo-Joshi 53c3a130ab Add Three New Test Bots (#3347) 2022-11-06 20:34:12 +01:00
Harshil 834568d7f4 Add a Test for MessageAttachmentType (#3335) 2022-11-06 16:04:01 +01:00
Dmitry Kolomatskiy d2c6c4b369 Add Shortcut Parameters caption, parse_mode and caption_entities to Bot.send_media_group (#3295) 2022-11-02 08:32:40 +01:00
Poolitzer 636654cb71 Split File.download Into File.download_to_drive And File.download_to_memory (#3223) 2022-11-02 08:28:41 +01:00
Biruk Alamirew 55106d6d57 Add constants.MessageLimit.DEEP_LINK_LENGTH (#3315) 2022-11-01 17:58:58 +01:00
pre-commit-ci[bot] a1e6a6e779 pre-commit autoupdate (#3325) 2022-11-01 12:59:06 +01:00
Bibo-Joshi e58cbcdb17 Make Almost All 3rd Party Dependencies Optional (#3267) 2022-10-31 10:12:18 +01:00
Bibo-Joshi 9e42dab184 Don't Edit Objects In-Place When Inserting ext.Defaults (#3311) 2022-10-31 09:46:56 +01:00
miles 25dc87a633 Add Methods Chat.mention_{html, markdown, markdown_v2} (#3308) 2022-10-31 09:45:21 +01:00
Bibo-Joshi f68663af7e Overhaul String Representation of TelegramObject (#3234) 2022-10-30 11:21:19 +01:00
dependabot[bot] 07f8dd1cb1 Bump pytest from 7.1.3 to 7.2.0 (#3318) 2022-10-29 16:05:55 +02:00
dependabot[bot] 18c15ed8d1 Bump pytest-xdist from 2.5.0 to 3.0.2 (#3317) 2022-10-29 14:56:31 +02:00
Harshil 959e6a8470 Update Test Matrix to Use Stable Python 3.11 (#3313) 2022-10-27 09:24:23 +02:00
dependabot[bot] 76c2fc1776 Bump sphinx from 5.2.3 to 5.3.0 (#3300)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-10-23 14:59:27 +02:00
dependabot[bot] 6340d6652a Bump pytest-asyncio from 0.19.0 to 0.20.1 (#3299) 2022-10-23 14:58:56 +02:00
Harshil 87b2e29d60 Run Unit Tests in Parallel (#3283) 2022-10-23 14:25:49 +02:00
Harshil 24d390e1aa Add recursive Parameter to TelegramObject.to_dict() (#3276) 2022-10-19 10:31:55 +02:00
Harshil 210f9afd66 Type Hinting Fix for Message.effective_attachment (#3294) 2022-10-17 20:38:53 +02:00
Harshil eb818da93f Add Two Constants Related to Local Bot API Servers (#3296) 2022-10-17 19:58:28 +02:00
Bibo-Joshi 1c20ff3fb9 Introduce TelegramObject.api_kwargs (#3233) 2022-10-07 11:51:53 +02:00
Bibo-Joshi fb87418473 Read-Only CallbackDataCache (#3266) 2022-10-07 10:18:08 +02:00
pre-commit-ci[bot] 870a20e834 pre-commit autoupdate (#3282) 2022-10-06 15:26:42 +02:00
dependabot[bot] 5b7356d905 Bump actions/stale from 5 to 6 (#3277) 2022-10-03 10:14:49 +02:00
Bibo-Joshi 918c486c65 Skip JobQueue Tests on Windows Again (#3280) 2022-10-03 10:12:08 +02:00
miles 26e7cd2afb Add chat_id and username Parameters to ChatJoinRequestHandler (#3261) 2022-10-02 17:54:30 +02:00
dependabot[bot] 2eda63e9ae Bump furo from 2022.6.21 to 2022.9.29 (#3268) 2022-10-01 22:33:55 +02:00
dependabot[bot] b2902a0789 Bump sphinx from 5.1.1 to 5.2.3 (#3269) 2022-10-01 13:41:45 +02:00
Bibo-Joshi edc3e2be84 Make Job.job a Property and Make Jobs Hashable (#3250) 2022-09-28 21:33:15 +02:00
Bibo-Joshi c6721a799d Fix CallbackQueryHandler Not Handling Non-String Data Correctly With Regex Patterns (#3252) 2022-09-22 20:30:30 +02:00
Bibo-Joshi fdfbcdf51e Explicit local_mode Setting (#3154) 2022-09-19 22:31:23 +02:00
Bibo-Joshi aed8e68fca Add Properties for API Settings of Bot (#3247) 2022-09-18 15:42:12 +02:00
Harshil 50249206df Bump Python 3.11 to RC2 in Test Matrix (#3246) 2022-09-17 15:09:41 +02:00
pre-commit-ci[bot] 5480be4c25 pre-commit Updates (#3221) 2022-09-17 15:08:54 +02:00
Bibo-Joshi 436b5ff7a8 Switch from Stale Bot to GitHub Actions (#3243) 2022-09-16 22:42:45 +02:00
Harshil 3536bb247e Improve Warning About Unknown ConversationHandler States (#3242) 2022-09-16 22:13:11 +02:00
dependabot[bot] a80a053b0a Bump pytest from 7.1.2 to 7.1.3 (#3228) 2022-09-11 10:37:43 +02:00
Hinrich Mahler 2642ecc737 Bump version to v20.0a4 2022-08-27 13:25:57 +02:00
Bibo-Joshi abfcf72a56 Fix setup.py Regarding Optional Dependencies (#3209) 2022-08-27 13:23:17 +02:00
Hinrich Mahler 0e044804d2 Bump version to v20.0a3 2022-08-27 12:39:38 +02:00
Bibo-Joshi 5b9afd5329 Type Hinting Fixes (#3202) 2022-08-27 11:58:28 +02:00
Bibo-Joshi a983a89964 Documentation Improvements (#3139, #3153, #3135)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Poolitzer <github@poolitzer.eu>
Co-authored-by: Pawan <pawanrai9999@gmail.com>
Co-authored-by: Aditya Yadav <69784758+aditya-yadav-27@users.noreply.github.com>
2022-08-27 11:46:51 +02:00
Bibo-Joshi 741a50ab97 New Rate Limiting Mechanism (#3148) 2022-08-26 06:50:03 +02:00
Poolitzer cf6c298b82 API 6.2 (#3195)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-08-25 19:36:55 +02:00
Harshil 90c0fe948b Add Python 3.11 to Test Suite & Adapt Enum Behaviour (#3168) 2022-08-17 18:24:50 +02:00
dependabot[bot] 2c84122654 Bump sphinx from 5.0.2 to 5.1.1 (#3177)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-03 22:03:00 +02:00
Harshil 143db5fc9d Drop Manual Token Validation (#3167) 2022-08-03 08:16:48 +02:00
pre-commit-ci[bot] c28ad86214 Update pre-commit Dependencies (#3085)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-08-02 08:26:36 +02:00
dependabot[bot] 15f153474a Bump pytest-asyncio from 0.18.3 to 0.19.0 (#3158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-17 13:34:08 +02:00
Harshil 55d66a9ea3 Fix helpers.mention_markdown for Markdown V1 and Improve Related Unit Tests (#3155)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-07-17 13:07:21 +02:00
dependabot[bot] 14c86daf23 Update tornado requirement from ~=6.1 to ~=6.2 (#3149)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-07-12 20:16:22 +02:00
Bibo-Joshi 460aaf8bb6 Make chat/user_data Available in Error Handler for Errors in Jobs (#3152) 2022-07-11 07:54:03 +02:00
Harshil 1e703a0be5 Simplify Unit Tests for Bot.send_chat_action (#3151) 2022-07-10 17:14:45 +02:00
Bibo-Joshi 142e3c0177 Add api_kwargs Paramater to Bot.log_out and Improve Related Unit Tests (#3147) 2022-07-10 15:37:12 +02:00
Bibo-Joshi d4b7a2b3e9 Drop pre-commit Dependencies from requirements-dev.txt (#3120)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-07-09 23:12:07 +02:00
dependabot[bot] dac6d03666 Bump black from 22.3.0 to 22.6.0 (#3132)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-07-08 00:13:57 +02:00
dependabot[bot] 3bfd58dfd9 Bump actions/setup-python from 3 to 4 (#3131)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-07 23:21:20 +02:00
Bibo-Joshi 2d6459b290 Make Bot.delete_my_commands a Coroutine Function (#3136) 2022-07-04 19:33:45 +02:00
Alex 1f0f6a8d3d Add Application.post_shutdown (#3126)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-07-03 15:22:50 +02:00
Bibo-Joshi 2ecb8d5413 Fix ConversationHandler.check_update not respecting per_user (#3128) 2022-07-03 15:21:04 +02:00
Bibo-Joshi f1d03393de Change Default Values for concurrent_updates and connection_pool_size (#3127) 2022-06-29 21:38:03 +02:00
Hinrich Mahler df07148e2d Bump version to v20.0a2 2022-06-27 19:19:54 +02:00
Bibo-Joshi 2d2cede442 Documentation Improvements (#3103, #3121, #3098)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: David <dsb321mp@gmail.com>
Co-authored-by: Harshil Mehta <37377066+harshil21@users.noreply.github.com>
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Alex <53974096+ExalFabu@users.noreply.github.com>
2022-06-27 18:58:51 +02:00
Poolitzer 08e223ba90 API 6.1 (#3112)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-27 18:54:11 +02:00
Bibo-Joshi 01d643913e Stabilize CI (#3119) 2022-06-27 18:46:52 +02:00
Aditya Yadav 755945172d Add Additional Shortcut Methods to Chat (#3115) 2022-06-27 18:45:30 +02:00
dependabot[bot] 24b4de9f10 Bump pyupgrade from 2.32.1 to 2.34.0 (#3096)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-25 11:52:39 +02:00
David 76bfe8ceff Mermaid-based Example State Diagrams (#3090)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-06-24 18:15:10 +02:00
dependabot[bot] b498786d7c Bump furo from 2022.6.4 to 2022.6.4.1 (#3095)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-19 17:12:54 +02:00
dependabot[bot] bfe30048e8 Bump mypy from 0.960 to 0.961 (#3093)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-19 17:12:26 +02:00
Hinrich Mahler e25c523b69 Bump version to v20.0a1 2022-06-09 19:07:15 +02:00
Bibo-Joshi 67e7468366 Move Examples To Documentation (#3089) 2022-06-09 17:22:32 +02:00
Bibo-Joshi 11007c1715 Documentation Improvements (#3010, #3007, #3012, #3067, #3081, #3082)
Co-authored-by: KnorpelSenf <shtrog@gmail.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Poolitzer <github@poolitzer.eu>
Co-authored-by: Adi <71205439+Aditya-Rajgor@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-09 17:08:54 +02:00
Poolitzer d6e95f1974 Improve Some Unit Tests (#3026)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-09 17:07:28 +02:00
dependabot[bot] de28f177bd Update cachetools requirement from ~=5.1.0 to ~=5.2.0 (#3080)
* Update cachetools requirement from ~=5.1.0 to ~=5.2.0

Updates the requirements on [cachetools](https://github.com/tkem/cachetools) to permit the latest version.
- [Release notes](https://github.com/tkem/cachetools/releases)
- [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/tkem/cachetools/compare/v5.1.0...v5.2.0)

---
updated-dependencies:
- dependency-name: cachetools
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* update pre-commit as well

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-09 17:06:49 +02:00
Bibo-Joshi 63104ac0b3 Add Application.post_init (#3078) 2022-06-08 07:44:22 +02:00
Bibo-Joshi 22419c0464 Fix Non-Blocking Entry Point in ConversationHandler (#3068) 2022-06-07 17:48:26 +02:00
Bibo-Joshi 42276338b1 Add Arguments chat/user_id to CallbackContext And Example On Custom Webhook Setups (#3059)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-06-03 16:55:36 +02:00
dependabot[bot] 5f547f3725 Update httpx requirement from ~=0.22.0 to ~=0.23.0 (#3069)
* Update httpx requirement from ~=0.22.0 to ~=0.23.0

Updates the requirements on [httpx](https://github.com/encode/httpx) to permit the latest version.
- [Release notes](https://github.com/encode/httpx/releases)
- [Changelog](https://github.com/encode/httpx/blob/master/CHANGELOG.md)
- [Commits](https://github.com/encode/httpx/compare/0.22.0...0.23.0)

---
updated-dependencies:
- dependency-name: httpx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* update other places as well

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-02 10:10:08 +02:00
dependabot[bot] 8e7220e5db Update cachetools requirement from ~=5.0.0 to ~=5.1.0 (#3058)
* Update cachetools requirement from ~=5.0.0 to ~=5.1.0

Updates the requirements on [cachetools](https://github.com/tkem/cachetools) to permit the latest version.
- [Release notes](https://github.com/tkem/cachetools/releases)
- [Changelog](https://github.com/tkem/cachetools/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/tkem/cachetools/compare/v5.0.0...v5.1.0)

---
updated-dependencies:
- dependency-name: cachetools
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* update other places as well

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-06-02 10:09:05 +02:00
dependabot[bot] 977d56ab43 Bump mypy from 0.950 to 0.960 (#3070)
* Bump mypy from 0.950 to 0.960

Bumps [mypy](https://github.com/python/mypy) from 0.950 to 0.960.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.950...v0.960)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* update pre-commit as well

* fix type hint for CIRHandler.collect_additional_context

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-06-02 10:08:15 +02:00
Poolitzer 306cc64170 Don't Set Signal Handlers On Windows By Default (#3065) 2022-06-02 09:43:03 +02:00
dglitxh 42955ecddf Add Convenience Property Message.id (#3077) 2022-06-01 21:29:46 +02:00
Bibo-Joshi 67869693a7 Expose BaseRequest.parse_json_payload (#3072) 2022-06-01 21:26:18 +02:00
Bibo-Joshi 6ded9cc25c Drop InputFile.is_image (#3053) 2022-05-29 14:35:26 +02:00
Bibo-Joshi 5e0bcfbcc6 Drop Explicit Type conversions in __init__ s (#3056)
* Drop explicit type conversions in `__init__` s

* missed one
2022-05-26 19:16:30 +02:00
Bibo-Joshi a17a4c6c8f Handle List-Valued Attributes More Consistently (#3057) 2022-05-26 19:15:54 +02:00
Bibo-Joshi dc13b69dac Split {Command, Prefix}Handler And Make Attributes Immutable (#3045) 2022-05-26 11:10:00 +02:00
James Carl Necio 349baa0202 Align Behavior Of JobQueue.run_daily With cron (#3046) 2022-05-25 10:02:00 +02:00
Bibo-Joshi 5e24765bbc Escape Backslashes in escape_markdown (#3055) 2022-05-21 16:54:11 +02:00
Bibo-Joshi e10d933fde Add Example for WebApp (#3052) 2022-05-19 22:14:02 +02:00
Bibo-Joshi 2175af6abc Apply isort and Update pre-commit.ci Configuration (#3049) 2022-05-19 15:10:08 +02:00
Bibo-Joshi ca4e4c6280 Drop Support for ujson (#3037) 2022-05-19 12:47:53 +02:00
Bibo-Joshi d2cabcaa74 Adjust pre-commit Settings for isort (#3043) 2022-05-18 17:23:00 +02:00
tal66 076955d04d Make PTB Specific Keyword-Only Arguments for PTB Specific in Bot methods (#3035)
* Introduce keyword-only arguments in Bot methods

* partial code review fix

* tests, code rev changes

* flake8

* tests, code rev, more shortcut methods

* One more iteration on `check_shortcut_signature`

* Update tests/conftest.py

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>

Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-18 17:18:44 +02:00
Bibo-Joshi c1041655f6 Adjust Equality Comparisons to Fit Bot API 6.0 (#3033) 2022-05-18 07:48:20 +02:00
dependabot[bot] 298c5fab3b Bump pylint from 2.13.8 to 2.13.9 (#3032)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-15 22:23:04 +02:00
Harshil 3013870c1f Add Version Check to Examples (#3036) 2022-05-15 14:08:40 +02:00
Bibo-Joshi 5e924014de Add Tuple Based Version Info and Rename telegram.bot_api_version to telegram.__bot_api_version__ (#3030) 2022-05-14 15:50:12 +02:00
Bibo-Joshi f792102212 Use Collection Instead of List and Tuple (#3025) 2022-05-13 16:41:34 +02:00
dependabot[bot] 72e357a780 Bump dessant/lock-threads from 2.0.1 to 3.0.0 (#2998)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-12 19:54:59 +02:00
Harshil 72c3eb857b Improve Type Annotations for CallbackContext and Move Default Type Alias to ContextTypes.DEFAULT_TYPE (#3017, #3023)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-12 19:36:25 +02:00
Aditya Yadav 1f7efe4519 Rename Job.context to Job.data (#3028) 2022-05-12 19:26:03 +02:00
Bibo-Joshi e47d18c9ec Remove Client-Side Parameter Validation (#3024) 2022-05-12 19:20:24 +02:00
Bibo-Joshi 65bbea780a Rename Handler to BaseHandler (#3019) 2022-05-12 18:18:40 +02:00
dependabot[bot] 23ed0880d2 Bump pyupgrade from 2.32.0 to 2.32.1 (#2999)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-10 18:35:59 +02:00
Bibo-Joshi a299867b1b Stabilize Application.run_* on Python 3.7 (#3009) 2022-05-10 18:35:20 +02:00
Harshil be8f4f7aad Don't Pass Default Values of Optional Parameters to Telegram (#2978) 2022-05-09 19:30:46 +02:00
Bibo-Joshi ea8089ad3e Ignore Code Style Commits in git blame (#3003) 2022-05-09 19:29:22 +02:00
Bibo-Joshi d917404de1 Adjust Tests to Changed API Behavior (#3002) 2022-05-07 21:47:50 +02:00
Hinrich Mahler 95d6272d20 Bump version to v20.0a0 2022-05-06 19:03:54 +02:00
Bibo-Joshi a10bf3241e Documentation Fixes & Improvements (#2969)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:22:36 +02:00
Bibo-Joshi 950d9a0751 Extend Code Formatting With Black (#2972) 2022-05-06 18:22:35 +02:00
Bibo-Joshi 62cbd11f14 Adapt Tests to Changed Bot.get_file Behavior (#2995) 2022-05-06 18:22:34 +02:00
Harshil 335772568f Update and Expand Tests & pre-commit Settings and Improve Code Quality (#2925)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:22:34 +02:00
Harshil e10f9164fe API 6.0 (#2956)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:22:34 +02:00
Bibo-Joshi a491eead5a Update Dependency Policy (#2958) 2022-05-06 18:22:28 +02:00
Bibo-Joshi 823d030c2c Use enums for dynamic types & rename two attributes in ChatMember (#2817) 2022-05-06 18:21:36 +02:00
Poolitzer d4e1a19ab1 adding permissions to workflow (#2984) 2022-05-06 18:21:36 +02:00
Bibo-Joshi 36888a7c47 Fix a Bug in ChatMemberUpdated.difference (#2947) 2022-05-06 18:21:36 +02:00
Poolitzer 97281da351 Add Convenience Shortcuts ChatPermissions.{all, no}_permissions (#2948) 2022-05-06 18:20:58 +02:00
Bibo-Joshi 3c8953cc5a Add Python 3.10 to Test Suite (#2968) 2022-05-06 18:19:15 +02:00
Harshil 7c113f5c75 Expand and Adjust filters.{Document, Sticker} (#2922)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:15 +02:00
Bibo-Joshi 42eaa67fd5 Switch to asyncio (#2731)
Co-authored-by: tsnoam <tsnoam@gmail.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2022-05-06 18:19:15 +02:00
Harshil a743726b08 Persistence of Bots: Refactor Automatic Replacement and Integration with TelegramObject (#2893) 2022-05-06 18:19:15 +02:00
Bibo-Joshi 7b37f9a6fa Documentation Improvements (#2856, #2798, #2854, #2841)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:19:15 +02:00
Harshil 835434c12f Return Plain Dicts from BasePersistence.get_*_data (#2873) 2022-05-06 18:19:15 +02:00
murugu-21 778eadbe7c Replace git.io Links (#2872)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:15 +02:00
DonalDuck004 9c9b133ed2 Add Dispatcher.migrate_chat_data (#2848)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:19:14 +02:00
Harshil 8560af9c4f Remove telegram.ReplyMarkup (#2870) 2022-05-06 18:19:14 +02:00
Harshil 0ccd7d40ac Add Method drop_chat/user_data to Dispatcher and Persistence (#2852) 2022-05-06 18:19:14 +02:00
Harshil e442782d8f Fix failing animation tests (#2865) 2022-05-06 18:19:14 +02:00
Harshil f4147fb583 Improve Code Quality & Test Suite (#2843) 2022-05-06 18:19:14 +02:00
Harshil 9354db7c19 Defaults.protect_content (#2840) 2022-05-06 18:19:14 +02:00
Bibo-Joshi 0a6cc7f722 Documentation Fixes & Improvements (#2822)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:19:14 +02:00
Bibo-Joshi 6382361161 Improve Job.__getattr__ (#2832) 2022-05-06 18:19:14 +02:00
Harshil 5891db2f6b Add Dispatcher.add_handlers (#2823)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:14 +02:00
Bibo-Joshi 9a8c76fc2b Improve Error Messages in CommandHandler.__init__ (#2837) 2022-05-06 18:19:14 +02:00
Bibo-Joshi ced58b790e Documentation Improvements (#2693, #2691, #2739) 2022-05-06 18:19:14 +02:00
Harshil 89d5310504 Use __all__ Consistently (#2805) 2022-05-06 18:19:13 +02:00
Bibo-Joshi de85eec674 Convenience Functionality for ChatInviteLinks (#2782) 2022-05-06 18:19:13 +02:00
Harshil 9b56be44b4 Update pre-commit Settings & Improve a Test (#2796) 2022-05-06 18:19:13 +02:00
Simon Damberg 28c8c155ce Improve Subscription of TelegramObject (#2719)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:19:13 +02:00
Bibo-Joshi 55e8c38e50 Improve Code Quality (#2783) 2022-05-06 18:19:13 +02:00
Harshil 145d04230b Overhaul of Filters (#2759) 2022-05-06 18:19:13 +02:00
Poolitzer b852a6866d Refactor Warnings in ConversationHandler (#2755, #2784) 2022-05-06 18:19:13 +02:00
Harshil 44f1ce3784 Update Code Quality Dependencies (#2748) 2022-05-06 18:19:13 +02:00
Harshil 42df3f471d Update Exceptions for Immutable Attributes (#2749) 2022-05-06 18:19:13 +02:00
Zisis Pavloudis 6f9e733f58 Introduce TelegramObject.set/get_bot (#2712) 2022-05-06 18:19:13 +02:00
Bibo-Joshi 0e60d56f53 Introduce Enums for telegram.constants (#2708) 2022-05-06 18:19:13 +02:00
eldbud 7e51901d51 Refactor MRO of InputMedia* and Some File-Like Classes (#2717) 2022-05-06 18:19:13 +02:00
eldbud 59014bee64 Make Tests Agnostic of the CWD (#2727) 2022-05-06 18:19:12 +02:00
Bibo-Joshi 0cb8d50aea Accept File Paths for Updater/DispatcherBuilder.private_key (#2724) 2022-05-06 18:19:12 +02:00
Kenneth Cheo 5275c45199 Mark Internal Modules As Private (#2687)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:12 +02:00
Bibo-Joshi 7afce46d9f Introduce Builder Pattern for Updater and Dispatcher (#2646) 2022-05-06 18:19:12 +02:00
Piraty edb30cf342 Use Error Messages for Pylint Instead of Codes (#2700) 2022-05-06 18:19:12 +02:00
Philipp 99581abe05 Add Filters.update.edited (#2705) 2022-05-06 18:19:11 +02:00
eldbud 1edfa1504c Handle Filepaths via the Pathlib Module (#2688) 2022-05-06 18:19:11 +02:00
Harshil 267d4e8191 Improve Signature Inspection for Bot Methods (#2686) 2022-05-06 18:19:11 +02:00
Bibo-Joshi 90b82eed99 Pass Failing Jobs to Error Handlers (#2692) 2022-05-06 18:19:11 +02:00
Poolitzer 51488bb4be Update Notification Workflows (#2695) 2022-05-06 18:19:11 +02:00
Bibo-Joshi f0efb14e6d Move Defaults to telegram.ext (#2648) 2022-05-06 18:19:11 +02:00
Bibo-Joshi c486c396da Doc Fixes (#2597)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
2022-05-06 18:19:11 +02:00
Bibo-Joshi ce94651490 Make InlineQuery.answer Raise ValueError (#2675) 2022-05-06 18:19:11 +02:00
Bibo-Joshi c440c255a7 Clear Up Import Policy (#2671)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:19:11 +02:00
Harshil f6497093ce Warnings Overhaul (#2662) 2022-05-06 18:19:11 +02:00
Bibo-Joshi 7528503794 Refine Dispatcher.dispatch_error (#2660)
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2022-05-06 18:19:11 +02:00
Harshil afcff83ebc Add User Friendly Type Check For Init Of {Inline, Reply}KeyboardMarkup (#2657) 2022-05-06 18:19:10 +02:00
Bibo-Joshi 8f0031e9c8 Remove Deprecated Functionality (#2644, #2740, #2745) 2022-05-06 18:19:10 +02:00
Harshil 5c500fb6fd Fix Signatures and Improve test_official (#2643) 2022-05-06 18:19:10 +02:00
Poolitzer 641f931f19 Drop Non-CallbackContext API (#2617) 2022-05-06 18:19:10 +02:00
Ankit Raibole 4d493aff16 Remove day_is_strict argument of JobQueue.run_monthly (#2634)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:10 +02:00
Harshil b4ea5557ac Remove __dict__ from __slots__ and drop Python 3.6 (#2619, #2636) 2022-05-06 18:19:10 +02:00
Bibo-Joshi be441d56f9 Refactor Initialization of Persistence Classes (#2604) 2022-05-06 18:19:09 +02:00
Stɑrry Shivɑm 633b7e7762 Make BasePersistence Methods Abstract (#2624)
Signed-off-by: starry69 <starry369126@outlook.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:09 +02:00
Poolitzer babcc2a448 Add Custom pytest Marker to Ease Development (#2628)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:09 +02:00
Iulian Onofrei 8a7aeaf86f Improve Type Hinting for CallbackContext (#2587)
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:09 +02:00
Poolitzer 97a585f240 Add Code Comment Guidelines to Contribution Guide (#2612)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2022-05-06 18:19:09 +02:00
Harshil 4a329aa4da Move and Rename TelegramDecryptionError to telegram.error.PassportDecryptionError (#2621) 2022-05-06 18:19:09 +02:00
Hinrich Mahler 92cb6f3ae8 Bump version to v13.11 2022-02-02 21:16:36 +01:00
Harshil a35ecf4065 API 5.7 (#2881) 2022-02-02 21:05:46 +01:00
Hinrich Mahler ade1529986 Bump version to v13.10 2022-01-03 08:36:27 +01:00
Harshil e6d9f3d057 Update Copyright to 2022 (#2836) 2022-01-03 08:15:18 +01:00
Harshil 98bf378c6e API 5.6 (#2835) 2022-01-03 08:13:33 +01:00
Poolitzer c4b413ef9e Update Documentation of BotCommand (#2820) 2021-12-17 16:12:34 +01:00
Hinrich Mahler a9dd2b1746 Bump version to v13.9 2021-12-11 15:44:21 +01:00
Bibo-Joshi cb95868c4a Api 5.5 (#2809)
Co-authored-by: poolitzer <github@poolitzer.eu>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2021-12-11 15:21:56 +01:00
Bibo-Joshi 2f6c4075c8 Adjust Automated Locking of Inactive Closed Threads (#2775) 2021-11-10 21:16:59 +01:00
Hinrich Mahler c53dc7dae4 Bump version to v13.8.1 2021-11-08 20:09:23 +01:00
Bibo-Joshi 8b3ea5ce56 Add ChatJoinRequest(Handler) to Docs (#2771) 2021-11-08 19:56:57 +01:00
Hinrich Mahler 51a4a6664c Bump version to v13.8 2021-11-08 19:12:10 +01:00
Bibo-Joshi e4dc80f41d API 5.4 (#2767)
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
2021-11-08 19:02:20 +01:00
Abshar Mohammed Aslam bc7c422a11 Create Issue Template Forms (#2689) 2021-10-03 20:08:04 +02:00
Yan c3e3bb77e5 Fix camelCase Functions in ExtBot (#2659)
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
2021-09-15 17:07:11 +02:00
DonalDuck004 a25c76e6a3 Fix Empty Captions not Being Passed by Bot.copy_message (#2651) 2021-09-09 07:50:04 +02:00
Mehdi 0c5085022c Fix Setting Thumbs When Uploading A Single File (#2583)
* Update request.py

If the media has a thumb, we also need to attach it to the data.

* Add test

* Editing syntax

* Debug test

* update request.py

* Update test_inputmedia.py

* Update test_inputmedia.py

* Update test_inputmedia.py

Fix test.

* Update AUTHORS.rst

Adding my name!

* Update AUTHORS.rst
2021-08-11 08:34:47 +02:00
Bibo-Joshi 1fdaaac809 Fix Bug in BasePersistence.insert/replace_bot for Objects with __dict__ not in __slots__ (#2603)
* More special cases with slots

* Fix failing tests
2021-07-24 17:17:25 +02:00
Hinrich Mahler bcec6f03cb Bump version to v13.7 2021-07-01 18:03:38 +02:00
Bibo-Joshi ed147813ab API 5.3 (#2572)
* BotCommandScopes

* pre-commit

* typo

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>

* rename kickChatMember & getChatMembersCount method

Signed-off-by: starry69 <starry369126@outlook.com>

* add `language_code` and `scope` to `get/set_my_commands`

and add `delete_my_commands()`

* add `input_field_placeholder` to replykeyboardmarkup.py and forcereply.py

also improved/fixed docs along the way

* showcase `input_field_placeholder` in conversationbot.py

* review 1

'i will not go away' has gone away 😢

* deprecate `Bot.commands` and make sure its only used for default scope

* review 2 (use constants for scope)

* Review

Signed-off-by: starry69 <starry369126@outlook.com>

* doc updates

* New ChatMember classes

Signed-off-by: starry69 <starry369126@outlook.com>

* Address review

Signed-off-by: starry69 <starry369126@outlook.com>

* add versionadded tags again

Signed-off-by: starry69 <starry369126@outlook.com>

* Improve tests & add a deprecation note to ChatMember

* test_official

* Documentation tweaks

* Bump bot api version number

* but bot

* Rename chat shortcuts

Signed-off-by: starry69 <starry369126@outlook.com>

* deepsource

Signed-off-by: starry69 <starry369126@outlook.com>

* add missing slot in botcommandscope & missing slot tests

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: starry69 <starry369126@outlook.com>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-07-01 17:45:19 +02:00
Bibo-Joshi 4315225642 Type Hinting Fixes (#2552)
* Fixe overload signatures for ContextTypes

* more fixing for contexttypes
2021-07-01 17:43:59 +02:00
Bibo-Joshi a75dffd4a8 Doc Fixes (#2551)
* Document ExtBot.insert_callbakc_data

* fix duplicate object descriptions

Fixed by removing `:undoc-members:` in the affected classes.
Closes https://github.com/sphinx-doc/sphinx/issues/9294

* fix incorrect shortcut docstrings in user.py

* fix object type in forcereply.py

* fix discuss bot link in loginurl.py

* document that message is None for (my)_chat_member

in `effective_message`

* numerous persistence rendering fixes

* move docstring from property setter to property

* Revert "fix object type in forcereply.py"

This reverts commit 012663e0c3.

* Document comparison of jobs

* Update min python version to 3.6.8

* remove old note from chat.py + some return msg fixes

* fix colon placement

Co-authored-by: Harshil <ilovebhagwan@gmail.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2021-07-01 17:34:23 +02:00
Harshil fce2993d21 Improve Deprecation Warning for __slots__ (#2574)
* add stacklevel to `set_new_attribute_deprecated`

* detail warning message and change stacklevel
2021-06-29 18:10:08 +02:00
Harshil 9aec8deec6 Stabilize CI (#2575)
* attempt 'surely this one' on fixing test_idle and test_depr_warnings

* remove unused filterwarnings
2021-06-26 22:19:59 +02:00
Bibo-Joshi ec3026673b Fix Coverage Configuration (#2571)
* remove possibly malicious line from config

* exclude overload signatures from coverage
2021-06-25 09:02:46 +02:00
zeroone2numeral2 105f1ccdb5 Better Exception-Handling for BasePersistence.replace/insert_bot (#2564)
* Catch exceptions raised while copying __dict__/__slots__ in BasePersistence.replace/insert_bot()

Also updated the docstrings to reflect the changes in behavior with unexpected errors

* Tests: added to CustomClass immutable object that would trigger a setattr() exception

* Tests: added new uuid_ property to own CustomClass methods

* Updated AUTHORS.rst

* Revert "Tests: added new uuid_ property to own CustomClass methods"

This reverts commit 9e67463cf7.

* Revert "Tests: added to CustomClass immutable object that would trigger a setattr() exception"

This reverts commit 1c258304

* Removed unneeded Exception cast to string

f-string will perform the string-ification on their own

* Removed another unneeded Exception cast to string

* Added test to parse unparsable objects in __dict__ or __slots__

* Applied black and pylint style suggestions

All lint tests passed

* Fix typo

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2021-06-20 22:14:05 +02:00
Bibo-Joshi 52ce03929b Fix Bug in BasePersistence.insert/replace_bot for Objects with __dict__ in their slots (#2561)
* Handle objects with __dict__ in __slots__

* Rework
2021-06-13 15:07:40 +02:00
Bibo-Joshi ac4768155f Remove Incorrect Warning About Defaults and ExtBot (#2553)
* Don't throw warning when passing defaults to ExtBot

* Review
2021-06-10 12:03:44 +02:00
Harshil d08172b4b0 Remove Deprecated pass_args from Deeplinking Example (#2550) 2021-06-07 09:05:17 +02:00
Hinrich Mahler e982a5a567 Bump version to v13.6 2021-06-06 12:28:01 +02:00
Bibo-Joshi cf4d3cae01 Doc Fixes (#2495)
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Bas ten Berge <bas+github@tenberge-ict.nl>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-06-06 12:16:23 +02:00
Bibo-Joshi 8531a7a40c Arbitrary callback_data (#1844) 2021-06-06 11:48:48 +02:00
Bibo-Joshi fce7cc903c Add ContextTypes & BasePersistence.refresh_user/chat/bot_data (#2262) 2021-06-06 10:37:53 +02:00
GauthamramRavichandran 5da1dd7ce9 Add max_connections Parameter to Updater.start_webhook (#2547)
* Include max_connections args

* Update docs & add test

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-06-06 09:27:45 +02:00
Stɑrry Shivɑm 46cdeb495a Fix for Promise.done_callback (#2544)
* Don't call done_cb on exceptions

Signed-off-by: starry69 <starry369126@outlook.com>

* improve docs

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

* revert black

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2021-06-05 17:08:45 +02:00
Bibo-Joshi 653691fafb Improve Slot Tests (#2541) 2021-05-30 20:30:26 +02:00
Harshil 92ff6a8e2b Add __slots__ (#2345)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-05-29 16:18:16 +02:00
Bibo-Joshi cc43aef64b Fix Test Failing Due To Telegram Updates (#2537)
* Update TestPhoto

* try to fix test_idle again...

* fix test_send_game due to photo size changes...

Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-05-28 22:24:43 +02:00
Bibo-Joshi e2c6d60721 Improve Code Quality (#2536)
* Start fixing stuff

* More docstrings

* stabilize test_idle

Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-05-27 20:34:58 +02:00
Bibo-Joshi 8bf88c3231 Supplement Codacy with DeepSource (#2454)
* Add deepsource config

* Update Badges

* Update Badges some more

* Stupid change to trigger analysis of all files

* Try to get ignore right

* Update badges again

* Get started on fixing issues

* Fix some more issues

* Remove more plank lines

* Docs for de_json/list & to_dict/json

* Some improvements from deepcode.ai

* Some more improvements

* Some more improvements

* More docstrnigs & let's run DS on the tests just for fun

* Autofix issues in 10 files

Resolved issues in the following files via DeepSource Autofix:
1. tests/conftest.py
2. tests/test_bot.py
3. tests/test_commandhandler.py
4. tests/test_conversationhandler.py
5. tests/test_dispatcher.py
6. tests/test_filters.py
7. tests/test_inputmedia.py
8. tests/test_messagehandler.py
9. tests/test_official.py
10. tests/test_persistence.py

* Some more improvements for tests, but that shall be enough

* Some more docstrings for functions

* Some minor stuff, try to fix tests

* Update DS config

* Still more docs

* Doc fixes

* More fixes

* Fix: indent docstring

* Some fixes

* Revert "Stupid change to trigger analysis of all files"

This reverts commit dd46c260

* Review

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2021-05-27 09:38:17 +02:00
Poolitzer 1572c61063 Increase Test Coverage of CallbackQueryHandler (#2520)
* Test: let's see

* Test: let's see, now in the correct place

* Fix: Explicitly return None in else clause

also documented this behaviour clearly in the docstring

* add link in doc

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

* Fix: remove unnecessary else statement

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2021-05-27 09:37:37 +02:00
Harshil 5ff3b76e18 Stabilize CI (#2522)
* asking the test what is wrong with them

* fix botscore_not_modified tests for good

* xfail game tests due to race conditions

* address review (add a comment)

* fix xfail marker

* address review

* simplify expression
2021-05-19 13:33:41 +02:00
Poolitzer cd69f69b28 Add Filters.attachment (#2528)
* feat: attachment filter

* fix: add versionadded statement

* Fix: small doc string changes

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2021-05-19 10:39:10 +02:00
Poolitzer 8b0d2e5f75 Add pattern Argument to ChosenInlineResultHandler (#2517)
* Feat: add pattern arg to ChosenInlineResultHandler

* Fix: remove unnecessary if clause

the attribute must be present, since it's not optional.

* Fix: wrong type documentation

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

* Fix: Addressing code review

small documentation fixes, and moving one test.

* Fix: link to matches

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

* Fix: also link here

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2021-05-19 10:32:11 +02:00
Nikolai Krivenko 7d0fb85c8c Fix send_phone_number_to_provider argument for Bot.send_invoice (#2527)
* [#2526] set data['send_phone_number_to_provider'] from corresponding variable

* [#2526] Add myself to AUTHORS.rst

* Add unit test

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-05-16 20:56:28 +02:00
Bibo-Joshi 08ba7c7793 Handle Classes as Input for BasePersistence.replace/insert_bot (#2523)
* Ignore classes on replace/insert_bot

* Review
2021-05-16 20:02:35 +02:00
Bibo-Joshi 9737b1d3c7 Bump Tornado Version and Remove Workaround from #2067 (#2494) 2021-05-05 20:59:06 +02:00
Hinrich Mahler 94a9b7f983 Bump version to v13.5 2021-04-30 11:15:38 +02:00
Bibo-Joshi bae57c7f8f Doc Fixes (#2437)
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2021-04-30 10:47:41 +02:00
Harshil b20265819b Stabilize CI (#2480)
* mark some occasionally failing tests as flaky

* fix test which was failing locally for some reason

* Don't fail tests if they've exceeded the timeout

* This reverts commit 1d0f982e95.

* remove flaky on two tests as per review

* the end of timeout failures, hopefully.

* first run successful. Fixing pre-commit to trigger 2nd run.
2021-04-30 10:43:52 +02:00
Bibo-Joshi 3938a57542 Convenience Utilities & Example for Handling ChatMemberUpdated (#2490)
* ChatMemberUpdate.difference

* constants for update types

* Add an example for ChatMemberHandler

* Update examples/chatmemberbot.py

* Review

* Review
2021-04-30 10:14:41 +02:00
Bibo-Joshi 4645d0e32a Improve Type Hints of Data Filters (#2456) 2021-04-30 10:12:18 +02:00
Stɑrry Shivɑm 7e554584b1 Improve Timeouts in ConversationHandler (#2417)
* Handle promise states in conversation timeout

Signed-off-by: starry69 <starry369126@outlook.com>

* warn if nested conversation & timeout

Signed-off-by: starry69 <starry369126@outlook.com>

* Add notes and test for conversation_timeout

Signed-off-by: starry69 <starry369126@outlook.com>

* Try to fix pre-commit

Signed-off-by: starry69 <starry369126@outlook.com>

* Test promise exception

Signed-off-by: starry69 <starry369126@outlook.com>

* Welp

Signed-off-by: starry69 <starry369126@outlook.com>

* improve docs

Signed-off-by: starry69 <starry369126@outlook.com>

* typo

Signed-off-by: starry69 <starry369126@outlook.com>

* try to fix codecov

Signed-off-by: starry69 <starry369126@outlook.com>

* refactor timeout logic with promise.add_done_cb

Signed-off-by: starry69 <starry369126@outlook.com>

* small fix

Signed-off-by: starry69 <starry369126@outlook.com>

* Address review

Signed-off-by: starry69 <starry369126@outlook.com>

* Fix some type hinting

* Few fixes

Signed-off-by: starry69 <starry369126@outlook.com>

* fix tests

Signed-off-by: starry69 <starry369126@outlook.com>

* minor nitpick

Signed-off-by: starry69 <starry369126@outlook.com>

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-04-30 10:10:46 +02:00
Bibo-Joshi b6a6d7f872 Api 5.2 (#2489)
* Bump API Version to v5.2

* InputInvoiceMessageContent & simplify *Markup.__eq__ on the fly

* Updates to send_invoice

* InlineQuery updatees and new parameter for InlineQueryhandler

* VCScheduled - not integrated into Message yet

* Bump requirements-dev.txt versions

* Message.voice_chat_scheduled & new Filters.status_update.vcs

* Some doc updates

* Review

* All praise harshil, the god of finding typos :)

* Review

* More warnings
2021-04-30 10:09:21 +02:00
Bibo-Joshi 3b92901892 Update ChatActions (#2460)
* deprecate CA.upload/record_audio in favor of ca.u/r_voice

* tests

* tests

* Fix test
2021-04-22 08:57:56 +02:00
Stɑrry Shivɑm b63877b1f2 Add Two UserWarnings (#2464)
* Warn if number of workers < one

Signed-off-by: starry69 <starry369126@outlook.com>

* improve warning message

Signed-off-by: starry69 <starry369126@outlook.com>

* warn if converstation handler return unknown state

Signed-off-by: starry69 <starry369126@outlook.com>

* Show handler name and state aswell, in warning

Signed-off-by: starry69 <starry369126@outlook.com>

* minor nitpick

Signed-off-by: starry69 <starry369126@outlook.com>
2021-04-16 19:02:43 +02:00
Aksh Gupta 9d93417d9a Improve Code Quality (#2450)
* chore: refactor code quality issues

* Add comment for removing assert statements

* Remove deepsource config file

* Fix Coverage

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-04-05 13:25:27 +02:00
Bibo-Joshi 9949b44560 Update Fallback Test-Bots (#2451) 2021-03-30 19:28:01 +02:00
Harshil 7abacb000b Fix echobot.py Example (#2448) 2021-03-29 11:16:22 +02:00
Harshil 43f5aeaff3 Improve Examples (#2441)
* close issue, typo fixes, remove unnecessary condition, etc

* use ForceReply in example

* remove extra whitespace

* address review, handle empty inline queries.

* Cosmetics

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-03-28 18:53:44 +02:00
Harshil 9e08fa30b6 Filters.forwarded_from (#2446)
* new filter and more tests!

* document forward filter better, fix a test.

* Minor formulation nitpicking

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-03-28 11:50:45 +02:00
Hinrich Mahler ccedd3a87d Bump version to v13.4.1 2021-03-14 19:21:44 +01:00
Bibo-Joshi 0bb4be55ac Fix setup.py (#2431) 2021-03-14 19:17:08 +01:00
Hinrich Mahler 21ded420e2 Bump version to v13.4 2021-03-14 17:00:26 +01:00
Bibo-Joshi 7d893fd04b Doc Fixes (#2404)
* Improve some badges for PTB-Raw

* doc fix for add_error_handler

* Some rendering

* Bump sphinx dependency

* Change signature annotation setting

* fix: chat_id can be string, message_id only int

* feat: add RTD link to documentation

* improving sender chat docstring (#2412)

* fix: improving sender chat docstring

also adding a note to a weird edge case

* fix: words being hard

* Add note on donations

* typo

* typo in User.get_profile_pictures docstrings

* Fix: meth, not attr for meth, not attr

* filters + inlinequery doc fix

* Bump versions, update RTD config file

* Try fix build

* Revert "fix: chat_id can be string, message_id only int"

This reverts commit ba04e5aa

* Add Starry & Harshil to credits

Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-03-14 16:46:37 +01:00
Bibo-Joshi 7015f8dedc Type Hinting Fixes (#2425)
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
2021-03-14 16:42:03 +01:00
Poolitzer ac02bce109 API 5.1 (#2424)
* Feat: New invite links

* Fix: doc strings

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

* new dice, new admin privilege, revoke_messages, update and fix some docs

* add missing param to shortcut

* Add ChatMemberUpdated

* Add voicechat related objects

Signed-off-by: starry69 <starry369126@outlook.com>

* add versionadd tags

Signed-off-by: starry69 <starry369126@outlook.com>

* Fix filter tests

* Update tg.Update

* ChatMemberHandler

* Add versioning directives

* add can_manage_voice_chats attr and fix docs

Signed-off-by: starry69 <starry369126@outlook.com>

* fix chat shortcut

Signed-off-by: starry69 <starry369126@outlook.com>

* address review

* MADTC

* Chat.message_auto_delete_time

* Some doc fixes

* address review

Signed-off-by: starry69 <starry369126@outlook.com>

* welp

Signed-off-by: starry69 <starry369126@outlook.com>

* Add voicechat related filters

Signed-off-by: starry69 <starry369126@outlook.com>

* Fix: Addressing review

change place of version adding, added obj:True as doc string, changing how member limit is initiated

* feat: adding chat shortcuts for invite links

* fix: changing equality of chatinviteobjects

* Non-test comments

* Some test fixes

* A bit more tests

* Bump API version in both readmes

* Increase coverage

* Add Bot API Version in telegram.constants (#2429)

* add bot api version in constants

Signed-off-by: starry69 <starry369126@outlook.com>

* addressing review

Signed-off-by: starry69 <starry369126@outlook.com>

* add versioning directive

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>

* pre-commit & coverage

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
Co-authored-by: starry69 <starry369126@outlook.com>
2021-03-14 16:41:35 +01:00
Bibo-Joshi 3a9a0ab96d Update pre-commit Settings (#2415)
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-03-13 16:21:03 +01:00
Bibo-Joshi aba17cb997 Improve Updater.set_webhook (#2419)
* Get started

* tests

* Some doc fixes

* Some doc fixes
2021-03-13 15:35:26 +01:00
Bibo-Joshi 038a3b4452 Fix Logging for Vendored urllib3 (#2427) 2021-03-13 15:14:10 +01:00
Bibo-Joshi b03ebc5a65 Stabilize Tests (#2409)
* Fix Photo Tests

* Try harder

* Try stabalizing pin&unpin test

* Drop file size tests

* Fix that one failing test …
2021-03-10 16:51:56 +01:00
Hinrich Mahler e9c01c7772 Bump version to v13.3 2021-02-19 19:55:49 +01:00
Bibo-Joshi 552298595c Doc Fixes (#2359)
* Improve some badges for PTB-Raw

* doc fix for add_error_handler

* Some rendering

* Doc fixes for filters.py

* render '@' as code

Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-02-19 19:27:17 +01:00
Bibo-Joshi 2a4a0d0ccd Refactor Defaults Integration (#2363)
* Change default handling, update signatures, get existing tests to pass.

* Try running tests on ubuntu 18.04

* Roll back

* Rework check_shortcut_call tests

* Further improve check_shortcut_call tests

* Start on defaults-checks for shortcuts, get it working for test_message

* Add check_shortcut_defaults to all other shortcut tests

* Some fine tuning

* Add defaults checking for bot methods

* Missing tests for TestCallbackQuery

* Test edit_message_media with defaults & some comments

* Fix cryptography requirement

* drop debug prints

* Remove debug prints

* Another try

* Try to fix coverage & logs

* Rearrange test order

* increase coverage

* Try to fix coverage reports

* address review

* Adapt tests like in #2386

* fix CI

* fix CI
2021-02-19 19:07:48 +01:00
Harshil eb993db473 Add Missing telegram.SecureValue to init and Docs (#2398) 2021-02-19 17:46:52 +01:00
Bibo-Joshi c77ef7eef3 Deprecate MessageQueue (#2393) 2021-02-19 17:29:50 +01:00
Bibo-Joshi a34f0b9bee Make cryptography Dependency Optional & Refactor Some Tests (#2386)
* Make cryptography optional

* Try fixing CI

* Try some more

* Update pytest, mypy & pyupgrade, refactor test_meta, hope that things start to work

* Fix filterwarnings

* Mama mia! Here we go again!

* Add stupid debug prints

* A new hope
2021-02-13 22:07:37 +01:00
Bibo-Joshi eee8921598 Update cryptography Dependency (#2370) 2021-02-08 19:28:54 +01:00
Hinrich Mahler 1902c0ac36 Bump version to v13.2 2021-02-02 20:57:14 +01:00
Bibo-Joshi 544a3fbf48 ConversationHandler: Docs & edited_channel_post behavior (#2339)
* Update docs & ignore edited channel posts

* typo

* Apply suggestions from code review

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* Update telegram/ext/conversationhandler.py

* fix pre-commit

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2021-02-01 19:26:03 +01:00
Bibo-Joshi 36d49ea9cd Doc Fixes (#2253)
* Render-fixes for BP

* docs: fix simple typo, submition -> submission (#2260)

There is a small typo in tests/test_bot.py.

Should read `submission` rather than `submition`.

* Type on rawapibot.py docstring

* typo

* Typo: Filters.document(s)

* Typo fix

* Doc fix for messageentity (#2311)

* Add New Shortcuts to Chat (#2291)

* Add shortcuts

* Add a note

* Add run_async Parameter to ConversationHandler (#2292)

* Add run_async parameter

* Update docstring

* Update test to explicitly specify parameter

* Fix test job queue

* Add version added tag to docs

* Update docstring

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* Doc nitpicking

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>

* Fix rendering in messageentity

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: zeshuaro <joshuaystang@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* fix: type hints for TelegramError

changed :class:`telegram.TelegramError` to :class:`telegram.error.TelegramError`

* fix: the error can be more then just a Telegram error

* Doc fix for inlinekeyboardbutton.py

added missing colon which broke rendering

* fix: remove context argument and doc remark

look at us already being in post 12

* use rtd badge

* filters doc fixes

* fix some rendering

* Doc & Rendering fixes for helpers.py

Co-authored-by: Tim Gates <tim.gates@iress.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: zeshuaro <joshuaystang@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
2021-02-01 17:59:39 +01:00
Bibo-Joshi 25506f131d python-telegram-bot-raw (#2324)
* POC

* Remove decorator dependency

* Rework setup.py & build, add separate readme

* Move utils -> ext.utils

* Move pytz dep to ext

* Try fixing timing stuff

* Add 'Typed' classifier

* Update README_RAW.rst

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>

* Some wording

* Deprecation warnings for moved tg.utils

* Tests for Promise

* Test time-helpers without pytz

* Try fixing time-helper tests

* Merge master

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2021-01-30 14:15:39 +01:00
Bibo-Joshi 70aba136e4 Reduce Usage of typing.Any (#2321)
* Use object instead of Any where possible

* Revert a lof of noise from the PR
2021-01-30 11:38:54 +01:00
Stɑrry Shivɑm 40995b19fe Extend Deeplinking Example (#2335)
* extend deeplinking example

Signed-off-by: starry69 <starry369126@outlook.com>

* use username property instead of get_me calls

Signed-off-by: starry69 <starry369126@outlook.com>
2021-01-28 17:12:13 +01:00
zeshuaro 32da6d6fce Add Missing Shortcuts to Message (#2330)
* Add shortcuts for Message

* Fix docs in Chat

* Update docs in Message

* Fix tests in request.py

* Rollback changes made to fix mypy errors
2021-01-23 13:40:19 +01:00
Bibo-Joshi f31787a8ef Add pyupgrade to pre-commit Hooks (#2301)
* Add pyupgrade to pre-commit

* update test_chat
2021-01-17 23:24:20 +01:00
Stɑrry Shivɑm b43a599e53 Rich Comparison for Bot (#2320)
* Make telegram.Bot comparable

Signed-off-by: starry69 <starry369126@outlook.com>

* Address review

Signed-off-by: starry69 <starry369126@outlook.com>

* Enhance tests & add docstring about comparison

Signed-off-by: starry69 <starry369126@outlook.com>

* Minor doc fix

* Extend tests

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-01-17 09:23:36 +01:00
Bibo-Joshi 7a3fd83570 Add PR Template (#2299)
* Add PR template

* Apply suggestions from code review

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* Some more

* reformulate

* Apply suggestions from code review

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2021-01-16 13:57:25 +01:00
Bibo-Joshi 9ada2a7cca Drop Nightly Tests & Update Badges (#2323) 2021-01-16 11:27:06 +01:00
Eana Hufwe be54cf4ece Fix Escaping in Nested Entities in Message Properties (#2312)
* fix: overly escape and offset error markdown v2 symbols when nested

Signed-off-by: Eana Hufwe <ilove@1a23.com>

* fix: nested entity escape for HTML parsers and tests

Signed-off-by: Eana Hufwe <ilove@1a23.com>
2021-01-12 19:33:26 +01:00
zeshuaro 0c9915243d Add run_async Parameter to ConversationHandler (#2292)
* Add run_async parameter

* Update docstring

* Update test to explicitly specify parameter

* Fix test job queue

* Add version added tag to docs

* Update docstring

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* Doc nitpicking

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2021-01-09 20:05:58 +01:00
Bibo-Joshi 9930725e2a Add New Shortcuts to Chat (#2291)
* Add shortcuts

* Add a note
2021-01-09 17:48:56 +01:00
Bibo-Joshi ffd675daec Adjust Calling of Dispatcher.update_persistence (#2285)
* Adjust calling of update_persistence

(cherry picked from commit 89c522d883)

* Fix tests and stuff
2021-01-07 21:31:00 +01:00
Bibo-Joshi 6a831f926b Add New Constant MAX_ANSWER_CALLBACK_QUERY_TEXT_LENGTH (#2282) 2021-01-07 21:27:51 +01:00
Bibo-Joshi 6903d58142 Update Copyright (#2289)
* Update coypright headers

* typos
2021-01-04 17:24:14 +01:00
Bibo-Joshi 07b6ee69d2 Update Copyright (#2287)
Signed-off-by: starry69 <starry369126@outlook.com>
2021-01-03 10:30:02 +01:00
starry69 c8a3c31dcc Update copyright of docs config
Signed-off-by: starry69 <starry369126@outlook.com>
2021-01-03 14:42:51 +05:30
starry69 91e0271e4c Update copyright headers
Signed-off-by: starry69 <starry369126@outlook.com>
2021-01-03 10:40:24 +05:30
Hinrich Mahler 9ddb361f76 Revert "Adjust calling of update_persistence"
This reverts commit 89c522d883.
2021-01-01 21:44:23 +01:00
Hinrich Mahler 89c522d883 Adjust calling of update_persistence 2021-01-01 21:40:42 +01:00
Bibo-Joshi 2effff8254 Change Order of Class DocStrings (#2256) 2020-12-30 15:59:50 +01:00
Bibo-Joshi 2788191657 Add macOS to Test Matrix (#2266)
* Try testing on macos

* Skip JobQueue tests on macos

* Try stabilizing tests

* Try harder
2020-12-30 15:39:38 +01:00
Bibo-Joshi aec6d3bada Explicit Signatures for Shortcuts (#2240)
* First POC

* Actually get it to work

* locals-less POC

* pre-commit

* Work on Message shortcuts, update some annotations in Bot methods

* Tippity Tappity, coding stuff

* CallbackQuery

* InlineQuery & Some other stuff

* Media Classes and PassportFile

* Fix tests

* PreCheckout- & ShippingQuery

* User

* Fix tests

* Chat

* Update rawapibot

* Update annotations for answer_inline_query
2020-12-30 13:41:07 +01:00
Bibo-Joshi 80b34811ab Handle Bytes as File Input (#2233)
* Handle bytes file input

* fix tests

* Docs, Tests & Rearrangements

* Use versioning directives

* fixing type hinting of send_photo

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2020-12-18 11:20:03 +01:00
Poolitzer 2d7a974b8f Start Using Versioning Directives in Docs (#2252)
* adding versioning in sphinx, closing #2250

* adding version requirement to contributors doc
2020-12-17 19:05:12 +01:00
Bibo-Joshi ef703d19e9 Doc Fixes (#2225)
* Fix dscr for soccer ball values

* Update docs of BasePersistence regarding abc

* elaborate run_daily docs

* Make docstring of send_document.filename more precise

* increase bot API and add Discussion link

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2020-12-17 09:29:17 +01:00
Bibo-Joshi 77a8c64f6c Improve Annotations & Docs of Handlers (#2243)
* Improve typing & docs of handlers

* Apply suggestions from code review

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2020-12-16 17:34:57 +01:00
Bibo-Joshi 786762bb73 Allow Passing Custom Filename For All Media (#2249)
* Add filename arg to send_media methods and InputMedia*

* Tests
2020-12-16 14:28:53 +01:00
Bibo-Joshi e0dbb99b08 Add quote kwarg to Message.reply_copy (#2232)
* add quote kwrag to Message.reply_copy

* Add docs & update tests
2020-12-03 20:51:47 +01:00
Hinrich Mahler 73b0e29a30 Bump version to v13.1 2020-11-29 17:01:03 +01:00
Bibo-Joshi d27d1ea4d5 Correct Some Type Hints (#2204)
* Correct some reply_markup hints

* Fix type hints of effective_message_type

* fixup
2020-11-29 16:32:38 +01:00
Bibo-Joshi ca04daf782 Doc Fixes & Extensions (#2201)
* Add note on dispatcherhandlerstop to conversationhandler

* Fine tune @run_async deprecation warning

* Refine docs of JobQueue.jobs/get_jobs_by_name
2020-11-29 16:25:47 +01:00
Bibo-Joshi ae9ce60b55 API 5.0 (#2181)
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
2020-11-29 16:20:46 +01:00
Bibo-Joshi 1cd3a0a156 Handle Non-Binary File Input (#2202)
* Don't fail if stream is not bytes

* move logger

* Refactor InputFile.is_image

* Use f-strings

* some clean up
2020-11-24 20:31:34 +01:00
Bibo-Joshi 58b9882021 Use F-Strings Where Possible (#2222) 2020-11-23 22:09:29 +01:00
Bibo-Joshi df6d5f0840 Fix bugs in replace/insert_bot (#2218)
* Fix bugs in replace/insert_bot

* Some tweaks
2020-11-22 11:08:46 +01:00
Stɑrry Shivɑm 425716f966 Add Defaults.run_async (#2210)
* Add Defaults.run_async support

Signed-off-by: starry69 <starry369126@outlook.com>

* Address some requested changes.

Signed-off-by: starry69 <starry369126@outlook.com>

* Add tests for defaults.run_async

Signed-off-by: starry69 <starry369126@outlook.com>

* Fix tests logic & add default value support for dp.add_error_handler

Signed-off-by: starry69 <starry369126@outlook.com>

* Fix tests, with requested changes

Signed-off-by: starry69 <starry369126@outlook.com>

* Add tests for error_handler

Signed-off-by: starry69 <starry369126@outlook.com>

* try to fix pre-commit

Signed-off-by: starry69 <starry369126@outlook.com>

* Enhance tests & address suggested changes

Signed-off-by: starry69 <starry369126@outlook.com>

* Improve docs

Signed-off-by: starry69 <starry369126@outlook.com>
2020-11-17 21:31:01 +01:00
Bibo-Joshi 8d9bb26cca Improve Handling of Custom Objects in BasePersistence.insert/replace_bot (#2151)
* Handle unpickable objects

* Improve coverage

* Add user warning

* make comparison to REPLACED_BOT safe

* make pre-commit happy

* Shorten warning
2020-11-14 03:08:18 +01:00
Bibo-Joshi d1438a9b23 Add XOR Filters and make Filters.name a Property (#2179)
* XOR Filters and make Filters.name a property

* add XORFilter to __all__

* Change example
2020-11-07 08:44:45 +01:00
Evgeny Denisov 27b03edc59 Expand Type Hints to Tuples (#2167)
Co-authored-by: Pranjalya <pranjalyawarrior@gmail.com>
2020-11-07 08:26:32 +01:00
Evgeny Denisov ac449deb5d Add Filters.document.file_extension (#2169)
Co-authored-by: Matheus Lemos <matheuslemosf@protonmail.com>
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2020-11-06 18:41:54 +01:00
Bibo-Joshi 3b9187ed5a Rename kwargs to _kwargs where possible (#2182) 2020-11-05 18:12:01 +01:00
Bibo-Joshi 9831458e22 Improve and Expand CallbackQuery Shortcuts (#2172)
* CallbackQuery.delete_message()

* Improve internals of CQ shortcuts
2020-11-05 17:11:35 +01:00
Marco Fincato a0cd6e8fef Add Filters.caption_regex (#2163)
* Check caption in Filters.regex

Added regex matching for message caption in Filters.regex.

* Moved caption check to Filters.caption_regex

* Added caption_regex tests

The same as for regex, with only the content of the message changed, that is now inside caption.

* Fixed pre-commit tests

Lines too long and an additional blank line

* Moved line break to comply

* Reformatted code with black

* Added docstrings
2020-11-04 20:54:24 +01:00
Bibo-Joshi 8e7c0d6976 Comply with PEP561 (#2168)
* Comply with PEP561

* Try harder

* third time's (hopefully) a charme
2020-11-01 19:33:01 +01:00
Bibo-Joshi 92b9370c23 Improve Code Quality (#2131)
* Make pre-commit more strict

* Get pylint to read setup.cfg

* Make pylint & mypy happy aka ignore all the things

* use LogRecord.getMessage() in tests

* Make noam happy

* Update both pylint & mypy while we're at it

* Bring reqs-dev and makefile up to speed

* try making pre-commit happy

* fix jobqueue tests on the fly
2020-10-31 16:33:34 +01:00
GauthamramRavichandran 237e73bfb4 Add Filters.chat_type (#2128)
* add supergroup filter

* add chat_type filter

* re-implemented ChatType

* Add deprecations, improve tests

* Fix some docs

* Fix black

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-10-29 19:42:08 +01:00
Bibo-Joshi ff3fd34f08 Update Credits (#2161) 2020-10-27 17:43:23 +01:00
Bibo-Joshi 83791d34e7 Fix Regex in Configuration of Black Formatter (#2159) 2020-10-23 14:46:56 +02:00
Bibo-Joshi 02cd7b642f Fix Configuration of Black Formatter (#2158)
* Fix Black in pre-commit

* Fix black some more
2020-10-23 13:40:02 +02:00
NikitaPirate 165a24e13d Add Convenience Properties for Service Chats and Anonymous Admins (#2147)
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2020-10-18 16:15:56 +02:00
Michael K 88440079e3 Update Wheel Settings (#2142)
Wheels are only universal if they support both Python 2 and 3.
2020-10-15 21:50:25 +02:00
Bibo-Joshi 9be4c7563b Improve Type Hinting for Class Variables (#2136) 2020-10-15 18:50:47 +02:00
Timur Kushukov b554f1a85d Update timerbot.py to v13.0 (#2149)
* Update timerbot example (#2144)

* update timerbot example (suggestions from review)

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2020-10-15 18:48:12 +02:00
NikitaPirate 3b4559dd95 Overhaul Constants (#2137)
* Move all constants to constants.py and documentation refactor.

* Move all constants to constants.py and documentation refactor.

* Overhaul constants

* Overhaul constants

* Minor docstring change

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-10-13 17:58:36 +02:00
Bibo-Joshi 9ae48fecfe Add Python 3.9 to Test Matrix (#2132)
* Add Py 3.9 to tests

* update setup-python action
2020-10-11 11:47:19 +02:00
Bibo-Joshi 6af6648509 Switch Codecov to GitHub Action (#2127) 2020-10-10 10:50:19 +02:00
Bibo-Joshi 264b2c9c72 Switch Code Formatting to Black (#2122)
* Swtich code formatting to Black

* Update docs

* Fix tests

* TRy fixing pre-commit
2020-10-09 17:22:07 +02:00
Nano 8efb05290a Specify Required pytz Version (#2121) 2020-10-09 09:15:34 +02:00
Harshil 83a8874bb5 Correct Some Type Hints (#2118)
* Add string type hint

* fixed type hint in send_message()

* change type hint of send_chat_action to str

* make flaky happy

* fixed another type hint in edit_message_text
2020-10-09 08:22:44 +02:00
Hinrich Mahler bf68942c91 Bump to v13.0 2020-10-07 21:23:55 +02:00
Hinrich Mahler 5fd7606084 Type Hinting (#1920) 2020-10-07 20:30:41 +02:00
Bibo-Joshi 103b115486 Defaults.tzinfo (#2042) 2020-10-07 20:30:41 +02:00
Hinrich Mahler b07e42ef33 Make context-based callbacks the default setting (#2050) 2020-10-07 20:30:41 +02:00
Bibo-Joshi 3842846b2d Refactor Handling of Message VS Update Filters (#2032)
* Refactor handling of message vs update filters

* address review
2020-10-07 20:30:41 +02:00
Bibo-Joshi 7daddfb54d Refactor handling of default_quote (#1965)
* Refactor handling of `default_quote`

* Make it a breaking change

* Pickle a bots defaults

* Temporarily enable tests for the v13 branch

* Temporarily enable tests for the v13 branch

* Refactor handling of kwargs in Bot methods (#1924)

* Unify kwargs handling in Bot methods

* Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class

* Fix test_official

* Update get_file methods

* Refactor JobQueue (#1981)

* First go on refactoring JobQueue

* Temporarily enable tests for the v13 branch

* Work on tests

* Temporarily enable tests for the v13 branch

* Increase coverage

* Remove JobQueue.tick()

* Address review

* Temporarily enable tests for the v13 branch

* Address review

* Dispatch errors

* Fix handling of job_kwargs

* Remove possibility to pass a Bot to JobQueue

* Refactor persistence of Bot instances (#1994)

* Refactor persistence of bots

* User BP.set_bot in Dispatcher

* Temporarily enable tests for the v13 branch

* Add documentation

* Add warning to Updater for passing both defaults and bot

* Address review

* Fix test
2020-10-07 20:30:41 +02:00
Bibo-Joshi 2d4d48b89d Extend rich comparison of objects (#1724)
* Make most objects comparable

* ID attrs for PollAnswer

* fix test_game

* fix test_userprofilephotos

* update for API 4.7

* Warn on meaningless comparisons

* Update for API 4.8

* Address review

* Get started on docs, update Message._id_attrs

* Change PollOption & InputLocation

* Some more changes

* Even more changes
2020-10-07 20:30:41 +02:00
Bibo-Joshi 2381724b7c Refactor persistence of Bot instances (#1994)
* Refactor persistence of bots

* Use BP.set_bot in Dispatcher

* Add documentation
2020-10-07 20:30:41 +02:00
Bibo-Joshi 19a4f9e53a Refactor JobQueue (#1981)
* First go on refactoring JobQueue

* Temporarily enable tests for the v13 branch

* Work on tests

* Temporarily enable tests for the v13 branch

* Increase coverage

* Remove JobQueue.tick()

* Address review

* Temporarily enable tests for the v13 branch

* Address review

* Dispatch errors

* Fix handling of job_kwargs

* Remove possibility to pass a Bot to JobQueue
2020-10-07 20:30:41 +02:00
Bibo-Joshi 3930072659 Refactor handling of kwargs in Bot methods (#1924)
* Unify kwargs handling in Bot methods

* Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class

* Fix test_official

* Update get_file methods
2020-10-07 20:30:41 +02:00
Bibo-Joshi 5555582b72 Doc Fixes/Additions (#2094)
* Add notes on thumbs being ignored for small video files

* Fix some cross refs

* Add not to DictPersistence about it not actually writing to file

* Fix reply_to_message docs of Message
2020-10-07 17:12:05 +02:00
Delgan e67b995e64 Make Errors picklable (#2106)
* Fix TypeError while unpickling TelegramError (and children)

* Add more extensive unit tests for errors pickling

* Move error pickling tests back to "test_error.py"

* Add test making sure that new errors are covered by tests

* Make meta test independent of sorting

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-10-04 18:15:36 +02:00
Bibo-Joshi 0d419ed6b4 Refactor Dispatcher.run_async (#2051) 2020-10-04 17:20:33 +02:00
Bibo-Joshi 97adcdf538 Automatic Pagination for answer_inline_query (#2072)
* Auto Pagination

* Fix test_official

* Get things to actually work

* Fine tune

* Tweak tests

* Address review

* Add warning to answer_inline_query
2020-09-27 14:11:49 +02:00
Poolitzer 2989108e95 Fix setting thumbs with send_media_group (#2093)
* fix: uploading thumb in media group

* add test

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-09-19 16:50:34 +02:00
Bibo-Joshi 897a20d758 Link Ask-Right Wiki Page in Question Template (#2090)
* Link ask-right wiki page in question template

* typo
2020-09-16 20:53:48 +02:00
Bibo-Joshi ed3a9b64e2 Add Note on PyPy to Readme (#2089) 2020-09-16 20:53:19 +02:00
Bibo-Joshi 49c0c9e4d1 Make MessageHandler filter for Filters.update first (#2085)
* Tweak MessageHandlers filters

* Improve test
2020-09-14 17:55:01 +02:00
Bibo-Joshi bb34c79909 Fix Webhook not working on Windows with Python 3.8+ (#2067)
* Fix start_webhook NotImplementedError on windows with python3.8

* Fine-tune and add tests.

* Minor fixes

* typos

* Make Codacy happy

Co-authored-by: n5y <41209360+n5y@users.noreply.github.com>
2020-08-25 22:21:24 +02:00
Bibo-Joshi a0720b9ac6 Documentation Improvements (#2008)
* Minor doc updates, following official API docs

* Fix spelling in Defaults docstrings

* Clarify Changelog of v12.7 about aware dates

* Fix typo in CHANGES.rst (#2024)

* Fix PicklePersistence.flush() with only bot_data (#2017)

* Update pylint in pre-commit to fix CI (#2018)

* Add Filters.via_bot (#2009)

* feat: via_bot filter

also fixing a small mistake in the empty parameter of the user filter and improve docs slightly

* fix: forgot to set via_bot to None

* fix: redoing subclassing to copy paste solution

* Cosmetic changes

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>

* Update CHANGES.rst

Fixed Typo

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* Update downloads badge, add info on IRC Channel to Getting Help section

* Remove RegexHandler from ConversationHandlers Docs (#1973)

Replaced RegexHandler with MessageHandler, since the former is deprecated

* Fix Filters.via_bot docstrings

* Add notes on Markdown v1 being legacy mode

* Fixed typo in the Regex doc.. (#2036)

* Typo: Spelling

* Minor cleanup from #2043

* Document CommandHandler ignoring channel posts

* Doc fixes for a few telegram.ext classes

* Doc fixes for most `telegram` classes.

* pep-8

forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.

* Address review and made rendering of booleans consistent

True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.

* Few doc fixes for inline* classes

As usual, docs were cross-checked with official tg api docs.

* Doc fixes for telegram/files classes

As usual, docs were cross-checked with official tg api docs.

* Doc fixes for telegram.Game

Mostly just added hyperlinks. And fixed message length doc.

As usual, docs were cross-checked with official tg api docs.

* Very minor doc fix for passportfile.py and passportelementerrors.py

Didn't bother changing too much since this seems to be a custom implementation.

* Doc fixes for telegram.payments

As usual, cross-checked with official bot api docs.

* Address review 2

Few tiny other fixes too.

* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.

Few tiny other doc fixes too.

Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
Bibo-Joshi faa93fbf75 Refine Codecov Settings (#2061) 2020-08-21 23:37:07 +02:00
Bibo-Joshi da452df07d Allow DispatcherHandlerStop in ConversationHandler (#2059)
* First go

* Fix bug with nested convs
2020-08-21 23:20:28 +02:00
Bibo-Joshi 3304cc5c90 Fix Lock-Bot configuration (#2053)
* Run lock bot twice a day and don't give a reason for locking

* Fix indentation

* Fix invalid time
2020-08-18 20:52:43 +02:00
Bibo-Joshi 9105d83d37 Refine Lock-Bot (#2052)
* Run lock bot twice a day and don't give a reason for locking

* Fix indentation
2020-08-18 20:43:27 +02:00
Bibo-Joshi b6b42b2043 Switch from Lock-Bot to GH Actions (#2049) 2020-08-16 10:43:30 +02:00
Bibo-Joshi f857e1c23b Add Lock-Bot (#2048) 2020-08-14 12:57:18 +02:00
Bibo-Joshi fc5844c13d Add missing shortcuts (#2043)
* Add all the methods

* Add tests and fix some typos

* A few more minor changes

* Address review
2020-08-13 13:39:43 +02:00
Leonardo Rezende dea24bcb7c Refine pollbot.py example (#2047)
* pollbot.py example was sending the poll to the effective_user and not effective_chat... well, it's a poll to be answered by multiple uses.

* Use User.mention_html() shortcut

Co-authored-by: Leonardo <leonardo.rezende@trt19.jus.br>
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-08-13 13:38:23 +02:00
Bibo-Joshi 2789fd2bff Refine Filters in examples (#2027) 2020-07-18 12:17:42 +02:00
Bibo-Joshi d6f8077a50 Rename echobot examples (#2025) 2020-07-16 19:17:57 +02:00
Poolitzer 0189442525 Add Filters.via_bot (#2009)
* feat: via_bot filter

also fixing a small mistake in the empty parameter of the user filter and improve docs slightly

* fix: forgot to set via_bot to None

* fix: redoing subclassing to copy paste solution

* Cosmetic changes

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-07-14 21:51:36 +02:00
Bibo-Joshi fd0325fbe5 Update pylint in pre-commit to fix CI (#2018) 2020-07-10 12:57:27 +02:00
Bibo-Joshi ff4bb15fef Fix PicklePersistence.flush() with only bot_data (#2017) 2020-07-10 11:10:53 +02:00
ikkemaniac 9288e4f2e4 Fix docstring of Message.reply_media_group (#2005) 2020-06-25 07:54:23 +02:00
ikkemaniac e60318166e Add test for clean argument of Updater.start_polling/webhook (#2002)
* added test for 'clean' argument passed to 'start_polling()'

* remove TODO

* prettify

* remove bool from func name

* improve name-ing of fake update func

* cleanup class and nameing

* replace while for for

* swap valueerror for runtimeerror

* remove all other code to reduce testing

* add comments

* don't raise error, complete cycle and assert

* remove inf loop protection

* Revert "remove all other code to reduce testing"

This reverts commit 4566a1debd.

* remove error parametrization

* remove comment

* remove pass from class

* rename update_id to offset as the original get_updates() takes argument offset (which is the update_id)

* rename test func to match original func

* fix comment

* shorten for loop

* mock get_updates() behavior when 'offset' is passed. Assert with get_updates()

* remove other functions to reduce testing

* replicate original get_updates()

* move fakeupdate class and list creation outside get_updates and store in var

* loop from 0 to make update_id consistant w array key, just easier to debug

* update comments

* Revert "remove other functions to reduce testing"

This reverts commit 1fb498a6cc.

* fix typo

* Revert "fix typo"

This reverts commit ade9fec609.

* Revert "Revert "remove other functions to reduce testing""

This reverts commit 734de1371c.

* Revert "update comments"

This reverts commit f3a032e75e.

* Revert "loop from 0 to make update_id consistant w array key, just easier to debug"

This reverts commit 0c6881d8a1.

* Revert "move fakeupdate class and list creation outside get_updates and store in var"

This reverts commit 71de999300.

* Revert "replicate original get_updates()"

This reverts commit 5d0710ac3a.

* Revert "remove other functions to reduce testing"

This reverts commit 1fb498a6cc.

* Revert "mock get_updates() behavior when 'offset' is passed. Assert with get_updates()"

This reverts commit 8c727ba1e8.

* loop from 0 to make update_id consistant w array key, for consitency

Co-authored-by: ikkemaniac <ikkemaniac@localhost>
2020-06-24 00:25:58 +02:00
908 changed files with 112128 additions and 43600 deletions
+19
View File
@@ -0,0 +1,19 @@
version = 1
test_patterns = ["tests/**"]
exclude_patterns = [
"tests/**",
"docs/**",
"setup.py",
"setup-raw.py"
]
[[analyzers]]
name = "python"
enabled = true
[analyzers.meta]
runtime_version = "3.x.x"
max_line_length = 99
skip_doc_coverage = ["module", "magic", "init", "nonpublic"]
+7
View File
@@ -0,0 +1,7 @@
# .git-blame-ignore-revs
# Use locally as `git blame file.py --ignore-revs-file .git-blame-ignore-revs`
# or configure git to always use it: `git config blame.ignoreRevsFile .git-blame-ignore-revs`
# First migration to code style Black (#2122)
264b2c9c72691c5937b80e84e061c52dd2d8861a
# Use Black more extensively (#2972)
950d9a0751d79b92d78ea44344ce3e3c5b3948f9
+134 -91
View File
@@ -1,10 +1,11 @@
=================
How To Contribute
=================
Every open source project lives from the generous help by contributors that sacrifice their time and ``python-telegram-bot`` is no different. To make participation as pleasant as possible, this project adheres to the `Code of Conduct`_ by the Python Software Foundation.
Setting things up
-----------------
=================
1. Fork the ``python-telegram-bot`` repository to your GitHub account.
@@ -12,7 +13,7 @@ Setting things up
.. code-block:: bash
$ git clone https://github.com/<your username>/python-telegram-bot --recursive
$ git clone https://github.com/<your username>/python-telegram-bot
$ cd python-telegram-bot
3. Add a track to the original repository:
@@ -25,7 +26,7 @@ Setting things up
.. code-block:: bash
$ pip install -r requirements.txt -r requirements-dev.txt
$ pip install -r requirements-all.txt
5. Install pre-commit hooks:
@@ -35,21 +36,23 @@ Setting things up
$ pre-commit install
Finding something to do
#######################
=======================
If you already know what you'd like to work on, you can skip this section.
If you have an idea for something to do, first check if it's already been filed on the `issue tracker`_. If so, add a comment to the issue saying you'd like to work on it, and we'll help you get started! Otherwise, please file a new issue and assign yourself to it.
Another great way to start contributing is by writing tests. Tests are really important because they help prevent developers from accidentally breaking existing code, allowing them to build cool things faster. If you're interested in helping out, let the development team know by posting to the `Telegram group`_ (use `@admins` to mention the maintainers), and we'll help you get started.
Another great way to start contributing is by writing tests. Tests are really important because they help prevent developers from accidentally breaking existing code, allowing them to build cool things faster. If you're interested in helping out, let the development team know by posting to the `Telegram group`_, and we'll help you get started.
That being said, we want to mention that we are very hesitant about adding new requirements to our projects. If you intend to do this, please state this in an issue and get a verification from one of the maintainers.
Instructions for making a code change
#####################################
=====================================
The central development branch is ``master``, which should be clean and ready for release at any time. In general, all changes should be done as feature branches based off of ``master``.
If you want to do solely documentation changes, base them and PR to the branch ``doc-fixes``. This branch also has its own `RTD build`_.
Here's how to make a one-off code change.
1. **Choose a descriptive branch name.** It should be lowercase, hyphen-separated, and a noun describing the change (so, ``fuzzy-rules``, but not ``implement-fuzzy-rules``). Also, it shouldn't start with ``hotfix`` or ``release``.
@@ -64,75 +67,43 @@ Here's how to make a one-off code change.
$ git checkout -b your-branch-name
3. **Make a commit to your feature branch**. Each commit should be self-contained and have a descriptive commit message that helps other developers understand why the changes were made.
We also have a check-list for PRs `below`_.
- You can refer to relevant issues in the commit message by writing, e.g., "#105".
- Your code should adhere to the `PEP 8 Style Guide`_, with the exception that we have a maximum line length of 99.
- Document your code. This project uses `sphinx`_ to generate static HTML docs. To build them, first make sure you have the required dependencies:
.. code-block:: bash
- Provide static typing with signature annotations. The documentation of `MyPy`_ will be a good start, the cheat sheet is `here`_. We also have some custom type aliases in ``telegram._utils.types``.
$ pip install -r docs/requirements-docs.txt
- Document your code. This step is pretty important to us, so it has its own `section`_.
then run the following from the PTB root directory:
.. code-block:: bash
$ make -C docs html
or, if you don't have ``make`` available (e.g. on Windows):
.. code-block:: bash
$ sphinx-build docs/source docs/build/html
Once the process terminates, you can view the built documentation by opening ``docs/build/html/index.html`` with a browser.
- For consistency, please conform to `Google Python Style Guide`_ and `Google Python Style Docstrings`_. In addition, code should be formatted consistently with other code around it.
- For consistency, please conform to `Google Python Style Guide`_ and `Google Python Style Docstrings`_.
- The following exceptions to the above (Google's) style guides applies:
- Documenting types of global variables and complex types of class members can be done using the Sphinx docstring convention.
- Documenting types of global variables and complex types of class members can be done using the Sphinx docstring convention.
- Please ensure that the code you write is well-tested.
- In addition, PTB uses some formatting/styling and linting tools in the pre-commit setup. Some of those tools also have command line tools that can help to run these tools outside of the pre-commit step. If you'd like to leverage that, please have a look at the `pre-commit config file`_ for an overview of which tools (and which versions of them) are used. For example, we use `Black`_ for code formatting. Plugins for Black exist for some `popular editors`_. You can use those instead of manually formatting everything.
- Dont break backward compatibility.
- Please ensure that the code you write is well-tested and that all automated tests still pass. We
have dedicated an `testing page`_ to help you with that.
- Don't break backward compatibility.
- Add yourself to the AUTHORS.rst_ file in an alphabetical fashion.
- Before making a commit ensure that all automated tests still pass:
- If you want run style & type checks before committing run
.. code-block::
.. code-block:: bash
$ make test
$ pre-commit run -a
If you don't have ``make``, do:
.. code-block::
$ pytest -v
To run ``test_official`` (particularly useful if you made API changes), run
.. code-block::
$ export TEST_OFFICIAL=true
prior to running the tests.
- To actually make the commit (this will trigger tests for yapf, lint and pep8 automatically):
- To actually make the commit (this will trigger tests style & type checks automatically):
.. code-block:: bash
$ git add your-file-changed.py
- yapf may change code formatting, make sure to re-add them to your commit.
.. code-block:: bash
$ git commit -a -m "your-commit-message-here"
- Finally, push it to your GitHub fork, run:
.. code-block:: bash
@@ -149,11 +120,13 @@ Here's how to make a one-off code change.
5. **Address review comments until all reviewers give LGTM ('looks good to me').**
- When your reviewer has reviewed the code, you'll get an email. You'll need to respond in two ways:
- When your reviewer has reviewed the code, you'll get a notification. You'll need to respond in two ways:
- Make a new commit addressing the comments you agree with, and push it to the same branch. Ideally, the commit message would explain what the commit does (e.g. "Fix lint error"), but if there are lots of disparate review comments, it's fine to refer to the original commit message and add something like "(address review comments)".
- Make a new commit addressing the comments you agree with, and push it to the same branch. Ideally, the commit message would explain what the commit does (e.g. "Fix lint error"), but if there are lots of disparate review comments, it's fine to refer to the original commit message and add something like "(address review comments)".
- In addition, please reply to each comment. Each reply should be either "Done" or a response explaining why the corresponding suggestion wasn't implemented. All comments must be resolved before LGTM can be given.
- In order to keep the commit history intact, please avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits.
- In addition, please reply to each comment. Each reply should be either "Done" or a response explaining why the corresponding suggestion wasn't implemented. All comments must be resolved before LGTM can be given.
- Resolve any merge conflicts that arise. To resolve conflicts between 'your-branch-name' (in your fork) and 'master' (in the ``python-telegram-bot`` repository), run:
@@ -167,12 +140,6 @@ Here's how to make a one-off code change.
$ git commit -a
$ git push origin your-branch-name
- If after merging you see local modified files in ``telegram/vendor/`` directory, that you didn't actually touch, that means you need to update submodules with this command:
.. code-block:: bash
$ git submodule update --init --recursive
- At the end, the reviewer will merge the pull request.
6. **Tidy up!** Delete the feature branch from both your local clone and the GitHub repository:
@@ -184,18 +151,101 @@ Here's how to make a one-off code change.
7. **Celebrate.** Congratulations, you have contributed to ``python-telegram-bot``!
Style commandments
Check-list for PRs
------------------
Specific commandments
#####################
This checklist is a non-exhaustive reminder of things that should be done before a PR is merged, both for you as contributor and for the maintainers.
Feel free to copy (parts of) the checklist to the PR description to remind you or the maintainers of open points or if you have questions on anything.
- Avoid using "double quotes" where you can reasonably use 'single quotes'.
- Added ``.. versionadded:: NEXT.VERSION``, ``.. versionchanged:: NEXT.VERSION`` or ``.. deprecated:: NEXT.VERSION`` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
- Created new or adapted existing unit tests
- Documented code changes according to the `CSI standard <https://standards.mousepawmedia.com/en/stable/csi.html>`__
- Added myself alphabetically to ``AUTHORS.rst`` (optional)
- Added new classes & modules to the docs and all suitable ``__all__`` s
- Checked the `Stability Policy <https://docs.python-telegram-bot.org/stability_policy.html>`_ in case of deprecations or changes to documented behavior
**If the PR contains API changes (otherwise, you can ignore this passage)**
- Checked the Bot API specific sections of the `Stability Policy <https://docs.python-telegram-bot.org/stability_policy.html>`_
- New classes:
- Added ``self._id_attrs`` and corresponding documentation
- ``__init__`` accepts ``api_kwargs`` as kw-only
- Added new shortcuts:
- In :class:`~telegram.Chat` & :class:`~telegram.User` for all methods that accept ``chat/user_id``
- In :class:`~telegram.Message` for all methods that accept ``chat_id`` and ``message_id``
- For new :class:`~telegram.Message` shortcuts: Added ``quote`` argument if methods accepts ``reply_to_message_id``
- In :class:`~telegram.CallbackQuery` for all methods that accept either ``chat_id`` and ``message_id`` or ``inline_message_id``
- If relevant:
- Added new constants at :mod:`telegram.constants` and shortcuts to them as class variables
- Link new and existing constants in docstrings instead of hard-coded numbers and strings
- Add new message types to :attr:`telegram.Message.effective_attachment`
- Added new handlers for new update types
- Add the handlers to the warning loop in the :class:`~telegram.ext.ConversationHandler`
- Added new filters for new message (sub)types
- Added or updated documentation for the changed class(es) and/or method(s)
- Added the new method(s) to ``_extbot.py``
- Added or updated ``bot_methods.rst``
- Updated the Bot API version number in all places: ``README.rst`` and ``README_RAW.rst`` (including the badge), as well as ``telegram.constants.BOT_API_VERSION_INFO``
- Added logic for arbitrary callback data in :class:`telegram.ext.ExtBot` for new methods that either accept a ``reply_markup`` in some form or have a return type that is/contains :class:`~telegram.Message`
Documenting
===========
The documentation of this project is separated in two sections: User facing and dev facing.
User facing docs are hosted at `RTD`_. They are the main way the users of our library are supposed to get information about the objects. They don't care about the internals, they just want to know
what they have to pass to make it work, what it actually does. You can/should provide examples for non obvious cases (like the Filter module), and notes/warnings.
Dev facing, on the other side, is for the devs/maintainers of this project. These
doc strings don't have a separate documentation site they generate, instead, they document the actual code.
User facing documentation
-------------------------
We use `sphinx`_ to generate static HTML docs. To build them, first make sure you're running Python 3.9 or above and have the required dependencies:
.. code-block:: bash
$ pip install -r docs/requirements-docs.txt
then run the following from the PTB root directory:
.. code-block:: bash
$ make -C docs html
or, if you don't have ``make`` available (e.g. on Windows):
.. code-block:: bash
$ sphinx-build docs/source docs/build/html
Once the process terminates, you can view the built documentation by opening ``docs/build/html/index.html`` with a browser.
- Add ``.. versionadded:: NEXT.VERSION``, ``.. versionchanged:: NEXT.VERSION`` or ``.. deprecated:: NEXT.VERSION`` to the associated documentation of your changes, depending on what kind of change you made. This only applies if the change you made is visible to an end user. The directives should be added to class/method descriptions if their general behaviour changed and to the description of all arguments & attributes that changed.
Dev facing documentation
------------------------
We adhere to the `CSI`_ standard. This documentation is not fully implemented in the project, yet, but new code changes should comply with the `CSI` standard.
The idea behind this is to make it very easy for you/a random maintainer or even a totally foreign person to drop anywhere into the code and more or less immediately understand what a particular line does. This will make it easier
for new to make relevant changes if said lines don't do what they are supposed to.
Style commandments
==================
Assert comparison order
#######################
-----------------------
- assert statements should compare in **actual** == **expected** order.
Assert statements should compare in **actual** == **expected** order.
For example (assuming ``test_call`` is the thing being tested):
.. code-block:: python
@@ -207,7 +257,7 @@ For example (assuming ``test_call`` is the thing being tested):
assert 5 == test_call()
Properly calling callables
##########################
--------------------------
Methods, functions and classes can specify optional parameters (with default
values) using Python's keyword arg syntax. When providing a value to such a
@@ -224,30 +274,23 @@ callable we prefer that the call also uses keyword arg syntax. For example:
This gives us the flexibility to re-order arguments and more importantly
to add new required arguments. It's also more explicit and easier to read.
Properly defining optional arguments
####################################
It's always good to not initialize optional arguments at class creation,
instead use ``**kwargs`` to get them. It's well known Telegram API can
change without notice, in that case if a new argument is added it won't
break the API classes. For example:
.. code-block:: python
# GOOD
def __init__(self, id, name, last_name=None, **kwargs):
self.last_name = last_name
# BAD
def __init__(self, id, name, last_name=None):
self.last_name = last_name
.. _`Code of Conduct`: https://www.python.org/psf/codeofconduct/
.. _`Code of Conduct`: https://www.python.org/psf/conduct/
.. _`issue tracker`: https://github.com/python-telegram-bot/python-telegram-bot/issues
.. _`Telegram group`: https://telegram.me/pythontelegrambotgroup
.. _`PEP 8 Style Guide`: https://www.python.org/dev/peps/pep-0008/
.. _`sphinx`: http://sphinx-doc.org
.. _`Google Python Style Guide`: http://google.github.io/styleguide/pyguide.html
.. _`PEP 8 Style Guide`: https://peps.python.org/pep-0008/
.. _`sphinx`: https://www.sphinx-doc.org/en/master
.. _`Google Python Style Guide`: https://google.github.io/styleguide/pyguide.html
.. _`Google Python Style Docstrings`: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
.. _AUTHORS.rst: ../AUTHORS.rst
.. _AUTHORS.rst: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/AUTHORS.rst
.. _`MyPy`: https://mypy.readthedocs.io/en/stable/index.html
.. _`here`: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
.. _`pre-commit config file`: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.pre-commit-config.yaml
.. _`Black`: https://black.readthedocs.io/en/stable/index.html
.. _`popular editors`: https://black.readthedocs.io/en/stable/integrations/editors.html
.. _`RTD`: https://docs.python-telegram-bot.org/
.. _`RTD build`: https://docs.python-telegram-bot.org/en/doc-fixes
.. _`CSI`: https://standards.mousepawmedia.com/en/stable/csi.html
.. _`section`: #documenting
.. _`testing page`: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/tests/README.rst
.. _`below`: #check-list-for-prs
+76
View File
@@ -0,0 +1,76 @@
name: Bug Report
description: Create a report to help us improve
title: "[BUG]"
labels: ["bug :bug:"]
body:
- type: markdown
attributes:
value: |
Thanks for reporting issues of python-telegram-bot!
Use this template to notify us if you found a bug.
To make it easier for us to help you please enter detailed information below.
Please note, we only support the latest version of python-telegram-bot and master branch. Please make sure to upgrade & recreate the issue on the latest version prior to opening an issue.
- type: textarea
id: steps-to-reproduce
attributes:
label: Steps to Reproduce
value: |
1.
2.
3.
validations:
required: true
- type: textarea
id: expected-behaviour
attributes:
label: Expected behaviour
description: Tell us what should happen
validations:
required: true
- type: textarea
id: actual-behaviour
attributes:
label: Actual behaviour
description: Tell us what happens instead
validations:
required: true
- type: markdown
attributes:
value: "### Configuration"
- type: input
id: operating-system
attributes:
label: Operating System
validations:
required: true
- type: textarea
id: versions
attributes:
label: Version of Python, python-telegram-bot & dependencies
description: Paste the output of `$ python -m telegram` here. This will be automatically formatted into code, so no need for backticks.
render: shell
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Insert logs here (if necessary). This will be automatically formatted into code, so no need for backticks.
render: python
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: You may provide any other additional context to the bug here.
-43
View File
@@ -1,43 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: 'bug :bug:'
assignees: ''
---
<!--
Thanks for reporting issues of python-telegram-bot!
Use this template to notify us if you found a bug.
To make it easier for us to help you please enter detailed information below.
Please note, we only support the latest version of python-telegram-bot and
master branch. Please make sure to upgrade & recreate the issue on the latest
version prior to opening an issue.
-->
### Steps to reproduce
1.
2.
3.
### Expected behaviour
Tell us what should happen
### Actual behaviour
Tell us what happens instead
### Configuration
**Operating System:**
**Version of Python, python-telegram-bot & dependencies:**
``$ python -m telegram``
### Logs
Insert logs here (if necessary)
+3 -3
View File
@@ -3,6 +3,6 @@ contact_links:
- name: Telegram Group
url: https://telegram.me/pythontelegrambotgroup
about: Questions asked on the group usually get answered faster.
- name: IRC Channel
url: https://webchat.freenode.net/?channels=##python-telegram-bot
about: In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel
- name: GitHub Discussions
url: https://github.com/python-telegram-bot/python-telegram-bot/discussions
about: For getting answers to usage on GitHub, Discussions is even better than this bug tracker :)
@@ -0,0 +1,37 @@
name: Feature Request
description: Suggest an idea for this project
title: "[FEATURE]"
labels: ["enhancement"]
body:
- type: textarea
id: related-problem
attributes:
label: "What kind of feature are you missing? Where do you notice a shortcoming of PTB?"
description: "A clear and concise description of what the problem is."
placeholder: "Example: I want to do X, but there is no way to do it."
validations:
required: true
- type: textarea
id: solution
attributes:
label: "Describe the solution you'd like"
description: "A clear and concise description of what you want to happen."
placeholder: "Example: I think it would be nice if you would add feature Y so I can do X."
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: "Describe alternatives you've considered"
description: "A clear and concise description of any alternative solutions or features you've considered."
placeholder: "Example: I considered Z to be able to do X, but that didn't work because..."
- type: textarea
id: additional-context
attributes:
label: "Additional context"
description: "Add any other context or screenshots about the feature request here."
placeholder: "Example: Here's a photo of my cat!"
-24
View File
@@ -1,24 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: enhancement
assignees: ''
---
#### Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
Ex. *I want to do X, but there is no way to do it.*
#### Describe the solution you'd like
A clear and concise description of what you want to happen.
Ex. *I think it would be nice if you would add feature Y so it will make it easier.*
#### Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Ex. *I considered Z, but that didn't work because...*
#### Additional context
Add any other context or screenshots about the feature request here.
Ex. *Here's a photo of my cat!*
-29
View File
@@ -1,29 +0,0 @@
---
name: Question
about: Get help with errors or general questions
title: "[QUESTION]"
labels: question
assignees: ''
---
<!--
Hey there, you have a question? We are happy to answer. Please make sure no similar question was opened already.
To make it easier for us to help you, please try to follow the template below as closely as possible.
Please mind that there is also a users' Telegram group at https://t.me/pythontelegrambotgroup for questions about the library. Questions asked there might be answered quicker than here. In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel at https://webchat.freenode.net/?channels=##python-telegram-bot to participate in the group.
-->
### Issue I am facing
Please describe the issue here in as much detail as possible
### Traceback to the issue
```
put it here
```
### Related part of your code
```python
put it here
```
+68
View File
@@ -0,0 +1,68 @@
name: Question
description: Get help with errors or general questions
title: "[QUESTION]"
labels: ["question"]
body:
- type: markdown
attributes:
value: |
Hey there, you have a question? We are happy to answer. Please make sure no similar question was opened already.
To make it easier for us to help you, please read this [article](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Ask-Right).
Please mind that there is also a users' [Telegram group](https://t.me/pythontelegrambotgroup) for questions about the library. Questions asked there might be answered quicker than here. Moreover, [GitHub Discussions](https://github.com/python-telegram-bot/python-telegram-bot/discussions) offer a slightly better format to discuss usage questions.
- type: textarea
id: issue-faced
attributes:
label: "Issue I am facing"
description: "Please describe the issue here in as much detail as possible"
validations:
required: true
- type: textarea
id: traceback
attributes:
label: "Traceback to the issue"
description: "If you are facing a specific error message, please paste the traceback here. This will be automatically formatted into python code, so no need for backticks."
placeholder: |
Traceback (most recent call last):
File "/home/bot.py", line 1, in main
foo = bar()
...
telegram.error.BadRequest: Traceback not found
render: python
- type: textarea
id: related-code
attributes:
label: "Related part of your code"
description: "This will be automatically formatted into code (python), so no need for backticks."
placeholder: |
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
logger = logging.getLogger(__name__)
render: python
- type: markdown
attributes:
value: "### Configuration"
- type: input
id: operating-system
attributes:
label: Operating System
validations:
required: true
- type: textarea
id: versions
attributes:
label: Version of Python, python-telegram-bot & dependencies
description: Paste the output of `$ python -m telegram` here. This will be automatically formatted into code, so no need for backticks.
render: shell
validations:
required: true
+14
View File
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
# Updates the dependencies of the GitHub Actions workflows
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
day: "friday"
+9
View File
@@ -0,0 +1,9 @@
# Config file for workflows/labelling.yml
version: 1
labels:
- label: "dependencies"
authors: ["dependabot[bot]", "pre-commit-ci[bot]"]
- label: "code quality ✨"
authors: ["pre-commit-ci[bot]"]
+6
View File
@@ -0,0 +1,6 @@
<!--
Hey! You're PRing? Cool!
Please be sure to check out our contribution guide (https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst).
Especially, please have a look at the check list for PRs (https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst#checklist-for-prs). Feel free to copy (parts of) the checklist to the PR description to remind you or the maintainers of open points or if you have questions on anything.
-->
-14
View File
@@ -1,14 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 3
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 2
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: question
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: false
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
This issue has been automatically closed due to inactivity. Feel free to comment in order to reopen
or ask again in our Telegram support group at https://t.me/pythontelegrambotgroup.
+38
View File
@@ -0,0 +1,38 @@
name: Process Dependabot PRs
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
process-dependabot-prs:
permissions:
pull-requests: read
contents: write
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- name: Fetch Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1.6.0
- uses: actions/checkout@v3.5.2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Update Version Number in Other Files
uses: jacobtomlinson/gha-find-replace@v3
with:
find: ${{ steps.dependabot-metadata.outputs.previous-version }}
replace: ${{ steps.dependabot-metadata.outputs.new-version }}
regex: false
exclude: CHANGES.rst
- name: Commit & Push Changes to PR
uses: EndBug/add-and-commit@v9.1.3
with:
message: 'Update version number in other files'
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
+27
View File
@@ -0,0 +1,27 @@
name: Check Links in Documentation
on:
schedule:
# First day of month at 05:46 in every 2nd month
- cron: '46 5 1 */2 *'
jobs:
test-sphinx-build:
name: test-sphinx-linkcheck
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: [3.9]
os: [ubuntu-latest]
fail-fast: False
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -W ignore -m pip install --upgrade pip
python -W ignore -m pip install -r requirements-all.txt
- name: Check Links
run: sphinx-build docs/source docs/build/html -W --keep-going -j auto -b linkcheck
+47
View File
@@ -0,0 +1,47 @@
name: Test Documentation Build
on:
pull_request:
branches:
- master
- doc-fixes
push:
branches:
- master
- doc-fixes
jobs:
test-sphinx-build:
name: test-sphinx-build
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: [3.9]
os: [ubuntu-latest]
fail-fast: False
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Install dependencies
run: |
python -W ignore -m pip install --upgrade pip
python -W ignore -m pip install -r requirements-all.txt
- name: Test autogeneration of admonitions
run: pytest -v --tb=short tests/docs/admonition_inserter.py
- name: Build docs
run: sphinx-build docs/source docs/build/html -W --keep-going -j auto
- name: Upload docs
uses: actions/upload-artifact@v3
with:
name: HTML Docs
retention-days: 7
path: |
# Exclude the .doctrees folder and .buildinfo file from the artifact
# since they are not needed and add to the size
docs/build/html/*
!docs/build/html/.doctrees
!docs/build/html/.buildinfo
-14
View File
@@ -1,14 +0,0 @@
name: Warning maintainers
on:
pull_request:
paths: examples/**
jobs:
job:
runs-on: ubuntu-latest
name: about example change
steps:
- name: running the check
uses: Poolitzer/notifier-action@master
with:
notify-message: Hey there. Relax, I am just a little warning for the maintainers to release directly after merging your PR, otherwise we have broken examples and people might get confused :)
repo-token: ${{ secrets.GITHUB_TOKEN }}
+17
View File
@@ -0,0 +1,17 @@
name: PR Labeler
on:
pull_request:
types: [opened]
jobs:
pre-commit-ci:
permissions:
contents: read # for srvaroa/labeler to read config file
pull-requests: write # for srvaroa/labeler to add labels in PR
runs-on: ubuntu-latest
steps:
- uses: srvaroa/labeler@v1.6.0
# Config file at .github/labeler.yml
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+17
View File
@@ -0,0 +1,17 @@
name: 'Lock Closed Threads'
on:
schedule:
- cron: '8 4 * * *'
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4.0.1
with:
github-token: ${{ github.token }}
issue-inactive-days: '7'
issue-lock-reason: ''
pr-inactive-days: '7'
pr-lock-reason: ''
@@ -0,0 +1,19 @@
name: Warning maintainers
on:
pull_request_target:
paths:
- requirements.txt
- requirements-opts.txt
- .pre-commit-config.yaml
permissions:
pull-requests: write
jobs:
job:
runs-on: ubuntu-latest
name: about pre-commit and dependency change
steps:
- name: running the check
uses: Poolitzer/notifier-action@master
with:
notify-message: Hey! Looks like you edited the (optional) requirements or the pre-commit hooks. I'm just a friendly reminder to keep the additional dependencies for the hooks in sync with the requirements :)
repo-token: ${{ secrets.GITHUB_TOKEN }}
+18
View File
@@ -0,0 +1,18 @@
name: Warning maintainers
on:
pull_request_target:
paths:
- README.rst
- README_RAW.rst
permissions:
pull-requests: write
jobs:
job:
runs-on: ubuntu-latest
name: about readme change
steps:
- name: running the check
uses: Poolitzer/notifier-action@master
with:
notify-message: Hey! Looks like you edited README.rst or README_RAW.rst. I'm just a friendly reminder to apply relevant changes to both of those files :)
repo-token: ${{ secrets.GITHUB_TOKEN }}
+19
View File
@@ -0,0 +1,19 @@
name: 'Mark & close stale questions'
on:
schedule:
- cron: '42 2 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
# PRs never get stale
days-before-stale: 3
days-before-close: 2
days-before-pr-stale: -1
stale-issue-label: 'stale'
only-labels: 'question'
stale-issue-message: ''
close-issue-message: 'This issue has been automatically closed due to inactivity. Feel free to comment in order to reopen or ask again in our Telegram support group at https://t.me/pythontelegrambotgroup.'
File diff suppressed because one or more lines are too long
+69
View File
@@ -0,0 +1,69 @@
name: Check Type Completeness
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
test-type-completeness:
name: test-type-completeness
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1 # https://github.com/actions/checkout/issues/329#issuecomment-674881489
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Install Pyright
run: |
python -W ignore -m pip install pyright~=1.1.316
- name: Get PR Completeness
# Must run before base completeness, as base completeness will checkout the base branch
# And we can't go back to the PR branch after that in case the PR is coming from a fork
run: |
pip install . -U
pyright --verifytypes telegram --ignoreexternal --outputjson > pr.json || true
pyright --verifytypes telegram --ignoreexternal > pr.readable || true
- name: Get Base Completeness
run: |
git checkout ${{ github.base_ref }}
pip install . -U
pyright --verifytypes telegram --ignoreexternal --outputjson > base.json || true
- name: Compare Completeness
uses: jannekem/run-python-script-action@v1
with:
script: |
import json
import os
from pathlib import Path
base = float(
json.load(open("base.json", "rb"))["typeCompleteness"]["completenessScore"]
)
pr = float(
json.load(open("pr.json", "rb"))["typeCompleteness"]["completenessScore"]
)
base_text = f"This PR changes type completeness from {round(base, 3)} to {round(pr, 3)}."
if pr < (base - 0.001):
text = f"{base_text} ❌"
set_summary(text)
print(Path("pr.readable").read_text(encoding="utf-8"))
error(text)
exit(1)
elif pr > (base + 0.001):
text = f"{base_text} ✨"
set_summary(text)
if pr < 1:
print(Path("pr.readable").read_text(encoding="utf-8"))
print(text)
else:
text = f"{base_text} This is less than 0.1 percentage points. ✅"
set_summary(text)
print(Path("pr.readable").read_text(encoding="utf-8"))
print(text)
+9
View File
@@ -46,10 +46,13 @@ htmlcov/
.coverage.*
.cache
.pytest_cache
.mypy_cache
nosetests.xml
coverage.xml
*,cover
.coveralls.yml
.testmondata
.testmondata-journal
# Translations
*.mo
@@ -68,6 +71,9 @@ target/
# Sublime Text 2
*.sublime*
# VS Code
.vscode
# unitests files
game.gif
telegram.mp3
@@ -83,3 +89,6 @@ telegram.jpg
# Exclude .exrc file for Vim
.exrc
# virtual env
venv*
-4
View File
@@ -1,4 +0,0 @@
[submodule "telegram/vendor/urllib3"]
path = telegram/vendor/ptb_urllib3
url = https://github.com/python-telegram-bot/urllib3.git
branch = ptb
+81 -11
View File
@@ -1,20 +1,90 @@
# Make sure that the additional_dependencies here match requirements.txt
ci:
autofix_prs: false
autoupdate_schedule: monthly
repos:
- repo: git://github.com/python-telegram-bot/mirrors-yapf
rev: 5769e088ef6e0a0d1eb63bd6d0c1fe9f3606d6c8
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: yapf
files: ^(telegram|tests)/.*\.py$
- id: black
args:
- --diff
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.1
- --check
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: git://github.com/pre-commit/mirrors-pylint
rev: 9d8dcbc2b86c796275680f239c1e90dcd50bd398
- repo: https://github.com/PyCQA/pylint
rev: v3.0.0a6
hooks:
- id: pylint
files: ^telegram/.*\.py$
files: ^(telegram|examples)/.*\.py$
args:
- --errors-only
- --disable=import-error
- --rcfile=setup.cfg
# run pylint across multiple cpu cores to speed it up-
# https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
- --jobs=0
additional_dependencies:
- httpx~=0.24.1
- tornado~=6.2
- APScheduler~=3.10.1
- cachetools~=5.3.1
- aiolimiter~=1.1.0
- . # this basically does `pip install -e .`
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
name: mypy-ptb
files: ^telegram/.*\.py$
additional_dependencies:
- types-pytz
- types-cryptography
- types-cachetools
- httpx~=0.24.1
- tornado~=6.2
- APScheduler~=3.10.1
- cachetools~=5.3.1
- aiolimiter~=1.1.0
- . # this basically does `pip install -e .`
- id: mypy
name: mypy-examples
files: ^examples/.*\.py$
args:
- --no-strict-optional
- --follow-imports=silent
additional_dependencies:
- tornado~=6.2
- APScheduler~=3.10.1
- cachetools~=5.3.1
- . # this basically does `pip install -e .`
- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
hooks:
- id: pyupgrade
files: ^(telegram|examples|tests|docs)/.*\.py$
args:
- --py38-plus
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort
args:
- --diff
- --check
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.277'
hooks:
- id: ruff
name: ruff
files: ^(telegram|examples|tests)/.*\.py$
additional_dependencies:
- httpx~=0.24.1
- tornado~=6.2
- APScheduler~=3.10.1
- cachetools~=5.3.1
- aiolimiter~=1.1.0
+46 -5
View File
@@ -1,10 +1,51 @@
# syntax: https://docs.readthedocs.io/en/latest/yaml-config.html
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Optionally build your docs in additional formats such as PDF
formats:
- pdf
- pdf
# Optionally set the version of Python and requirements required to build your docs
python:
setup_py_install: true
version: 3
install:
- method: pip
path: .
- requirements: docs/requirements-docs.txt
requirements_file: docs/requirements-docs.txt
build:
os: ubuntu-22.04
tools:
python: "3" # latest stable cpython version
search:
ranking: # bump up rank of commonly searched pages: (default: 0, values range from -10 to 10)
telegram.bot.html: 7
telegram.message.html: 3
telegram.update.html: 3
telegram.user.html: 2
telegram.chat.html: 2
telegram.ext.application.html: 3
telegram.ext.filters.html: 3
telegram.ext.callbackcontext.html: 2
telegram.ext.inlinekeyboardbutton.html: 1
telegram.passport*.html: -7
ignore:
- changelog.html
- coc.html
- bot_methods.html#
- bot_methods.html
# Defaults
- search.html
- search/index.html
- 404.html
- 404/index.html'
+42 -6
View File
@@ -2,46 +2,62 @@ Credits
=======
``python-telegram-bot`` was originally created by
`Leandro Toledo <https://github.com/leandrotoledo>`_ and is now maintained by
`Jannes Höke <https://github.com/jh0ker>`_ (`@jh0ker <https://t.me/jh0ker>`_ on Telegram),
`Noam Meltzer <https://github.com/tsnoam>`_, `Pieter Schutz <https://github.com/eldinnie>`_, `Jasmin Bom <https://github.com/jsmnbom>`_ and `Hinrich Mahler <https://github.com/Bibo-Joshi>`_.
`Leandro Toledo <https://github.com/leandrotoledo>`_.
The current development team includes
We're vendoring urllib3 as part of ``python-telegram-bot`` which is distributed under the MIT
license. For more info, full credits & license terms, the sources can be found here:
`https://github.com/python-telegram-bot/urllib3`.
- `Hinrich Mahler <https://github.com/Bibo-Joshi>`_ (maintainer)
- `Poolitzer <https://github.com/Poolitzer>`_ (community liaison)
- `Shivam <https://github.com/Starry69>`_
- `Harshil <https://github.com/harshil21>`_
- `Dmitry Kolomatskiy <https://github.com/lemontree210>`_
- `Aditya <https://github.com/clot27>`_
Emeritus maintainers include
`Jannes Höke <https://github.com/jh0ker>`_ (`@jh0ker <https://t.me/jh0ker>`_ on Telegram),
`Noam Meltzer <https://github.com/tsnoam>`_, `Pieter Schutz <https://github.com/eldinnie>`_ and `Jasmin Bom <https://github.com/jsmnbom>`_.
Contributors
------------
The following wonderful people contributed directly or indirectly to this project:
- `Abshar <https://github.com/abxhr>`_
- `Alateas <https://github.com/alateas>`_
- `Ales Dokshanin <https://github.com/alesdokshanin>`_
- `Alizia <https://github.com/thefunkycat>`_
- `Ambro17 <https://github.com/Ambro17>`_
- `Andrej Zhilenkov <https://github.com/Andrej730>`_
- `Anton Tagunov <https://github.com/anton-tagunov>`_
- `Avanatiker <https://github.com/Avanatiker>`_
- `Balduro <https://github.com/Balduro>`_
- `Bibo-Joshi <https://github.com/Bibo-Joshi>`_
- `Biruk Alamirew <https://github.com/BAcode-X>`_
- `bimmlerd <https://github.com/bimmlerd>`_
- `cyc8 <https://github.com/cyc8>`_
- `d-qoi <https://github.com/d-qoi>`_
- `daimajia <https://github.com/daimajia>`_
- `Daniel Reed <https://github.com/nmlorg>`_
- `D David Livingston <https://github.com/daviddl9>`_
- `DonalDuck004 <https://github.com/DonalDuck004>`_
- `Eana Hufwe <https://github.com/blueset>`_
- `Ehsan Online <https://github.com/ehsanonline>`_
- `Eldad Carin <https://github.com/eldbud>`_
- `Eli Gao <https://github.com/eligao>`_
- `Emilio Molinari <https://github.com/xates>`_
- `ErgoZ Riftbit Vaper <https://github.com/ergoz>`_
- `Eugene Lisitsky <https://github.com/lisitsky>`_
- `Eugenio Panadero <https://github.com/azogue>`_
- `Evan Haberecht <https://github.com/habereet>`_
- `Evgeny Denisov <https://github.com/eIGato>`_
- `evgfilim1 <https://github.com/evgfilim1>`_
- `ExalFabu <https://github.com/ExalFabu>`_
- `franciscod <https://github.com/franciscod>`_
- `gamgi <https://github.com/gamgi>`_
- `Gauthamram Ravichandran <https://github.com/GauthamramRavichandran>`_
- `Harshil <https://github.com/harshil21>`_
- `Hugo Damer <https://github.com/HakimusGIT>`_
- `ihoru <https://github.com/ihoru>`_
- `Iulian Onofrei <https://github.com/revolter>`_
- `Jasmin Bom <https://github.com/jsmnbom>`_
- `JASON0916 <https://github.com/JASON0916>`_
- `jeffffc <https://github.com/jeffffc>`_
@@ -52,41 +68,61 @@ The following wonderful people contributed directly or indirectly to this projec
- `Joscha Götzer <https://github.com/Rostgnom>`_
- `jossalgon <https://github.com/jossalgon>`_
- `JRoot3D <https://github.com/JRoot3D>`_
- `kennethcheo <https://github.com/kennethcheo>`_
- `Kirill Vasin <https://github.com/vasinkd>`_
- `Kjwon15 <https://github.com/kjwon15>`_
- `Li-aung Yip <https://github.com/LiaungYip>`_
- `Loo Zheng Yuan <https://github.com/loozhengyuan>`_
- `LRezende <https://github.com/lrezende>`_
- `Luca Bellanti <https://github.com/Trifase>`_
- `macrojames <https://github.com/macrojames>`_
- `Matheus Lemos <https://github.com/mlemosf>`_
- `Michael Dix <https://github.com/Eisberge>`_
- `Michael Elovskikh <https://github.com/wronglink>`_
- `Miguel C. R. <https://github.com/MiguelX413>`_
- `miles <https://github.com/miles170>`_
- `Mischa Krüger <https://github.com/Makman2>`_
- `naveenvhegde <https://github.com/naveenvhegde>`_
- `neurrone <https://github.com/neurrone>`_
- `NikitaPirate <https://github.com/NikitaPirate>`_
- `Nikolai Krivenko <https://github.com/nkrivenko>`_
- `njittam <https://github.com/njittam>`_
- `Noam Meltzer <https://github.com/tsnoam>`_
- `Oleg Shlyazhko <https://github.com/ollmer>`_
- `Oleg Sushchenko <https://github.com/feuillemorte>`_
- `Or Bin <https://github.com/OrBin>`_
- `overquota <https://github.com/overquota>`_
- `Paradox <https://github.com/paradox70>`_
- `Patrick Hofmann <https://github.com/PH89>`_
- `Paul Larsen <https://github.com/PaulSonOfLars>`_
- `Pawan <https://github.com/pawanrai9999>`_
- `Pieter Schutz <https://github.com/eldinnie>`_
- `Piraty <https://github.com/piraty>`_
- `Poolitzer <https://github.com/Poolitzer>`_
- `Pranjalya Tiwari <https://github.com/Pranjalya>`_
- `Rahiel Kasim <https://github.com/rahiel>`_
- `Riko Naka <https://github.com/rikonaka>`_
- `Rizlas <https://github.com/rizlas>`_
- `Sahil Sharma <https://github.com/sahilsharma811>`_
- `Sam Mosleh <https://github.com/sam-mosleh>`_
- `Sascha <https://github.com/saschalalala>`_
- `Shelomentsev D <https://github.com/shelomentsevd>`_
- `Shivam Saini <https://github.com/shivamsn97>`_
- `Simon Schürrle <https://github.com/SitiSchu>`_
- `sooyhwang <https://github.com/sooyhwang>`_
- `syntx <https://github.com/syntx>`_
- `thodnev <https://github.com/thodnev>`_
- `Timur Kushukov <https://github.com/timqsh>`_
- `Trainer Jono <https://github.com/Tr-Jono>`_
- `Valentijn <https://github.com/Faalentijn>`_
- `voider1 <https://github.com/voider1>`_
- `Vorobjev Simon <https://github.com/simonvorobjev>`_
- `Wagner Macedo <https://github.com/wagnerluis1982>`_
- `wjt <https://github.com/wjt>`_
- `Yaw Danso <https://github.com/dglitxh>`_
- `zeroone2numeral2 <https://github.com/zeroone2numeral2>`_
- `zeshuaro <https://github.com/zeshuaro>`_
- `zpavloudis <https://github.com/zpavloudis>`_
Please add yourself here alphabetically when you submit your first pull request.
+1240 -543
View File
File diff suppressed because it is too large Load Diff
+16 -11
View File
@@ -1,10 +1,14 @@
# Contributor Covenant Code of Conduct
====================================
Contributor Covenant Code of Conduct
====================================
## Our Pledge
Our Pledge
==========
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.
## Our Standards
Our Standards
=============
Examples of behavior that contributes to creating a positive environment include:
@@ -23,25 +27,26 @@ Examples of unacceptable behavior by participants include:
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Our Responsibilities
====================
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.
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.
## Scope
Scope
=====
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.
## Enforcement
Enforcement
===========
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at devs@python-telegram-bot.org. 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.
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.
## Attribution
Attribution
===========
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
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/>`_.
+1 -1
View File
@@ -1 +1 @@
include LICENSE LICENSE.lesser Makefile requirements.txt
include LICENSE LICENSE.lesser requirements.txt requirements-opts.txt README_RAW.rst telegram/py.typed
-52
View File
@@ -1,52 +0,0 @@
.DEFAULT_GOAL := help
.PHONY: clean pep257 pep8 yapf lint test install
PYLINT := pylint
PYTEST := pytest
PEP257 := pep257
PEP8 := flake8
YAPF := yapf
PIP := pip
clean:
rm -fr build
rm -fr dist
find . -name '*.pyc' -exec rm -f {} \;
find . -name '*.pyo' -exec rm -f {} \;
find . -name '*~' -exec rm -f {} \;
find . -regex "./telegram.\(mp3\|mp4\|ogg\|png\|webp\)" -exec rm {} \;
pep257:
$(PEP257) telegram
pep8:
$(PEP8) telegram
yapf:
$(YAPF) -r telegram
lint:
$(PYLINT) -E telegram --disable=no-name-in-module,import-error
test:
$(PYTEST) -v
install:
$(PIP) install -r requirements.txt -r requirements-dev.txt
help:
@echo "Available targets:"
@echo "- clean Clean up the source directory"
@echo "- pep257 Check docstring style with pep257"
@echo "- pep8 Check style with flake8"
@echo "- lint Check style with pylint"
@echo "- yapf Check style with yapf"
@echo "- test Run tests using pytest"
@echo
@echo "Available variables:"
@echo "- PYLINT default: $(PYLINT)"
@echo "- PYTEST default: $(PYTEST)"
@echo "- PEP257 default: $(PEP257)"
@echo "- PEP8 default: $(PEP8)"
@echo "- YAPF default: $(YAPF)"
@echo "- PIP default: $(PIP)"
+127 -111
View File
@@ -1,14 +1,11 @@
.. image:: https://github.com/python-telegram-bot/logos/blob/master/logo-text/png/ptb-logo-text_768.png?raw=true
..
Make sure to apply any changes to this file to README_RAW.rst as well!
.. image:: https://raw.githubusercontent.com/python-telegram-bot/logos/master/logo-text/png/ptb-logo-text_768.png
:align: center
:target: https://python-telegram-bot.org
:alt: python-telegram-bot Logo
We have made you a wrapper you can't refuse
We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
*Stay tuned for library updates and new releases on our* `Telegram Channel <https://telegram.me/pythontelegrambotchannel>`_.
.. image:: https://img.shields.io/pypi/v/python-telegram-bot.svg
:target: https://pypi.org/project/python-telegram-bot/
:alt: PyPi Package Version
@@ -17,192 +14,211 @@ We have a vibrant community of developers helping each other in our `Telegram gr
:target: https://pypi.org/project/python-telegram-bot/
:alt: Supported Python versions
.. image:: https://www.cpu.re/static/python-telegram-bot/downloads.svg
:target: https://www.cpu.re/static/python-telegram-bot/downloads-by-python-version.txt
.. image:: https://img.shields.io/badge/Bot%20API-6.7-blue?logo=telegram
:target: https://core.telegram.org/bots/api-changelog
:alt: Supported Bot API versions
.. image:: https://img.shields.io/pypi/dm/python-telegram-bot
:target: https://pypistats.org/packages/python-telegram-bot
:alt: PyPi Package Monthly Download
.. image:: https://img.shields.io/badge/docs-latest-af1a97.svg
:target: https://python-telegram-bot.readthedocs.io/
.. image:: https://readthedocs.org/projects/python-telegram-bot/badge/?version=stable
:target: https://docs.python-telegram-bot.org/en/stable/
:alt: Documentation Status
.. image:: https://img.shields.io/pypi/l/python-telegram-bot.svg
:target: https://www.gnu.org/licenses/lgpl-3.0.html
:alt: LGPLv3 License
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/GitHub%20Actions/badge.svg?event=schedule
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/GitHub%20Actions/badge.svg
:target: https://github.com/python-telegram-bot/python-telegram-bot/
:alt: Github Actions workflow
.. image:: https://codecov.io/gh/python-telegram-bot/python-telegram-bot/branch/master/graph/badge.svg
:target: https://codecov.io/gh/python-telegram-bot/python-telegram-bot
:target: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot
:alt: Code coverage
.. image:: http://isitmaintained.com/badge/resolution/python-telegram-bot/python-telegram-bot.svg
:target: http://isitmaintained.com/project/python-telegram-bot/python-telegram-bot
.. image:: https://isitmaintained.com/badge/resolution/python-telegram-bot/python-telegram-bot.svg
:target: https://isitmaintained.com/project/python-telegram-bot/python-telegram-bot
:alt: Median time to resolve an issue
.. image:: https://api.codacy.com/project/badge/Grade/99d901eaa09b44b4819aec05c330c968
:target: https://www.codacy.com/app/python-telegram-bot/python-telegram-bot?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=python-telegram-bot/python-telegram-bot&amp;utm_campaign=Badge_Grade
:alt: Code quality
:target: https://app.codacy.com/gh/python-telegram-bot/python-telegram-bot/dashboard
:alt: Code quality: Codacy
.. image:: https://img.shields.io/badge/Telegram-Group-blue.svg
.. image:: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot.svg/?label=active+issues
:target: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot/?ref=repository-badge
:alt: Code quality: DeepSource
.. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
:target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
:alt: pre-commit.ci status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: Black
.. image:: https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram
:target: https://t.me/pythontelegrambotchannel
:alt: Telegram Channel
.. image:: https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram
:target: https://telegram.me/pythontelegrambotgroup
:alt: Telegram Group
.. image:: https://img.shields.io/badge/IRC-Channel-blue.svg
:target: https://webchat.freenode.net/?channels=##python-telegram-bot
:alt: IRC Bridge
We have made you a wrapper you can't refuse
=================
Table of contents
=================
We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
- `Introduction`_
*Stay tuned for library updates and new releases on our* `Telegram Channel <https://telegram.me/pythontelegrambotchannel>`_.
- `Telegram API support`_
- `Installing`_
- `Getting started`_
#. `Learning by example`_
#. `Logging`_
#. `Documentation`_
- `Getting help`_
- `Contributing`_
- `License`_
============
Introduction
============
This library provides a pure Python interface for the
This library provides a pure Python, asynchronous interface for the
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
It's compatible with Python versions 3.5+ and `PyPy <http://pypy.org/>`_.
It's compatible with Python versions **3.8+**.
In addition to the pure API implementation, this library features a number of high-level classes to
make the development of bots easy and straightforward. These classes are contained in the
``telegram.ext`` submodule.
====================
A pure API implementation *without* ``telegram.ext`` is available as the standalone package ``python-telegram-bot-raw``. `See here for details. <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/README_RAW.rst>`_
Note
----
Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conjunction will result in undesired side-effects, so only install *one* of both.
Telegram API support
====================
All types and methods of the Telegram Bot API **4.8** are supported.
All types and methods of the Telegram Bot API **6.7** are supported.
==========
Installing
==========
You can install or upgrade python-telegram-bot with:
You can install or upgrade ``python-telegram-bot`` via
.. code:: shell
$ pip install python-telegram-bot --upgrade
Or you can install from source with:
To install a pre-release, use the ``--pre`` `flag <https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-pre>`_ in addition.
You can also install ``python-telegram-bot`` from source, though this is usually not necessary.
.. code:: shell
$ git clone https://github.com/python-telegram-bot/python-telegram-bot --recursive
$ git clone https://github.com/python-telegram-bot/python-telegram-bot
$ cd python-telegram-bot
$ python setup.py install
In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:
.. code:: shell
Verifying Releases
------------------
$ git submodule update --init --recursive
We sign all the releases with a GPG key.
The signatures are uploaded to both the `GitHub releases page <https://github.com/python-telegram-bot/python-telegram-bot/releases>`_ and the `PyPI project <https://pypi.org/project/python-telegram-bot/>`_ and end with a suffix ``.asc``.
Please find the public keys `here <https://github.com/python-telegram-bot/python-telegram-bot/tree/master/public_keys>`_.
The keys are named in the format ``<first_version>-<last_version>.gpg`` or ``<first_version>-current.gpg`` if the key is currently being used for new releases.
===============
Getting started
===============
In addition, the GitHub release page also contains the sha1 hashes of the release files in the files with the suffix ``.sha1``.
Our Wiki contains a lot of resources to get you started with ``python-telegram-bot``:
This allows you to verify that a release file that you downloaded was indeed provided by the ``python-telegram-bot`` team.
- `Introduction to the API <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API>`_
- Tutorial: `Your first Bot <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Your-first-Bot>`_
Dependencies & Their Versions
-----------------------------
Other references:
``python-telegram-bot`` tries to use as few 3rd party dependencies as possible.
However, for some features using a 3rd party library is more sane than implementing the functionality again.
As these features are *optional*, the corresponding 3rd party dependencies are not installed by default.
Instead, they are listed as optional dependencies.
This allows to avoid unnecessary dependency conflicts for users who don't need the optional features.
- `Telegram API documentation <https://core.telegram.org/bots/api>`_
- `python-telegram-bot documentation <https://python-telegram-bot.readthedocs.io/>`_
The only required dependency is `httpx ~= 0.24.1 <https://www.python-httpx.org>`_ for
``telegram.request.HTTPXRequest``, the default networking backend.
-------------------
Learning by example
-------------------
``python-telegram-bot`` is most useful when used along with additional libraries.
To minimize dependency conflicts, we try to be liberal in terms of version requirements on the (optional) dependencies.
On the other hand, we have to ensure stability of ``python-telegram-bot``, which is why we do apply version bounds.
If you encounter dependency conflicts due to these bounds, feel free to reach out.
We believe that the best way to learn this package is by example. Here
are some examples for you to review. Even if it is not your approach for learning, please take a
look at ``echobot2``, it is the de facto base for most of the bots out there. Best of all,
the code for these examples are released to the public domain, so you can start by grabbing the
code and building on top of it.
Optional Dependencies
#####################
Visit `this page <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/README.md>`_ to discover the official examples or look at the examples on the `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Examples>`_ to see other bots the community has built.
PTB can be installed with optional dependencies:
-------
Logging
-------
* ``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.
* ``pip install "python-telegram-bot[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
* ``pip install "python-telegram-bot[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
* ``pip install "python-telegram-bot[rate-limiter]"`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
* ``pip install "python-telegram-bot[webhooks]"`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
* ``pip install "python-telegram-bot[callback-data]"`` installs the `cachetools~=5.3.1 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
* ``pip install "python-telegram-bot[job-queue]"`` installs the `APScheduler~=3.10.1 <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``.
This library uses the ``logging`` module. To set up logging to standard output, put:
To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot[socks,webhooks]"``.
.. code:: python
Additionally, two shortcuts are provided:
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
* ``pip install "python-telegram-bot[all]"`` installs all optional dependencies.
* ``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]``.
at the beginning of your script.
Quick Start
===========
You can also use logs in your application by calling ``logging.getLogger()`` and setting the log level you want:
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``.
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.
.. code:: python
Resources
=========
logger = logging.getLogger()
logger.setLevel(logging.INFO)
- The `package documentation <https://docs.python-telegram-bot.org/>`_ is the technical reference for ``python-telegram-bot``.
It contains descriptions of all available classes, modules, methods and arguments as well as the `changelog <https://docs.python-telegram-bot.org/changelog.html>`_.
- 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.
- 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``.
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.
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.
- The `official Telegram Bot API documentation <https://core.telegram.org/bots/api>`_ is of course always worth a read.
If you want DEBUG logs instead:
.. code:: python
logger.setLevel(logging.DEBUG)
=============
Documentation
=============
``python-telegram-bot``'s documentation lives at `readthedocs.io <https://python-telegram-bot.readthedocs.io/>`_.
============
Getting help
============
You can get help in several ways:
If the resources mentioned above don't answer your questions or simply overwhelm you, there are several ways of getting help.
1. We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
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.
2. Report bugs, request new features or ask questions by `creating an issue <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_.
2. Ask questions by opening `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
3. Our `Wiki pages <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ offer a growing amount of resources.
3. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
4. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
Concurrency
===========
Since v20.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.
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:
* ``telegram.ext.Application/Updater.update_queue``
* ``telegram.ext.ConversationHandler.check/handle_update``
* ``telegram.ext.CallbackDataCache``
* ``telegram.ext.BasePersistence``
* all classes in the ``telegram.ext.filters`` module that allow to add/remove allowed users/chats at runtime
============
Contributing
============
Contributions of all sizes are welcome. Please review our `contribution guidelines <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst>`_ to get started. You can also help by `reporting bugs <https://github.com/python-telegram-bot/python-telegram-bot/issues/new>`_.
Contributions of all sizes are welcome.
Please review our `contribution guidelines <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst>`_ to get started.
You can also help by `reporting bugs or feature requests <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_.
Donating
========
Occasionally we are asked if we accept donations to support the development.
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.
If you still want to donate, we kindly ask you to donate to another open source project/initiative of your choice instead.
=======
License
=======
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>`_. 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.
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>`_.
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.
+210
View File
@@ -0,0 +1,210 @@
..
Make sure to apply any changes to this file to README.rst as well!
.. image:: https://github.com/python-telegram-bot/logos/blob/master/logo-text/png/ptb-raw-logo-text_768.png?raw=true
:align: center
:target: https://python-telegram-bot.org
:alt: python-telegram-bot-raw Logo
.. image:: https://img.shields.io/pypi/v/python-telegram-bot-raw.svg
:target: https://pypi.org/project/python-telegram-bot-raw/
:alt: PyPi Package Version
.. image:: https://img.shields.io/pypi/pyversions/python-telegram-bot-raw.svg
:target: https://pypi.org/project/python-telegram-bot-raw/
:alt: Supported Python versions
.. image:: https://img.shields.io/badge/Bot%20API-6.7-blue?logo=telegram
:target: https://core.telegram.org/bots/api-changelog
:alt: Supported Bot API versions
.. image:: https://img.shields.io/pypi/dm/python-telegram-bot-raw
:target: https://pypistats.org/packages/python-telegram-bot-raw
:alt: PyPi Package Monthly Download
.. image:: https://readthedocs.org/projects/python-telegram-bot/badge/?version=stable
:target: https://docs.python-telegram-bot.org/
:alt: Documentation Status
.. image:: https://img.shields.io/pypi/l/python-telegram-bot-raw.svg
:target: https://www.gnu.org/licenses/lgpl-3.0.html
:alt: LGPLv3 License
.. image:: https://github.com/python-telegram-bot/python-telegram-bot/workflows/GitHub%20Actions/badge.svg
:target: https://github.com/python-telegram-bot/python-telegram-bot/
:alt: Github Actions workflow
.. image:: https://codecov.io/gh/python-telegram-bot/python-telegram-bot/branch/master/graph/badge.svg
:target: https://app.codecov.io/gh/python-telegram-bot/python-telegram-bot
:alt: Code coverage
.. image:: https://isitmaintained.com/badge/resolution/python-telegram-bot/python-telegram-bot.svg
:target: https://isitmaintained.com/project/python-telegram-bot/python-telegram-bot
:alt: Median time to resolve an issue
.. image:: https://api.codacy.com/project/badge/Grade/99d901eaa09b44b4819aec05c330c968
:target: https://app.codacy.com/gh/python-telegram-bot/python-telegram-bot/dashboard
:alt: Code quality: Codacy
.. image:: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot.svg/?label=active+issues
:target: https://app.deepsource.com/gh/python-telegram-bot/python-telegram-bot/?ref=repository-badge
:alt: Code quality: DeepSource
.. image:: https://results.pre-commit.ci/badge/github/python-telegram-bot/python-telegram-bot/master.svg
:target: https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master
:alt: pre-commit.ci status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: Black
.. image:: https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram
:target: https://t.me/pythontelegrambotchannel
:alt: Telegram Channel
.. image:: https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram
:target: https://telegram.me/pythontelegrambotgroup
:alt: Telegram Group
We have made you a wrapper you can't refuse
We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
*Stay tuned for library updates and new releases on our* `Telegram Channel <https://telegram.me/pythontelegrambotchannel>`_.
Introduction
============
This library provides a pure Python, asynchronous interface for the
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
It's compatible with Python versions **3.8+**.
``python-telegram-bot-raw`` is part of the `python-telegram-bot <https://python-telegram-bot.org>`_ ecosystem and provides the pure API functionality extracted from PTB. It therefore does not have independent release schedules, changelogs or documentation.
Note
----
Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conjunction will result in undesired side-effects, so only install *one* of both.
Telegram API support
====================
All types and methods of the Telegram Bot API **6.7** are supported.
Installing
==========
You can install or upgrade ``python-telegram-bot`` via
.. code:: shell
$ pip install python-telegram-bot-raw --upgrade
To install a pre-release, use the ``--pre`` `flag <https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-pre>`_ in addition.
You can also install ``python-telegram-bot-raw`` from source, though this is usually not necessary.
.. code:: shell
$ git clone https://github.com/python-telegram-bot/python-telegram-bot
$ cd python-telegram-bot
$ python setup-raw.py install
Note
----
Installing the ``.tar.gz`` archive available on PyPi directly via ``pip`` will *not* work as expected, as ``pip`` does not recognize that it should use ``setup-raw.py`` instead of ``setup.py``.
Verifying Releases
------------------
We sign all the releases with a GPG key.
The signatures are uploaded to both the `GitHub releases page <https://github.com/python-telegram-bot/python-telegram-bot/releases>`_ and the `PyPI project <https://pypi.org/project/python-telegram-bot/>`_ and end with a suffix ``.asc``.
Please find the public keys `here <https://github.com/python-telegram-bot/python-telegram-bot/tree/master/public_keys>`_.
The keys are named in the format ``<first_version>-<last_version>.gpg`` or ``<first_version>-current.gpg`` if the key is currently being used for new releases.
In addition, the GitHub release page also contains the sha1 hashes of the release files in the files with the suffix ``.sha1``.
This allows you to verify that a release file that you downloaded was indeed provided by the ``python-telegram-bot`` team.
Dependencies & Their Versions
-----------------------------
``python-telegram-bot`` tries to use as few 3rd party dependencies as possible.
However, for some features using a 3rd party library is more sane than implementing the functionality again.
As these features are *optional*, the corresponding 3rd party dependencies are not installed by default.
Instead, they are listed as optional dependencies.
This allows to avoid unnecessary dependency conflicts for users who don't need the optional features.
The only required dependency is `httpx ~= 0.24.1 <https://www.python-httpx.org>`_ for
``telegram.request.HTTPXRequest``, the default networking backend.
``python-telegram-bot`` is most useful when used along with additional libraries.
To minimize dependency conflicts, we try to be liberal in terms of version requirements on the (optional) dependencies.
On the other hand, we have to ensure stability of ``python-telegram-bot``, which is why we do apply version bounds.
If you encounter dependency conflicts due to these bounds, feel free to reach out.
Optional Dependencies
#####################
PTB can be installed with optional dependencies:
* ``pip install "python-telegram-bot-raw[passport]"`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install "python-telegram-bot-raw[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
* ``pip install "python-telegram-bot-raw[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot-raw[passport,socks]"``.
Additionally, the shortcut ``pip install "python-telegram-bot-raw[all]"`` installs all optional dependencies.
Quick Start
===========
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``.
Resources
=========
- The `package documentation <https://docs.python-telegram-bot.org/>`_ is the technical reference for ``python-telegram-bot``.
It contains descriptions of all available classes, modules, methods and arguments as well as the `changelog <https://docs.python-telegram-bot.org/changelog.html>`_.
- 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.
- 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``.
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.
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.
- The `official Telegram Bot API documentation <https://core.telegram.org/bots/api>`_ is of course always worth a read.
Getting help
============
If the resources mentioned above don't answer your questions or simply overwhelm you, there are several ways of getting help.
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.
2. Ask questions by opening `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
3. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
Concurrency
===========
Since v20.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.
Contributing
============
Contributions of all sizes are welcome.
Please review our `contribution guidelines <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/.github/CONTRIBUTING.rst>`_ to get started.
You can also help by `reporting bugs or feature requests <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_.
Donating
========
Occasionally we are asked if we accept donations to support the development.
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.
If you still want to donate, we kindly ask you to donate to another open source project/initiative of your choice instead.
License
=======
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>`_.
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.
+9
View File
@@ -1 +1,10 @@
comment: false
coverage:
status:
project:
default:
# We allow small coverage decreases in the project because we don't retry
# on hitting flood limits, which adds noise to the coverage
target: auto
threshold: 0.1%
+3 -1
View File
@@ -15,7 +15,7 @@ endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -j auto
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
@@ -56,6 +56,8 @@ html:
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
rebuild: clean html
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
+594
View File
@@ -0,0 +1,594 @@
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2023
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import collections.abc
import inspect
import re
import typing
from collections import defaultdict
from typing import Any, Iterator, Union
import telegram
import telegram.ext
def _iter_own_public_methods(cls: type) -> Iterator[tuple[str, type]]:
"""Iterates over methods of a class that are not protected/private,
not camelCase and not inherited from the parent class.
Returns pairs of method names and methods.
This function is defined outside the class because it is used to create class constants.
"""
return (
m
for m in inspect.getmembers(cls, predicate=inspect.isfunction) # not .ismethod
if not m[0].startswith("_")
and m[0].islower() # to avoid camelCase methods
and m[0] in cls.__dict__ # method is not inherited from parent class
)
class AdmonitionInserter:
"""Class for inserting admonitions into docs of Telegram classes."""
CLASS_ADMONITION_TYPES = ("use_in", "available_in", "returned_in")
METHOD_ADMONITION_TYPES = ("shortcuts",)
ALL_ADMONITION_TYPES = CLASS_ADMONITION_TYPES + METHOD_ADMONITION_TYPES
FORWARD_REF_PATTERN = re.compile(r"^ForwardRef\('(?P<class_name>\w+)'\)$")
""" A pattern to find a class name in a ForwardRef typing annotation.
Class name (in a named group) is surrounded by parentheses and single quotes.
Note that since we're analyzing argument by argument, the pattern can be strict, with
start and end markers.
"""
FORWARD_REF_SKIP_PATTERN = re.compile(r"^ForwardRef\('DefaultValue\[\w+]'\)$")
"""A pattern that will be used to skip known ForwardRef's that need not be resolved
to a Telegram class, e.g.:
ForwardRef('DefaultValue[None]')
ForwardRef('DefaultValue[DVValueType]')
"""
METHOD_NAMES_FOR_BOT_AND_APPBUILDER: dict[type, str] = {
cls: tuple(m[0] for m in _iter_own_public_methods(cls)) # m[0] means we take only names
for cls in (telegram.Bot, telegram.ext.ApplicationBuilder)
}
"""A dictionary mapping Bot and ApplicationBuilder classes to their relevant methods that will
be mentioned in 'Returned in' and 'Use in' admonitions in other classes' docstrings.
Methods must be public, not aliases, not inherited from TelegramObject.
"""
def __init__(self):
self.admonitions: dict[str, dict[Union[type, collections.abc.Callable], str]] = {
# dynamically determine which method to use to create a sub-dictionary
admonition_type: getattr(self, f"_create_{admonition_type}")()
for admonition_type in self.ALL_ADMONITION_TYPES
}
"""Dictionary with admonitions. Contains sub-dictionaries, one per admonition type.
Each sub-dictionary matches bot methods (for "Shortcuts") or telegram classes (for other
admonition types) to texts of admonitions, e.g.:
```
{
"use_in": {<class 'telegram._chatinvitelink.ChatInviteLink'>:
<"Use in" admonition for ChatInviteLink>, ...},
"available_in": {<class 'telegram._chatinvitelink.ChatInviteLink'>:
<"Available in" admonition">, ...},
"returned_in": {...}
}
```
"""
def insert_admonitions(
self,
obj: Union[type, collections.abc.Callable],
docstring_lines: list[str],
):
"""Inserts admonitions into docstring lines for a given class or method.
**Modifies lines in place**.
"""
# A better way would be to copy the lines and return them, but that will not work with
# docs.auxil.sphinx_hooks.autodoc_process_docstring()
for admonition_type in self.ALL_ADMONITION_TYPES:
# If there is no admonition of the given type for the given class or method,
# continue to the next admonition type, maybe the class/method is listed there.
if obj not in self.admonitions[admonition_type]:
continue
insert_idx = self._find_insert_pos_for_admonition(docstring_lines)
admonition_lines = self.admonitions[admonition_type][obj].splitlines()
for idx in range(insert_idx, insert_idx + len(admonition_lines)):
docstring_lines.insert(idx, admonition_lines[idx - insert_idx])
def _create_available_in(self) -> dict[type, str]:
"""Creates a dictionary with 'Available in' admonitions for classes that are available
in attributes of other classes.
"""
# Generate a mapping of classes to ReST links to attributes in other classes that
# correspond to instances of a given class
# i.e. {telegram._files.sticker.Sticker: {":attr:`telegram.Message.sticker`", ...}}
attrs_for_class = defaultdict(set)
# The following regex is supposed to capture a class name in a line like this:
# media (:obj:`str` | :class:`telegram.InputFile`): Audio file to send.
#
# Note that even if such typing description spans over multiple lines but each line ends
# with a backslash (otherwise Sphinx will throw an error)
# (e.g. EncryptedPassportElement.data), then Sphinx will combine these lines into a single
# line automatically, and it will contain no backslash (only some extra many whitespaces
# from the indentation).
attr_docstr_pattern = re.compile(
r"^\s*(?P<attr_name>[a-z_]+)" # Any number of spaces, named group for attribute
r"\s?\(" # Optional whitespace, opening parenthesis
r".*" # Any number of characters (that could denote a built-in type)
r":class:`.+`" # Marker of a classref, class name in backticks
r".*\):" # Any number of characters, closing parenthesis, colon.
# The ^ colon above along with parenthesis is important because it makes sure that
# the class is mentioned in the attribute description, not in free text.
r".*$", # Any number of characters, end of string (end of line)
re.VERBOSE,
)
# for properties: there is no attr name in docstring. Just check if there's a class name.
prop_docstring_pattern = re.compile(r":class:`.+`.*:")
# pattern for iterating over potentially many class names in docstring for one attribute.
# Tilde is optional (sometimes it is in the docstring, sometimes not).
single_class_name_pattern = re.compile(r":class:`~?(?P<class_name>[\w.]*)`")
classes_to_inspect = inspect.getmembers(telegram, inspect.isclass) + inspect.getmembers(
telegram.ext, inspect.isclass
)
for class_name, inspected_class in classes_to_inspect:
# We need to make "<class 'telegram._files.sticker.StickerSet'>" into
# "telegram.StickerSet" because that's the way the classes are mentioned in
# docstrings.
name_of_inspected_class_in_docstr = self._generate_class_name_for_link(inspected_class)
# Parsing part of the docstring with attributes (parsing of properties follows later)
docstring_lines = inspect.getdoc(inspected_class).splitlines()
lines_with_attrs = []
for idx, line in enumerate(docstring_lines):
if line.strip() == "Attributes:":
lines_with_attrs = docstring_lines[idx + 1 :]
break
for line in lines_with_attrs:
if not (line_match := attr_docstr_pattern.match(line)):
continue
target_attr = line_match.group("attr_name")
# a typing description of one attribute can contain multiple classes
for match in single_class_name_pattern.finditer(line):
name_of_class_in_attr = match.group("class_name")
# Writing to dictionary: matching the class found in the docstring
# and its subclasses to the attribute of the class being inspected.
# The class in the attribute docstring (or its subclass) is the key,
# ReST link to attribute of the class currently being inspected is the value.
try:
self._resolve_arg_and_add_link(
arg=name_of_class_in_attr,
dict_of_methods_for_class=attrs_for_class,
link=f":attr:`{name_of_inspected_class_in_docstr}.{target_attr}`",
)
except NotImplementedError as e:
raise NotImplementedError(
f"Error generating Sphinx 'Available in' admonition "
f"(admonition_inserter.py). Class {name_of_class_in_attr} present in "
f"attribute {target_attr} of class {name_of_inspected_class_in_docstr}"
f" could not be resolved. {str(e)}"
)
# Properties need to be parsed separately because they act like attributes but not
# listed as attributes.
properties = inspect.getmembers(inspected_class, lambda o: isinstance(o, property))
for prop_name, _ in properties:
# Make sure this property is really defined in the class being inspected.
# A property can be inherited from a parent class, then a link to it will not work.
if prop_name not in inspected_class.__dict__:
continue
# 1. Can't use typing.get_type_hints because double-quoted type hints
# (like "Application") will throw a NameError
# 2. Can't use inspect.signature because return annotations of properties can be
# hard to parse (like "(self) -> BD").
# 3. fget is used to access the actual function under the property wrapper
docstring = inspect.getdoc(getattr(inspected_class, prop_name).fget)
if docstring is None:
continue
first_line = docstring.splitlines()[0]
if not prop_docstring_pattern.match(first_line):
continue
for match in single_class_name_pattern.finditer(first_line):
name_of_class_in_prop = match.group("class_name")
# Writing to dictionary: matching the class found in the docstring and its
# subclasses to the property of the class being inspected.
# The class in the property docstring (or its subclass) is the key,
# ReST link to property of the class currently being inspected is the value.
try:
self._resolve_arg_and_add_link(
arg=name_of_class_in_prop,
dict_of_methods_for_class=attrs_for_class,
link=f":attr:`{name_of_inspected_class_in_docstr}.{prop_name}`",
)
except NotImplementedError as e:
raise NotImplementedError(
f"Error generating Sphinx 'Available in' admonition "
f"(admonition_inserter.py). Class {name_of_class_in_prop} present in "
f"property {prop_name} of class {name_of_inspected_class_in_docstr}"
f" could not be resolved. {str(e)}"
)
return self._generate_admonitions(attrs_for_class, admonition_type="available_in")
def _create_returned_in(self) -> dict[type, str]:
"""Creates a dictionary with 'Returned in' admonitions for classes that are returned
in Bot's and ApplicationBuilder's methods.
"""
# Generate a mapping of classes to ReST links to Bot methods which return it,
# i.e. {<class 'telegram._message.Message'>: {:meth:`telegram.Bot.send_message`, ...}}
methods_for_class = defaultdict(set)
for cls, method_names in self.METHOD_NAMES_FOR_BOT_AND_APPBUILDER.items():
for method_name in method_names:
sig = inspect.signature(getattr(cls, method_name))
ret_annot = sig.return_annotation
method_link = self._generate_link_to_method(method_name, cls)
try:
self._resolve_arg_and_add_link(
arg=ret_annot,
dict_of_methods_for_class=methods_for_class,
link=method_link,
)
except NotImplementedError as e:
raise NotImplementedError(
f"Error generating Sphinx 'Returned in' admonition "
f"(admonition_inserter.py). {cls}, method {method_name}. "
f"Couldn't resolve type hint in return annotation {ret_annot}. {str(e)}"
)
return self._generate_admonitions(methods_for_class, admonition_type="returned_in")
def _create_shortcuts(self) -> dict[collections.abc.Callable, str]:
"""Creates a dictionary with 'Shortcuts' admonitions for Bot methods that
have shortcuts in other classes.
"""
# pattern for looking for calls to Bot methods only
bot_method_pattern = re.compile(
r"""\s* # any number of whitespaces
(?<=return\sawait\sself\.get_bot\(\)\.) # lookbehind
\w+ # the method name we are looking for, letters/underscores
(?=\() # lookahead: opening bracket before the args of the method start
""",
re.VERBOSE,
)
# Generate a mapping of methods of classes to links to Bot methods which they are shortcuts
# for, i.e. {<function Bot.send_voice at ...>: {:meth:`telegram.User.send_voice`, ...}
shortcuts_for_bot_method = defaultdict(set)
# inspect methods of all telegram classes for return statements that indicate
# that this given method is a shortcut for a Bot method
for class_name, cls in inspect.getmembers(telegram, predicate=inspect.isclass):
# no need to inspect Bot's own methods, as Bot can't have shortcuts in Bot
if cls is telegram.Bot:
continue
for method_name, method in _iter_own_public_methods(cls):
# .getsourcelines() returns a tuple. Item [1] is an int
for line in inspect.getsourcelines(method)[0]:
if not (bot_method_match := bot_method_pattern.search(line)):
continue
bot_method = getattr(telegram.Bot, bot_method_match.group())
link_to_shortcut_method = self._generate_link_to_method(method_name, cls)
shortcuts_for_bot_method[bot_method].add(link_to_shortcut_method)
return self._generate_admonitions(shortcuts_for_bot_method, admonition_type="shortcuts")
def _create_use_in(self) -> dict[type, str]:
"""Creates a dictionary with 'Use in' admonitions for classes whose instances are
accepted as arguments for Bot's and ApplicationBuilder's methods.
"""
# Generate a mapping of classes to links to Bot methods which accept them as arguments,
# i.e. {<class 'telegram._inline.inlinequeryresult.InlineQueryResult'>:
# {:meth:`telegram.Bot.answer_inline_query`, ...}}
methods_for_class = defaultdict(set)
for cls, method_names in self.METHOD_NAMES_FOR_BOT_AND_APPBUILDER.items():
for method_name in method_names:
method_link = self._generate_link_to_method(method_name, cls)
sig = inspect.signature(getattr(cls, method_name))
parameters = sig.parameters
for param in parameters.values():
try:
self._resolve_arg_and_add_link(
arg=param.annotation,
dict_of_methods_for_class=methods_for_class,
link=method_link,
)
except NotImplementedError as e:
raise NotImplementedError(
f"Error generating Sphinx 'Use in' admonition "
f"(admonition_inserter.py). {cls}, method {method_name}, parameter "
f"{param}: Couldn't resolve type hint {param.annotation}. {str(e)}"
)
return self._generate_admonitions(methods_for_class, admonition_type="use_in")
@staticmethod
def _find_insert_pos_for_admonition(lines: list[str]) -> int:
"""Finds the correct position to insert the class admonition and returns the index.
The admonition will be insert above "See also", "Examples:", version added/changed notes
and args, whatever comes first.
If no key phrases are found, the admonition will be inserted at the very end.
"""
for idx, value in list(enumerate(lines)):
if (
value.startswith(".. seealso:")
# The docstring contains heading "Examples:", but Sphinx will have it converted
# to ".. admonition: Examples":
or value.startswith(".. admonition:: Examples")
or value.startswith(".. version")
# The space after ":param" is important because docstring can contain ":paramref:"
# in its plain text in the beginning of a line (e.g. ExtBot):
or value.startswith(":param ")
# some classes (like "Credentials") have no params, so insert before attrs:
or value.startswith(".. attribute::")
):
return idx
return len(lines) - 1
def _generate_admonitions(
self,
attrs_or_methods_for_class: dict[type, set[str]],
admonition_type: str,
) -> dict[type, str]:
"""Generates admonitions of a given type.
Takes a dictionary of classes matched to ReST links to methods or attributes, e.g.:
```
{<class 'telegram._files.sticker.StickerSet'>:
[":meth: `telegram.Bot.get_sticker_set`", ...]}.
```
Returns a dictionary of classes matched to full admonitions, e.g.
for `admonition_type` "returned_in" (note that title and CSS class are generated
automatically):
```
{<class 'telegram._files.sticker.StickerSet'>:
".. admonition:: Returned in:
:class: returned-in
:meth: `telegram.Bot.get_sticker_set`"}.
```
"""
if admonition_type not in self.ALL_ADMONITION_TYPES:
raise TypeError(f"Admonition type {admonition_type} not supported.")
admonition_for_class = {}
for cls, attrs in attrs_or_methods_for_class.items():
if cls is telegram.ext.ApplicationBuilder:
# ApplicationBuilder is only used in and returned from its own methods,
# so its page needs no admonitions.
continue
attrs = sorted(attrs)
# e.g. for admonition type "use_in" the title will be "Use in" and CSS class "use-in".
admonition = f"""
.. admonition:: {admonition_type.title().replace("_", " ")}
:class: {admonition_type.replace("_", "-")}
"""
if len(attrs) > 1:
for target_attr in attrs:
admonition += "\n * " + target_attr
else:
admonition += f"\n {attrs[0]}"
admonition += "\n " # otherwise an unexpected unindent warning will be issued
admonition_for_class[cls] = admonition
return admonition_for_class
@staticmethod
def _generate_class_name_for_link(cls: type) -> str:
"""Generates class name that can be used in a ReST link."""
# Check for potential presence of ".ext.", we will need to keep it.
ext = ".ext" if ".ext." in str(cls) else ""
return f"telegram{ext}.{cls.__name__}"
def _generate_link_to_method(self, method_name: str, cls: type) -> str:
"""Generates a ReST link to a method of a telegram class."""
return f":meth:`{self._generate_class_name_for_link(cls)}.{method_name}`"
@staticmethod
def _iter_subclasses(cls: type) -> Iterator:
return (
# exclude private classes
c
for c in cls.__subclasses__()
if not str(c).split(".")[-1].startswith("_")
)
def _resolve_arg_and_add_link(
self,
arg: Any,
dict_of_methods_for_class: defaultdict,
link: str,
) -> None:
"""A helper method. Tries to resolve the arg into a valid class. In case of success,
adds the link (to a method, attribute, or property) for that class' and its subclasses'
sets of links in the dictionary of admonitions.
**Modifies dictionary in place.**
"""
for cls in self._resolve_arg(arg):
# When trying to resolve an argument from args or return annotation,
# the method _resolve_arg returns None if nothing could be resolved.
# Also, if class was resolved correctly, "telegram" will definitely be in its str().
if cls is None or "telegram" not in str(cls):
continue
dict_of_methods_for_class[cls].add(link)
for subclass in self._iter_subclasses(cls):
dict_of_methods_for_class[subclass].add(link)
def _resolve_arg(self, arg: Any) -> Iterator[Union[type, None]]:
"""Analyzes an argument of a method and recursively yields classes that the argument
or its sub-arguments (in cases like Union[...]) belong to, if they can be resolved to
telegram or telegram.ext classes.
Raises `NotImplementedError`.
"""
origin = typing.get_origin(arg)
if (
origin in (collections.abc.Callable, typing.IO)
or arg is None
# no other check available (by type or origin) for these:
or str(type(arg)) in ("<class 'typing._SpecialForm'>", "<class 'ellipsis'>")
):
pass
# RECURSIVE CALLS
# for cases like Union[Sequence....
elif origin in (
Union,
collections.abc.Coroutine,
collections.abc.Sequence,
):
for sub_arg in typing.get_args(arg):
yield from self._resolve_arg(sub_arg)
elif isinstance(arg, typing.TypeVar):
# gets access to the "bound=..." parameter
yield from self._resolve_arg(arg.__bound__)
# END RECURSIVE CALLS
elif isinstance(arg, typing.ForwardRef):
m = self.FORWARD_REF_PATTERN.match(str(arg))
# We're sure it's a ForwardRef, so, unless it belongs to known exceptions,
# the class must be resolved.
# If it isn't resolved, we'll have the program throw an exception to be sure.
try:
cls = self._resolve_class(m.group("class_name"))
except AttributeError:
# skip known ForwardRef's that need not be resolved to a Telegram class
if self.FORWARD_REF_SKIP_PATTERN.match(str(arg)):
pass
else:
raise NotImplementedError(f"Could not process ForwardRef: {arg}")
else:
yield cls
# For custom generics like telegram.ext._application.Application[~BT, ~CCT, ~UD...].
# This must come before the check for isinstance(type) because GenericAlias can also be
# recognized as type if it belongs to <class 'types.GenericAlias'>.
elif str(type(arg)) in (
"<class 'typing._GenericAlias'>",
"<class 'types.GenericAlias'>",
"<class 'typing._LiteralGenericAlias'>",
):
if "telegram" in str(arg):
# get_origin() of telegram.ext._application.Application[~BT, ~CCT, ~UD...]
# will produce <class 'telegram.ext._application.Application'>
yield origin
elif isinstance(arg, type):
if "telegram" in str(arg):
yield arg
# For some reason "InlineQueryResult", "InputMedia" & some others are currently not
# recognized as ForwardRefs and are identified as plain strings.
elif isinstance(arg, str):
# args like "ApplicationBuilder[BT, CCT, UD, CD, BD, JQ]" can be recognized as strings.
# Remove whatever is in the square brackets because it doesn't need to be parsed.
arg = re.sub(r"\[.+]", "", arg)
cls = self._resolve_class(arg)
# Here we don't want an exception to be thrown since we're not sure it's ForwardRef
if cls is not None:
yield cls
else:
raise NotImplementedError(
f"Cannot process argument {arg} of type {type(arg)} (origin {origin})"
)
@staticmethod
def _resolve_class(name: str) -> Union[type, None]:
"""The keys in the admonitions dictionary are not strings like "telegram.StickerSet"
but classes like <class 'telegram._files.sticker.StickerSet'>.
This method attempts to resolve a PTB class from a name that does or does not
contain the word 'telegram', e.g.
<class 'telegram._files.sticker.StickerSet'> from "telegram.StickerSet" or "StickerSet".
Returns a class on success, :obj:`None` if nothing could be resolved.
"""
for option in (
name,
f"telegram.{name}",
f"telegram.ext.{name}",
f"telegram.ext.filters.{name}",
):
try:
return eval(option)
# NameError will be raised if trying to eval just name and it doesn't work, e.g.
# "Name 'ApplicationBuilder' is not defined".
# AttributeError will be raised if trying to e.g. eval f"telegram.{name}" when the
# class denoted by `name` actually belongs to `telegram.ext`:
# "module 'telegram' has no attribute 'ApplicationBuilder'".
# If neither option works, this is not a PTB class.
except (NameError, AttributeError):
continue
if __name__ == "__main__":
# just try instantiating for debugging purposes
AdmonitionInserter()
+79
View File
@@ -0,0 +1,79 @@
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2023
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import inspect
keyword_args = [
":keyword _sphinx_paramlinks_telegram.Bot.{method}.read_timeout: Value to pass to "
":paramref:`telegram.request.BaseRequest.post.read_timeout`. Defaults to {read_timeout}.",
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.read_timeout: {read_timeout_type}, optional",
":keyword _sphinx_paramlinks_telegram.Bot.{method}.write_timeout: Value to pass to "
":paramref:`telegram.request.BaseRequest.post.write_timeout`. Defaults to {write_timeout}.",
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.write_timeout: :obj:`float` | :obj:`None`, "
"optional",
":keyword _sphinx_paramlinks_telegram.Bot.{method}.connect_timeout: Value to pass to "
":paramref:`telegram.request.BaseRequest.post.connect_timeout`. Defaults to "
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.connect_timeout: :obj:`float` | "
":obj:`None`, optional",
":keyword _sphinx_paramlinks_telegram.Bot.{method}.pool_timeout: Value to pass to "
":paramref:`telegram.request.BaseRequest.post.pool_timeout`. Defaults to "
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.pool_timeout: :obj:`float` | :obj:`None`, "
"optional",
":keyword _sphinx_paramlinks_telegram.Bot.{method}.api_kwargs: Arbitrary keyword arguments "
"to be passed to the Telegram API.",
":kwtype _sphinx_paramlinks_telegram.Bot.{method}.api_kwargs: :obj:`dict`, optional",
"",
]
write_timeout_sub = [":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`", "``20``"]
read_timeout_sub = [
":attr:`~telegram.request.BaseRequest.DEFAULT_NONE`.",
"``2``. :paramref:`timeout` will be added to this value",
]
read_timeout_type = [":obj:`float` | :obj:`None`", ":obj:`float`"]
def find_insert_pos_for_kwargs(lines: list[str]) -> int:
"""Finds the correct position to insert the keyword arguments and returns the index."""
for idx, value in reversed(list(enumerate(lines))): # reversed since :returns: is at the end
if value.startswith(":returns:"):
return idx
else:
return False
def is_write_timeout_20(obj: object) -> int:
"""inspects the default value of write_timeout parameter of the bot method."""
sig = inspect.signature(obj)
return 1 if (sig.parameters["write_timeout"].default == 20) else 0
def check_timeout_and_api_kwargs_presence(obj: object) -> int:
"""Checks if the method has timeout and api_kwargs keyword only parameters."""
sig = inspect.signature(obj)
params_to_check = (
"read_timeout",
"write_timeout",
"connect_timeout",
"pool_timeout",
"api_kwargs",
)
return all(
param in sig.parameters and sig.parameters[param].kind == inspect.Parameter.KEYWORD_ONLY
for param in params_to_check
)
+77
View File
@@ -0,0 +1,77 @@
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2023
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""Functionality in this file is used for getting the [source] links on the classes, methods etc
to link to the correct files & lines on github. Can be simplified once
https://github.com/sphinx-doc/sphinx/issues/1556 is closed
"""
import subprocess
from sphinx.util import logging
# get the sphinx(!) logger
# Makes sure logs render in red and also plays nicely with e.g. the `nitpicky` option.
sphinx_logger = logging.getLogger(__name__)
# must be a module-level variable so that it can be written to by the `autodoc-process-docstring`
# event handler in `sphinx_hooks.py`
LINE_NUMBERS = {}
def _git_branch() -> str:
"""Get's the current git sha if available or fall back to `master`"""
try:
output = subprocess.check_output( # skipcq: BAN-B607
["git", "describe", "--tags", "--always"], stderr=subprocess.STDOUT
)
return output.decode().strip()
except Exception as exc:
sphinx_logger.exception(
"Failed to get a description of the current commit. Falling back to `master`.",
exc_info=exc,
)
return "master"
git_branch = _git_branch()
base_url = "https://github.com/python-telegram-bot/python-telegram-bot/blob/"
def linkcode_resolve(_, info):
"""See www.sphinx-doc.org/en/master/usage/extensions/linkcode.html"""
combined = ".".join((info["module"], info["fullname"]))
# special casing for ExtBot which is due to the special structure of extbot.rst
combined = combined.replace("ExtBot.ExtBot", "ExtBot")
line_info = LINE_NUMBERS.get(combined)
if not line_info:
# Try the __init__
line_info = LINE_NUMBERS.get(f"{combined.rsplit('.', 1)[0]}.__init__")
if not line_info:
# Try the class
line_info = LINE_NUMBERS.get(f"{combined.rsplit('.', 1)[0]}")
if not line_info:
# Try the module
line_info = LINE_NUMBERS.get(info["module"])
if not line_info:
return
file, start_line, end_line = line_info
return f"{base_url}{git_branch}/{file}#L{start_line}-L{end_line}"
+211
View File
@@ -0,0 +1,211 @@
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2023
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import collections.abc
import inspect
import re
import typing
from pathlib import Path
from sphinx.application import Sphinx
import telegram
import telegram.ext
from docs.auxil.admonition_inserter import AdmonitionInserter
from docs.auxil.kwargs_insertion import (
check_timeout_and_api_kwargs_presence,
find_insert_pos_for_kwargs,
is_write_timeout_20,
keyword_args,
read_timeout_sub,
read_timeout_type,
write_timeout_sub,
)
from docs.auxil.link_code import LINE_NUMBERS
ADMONITION_INSERTER = AdmonitionInserter()
# Some base classes are implementation detail
# We want to instead show *their* base class
PRIVATE_BASE_CLASSES = {
"_ChatUserBaseFilter": "MessageFilter",
"_Dice": "MessageFilter",
"_BaseThumbedMedium": "TelegramObject",
"_BaseMedium": "TelegramObject",
"_CredentialsBase": "TelegramObject",
}
FILE_ROOT = Path(inspect.getsourcefile(telegram)).parent.parent.resolve()
def autodoc_skip_member(app, what, name, obj, skip, options):
"""We use this to not document certain members like filter() or check_update() for filters.
See https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#skipping-members"""
included = {"MessageFilter", "UpdateFilter"} # filter() and check_update() only for these.
included_in_obj = any(inc in repr(obj) for inc in included)
if included_in_obj: # it's difficult to see if check_update is from an inherited-member or not
for frame in inspect.stack(): # From https://github.com/sphinx-doc/sphinx/issues/9533
if frame.function == "filter_members":
docobj = frame.frame.f_locals["self"].object
if not any(inc in str(docobj) for inc in included) and name == "check_update":
return True
break
if name == "filter" and obj.__module__ == "telegram.ext.filters":
if not included_in_obj:
return True # return True to exclude from docs.
def autodoc_process_docstring(
app: Sphinx, what, name: str, obj: object, options, lines: list[str]
):
"""We do the following things:
1) Use this method to automatically insert the Keyword Args and "Shortcuts" admonitions
for the Bot methods.
2) Use this method to automatically insert "Returned in" admonition into classes
that are returned from the Bot methods
3) Use this method to automatically insert "Available in" admonition into classes
whose instances are available as attributes of other classes
4) Use this method to automatically insert "Use in" admonition into classes
whose instances can be used as arguments of the Bot methods
5) Misuse this autodoc hook to get the file names & line numbers because we have access
to the actual object here.
"""
# 1) Insert the Keyword Args and "Shortcuts" admonitions for the Bot methods
method_name = name.split(".")[-1]
if (
name.startswith("telegram.Bot.")
and what == "method"
and method_name.islower()
and check_timeout_and_api_kwargs_presence(obj)
):
insert_index = find_insert_pos_for_kwargs(lines)
if not insert_index:
raise ValueError(
f"Couldn't find the correct position to insert the keyword args for {obj}."
)
long_write_timeout = is_write_timeout_20(obj)
get_updates_sub = 1 if (method_name == "get_updates") else 0
# The below can be done in 1 line with itertools.chain, but this must be modified in-place
for i in range(insert_index, insert_index + len(keyword_args)):
lines.insert(
i,
keyword_args[i - insert_index].format(
method=method_name,
write_timeout=write_timeout_sub[long_write_timeout],
read_timeout=read_timeout_sub[get_updates_sub],
read_timeout_type=read_timeout_type[get_updates_sub],
),
)
ADMONITION_INSERTER.insert_admonitions(
obj=typing.cast(collections.abc.Callable, obj),
docstring_lines=lines,
)
# 2-4) Insert "Returned in", "Available in", "Use in" admonitions into classes
# (where applicable)
if what == "class":
ADMONITION_INSERTER.insert_admonitions(
obj=typing.cast(type, obj), # since "what" == class, we know it's not just object
docstring_lines=lines,
)
# 5) Get the file names & line numbers
# We can't properly handle ordinary attributes.
# In linkcode_resolve we'll resolve to the `__init__` or module instead
if what == "attribute":
return
# Special casing for properties
if hasattr(obj, "fget"):
obj = obj.fget
# Special casing for filters
if isinstance(obj, telegram.ext.filters.BaseFilter):
obj = obj.__class__
try:
source_lines, start_line = inspect.getsourcelines(obj)
end_line = start_line + len(source_lines)
file = Path(inspect.getsourcefile(obj)).relative_to(FILE_ROOT)
LINE_NUMBERS[name] = (file, start_line, end_line)
except Exception:
pass
# Since we don't document the `__init__`, we call this manually to have it available for
# attributes -- see the note above
if what == "class":
autodoc_process_docstring(app, "method", f"{name}.__init__", obj.__init__, options, lines)
def autodoc_process_bases(app, name, obj, option, bases: list):
"""Here we fine tune how the base class's classes are displayed."""
for idx, base in enumerate(bases):
# let's use a string representation of the object
base = str(base)
# Special case for abstract context managers which are wrongly resoled for some reason
if base.startswith("typing.AbstractAsyncContextManager"):
bases[idx] = ":class:`contextlib.AbstractAsyncContextManager`"
continue
# Special case because base classes are in std lib:
if "StringEnum" in base == "<enum 'StringEnum'>":
bases[idx] = ":class:`enum.Enum`"
bases.insert(0, ":class:`str`")
continue
if "IntEnum" in base:
bases[idx] = ":class:`enum.IntEnum`"
continue
# Drop generics (at least for now)
if base.endswith("]"):
base = base.split("[", maxsplit=1)[0]
bases[idx] = f":class:`{base}`"
# Now convert `telegram._message.Message` to `telegram.Message` etc
if (
not (match := re.search(pattern=r"(telegram(\.ext|))\.[_\w\.]+", string=base))
or "_utils" in base
):
continue
parts = match.group(0).split(".")
# Remove private paths
for index, part in enumerate(parts):
if part.startswith("_"):
parts = parts[:index] + parts[-1:]
break
# Replace private base classes with their respective parent
parts = [PRIVATE_BASE_CLASSES.get(part, part) for part in parts]
base = ".".join(parts)
bases[idx] = f":class:`{base}`"
+92
View File
@@ -0,0 +1,92 @@
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2023
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
from enum import Enum
from docutils.nodes import Element
from sphinx.domains.python import PyXRefRole
from sphinx.environment import BuildEnvironment
from sphinx.util import logging
import telegram
# get the sphinx(!) logger
# Makes sure logs render in red and also plays nicely with e.g. the `nitpicky` option.
sphinx_logger = logging.getLogger(__name__)
CONSTANTS_ROLE = "tg-const"
class TGConstXRefRole(PyXRefRole):
"""This is a bit of Sphinx magic. We add a new role type called tg-const that allows us to
reference values from the `telegram.constants.module` while using the actual value as title
of the link.
Example:
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` renders as `4096` but links to
the constant.
"""
def process_link(
self,
env: BuildEnvironment,
refnode: Element,
has_explicit_title: bool,
title: str,
target: str,
) -> tuple[str, str]:
title, target = super().process_link(env, refnode, has_explicit_title, title, target)
try:
# We use `eval` to get the value of the expression. Maybe there are better ways to
# do this via importlib or so, but it does the job for now
value = eval(target)
# Maybe we need a better check if the target is actually from tg.constants
# for now checking if it's an Enum suffices since those are used nowhere else in PTB
if isinstance(value, Enum):
# Special casing for file size limits
if isinstance(value, telegram.constants.FileSizeLimit):
return f"{int(value.value / 1e6)} MB", target
return repr(value.value), target
# Just for (Bot API) versions number auto add in constants:
if isinstance(value, str) and target in (
"telegram.constants.BOT_API_VERSION",
"telegram.__version__",
):
return value, target
if isinstance(value, tuple) and target in (
"telegram.constants.BOT_API_VERSION_INFO",
"telegram.__version_info__",
):
return repr(value), target
sphinx_logger.warning(
f"%s:%d: WARNING: Did not convert reference %s. :{CONSTANTS_ROLE}: is not supposed"
" to be used with this type of target.",
refnode.source,
refnode.line,
refnode.rawsource,
)
return title, target
except Exception as exc:
sphinx_logger.exception(
"%s:%d: WARNING: Did not convert reference %s due to an exception.",
refnode.source,
refnode.line,
refnode.rawsource,
exc_info=exc,
)
return title, target
+6 -2
View File
@@ -1,3 +1,7 @@
sphinx>=1.7.9
sphinx_rtd_theme
sphinx==7.0.1
sphinx-pypi-upload
furo==2023.5.20
git+https://github.com/harshil21/furo-sphinx-search@01efc7be422d7dc02390aab9be68d6f5ce1a5618#egg=furo-sphinx-search
sphinx-paramlinks==0.5.4
sphinxcontrib-mermaid==0.9.2
sphinx-copybutton==0.5.2
+65
View File
@@ -0,0 +1,65 @@
:root {
--icon--shortcuts: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-signpost' viewBox='0 0 16 16'%3E%3Cpath d='M7 1.414V4H2a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h5v6h2v-6h3.532a1 1 0 0 0 .768-.36l1.933-2.32a.5.5 0 0 0 0-.64L13.3 4.36a1 1 0 0 0-.768-.36H9V1.414a1 1 0 0 0-2 0zM12.532 5l1.666 2-1.666 2H2V5h10.532z'/%3E%3C/svg%3E");
--icon--returned-in: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-arrow-return-right' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.5 1.5A.5.5 0 0 0 1 2v4.8a2.5 2.5 0 0 0 2.5 2.5h9.793l-3.347 3.346a.5.5 0 0 0 .708.708l4.2-4.2a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 8.3H3.5A1.5 1.5 0 0 1 2 6.8V2a.5.5 0 0 0-.5-.5z'/%3E%3C/svg%3E");
--icon--available-in: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-geo-fill' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4 4a4 4 0 1 1 4.5 3.969V13.5a.5.5 0 0 1-1 0V7.97A4 4 0 0 1 4 3.999zm2.493 8.574a.5.5 0 0 1-.411.575c-.712.118-1.28.295-1.655.493a1.319 1.319 0 0 0-.37.265.301.301 0 0 0-.057.09V14l.002.008a.147.147 0 0 0 .016.033.617.617 0 0 0 .145.15c.165.13.435.27.813.395.751.25 1.82.414 3.024.414s2.273-.163 3.024-.414c.378-.126.648-.265.813-.395a.619.619 0 0 0 .146-.15.148.148 0 0 0 .015-.033L12 14v-.004a.301.301 0 0 0-.057-.09 1.318 1.318 0 0 0-.37-.264c-.376-.198-.943-.375-1.655-.493a.5.5 0 1 1 .164-.986c.77.127 1.452.328 1.957.594C12.5 13 13 13.4 13 14c0 .426-.26.752-.544.977-.29.228-.68.413-1.116.558-.878.293-2.059.465-3.34.465-1.281 0-2.462-.172-3.34-.465-.436-.145-.826-.33-1.116-.558C3.26 14.752 3 14.426 3 14c0-.599.5-1 .961-1.243.505-.266 1.187-.467 1.957-.594a.5.5 0 0 1 .575.411z'/%3E%3C/svg%3E");
--icon--use-in:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-funnel' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 1.5A.5.5 0 0 1 2 1h12a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.128.334L10 8.692V13.5a.5.5 0 0 1-.342.474l-3 1A.5.5 0 0 1 6 14.5V8.692L1.628 3.834A.5.5 0 0 1 1.5 3.5v-2zm1 .5v1.308l4.372 4.858A.5.5 0 0 1 7 8.5v5.306l2-.666V8.5a.5.5 0 0 1 .128-.334L13.5 3.308V2h-11z'/%3E%3C/svg%3E");
}
.admonition.shortcuts {
border-color: rgb(43, 155, 70);
}
.admonition.shortcuts > .admonition-title {
background-color: rgba(43, 155, 70, 0.1);
border-color: rgb(43, 155, 70);
}
.admonition.shortcuts > .admonition-title::before {
background-color: rgb(43, 155, 70);
-webkit-mask-image: var(--icon--shortcuts);
mask-image: var(--icon--shortcuts);
}
.admonition.returned-in {
border-color: rgb(230, 109, 15);
}
.admonition.returned-in > .admonition-title {
background-color: rgba(177, 108, 51, 0.1);
border-color: rgb(230, 109, 15);
}
.admonition.returned-in > .admonition-title::before {
background-color: rgb(230, 109, 15);
-webkit-mask-image: var(--icon--returned-in);
mask-image: var(--icon--returned-in);
}
.admonition.available-in {
border-color: rgb(183, 4, 215);
}
.admonition.available-in > .admonition-title {
background-color: rgba(165, 99, 177, 0.1);
border-color: rgb(183, 4, 215);
}
.admonition.available-in > .admonition-title::before {
background-color: rgb(183, 4, 215);
-webkit-mask-image: var(--icon--available-in);
mask-image: var(--icon--available-in);
}
.admonition.use-in {
border-color: rgb(203, 147, 1);
}
.admonition.use-in > .admonition-title {
background-color: rgba(176, 144, 60, 0.1);
border-color: rgb(203, 147, 1);
}
.admonition.use-in > .admonition-title::before {
background-color: rgb(203, 147, 1);
-webkit-mask-image: var(--icon--use-in);
mask-image: var(--icon--use-in);
}
.admonition.returned-in > ul:hover, .admonition.available-in > ul:hover, .admonition.use-in > ul:hover, .admonition.shortcuts > ul:hover {
cursor: move;
}
.admonition.returned-in > ul, .admonition.available-in > ul, .admonition.use-in > ul, .admonition.shortcuts > ul {
max-height: 200px;
overflow-y: scroll;
}
@@ -0,0 +1,5 @@
article a.reference.external:not([href*="/python-telegram-bot/blob/"])::after {
content: url('data:image/svg+xml,<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="%23607D8B" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z"/><path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" /><line x1="10" y1="14" x2="20" y2="4" /><polyline points="15 4 20 4 20 9" /></svg>');
margin: 0 0.25rem;
vertical-align: middle;
}
+3
View File
@@ -0,0 +1,3 @@
.article-container h1 {
overflow-wrap: anywhere;
}
+15
View File
@@ -0,0 +1,15 @@
figure > img {
height: 300px; /* resize figures so they aren't too big */
}
@media (prefers-color-scheme: dark) {
body:not([data-theme="light"]) figure > img { /* auto and dark is dark mode */
filter: invert(92%);
}
}
@media (prefers-color-scheme: light) {
body[data-theme="dark"] figure > img { /* auto and light is light mode */
filter: invert(92%);
}
}
@@ -0,0 +1,3 @@
.mermaid svg {
height: auto;
}
@@ -0,0 +1,11 @@
.sidebar-sticky .sidebar-brand {
flex-direction: row;
}
.sidebar-sticky .sidebar-brand .sidebar-logo-container {
align-self: center;
}
.sidebar-sticky .sidebar-brand .sidebar-brand-text {
align-self: center;
}
+1
View File
@@ -0,0 +1 @@
.. include:: ../../CODE_OF_CONDUCT.rst
+220 -217
View File
@@ -1,270 +1,273 @@
# -*- coding: utf-8 -*-
#
# Python Telegram Bot documentation build configuration file, created by
# sphinx-quickstart on Mon Aug 10 22:25:07 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import shlex
# import telegram
import re
import sys
from pathlib import Path
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../..'))
from sphinx.application import Sphinx
sys.path.insert(0, os.path.abspath("../.."))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.7.9'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Python Telegram Bot'
copyright = u'2015-2020, Leandro Toledo'
author = u'Leandro Toledo'
project = "python-telegram-bot"
copyright = "2015-2023, Leandro Toledo"
author = "Leandro Toledo"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '12.8' # telegram.__version__[:3]
version = "20.4" # telegram.__version__[:3]
# The full version, including alpha/beta/rc tags.
release = '12.8' # telegram.__version__
release = "20.3" # telegram.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "6.1.3"
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.linkcode",
"sphinx.ext.extlinks",
"sphinx_paramlinks",
"sphinx_copybutton",
"sphinxcontrib.mermaid",
"sphinx_search.extension",
]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# For shorter links to Wiki in docstrings
extlinks = {
"wiki": ("https://github.com/python-telegram-bot/python-telegram-bot/wiki/%s", "%s"),
"pr": ("https://github.com/python-telegram-bot/python-telegram-bot/pull/%s", "#%s"),
"issue": ("https://github.com/python-telegram-bot/python-telegram-bot/issues/%s", "#%s"),
}
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# Use intersphinx to reference the python builtin library docs
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"APScheduler": ("https://apscheduler.readthedocs.io/en/3.x/", None),
}
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# Global substitutions
rst_prolog = (Path.cwd() / "../substitutions/global.rst").read_text(encoding="utf-8")
# -- Extension settings ------------------------------------------------
napoleon_use_admonition_for_examples = True
# Don't show type hints in the signature - that just makes it hardly readable
# and we document the types anyway
autodoc_typehints = "none"
# Fail on warnings & unresolved references etc
nitpicky = True
# Paramlink style
paramlinks_hyperlink_param = "name"
# Linkcheck settings
linkcheck_ignore = [
# Let's not check issue/PR links - that's wasted resources
r"http(s)://github\.com/python-telegram-bot/python-telegram-bot/(issues|pull)/\d+/?",
# For some reason linkcheck has a problem with these two:
re.escape("https://github.com/python-telegram-bot/python-telegram-bot/discussions/new"),
re.escape("https://github.com/python-telegram-bot/python-telegram-bot/issues/new"),
# Anchors are apparently inserted by GitHub dynamically, so let's skip checking them
"https://github.com/python-telegram-bot/python-telegram-bot/tree/master/examples#",
r"https://github\.com/python-telegram-bot/python-telegram-bot/wiki/[\w\-_,]+\#",
]
linkcheck_allowed_redirects = {
# Redirects to the default version are okay
r"https://docs\.python-telegram-bot\.org/.*": r"https://docs\.python-telegram-bot\.org/en/[\w\d\.]+/.*",
# pre-commit.ci always redirects to the latest run
re.escape(
"https://results.pre-commit.ci/latest/github/python-telegram-bot/python-telegram-bot/master"
): r"https://results\.pre-commit\.ci/run/github/.*",
}
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# Decides the language used for syntax highlighting of code blocks.
highlight_language = "python3"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
html_theme = "furo"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# further. For a list of options available for each theme, see the documentation.
html_theme_options = {
"navigation_with_keys": True,
"dark_css_variables": {
"admonition-title-font-size": "0.95rem",
"admonition-font-size": "0.92rem",
},
"light_css_variables": {
"admonition-title-font-size": "0.95rem",
"admonition-font-size": "0.92rem",
},
"announcement": "PTB has undergone significant changes in v20. Please read the documentation "
"carefully and also check out the transition guide in the "
'<a href="https://github.com/python-telegram-bot/python-telegram-bot/wiki/'
'Transition-guide-to-Version-20.0">wiki</a>.',
"footer_icons": [
{
# Telegram channel logo
"name": "Telegram Channel",
"url": "https://t.me/pythontelegrambotchannel/",
# Following svg is from https://react-icons.github.io/react-icons/search?q=telegram
"html": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
'<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.287 5.906c-.778.324-2.334.994'
"-4.666 2.01-.378.15-.577.298-.595.442-.03.243.275.339.69.47l.175.055c.408.133."
"958.288 1.243.294.26.006.549-.1.868-.32 2.179-1.471 3.304-2.214 3.374-2.23.0"
"5-.012.12-.026.166.016.047.041.042.12.037.141-.03.129-1.227 1.241-1.846 1.81"
"7-.193.18-.33.307-.358.336a8.154 8.154 0 0 1-.188.186c-.38.366-.664.64.015 1.08"
"8.327.216.589.393.85.571.284.194.568.387.936.629.093.06.183.125.27.187.331.23"
"6.63.448.997.414.214-.02.435-.22.547-.82.265-1.417.786-4.486.906-5.751a1.426 "
"1.426 0 0 0-.013-.315.337.337 0 0 0-.114-.217.526.526 0 0 0-.31-.093c-.3.005-.7"
'63.166-2.984 1.09z"></path></svg>',
"class": "",
},
{ # Github logo
"name": "GitHub",
"url": "https://github.com/python-telegram-bot/python-telegram-bot/",
"html": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
'viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 '
"2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.4"
"9-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23"
".82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 "
"0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.2"
"7 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.5"
"1.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 "
'1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">'
"</path></svg>",
"class": "",
},
{ # PTB website logo - globe
"name": "python-telegram-bot website",
"url": "https://python-telegram-bot.org/",
"html": '<svg stroke="currentColor" fill="currentColor" stroke-width="0" '
'viewBox="0 0 16 16" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">'
'<path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 '
"1.855-.143.268-.276.56-.395.872.705.157 1.472.257 2.282.287V1.077zM4.249 3.53"
"9c.142-.384.304-.744.481-1.078a6.7 6.7 0 0 1 .597-.933A7.01 7.01 0 0 0 3.051 "
"3.05c.362.184.763.349 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9.124 "
"9.124 0 0 1-1.565-.667A6.964 6.964 0 0 0 1.018 7.5h2.49zm1.4-2.741a12.344 "
"12.344 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332zM8.5 5.09V7.5h"
"2.99a12.342 12.342 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.03"
"5.987.176 1.914.399 2.741A13.612 13.612 0 0 1 7.5 10.91V8.5H4.51zm3.99 0v2.409"
"c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741H8.5zm-3.282 3.696c.12.31"
"2.252.604.395.872.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.28"
"2.287zm.11 2.276a6.696 6.696 0 0 1-.598-.933 8.853 8.853 0 0 1-.481-1.079 8.38 "
"8.38 0 0 0-1.198.49 7.01 7.01 0 0 0 2.276 1.522zm-1.383-2.964A13.36 13.36 0 0 1"
" 3.508 8.5h-2.49a6.963 6.963 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667zm"
"6.728 2.964a7.009 7.009 0 0 0 2.275-1.521 8.376 8.376 0 0 0-1.197-.49 8.853 "
"8.853 0 0 1-.481 1.078 6.688 6.688 0 0 1-.597.933zM8.5 11.909v3.014c.67-.204 "
"1.335-.82 1.887-1.855.143-.268.276-.56.395-.872A12.63 12.63 0 0 0 8.5 11.91zm"
"3.555-.401c.57.185 1.095.409 1.565.667A6.963 6.963 0 0 0 14.982 8.5h-2.49a1"
"3.36 13.36 0 0 1-.437 3.008zM14.982 7.5a6.963 6.963 0 0 0-1.362-3.675c-.47.25"
"8-.995.482-1.565.667.248.92.4 1.938.437 3.008h2.49zM11.27 2.461c.177.334.339.6"
"94.482 1.078a8.368 8.368 0 0 0 1.196-.49 7.01 7.01 0 0 0-2.275-1.52c.218.283.4"
"18.597.597.932zm-.488 1.343a7.765 7.765 0 0 0-.395-.872C9.835 1.897 9.17 1.282 "
'8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z"></path></svg>',
"class": "",
},
],
}
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
html_title = f"python-telegram-bot<br> v{version}"
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = 'ptb-logo-orange.png'
html_logo = "ptb-logo_1024.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = 'ptb-logo-orange.ico'
html_favicon = "ptb-logo_1024.ico"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
html_css_files = [
"style_external_link.css",
"style_mermaid_diagrams.css",
"style_sidebar_brand.css",
"style_general.css",
"style_admonitions.css",
"style_images.css",
]
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
#html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
html_permalinks_icon = "" # Furo's default permalink icon is `#` which doesn't look great imo.
# Output file base name for HTML help builder.
htmlhelp_basename = 'PythonTelegramBotdoc'
htmlhelp_basename = "python-telegram-bot-doc"
# The base URL which points to the root of the HTML documentation. It is used to indicate the
# location of document using The Canonical Link Relation. Default: ''.
html_baseurl = "https://docs.python-telegram-bot.org"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
'preamble': r'''\setcounter{tocdepth}{2}
# The paper size ('letterpaper' or 'a4paper').
"papersize": "a4paper",
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
"preamble": r"""\setcounter{tocdepth}{2}
\usepackage{enumitem}
\setlistdepth{99}''',
# Latex figure (float) alignment
#'figure_align': 'htbp',
\setlistdepth{99}""",
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PythonTelegramBot.tex', u'Python Telegram Bot Documentation',
author, 'manual'),
(master_doc, "python-telegram-bot.tex", "python-telegram-bot Documentation", author, "manual"),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = 'ptb-logo_1024.png'
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
latex_logo = "ptb-logo_1024.png"
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pythontelegrambot', u'Python Telegram Bot Documentation',
[author], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
man_pages = [(master_doc, "python-telegram-bot", "python-telegram-bot Documentation", [author], 1)]
# rtd_sphinx_search_file_type = "un-minified" # Configuration for furo-sphinx-search
# -- Options for Texinfo output -------------------------------------------
@@ -272,33 +275,33 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PythonTelegramBot', u'Python Telegram Bot Documentation',
author, 'PythonTelegramBot', "We have made you a wrapper you can't refuse",
'Miscellaneous'),
(
master_doc,
"python-telegram-bot",
"python-telegram-bot Documentation",
author,
"python-telegram-bot",
"We have made you a wrapper you can't refuse",
"Miscellaneous",
),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# Napoleon stuff
napoleon_use_admonition_for_examples = True
# -- script stuff --------------------------------------------------------
# Due to Sphinx behaviour, these imports only work when imported here, not at top of module.
def autodoc_skip_member(app, what, name, obj, skip, options):
pass
# Not used but must be imported for the linkcode extension to find it
from docs.auxil.link_code import linkcode_resolve
from docs.auxil.sphinx_hooks import (
autodoc_process_bases,
autodoc_process_docstring,
autodoc_skip_member,
)
from docs.auxil.tg_const_role import CONSTANTS_ROLE, TGConstXRefRole
def setup(app):
app.connect('autodoc-skip-member', autodoc_skip_member)
def setup(app: Sphinx):
app.connect("autodoc-skip-member", autodoc_skip_member)
app.connect("autodoc-process-bases", autodoc_process_bases)
app.connect("autodoc-process-docstring", autodoc_process_docstring)
app.add_role_to_domain("py", CONSTANTS_ROLE, TGConstXRefRole())
+1
View File
@@ -0,0 +1 @@
.. include:: ../../.github/CONTRIBUTING.rst
@@ -0,0 +1,7 @@
``arbitrarycallbackdatabot.py``
===============================
.. literalinclude:: ../../examples/arbitrarycallbackdatabot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``chatmemberbot.py``
====================
.. literalinclude:: ../../examples/chatmemberbot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``contexttypesbot.py``
======================
.. literalinclude:: ../../examples/contexttypesbot.py
:language: python
:linenos:
+13
View File
@@ -0,0 +1,13 @@
``conversationbot.py``
======================
.. literalinclude:: ../../examples/conversationbot.py
:language: python
:linenos:
.. _conversationbot-diagram:
State Diagram
-------------
.. mermaid:: ../../examples/conversationbot.mmd
+13
View File
@@ -0,0 +1,13 @@
``conversationbot2.py``
=======================
.. literalinclude:: ../../examples/conversationbot2.py
:language: python
:linenos:
.. _conversationbot2-diagram:
State Diagram
-------------
.. mermaid:: ../../examples/conversationbot2.mmd
@@ -0,0 +1,7 @@
``customwebhookbot.py``
=======================
.. literalinclude:: ../../examples/customwebhookbot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``deeplinking.py``
==================
.. literalinclude:: ../../examples/deeplinking.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``echobot.py``
==============
.. literalinclude:: ../../examples/echobot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``errorhandlerbot.py``
======================
.. literalinclude:: ../../examples/errorhandlerbot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``inlinebot.py``
================
.. literalinclude:: ../../examples/inlinebot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``inlinekeyboard.py``
=====================
.. literalinclude:: ../../examples/inlinekeyboard.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``inlinekeyboard2.py``
======================
.. literalinclude:: ../../examples/inlinekeyboard2.py
:language: python
:linenos:
@@ -0,0 +1,13 @@
``nestedconversationbot.py``
============================
.. literalinclude:: ../../examples/nestedconversationbot.py
:language: python
:linenos:
.. _nestedconversationbot-diagram:
State Diagram
-------------
.. mermaid:: ../../examples/nestedconversationbot.mmd
+16
View File
@@ -0,0 +1,16 @@
``passportbot.py``
==================
.. literalinclude:: ../../examples/passportbot.py
:language: python
:linenos:
.. _passportbot-html:
HTML Page
---------
.. literalinclude:: ../../examples/passportbot.html
:language: html
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``paymentbot.py``
=================
.. literalinclude:: ../../examples/paymentbot.py
:language: python
:linenos:
@@ -0,0 +1,7 @@
``persistentconversationbot.py``
================================
.. literalinclude:: ../../examples/persistentconversationbot.py
:language: python
:linenos:
+7
View File
@@ -0,0 +1,7 @@
``pollbot.py``
==============
.. literalinclude:: ../../examples/pollbot.py
:language: python
:linenos:
+11
View File
@@ -0,0 +1,11 @@
`rawapibot.py`
==============
This example uses only the pure, "bare-metal" API wrapper.
.. literalinclude:: ../../examples/rawapibot.py
:language: python
:linenos:
+196
View File
@@ -0,0 +1,196 @@
Examples
========
In this section we display small examples to show what a bot written with
``python-telegram-bot`` looks like.
Some bots focus on one specific
aspect of the Telegram Bot API while others focus on one of the
mechanics of this library. Except for the
:any:`examples.rawapibot` example, they all use the high-level
framework this library provides with the
:mod:`telegram.ext` submodule.
All examples are licensed under the `CC0
License <https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/LICENSE.txt>`__
and are therefore fully dedicated to the public domain. You can use them
as the base for your own bots without worrying about copyrights.
Do note that we ignore one pythonic convention. Best practice would
dictate, in many handler callbacks function signatures, to replace the
argument ``context`` with an underscore, since ``context`` is an unused
local variable in those callbacks. However, since these are examples and
not having a name for that argument confuses beginners, we decided to
have it present.
:any:`examples.echobot`
-----------------------
This is probably the base for most of the bots made with
``python-telegram-bot``. It simply replies to each text message with a
message that contains the same text.
:any:`examples.timerbot`
------------------------
This bot uses the
:class:`telegram.ext.JobQueue`
class to send timed messages. The user sets a timer by using ``/set``
command with a specific time, for example ``/set 30``. The bot then sets
up a job to send a message to that user after 30 seconds. The user can
also cancel the timer by sending ``/unset``. To learn more about the
``JobQueue``, read `this wiki article <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions---JobQueue>`__.
Note: To use ``JobQueue``, you must install PTB via ``pip install "python-telegram-bot[job-queue]"``
:any:`examples.conversationbot`
-------------------------------
A common task for a bot is to ask information from the user. In v5.0 of
this library, we introduced the
:class:`telegram.ext.ConversationHandler`
for that exact purpose. This example uses it to retrieve
user-information in a conversation-like style. To get a better
understanding, take a look at the :ref:`state diagram <conversationbot-diagram>`.
:any:`examples.conversationbot2`
--------------------------------
A more complex example of a bot that uses the ``ConversationHandler``.
It is also more confusing. Good thing there is a :ref:`fancy state diagram <conversationbot2-diagram>`.
for this one, too!
:any:`examples.nestedconversationbot`
-------------------------------------
A even more complex example of a bot that uses the nested
``ConversationHandler``\ s. While its certainly not that complex that
you couldnt built it without nested ``ConversationHanldler``\ s, it
gives a good impression on how to work with them. Of course, there is a
:ref:`fancy state diagram <nestedconversationbot-diagram>`
for this example, too!
:any:`examples.persistentconversationbot`
-----------------------------------------
A basic example of a bot store conversation state and user_data over
multiple restarts.
:any:`examples.inlinekeyboard`
------------------------------
This example sheds some light on inline keyboards, callback queries and
message editing. A wiki site explaining this examples lives
`here <https://github.com/python-telegram-bot/python-telegram-bot/wiki/InlineKeyboard-Example>`__.
:any:`examples.inlinekeyboard2`
-------------------------------
A more complex example about inline keyboards, callback queries and
message editing. This example showcases how an interactive menu could be
build using inline keyboards.
:any:`examples.deeplinking`
---------------------------
A basic example on how to use deeplinking with inline keyboards.
:any:`examples.inlinebot`
-------------------------
A basic example of an `inline
bot <https://core.telegram.org/bots/inline>`__. Dont forget to enable
inline mode with `@BotFather <https://telegram.me/BotFather>`_.
:any:`examples.pollbot`
-----------------------
This example sheds some light on polls, poll answers and the
corresponding handlers.
:any:`examples.passportbot`
---------------------------
A basic example of a bot that can accept passports. Use in combination
with the :ref:`HTML page <passportbot-html>`.
Dont forget to enable and configure payments with
`@BotFather <https://telegram.me/BotFather>`_. Check out this
`guide <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport>`__
on Telegram passports in PTB.
Note: To use Telegram Passport, you must install PTB via ``pip install "python-telegram-bot[passport]"``
:any:`examples.paymentbot`
--------------------------
A basic example of a bot that can accept payments. Dont forget to
enable and configure payments with
`@BotFather <https://telegram.me/BotFather>`_.
:any:`examples.errorhandlerbot`
-------------------------------
A basic example on how to set up a custom error handler.
:any:`examples.chatmemberbot`
-----------------------------
A basic example on how ``(my_)chat_member`` updates can be used.
:any:`examples.webappbot`
-------------------------
A basic example of how `Telegram
WebApps <https://core.telegram.org/bots/webapps>`__ can be used. Use in
combination with the :ref:`HTML page <webappbot-html>`.
For your convenience, this file is hosted by the PTB team such that you
dont need to host it yourself. Uses the
`iro.js <https://iro.js.org>`__ JavaScript library to showcase a
user interface that is hard to achieve with native Telegram
functionality.
:any:`examples.contexttypesbot`
-------------------------------
This example showcases how ``telegram.ext.ContextTypes`` can be used to
customize the ``context`` argument of handler and job callbacks.
:any:`examples.customwebhookbot`
--------------------------------
This example showcases how a custom webhook setup can be used in
combination with ``telegram.ext.Application``.
:any:`examples.arbitrarycallbackdatabot`
----------------------------------------
This example showcases how PTBs “arbitrary callback data” feature can be
used.
Note: To use arbitrary callback data, you must install PTB via ``pip install "python-telegram-bot[callback-data]"``
Pure API
--------
The :any:`examples.rawapibot` example example uses only the pure, “bare-metal” API wrapper.
.. toctree::
:hidden:
examples.arbitrarycallbackdatabot
examples.chatmemberbot
examples.contexttypesbot
examples.conversationbot
examples.conversationbot2
examples.customwebhookbot
examples.deeplinking
examples.echobot
examples.errorhandlerbot
examples.inlinebot
examples.inlinekeyboard
examples.inlinekeyboard2
examples.nestedconversationbot
examples.passportbot
examples.paymentbot
examples.persistentconversationbot
examples.pollbot
examples.rawapibot
examples.timerbot
examples.webappbot
+7
View File
@@ -0,0 +1,7 @@
``timerbot.py``
===============
.. literalinclude:: ../../examples/timerbot.py
:language: python
:linenos:
+16
View File
@@ -0,0 +1,16 @@
``webappbot.py``
================
.. literalinclude:: ../../examples/webappbot.py
:language: python
:linenos:
.. _webappbot-html:
HTML Page
---------
.. literalinclude:: ../../examples/webappbot.html
:language: html
:linenos:
@@ -0,0 +1,7 @@
.. tip::
When combining ``python-telegram-bot`` with other :mod:`asyncio` based frameworks, using this
method is likely not the best choice, as it blocks the event loop until it receives a stop
signal as described above.
Instead, you can manually call the methods listed below to start and shut down the application
and the :attr:`~telegram.ext.Application.updater`.
Keeping the event loop running and listening for a stop signal is then up to you.
+406
View File
@@ -0,0 +1,406 @@
.. raw:: html
<hr style="height:2px;border-width:0;color:gray;background-color:gray">
<p>Since this class has a large number of methods and attributes, below you can find a quick overview.
</p>
<details>
<summary>Sending Messages</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.send_animation`
- Used for sending animations
* - :meth:`~telegram.Bot.send_audio`
- Used for sending audio files
* - :meth:`~telegram.Bot.send_chat_action`
- Used for sending chat actions
* - :meth:`~telegram.Bot.send_contact`
- Used for sending contacts
* - :meth:`~telegram.Bot.send_dice`
- Used for sending dice messages
* - :meth:`~telegram.Bot.send_document`
- Used for sending documents
* - :meth:`~telegram.Bot.send_game`
- Used for sending a game
* - :meth:`~telegram.Bot.send_invoice`
- Used for sending an invoice
* - :meth:`~telegram.Bot.send_location`
- Used for sending location
* - :meth:`~telegram.Bot.send_media_group`
- Used for sending media grouped together
* - :meth:`~telegram.Bot.send_message`
- Used for sending text messages
* - :meth:`~telegram.Bot.send_photo`
- Used for sending photos
* - :meth:`~telegram.Bot.send_poll`
- Used for sending polls
* - :meth:`~telegram.Bot.send_sticker`
- Used for sending stickers
* - :meth:`~telegram.Bot.send_venue`
- Used for sending venue locations.
* - :meth:`~telegram.Bot.send_video`
- Used for sending videos
* - :meth:`~telegram.Bot.send_video_note`
- Used for sending video notes
* - :meth:`~telegram.Bot.send_voice`
- Used for sending voice messages
* - :meth:`~telegram.Bot.copy_message`
- Used for copying the contents of an arbitrary message
* - :meth:`~telegram.Bot.forward_message`
- Used for forwarding messages
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Updating Messages</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.answer_callback_query`
- Used for answering the callback query
* - :meth:`~telegram.Bot.answer_inline_query`
- Used for answering the inline query
* - :meth:`~telegram.Bot.answer_pre_checkout_query`
- Used for answering a pre checkout query
* - :meth:`~telegram.Bot.answer_shipping_query`
- Used for answering a shipping query
* - :meth:`~telegram.Bot.answer_web_app_query`
- Used for answering a web app query
* - :meth:`~telegram.Bot.edit_message_caption`
- Used for editing captions
* - :meth:`~telegram.Bot.edit_message_media`
- Used for editing the media on messages
* - :meth:`~telegram.Bot.edit_message_live_location`
- Used for editing the location in live location messages
* - :meth:`~telegram.Bot.edit_message_reply_markup`
- Used for editing the reply markup on messages
* - :meth:`~telegram.Bot.edit_message_text`
- Used for editing text messages
* - :meth:`~telegram.Bot.stop_poll`
- Used for stopping the running poll
* - :meth:`~telegram.Bot.delete_message`
- Used for deleting messages.
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Chat Moderation and information</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.ban_chat_member`
- Used for banning a member from the chat
* - :meth:`~telegram.Bot.unban_chat_member`
- Used for unbanning a member from the chat
* - :meth:`~telegram.Bot.ban_chat_sender_chat`
- Used for banning a channel in a channel or supergroup
* - :meth:`~telegram.Bot.unban_chat_sender_chat`
- Used for unbanning a channel in a channel or supergroup
* - :meth:`~telegram.Bot.restrict_chat_member`
- Used for restricting a chat member
* - :meth:`~telegram.Bot.promote_chat_member`
- Used for promoting a chat member
* - :meth:`~telegram.Bot.set_chat_administrator_custom_title`
- Used for assigning a custom admin title to an admin
* - :meth:`~telegram.Bot.set_chat_permissions`
- Used for setting the permissions of a chat
* - :meth:`~telegram.Bot.export_chat_invite_link`
- Used for creating a new primary invite link for a chat
* - :meth:`~telegram.Bot.create_chat_invite_link`
- Used for creating an additional invite link for a chat
* - :meth:`~telegram.Bot.edit_chat_invite_link`
- Used for editing a non-primary invite link
* - :meth:`~telegram.Bot.revoke_chat_invite_link`
- Used for revoking an invite link created by the bot
* - :meth:`~telegram.Bot.approve_chat_join_request`
- Used for approving a chat join request
* - :meth:`~telegram.Bot.decline_chat_join_request`
- Used for declining a chat join request
* - :meth:`~telegram.Bot.set_chat_photo`
- Used for setting a photo to a chat
* - :meth:`~telegram.Bot.delete_chat_photo`
- Used for deleting a chat photo
* - :meth:`~telegram.Bot.set_chat_title`
- Used for setting a chat title
* - :meth:`~telegram.Bot.set_chat_description`
- Used for setting the description of a chat
* - :meth:`~telegram.Bot.pin_chat_message`
- Used for pinning a message
* - :meth:`~telegram.Bot.unpin_chat_message`
- Used for unpinning a message
* - :meth:`~telegram.Bot.unpin_all_chat_messages`
- Used for unpinning all pinned chat messages
* - :meth:`~telegram.Bot.get_user_profile_photos`
- Used for obtaining user's profile pictures
* - :meth:`~telegram.Bot.get_chat`
- Used for getting information about a chat
* - :meth:`~telegram.Bot.get_chat_administrators`
- Used for getting the list of admins in a chat
* - :meth:`~telegram.Bot.get_chat_member_count`
- Used for getting the number of members in a chat
* - :meth:`~telegram.Bot.get_chat_member`
- Used for getting a member of a chat
* - :meth:`~telegram.Bot.leave_chat`
- Used for leaving a chat
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Bot settings</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.set_my_commands`
- Used for setting the list of commands
* - :meth:`~telegram.Bot.delete_my_commands`
- Used for deleting the list of commands
* - :meth:`~telegram.Bot.get_my_commands`
- Used for obtaining the list of commands
* - :meth:`~telegram.Bot.get_my_default_administrator_rights`
- Used for obtaining the default administrator rights for the bot
* - :meth:`~telegram.Bot.set_my_default_administrator_rights`
- Used for setting the default administrator rights for the bot
* - :meth:`~telegram.Bot.get_chat_menu_button`
- Used for obtaining the menu button of a private chat or the default menu button
* - :meth:`~telegram.Bot.set_chat_menu_button`
- Used for setting the menu button of a private chat or the default menu button
* - :meth:`~telegram.Bot.set_my_description`
- Used for setting the description of the bot
* - :meth:`~telegram.Bot.get_my_description`
- Used for obtaining the description of the bot
* - :meth:`~telegram.Bot.set_my_short_description`
- Used for setting the short description of the bot
* - :meth:`~telegram.Bot.get_my_short_description`
- Used for obtaining the short description of the bot
* - :meth:`~telegram.Bot.set_my_name`
- Used for setting the name of the bot
* - :meth:`~telegram.Bot.get_my_name`
- Used for obtaining the name of the bot
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Stickerset management</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.add_sticker_to_set`
- Used for adding a sticker to a set
* - :meth:`~telegram.Bot.delete_sticker_from_set`
- Used for deleting a sticker from a set
* - :meth:`~telegram.Bot.create_new_sticker_set`
- Used for creating a new sticker set
* - :meth:`~telegram.Bot.delete_sticker_set`
- Used for deleting a sticker set made by a bot
* - :meth:`~telegram.Bot.set_chat_sticker_set`
- Used for setting a sticker set of a chat
* - :meth:`~telegram.Bot.delete_chat_sticker_set`
- Used for deleting the set sticker set of a chat
* - :meth:`~telegram.Bot.set_sticker_position_in_set`
- Used for moving a sticker's position in the set
* - :meth:`~telegram.Bot.set_sticker_set_title`
- Used for setting the title of a sticker set
* - :meth:`~telegram.Bot.set_sticker_emoji_list`
- Used for setting the emoji list of a sticker
* - :meth:`~telegram.Bot.set_sticker_keywords`
- Used for setting the keywords of a sticker
* - :meth:`~telegram.Bot.set_sticker_mask_position`
- Used for setting the mask position of a mask sticker
* - :meth:`~telegram.Bot.set_sticker_set_thumb`
- Used for setting the thumbnail of a sticker set
* - :meth:`~telegram.Bot.set_custom_emoji_sticker_set_thumbnail`
- Used for setting the thumbnail of a custom emoji sticker set
* - :meth:`~telegram.Bot.get_sticker_set`
- Used for getting a sticker set
* - :meth:`~telegram.Bot.upload_sticker_file`
- Used for uploading a sticker file
* - :meth:`~telegram.Bot.get_custom_emoji_stickers`
- Used for getting custom emoji files based on their IDs
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Games</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.get_game_high_scores`
- Used for getting the game high scores
* - :meth:`~telegram.Bot.set_game_score`
- Used for setting the game score
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Getting updates</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.get_updates`
- Used for getting updates using long polling
* - :meth:`~telegram.Bot.get_webhook_info`
- Used for getting current webhook status
* - :meth:`~telegram.Bot.set_webhook`
- Used for setting a webhook to receive updates
* - :meth:`~telegram.Bot.delete_webhook`
- Used for removing webhook integration
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Forum topic management</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.close_forum_topic`
- Used for closing a forum topic
* - :meth:`~telegram.Bot.close_general_forum_topic`
- Used for closing the general forum topic
* - :meth:`~telegram.Bot.create_forum_topic`
- Used to create a topic
* - :meth:`~telegram.Bot.delete_forum_topic`
- Used for deleting a forum topic
* - :meth:`~telegram.Bot.edit_forum_topic`
- Used to edit a topic
* - :meth:`~telegram.Bot.edit_general_forum_topic`
- Used to edit the general topic
* - :meth:`~telegram.Bot.get_forum_topic_icon_stickers`
- Used to get custom emojis to use as topic icons
* - :meth:`~telegram.Bot.hide_general_forum_topic`
- Used to hide the general topic
* - :meth:`~telegram.Bot.unhide_general_forum_topic`
- Used to unhide the general topic
* - :meth:`~telegram.Bot.reopen_forum_topic`
- Used to reopen a topic
* - :meth:`~telegram.Bot.reopen_general_forum_topic`
- Used to reopen the general topic
* - :meth:`~telegram.Bot.unpin_all_forum_topic_messages`
- Used to unpin all messages in a forum topic
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Miscellaneous</summary>
.. list-table::
:align: left
:widths: 1 4
* - :meth:`~telegram.Bot.create_invoice_link`
- Used to generate an HTTP link for an invoice
* - :meth:`~telegram.Bot.close`
- Used for closing server instance when switching to another local server
* - :meth:`~telegram.Bot.log_out`
- Used for logging out from cloud Bot API server
* - :meth:`~telegram.Bot.get_file`
- Used for getting basic info about a file
* - :meth:`~telegram.Bot.get_me`
- Used for getting basic information about the bot
.. raw:: html
</details>
<br>
.. raw:: html
<details>
<summary>Properties</summary>
.. list-table::
:align: left
:widths: 1 4
* - :attr:`~telegram.Bot.base_file_url`
- Telegram Bot API file URL
* - :attr:`~telegram.Bot.base_url`
- Telegram Bot API service URL
* - :attr:`~telegram.Bot.bot`
- The user instance of the bot as returned by :meth:`~telegram.Bot.get_me`
* - :attr:`~telegram.Bot.can_join_groups`
- Whether the bot can join groups
* - :attr:`~telegram.Bot.can_read_all_group_messages`
- Whether the bot can read all incoming group messages
* - :attr:`~telegram.Bot.id`
- The user id of the bot
* - :attr:`~telegram.Bot.name`
- The username of the bot, with leading ``@``
* - :attr:`~telegram.Bot.first_name`
- The first name of the bot
* - :attr:`~telegram.Bot.last_name`
- The last name of the bot
* - :attr:`~telegram.Bot.local_mode`
- Whether the bot is running in local mode
* - :attr:`~telegram.Bot.username`
- The username of the bot, without leading ``@``
* - :attr:`~telegram.Bot.link`
- The t.me link of the bot
* - :attr:`~telegram.Bot.private_key`
- Deserialized private key for decryption of telegram passport data
* - :attr:`~telegram.Bot.supports_inline_queries`
- Whether the bot supports inline queries
* - :attr:`~telegram.Bot.token`
- Bot's unique authentication token
.. raw:: html
</details>
<br>
<hr style="height:2px;border-width:0;color:gray;background-color:gray">
@@ -0,0 +1,3 @@
.. raw:: html
<center><video height="300px" loop autoplay muted><source src="https://core.telegram.org/file/464001555/10fbd/jvTuV2Ke7WQ.1916669.mp4/a056de323645db409d" type="video/mp4"></video></center>
+10
View File
@@ -0,0 +1,10 @@
.. tip::
When making requests to the Bot API in an asynchronous fashion (e.g. via
:attr:`block=False <telegram.ext.BaseHandler.block>`, :meth:`Application.create_task <telegram.ext.Application.create_task>`,
:meth:`~telegram.ext.ApplicationBuilder.concurrent_updates` or the :class:`~telegram.ext.JobQueue`), it can happen that more requests
are being made in parallel than there are connections in the pool.
If the number of requests is much higher than the number of connections, even setting
:meth:`~telegram.ext.ApplicationBuilder.pool_timeout` to a larger value may not always be enough to prevent pool
timeouts.
You should therefore set :meth:`~telegram.ext.ApplicationBuilder.concurrent_updates`, :meth:`~telegram.ext.ApplicationBuilder.connection_pool_size` and
:meth:`~telegram.ext.ApplicationBuilder.pool_timeout` to values that make sense for your setup.
+25 -25
View File
@@ -3,36 +3,36 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Python Telegram Bot's documentation!
===============================================
.. include:: ../../README.rst
Guides and tutorials
====================
If you're just starting out with the library, we recommend following our `"Your first Bot" <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-Your-first-Bot>`_ tutorial that you can find on our `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki>`_.
On our wiki you will also find guides like how to use handlers, webhooks, emoji, proxies and much more.
Examples
========
A great way to learn is by looking at examples. Ours can be found at our `github in the examples folder <https://github.com/python-telegram-bot/python-telegram-bot/tree/master/examples>`_.
Reference
=========
Below you can find a reference of all the classes and methods in python-telegram-bot.
Apart from the `telegram.ext` package the objects should reflect the types defined in the `official telegram bot api documentation <https://core.telegram.org/bots/api>`_.
.. The toctrees are hidden such that they don't render on the start page but still include the contents into the documentation.
.. toctree::
:hidden:
:caption: Reference
telegram
Changelog
---------
telegram.ext
telegram_auxil
Telegrams Bot API Docs <https://core.telegram.org/bots/api>
.. toctree::
:maxdepth: 2
:hidden:
:caption: Resources
examples
Wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki>
.. toctree::
:hidden:
:caption: Project
stability_policy
changelog
coc
contributing
testing
Website <https://python-telegram-bot.org>
GitHub Repository <https://github.com/python-telegram-bot/python-telegram-bot/>
Telegram Channel <https://t.me/pythontelegrambotchannel/>
Telegram User Group <https://t.me/pythontelegrambotgroup/>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+146
View File
@@ -0,0 +1,146 @@
Stability Policy
================
.. important::
This stability policy is in place since version 20.3.
While earlier versions of ``python-telegram-bot`` also had stable interfaces, they had no explicit stability policy and hence did not follow the rules outlined below in all detail.
Please also refer to the :ref:`changelog <ptb-changelog>`.
.. caution::
Large parts of the :mod:`telegram` package are the Python representations of the Telegram Bot API, whose stability policy PTB can not influence.
This policy hence includes some special cases for those parts.
What does this policy cover?
----------------------------
This policy includes any API or behavior that is covered in this documentation.
This covers both the :mod:`telegram` package and the :mod:`telegram.ext` package.
What doesn't this policy cover?
-------------------------------
Introduction of new features or changes of flavors of comparable behavior (e.g. the default for the HTTP protocol version being used) are not covered by this policy.
The internal structure of classes in PTB, i.e. things like the result of ``dir(obj))`` or the contents of ``obj.__dict__``, is not covered by this policy.
Objects are in general not guaranteed to be pickleable (unless stated otherwise) and pickled objects from one version of PTB may not be loadable in future versions.
We may provide a way to convert pickled objects from one version to another, but this is not guaranteed.
Functionality that is part of PTBs API but is explicitly documented as not being intended to be used directly by users (e.g. :meth:`telegram.request.BaseRequest.do_request`) may change.
This also applies to functions or attributes marked as final in the sense of `PEP 591 <https://peps.python.org/pep-0591/>`__.
PTB has dependencies to third-party packages.
The versions that PTB uses of these third-party packages may change if that does not affect PTBs public API.
PTB does not give guarantees about which Python versions are supported.
In general, we will try to support all Python versions that have not yet reached their end of life, but we reserve ourselves the option to drop support for Python versions earlier if that benefits the advancement of the library.
PTB provides static type hints for all public attributes, parameters, return values and generic classes.
These type hints are not covered by this policy and may change at any time under the condition that these changes have no impact on the runtime behavior of PTB.
.. _bot-api-functionality-1:
Bot API Functionality
~~~~~~~~~~~~~~~~~~~~~
Comparison of equality of instances of the classes in the :mod:`telegram` package is subject to change and the PTB team will update the behavior to best reflect updates in the Bot API.
Changes in this regard will be documented in the affected classes.
Note that equality comparison with objects that where serialized by an older version of PTB may hence give unexpected results.
When the order of arguments of the Bot API methods changes or they become optional/mandatory due to changes in the Bot API, PTB will always try to reflect these changes.
While we try to make such changes backward compatible, this is not always possible or only with significant effort.
In such cases we will find a trade-off between backward compatibility and fully complying with the Bot API, which may result in breaking changes.
We highly recommend using keyword arguments, which can help make such changes non-breaking on your end.
..
We have documented a few common cases and possible backwards compatible solutions in the wiki as a reference for the dev team: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Bot-API-Backward-Compatibility
When the Bot API changes attributes of classes, the method :meth:`telegram.TelegramObject.to_dict` will change as necessary to reflect these changes.
In particular, attributes deprecated by Telegram will be removed from the returned dictionary.
Deprecated attributes that are still passed by Telegram will be available in the :attr:`~telegram.TelegramObject.api_kwargs` dictionary as long as PTB can support that with feasible effort.
Since attributes of the classes in the :mod:`telegram` package are not writable, we may change them to properties where appropriate.
Development Versions
~~~~~~~~~~~~~~~~~~~~
Pre-releases marked as alpha, beta or release candidate are not covered by this policy.
Before a feature is in a stable release, i.e. the feature was merged into the ``master`` branch but not released yet (or only in a pre-release), it is not covered by this policy either and may change.
Security
~~~~~~~~
We make exceptions from our stability policy for security.
We will violate this policy as necessary in order to resolve a security issue or harden PTB against a possible attack.
Versioning
----------
PTB uses a versioning scheme that roughly follows `https://semver.org/ <https://semver.org/>`_, although it may not be quite as strict.
Given a version of PTB X.Y.Z,
- X indicates the major version number.
This is incremented when backward incompatible changes are introduced.
- Y indicates the minor version number.
This is incremented when new functionality or backward compatible changes are introduced by PTB.
*This is also incremented when PTB adds support for a new Bot API version, which may include backward incompatible changes in some cases as outlined* :ref:`below <bot-api-versioning>`.
- Z is the patch version.
This is incremented if backward compatible bug fixes or smaller changes are introduced.
If this number is 0, it can be omitted, i.e. we just write X.Y instead of X.Y.0.
Deprecation
~~~~~~~~~~~
From time to time we will want to change the behavior of an API or remove it entirely, or we do so to comply with changes in the Telegram Bot API.
In those cases, we follow a deprecation schedule as detailed below.
Functionality is marked as deprecated by a corresponding note in the release notes and the documentation.
Where possible, a :class:`~telegram.warnings.PTBDeprecationWarning` is issued when deprecated functionality is used, but this is not mandatory.
From time to time, we may decide to deprecate an API that is particularly widely used.
In these cases, we may decide to provide an extended deprecation period, at our discretion.
With version 20.0.0, PTB introduced major structural breaking changes without the above deprecation period.
Should a similarly big change ever be deemed necessary again by the development team and should a deprecation period prove too much additional effort, this violation of the stability policy will be announced well ahead of the release in our channel, `as was done for v20 <https://t.me/pythontelegrambotchannel/94>`_.
Non-Bot API Functionality
#########################
Starting with version 20.3, deprecated functionality will stay available for the current and the next major version.
For example:
- In PTB v20.1.1 the feature exists
- In PTB v20.1.2 or v20.2.0 the feature is marked as deprecated
- In PTB v21.*.* the feature is marked as deprecated
- In PTB v22.0 the feature is removed or changed
.. _bot-api-versioning:
Bot API Functionality
#####################
As PTB has no control over deprecations introduced by Telegram and the schedule of these deprecations rarely coincides with PTBs deprecation schedule, we have a special policy for Bot API functionality.
Starting with 20.3, deprecated Bot API functionality will stay available for the current and the next major version of PTB *or* until the next version of the Bot API.
More precisely, two cases are possible, for which we show examples below.
Case 1
^^^^^^
- In PTB v20.1 the feature exists
- Bot API version 6.6 is released and deprecates the feature
- PTB v20.2 adds support for Bot API 6.6 and the feature is
marked as deprecated
- In PTB v21.0 the feature is removed or changed
Case 2
^^^^^^
- In PTB v20.1 the feature exists
- Bot API version 6.6 is released and deprecates the feature
- PTB v20.2 adds support for Bot API version 6.6 and the feature is marked as deprecated
- In PTB v20.2.* and v20.3.* the feature is marked as deprecated
- Bot API version 6.7 is released
- PTB v20.4 adds support for Bot API version 6.7 and the feature is removed or changed
+5 -2
View File
@@ -1,6 +1,9 @@
telegram.Animation
==================
Animation
=========
.. Also lists methods of _BaseThumbedMedium, but not the ones of TelegramObject
.. autoclass:: telegram.Animation
:members:
:show-inheritance:
:inherited-members: TelegramObject
+100
View File
@@ -0,0 +1,100 @@
Available Types
---------------
.. toctree::
:titlesonly:
telegram.animation
telegram.audio
telegram.botcommand
telegram.botcommandscope
telegram.botcommandscopeallchatadministrators
telegram.botcommandscopeallgroupchats
telegram.botcommandscopeallprivatechats
telegram.botcommandscopechat
telegram.botcommandscopechatadministrators
telegram.botcommandscopechatmember
telegram.botcommandscopedefault
telegram.botdescription
telegram.botname
telegram.botshortdescription
telegram.callbackquery
telegram.chat
telegram.chatadministratorrights
telegram.chatinvitelink
telegram.chatjoinrequest
telegram.chatlocation
telegram.chatmember
telegram.chatmemberadministrator
telegram.chatmemberbanned
telegram.chatmemberleft
telegram.chatmembermember
telegram.chatmemberowner
telegram.chatmemberrestricted
telegram.chatmemberupdated
telegram.chatpermissions
telegram.chatphoto
telegram.chatshared
telegram.contact
telegram.dice
telegram.document
telegram.file
telegram.forcereply
telegram.forumtopic
telegram.forumtopicclosed
telegram.forumtopiccreated
telegram.forumtopicedited
telegram.forumtopicreopened
telegram.generalforumtopichidden
telegram.generalforumtopicunhidden
telegram.inlinekeyboardbutton
telegram.inlinekeyboardmarkup
telegram.inputfile
telegram.inputmedia
telegram.inputmediaanimation
telegram.inputmediaaudio
telegram.inputmediadocument
telegram.inputmediaphoto
telegram.inputmediavideo
telegram.inputsticker
telegram.keyboardbutton
telegram.keyboardbuttonpolltype
telegram.keyboardbuttonrequestchat
telegram.keyboardbuttonrequestuser
telegram.location
telegram.loginurl
telegram.menubutton
telegram.menubuttoncommands
telegram.menubuttondefault
telegram.menubuttonwebapp
telegram.message
telegram.messageautodeletetimerchanged
telegram.messageentity
telegram.messageid
telegram.photosize
telegram.poll
telegram.pollanswer
telegram.polloption
telegram.proximityalerttriggered
telegram.replykeyboardmarkup
telegram.replykeyboardremove
telegram.sentwebappmessage
telegram.switchinlinequerychosenchat
telegram.telegramobject
telegram.update
telegram.user
telegram.userprofilephotos
telegram.usershared
telegram.venue
telegram.video
telegram.videochatended
telegram.videochatparticipantsinvited
telegram.videochatscheduled
telegram.videochatstarted
telegram.videonote
telegram.voice
telegram.webappdata
telegram.webappinfo
telegram.webhookinfo
telegram.writeaccessallowed
+5 -2
View File
@@ -1,6 +1,9 @@
telegram.Audio
==============
Audio
=====
.. Also lists methods of _BaseThumbedMedium, but not the ones of TelegramObject
.. autoclass:: telegram.Audio
:members:
:show-inheritance:
:inherited-members: TelegramObject
+4 -3
View File
@@ -1,6 +1,7 @@
telegram.Bot
============
Bot
===
.. autoclass:: telegram.Bot
:members:
:show-inheritance:
:show-inheritance:
:special-members: __reduce__, __deepcopy__
+2 -2
View File
@@ -1,5 +1,5 @@
telegram.BotCommand
===================
BotCommand
==========
.. autoclass:: telegram.BotCommand
:members:
+6
View File
@@ -0,0 +1,6 @@
BotCommandScope
===============
.. autoclass:: telegram.BotCommandScope
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeAllChatAdministrators
====================================
.. autoclass:: telegram.BotCommandScopeAllChatAdministrators
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeAllGroupChats
============================
.. autoclass:: telegram.BotCommandScopeAllGroupChats
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeAllPrivateChats
==============================
.. autoclass:: telegram.BotCommandScopeAllPrivateChats
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeChat
===================
.. autoclass:: telegram.BotCommandScopeChat
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeChatAdministrators
=================================
.. autoclass:: telegram.BotCommandScopeChatAdministrators
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeChatMember
=========================
.. autoclass:: telegram.BotCommandScopeChatMember
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotCommandScopeDefault
======================
.. autoclass:: telegram.BotCommandScopeDefault
:members:
:show-inheritance:
+6
View File
@@ -0,0 +1,6 @@
BotDescription
==============
.. autoclass:: telegram.BotDescription
:members:
:show-inheritance:
+6
View File
@@ -0,0 +1,6 @@
BotName
=======
.. autoclass:: telegram.BotName
:members:
:show-inheritance:
@@ -0,0 +1,6 @@
BotShortDescription
===================
.. autoclass:: telegram.BotShortDescription
:members:
:show-inheritance:
+2 -2
View File
@@ -1,5 +1,5 @@
telegram.Callbackgame
=====================
Callbackgame
============
.. autoclass:: telegram.CallbackGame
:members:
+2 -2
View File
@@ -1,5 +1,5 @@
telegram.CallbackQuery
======================
CallbackQuery
=============
.. autoclass:: telegram.CallbackQuery
:members:
+2 -2
View File
@@ -1,5 +1,5 @@
telegram.Chat
=============
Chat
====
.. autoclass:: telegram.Chat
:members:

Some files were not shown because too many files have changed in this diff Show More