Commit graph

1595 commits

Author SHA1 Message Date
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]
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
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
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
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
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
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
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
823d030c2c Use enums for dynamic types & rename two attributes in ChatMember (#2817) 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Bibo-Joshi
9be4c7563b
Improve Type Hinting for Class Variables (#2136) 2020-10-15 18:50:47 +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
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
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
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
da452df07d
Allow DispatcherHandlerStop in ConversationHandler (#2059)
* First go

* Fix bug with nested convs
2020-08-21 23:20:28 +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
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
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
Hinrich Mahler
15268acb27 Bump to v12.8 2020-06-22 20:20:00 +02:00
Poolitzer
927502e588
API 4.9 (#1980)
* Add Basketball Dice

Added Basketball Dice Variation

* Update dice.py

* Update dice.py

* Update telegram/dice.py

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

* Update bot.py

* Update filters.py

* Update test_filters.py

* Fixed whitespaces

* Update dice.py

* Fix line length

* adding dice values to docstring

* adding via_bot to message and thumb_mime_type to iqresults

* feat: updating docs

* feat: improving message attribute test

* Fix flake8

Co-authored-by: Jannik <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2020-06-22 20:09:52 +02:00
Nils K
8406889179
Remove Python 2 Support (#1715)
* Remove usages of python-future lib

* Remove python2 datetime.timezone replacement

* Remove python2 workaround in InputFile.__init__

* Remove import of str necessary for python2

* Remove urllib2 import necessary for python2

* Remove a mention of python 2 in doc

* Remove python 2 from travis config file

* Remove python 2 from appveyor config

* Remove python2 from debian build rules

* Remove unnecessarry aliasing of time.perf_counter

* Remove python 2 from github workflow

* Remove mention of python 2 in descriptions/readme

* Remove version check for queue import

* Remove version checks in tests

* Adjust docs to correctly mention supported version

* Fix indentation

* Remove unused 'sys' imports

* Fix indentation

* Remove references to mq.curtime in tests

* Replace super calls by argumentsless version

* Remove future dependency

* Fix error in de_json declaration

* Use python3 metaclass syntax

* Use implicit inheriting from object

* Remove accidentally committed .vscode folder

* Use nameless f-string and raw string

* Fix regex string literal syntax

* Remove old style classes

* Run pyupgrade

* Fix leftover from automatic merge

* Fix lint errors

* Update telegram/files/sticker.py

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2020-06-15 18:20:51 +02:00
n5y
ac7cc7fe5e
Ignore private attributes in TelegramObject.to_dict() (#1989) 2020-06-10 22:21:25 +02:00
Bibo-Joshi
a42b68933c
Add User.send_poll (#1968) 2020-05-27 21:59:49 +02:00
ѕнιναм
c2d91c752f
Typo-Fix (#1962) 2020-05-22 15:32:03 +02:00
Bibo-Joshi
5057825586
Doc fixes (#1940)
* Update notes on editing messages

* Update thumb and InputMedia* doc strings

* Fix attribute docstring for Updater.user_sig_handler

* Improve rendering for CCs attributes

* fix doc str for InputMedia*.media attribute

* Minor fix
2020-05-15 15:59:41 +02:00
Bibo-Joshi
613175b2c4
Allow updating ids/usernames of Filters.{user, chat} (#1757)
* Make Filters.user attrs mutable

* Add test_filters_user_empty_args

* Add test_filters_user_empty_args

* fix locks

* Make codecov happy

* Make user_ids and usernames sets

* Correct doc string

* Address review

* Review Vol. II

* Apply suggestions from code review

Co-authored-by: Noam Meltzer <tsnoam@gmail.com>

* Review Vol III.

* propery setter is now only a wrapper to a private method + more cleanups

pylint complained on some extra stuff, so cleaned them as well

* Review Vol. IV

* Review Vol. V

* Apply changes to Filters.chat

Co-authored-by: Noam Meltzer <tsnoam@gmail.com>
2020-05-10 12:15:11 +02:00
n5y
5898e1fe7a
Remove NullHandlers (#1913) 2020-05-03 10:28:03 +02:00
Hinrich Mahler
186fd1b418 Bump version to v12.7 2020-05-02 12:14:38 +02:00
Hinrich Mahler
284786fdb8 Fix doc string of run_monthly 2020-05-02 12:14:01 +02:00
Bibo-Joshi
c7c56ad24e
Api 4.8 (#1917)
* API 4.8

* Elaborate docs

* Address review

* Fix Message.to_json/dict() test

* More coverage

* Update telegram/bot.py

Co-authored-by: Noam Meltzer <tsnoam@gmail.com>

Co-authored-by: Noam Meltzer <tsnoam@gmail.com>
2020-05-02 11:56:52 +02:00
D David Livingston
ae17ce977e
Add JobQueue.run_monthly() (#1705)
* added monthly job

* removed fold argument

* addressed pr comments

* addressed pr comments

* made changes from pr review

* updated comments

* clean up code

* Update .pre-commit-config.yaml

* Minor cleanup

* Update according to #1685, minor robustness changes

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-05-02 08:59:50 +02:00
Bibo-Joshi
7e231183c4
Add tzinfo kwarg to from_timestamp() (#1621)
* Add tz kwarg to from_timestamp()

* Correct handling of tzinfo=None

* Small Improvements

* None-tz yields naive dto

* Remove legacey compatibility of UTC stuff

* Update telegram/utils/helpers.py

Co-authored-by: Noam Meltzer <tsnoam@gmail.com>
2020-05-01 22:55:13 +02:00
Bibo-Joshi
632b989d90
Use @abstractmethod instead of raising NotImplementedError (#1905) 2020-05-01 21:27:34 +03:00
Bibo-Joshi
2bd3f2a65a
Render Notes correctly (#1914)
* Renders Notes in JobQueues docs correctly

* Notes: -> Note:
2020-04-25 12:34:13 +02:00
Andrej730
110e2df443
Job.next_t (#1685)
* next_t property is added to Job class

Added new property to Job class - next_t, it will show the datetime when the job will be executed next time.
The property is updated during JobQueue._put method, right after job is added to queue.
Related to #1676

* Fixed newline and trailing whitespace

* Fixed PR issues, added test

1. Added setter for next_t - now JobQueue doesn't access protected Job._next_t.
2. Fixed Job class docstring.
3. Added test for next_t property.
4. Set next_t to None for run_once jobs that already ran.

* Fixed Flake8 issues

* Added next_t setter for datetime, added test

1. next_t setter now can accept datetime type.
2. added test for setting datetime to next_t and added some asserts that check tests results.
3. Also noticed Job.days setter raises ValueError when it's more appropriate to raise TypeError.

* Fixed test_warnings, added Number type to next_t setter

1. Changed type of error raised by interval setter from ValueError to TypeError..
2. Fixed test_warning after changing type of errors in Job.days and Job.interval.
3. Added Number type to next_t setter - now it can accept int too.

* Python 2 compatibility for test_job_next_t_property

Added _UTC and _UtcOffsetTimezone for python 2 compatibility

* Fixed PR issues

1. Replaced "datetime.replace tzinfo" with "datetime.astimezone"
2. Moved testing next_t setter to separate test.
3. Changed test_job_next_t_setter so it now uses non UTC timezone.

* Defining tzinfo from run_once, run_repeating

1. Added option to define Job.tzinfo from run_once (by when.tzinfo) and run_repeating (first.tzinfo)
2. Added test to check that tzinfo is always passed correctly.

* address review

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-04-18 15:08:16 +02:00
Bibo-Joshi
57546795c5
Notes on Filters.text accepting command messages (#1902) 2020-04-18 12:16:14 +02:00
Hinrich Mahler
314f87ec44 Bump version to v12.6.1 2020-04-11 09:53:29 +02:00
Bibo-Joshi
4bbcd51ef5
Fix serialization of reply_markups (#1889) 2020-04-11 09:44:40 +02:00
Hinrich Mahler
38a33581b1 Bump version to v12.6 2020-04-10 23:52:08 +02:00
Hinrich Mahler
fe821c08e6 Doc Fixes 2020-04-10 23:43:58 +02:00
Harshil
0a9f4bfbdd
Doc fixes (#1884)
* Bot.py doc fixes

All docs obtained from official Bot API docs

* made flake8 happy

* address review

Also improved consistency of `returns:` in docs

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-04-10 20:05:01 +02:00
Bibo-Joshi
d63e710784
API 4.7 (#1858)
* Pure API changes

* Address review

* set Bot.commands on successfull call of set_my_commands

* Get started on tests

* More tests!

* More Coverage!

* Reset changes in utils.request

* Filters.dice, Filters.dice.text

* more coverage

* Address review

* Address review

* Test stop_poll with reply_markup

* Test stop_poll also without reply_markup

* Rephrase note on 'dice'

* Fix grammar in note on Filters.dice

* update api version readme

* address review
2020-04-10 19:22:45 +02:00
Bibo-Joshi
f379f54d5a
Tweak persistence handling (#1827)
* Unify persistence updates in dispatcher

* Ensure user/chat_data is not None when updating it

* Update persistence after job runs

* Increase coverage
2020-04-10 13:23:13 +02:00
Bibo-Joshi
bdf0cb91f3
Pass last valid context to TIMEOUT handlers (#1826) 2020-04-10 13:18:43 +02:00
Bibo-Joshi
3101ea8432
Favor concrete types over "Iterable" (#1882)
* Use concrete types instead of 'iterable'

* Fix overlooked docstring

* address review
2020-04-08 22:49:01 +02:00
Harshil
beb8ba3db0
Doc Fixes (#1874)
* doc fixes

* Update AUTHORS.rst

* More doc fixes

All docs were obtained from official Bot API docs.

* Shortened line length

Did this so it passes codacy check

* Revert id docstring changes

* typo

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-04-07 17:25:17 +02:00
Bibo-Joshi
d65558888e
Add note on UTC to run_{repeating, once} (#1854) 2020-03-31 00:05:08 +02:00