Commit graph

84 commits

Author SHA1 Message Date
Piraty
edb30cf342 Use Error Messages for Pylint Instead of Codes (#2700) 2022-05-06 18:19:12 +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
b4ea5557ac Remove __dict__ from __slots__ and drop Python 3.6 (#2619, #2636) 2022-05-06 18:19:10 +02: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
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
e4dc80f41d
API 5.4 (#2767)
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
2021-11-08 19:02:20 +01: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
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
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
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
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
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
Bibo-Joshi
9930725e2a
Add New Shortcuts to Chat (#2291)
* Add shortcuts

* Add a note
2021-01-09 17:48:56 +01:00
starry69
91e0271e4c Update copyright headers
Signed-off-by: starry69 <starry369126@outlook.com>
2021-01-03 10:40:24 +05:30
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
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
58b9882021
Use F-Strings Where Possible (#2222) 2020-11-23 22:09:29 +01:00
Bibo-Joshi
3b9187ed5a
Rename kwargs to _kwargs where possible (#2182) 2020-11-05 18:12: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
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
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
Hinrich Mahler
5fd7606084 Type Hinting (#1920) 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
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
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
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
Bibo-Joshi
a42b68933c
Add User.send_poll (#1968) 2020-05-27 21:59:49 +02:00
Poolitzer
55e3ecf9f8
API 4.6 (#1723)
* First take on 4.6 support

* improved docs

* Minor doc formattings

* added poll and poll_answer to filters

* added tests, fixed mentioned issues

* added poll_answer + poll filter tests

* Update docs according to official API docs

* introducing pollhandler and pollanswerhandler

* First take on 4.6 support

* improved docs

* Minor doc formattings

* added poll and poll_answer to filters

* added tests, fixed mentioned issues

* added poll_answer + poll filter tests

* Update docs according to official API docs

* introducing pollhandler and pollanswerhandler

* correct_option_id validated with None

when trying to send a poll with correct option id 0 it was failing. Now None check is done so that even when 0 is passed it is assigned.

* improving example

* improving code

* adding poll filter example to the pollbot.py

* Update Readme

* simplify pollbot.py and add some comments

* add tests for Poll(Answer)Handler

* We just want Filters.poll, not Filters.update.poll

* Make test_official fail again

* Handle ME.language in M._parse_*

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
Co-authored-by: Sharun Kumar <715417+sharunkumar@users.noreply.github.com>
2020-03-29 09:52:30 +02:00
Bibo-Joshi
8d2c7af1f3
API 4.5 (#1508)
* Allow for nested MessageEntities in Message._parse_markdown/html, adjust tests

* remove testing relict

* Use MessageEntitys new equality check (#1465)

* Remove unused variable

* Update to custom_title feature and slow_mode_delay option

Changes:

 - custom_title for ChatMember
 - new method setChatAdministratorCustomTitle for Bot
 - new slow_mode_delay for Chat

Update due to new API future `custom_title` from API 4.5 (https://core.telegram.org/bots/api#december-31-2019)

* Minor typo fix

* Comply with Flake8

* Add new MessageEntities and MarkdownV2

* Added file_unique_id attrs from API 4.5 and updated tests for it

* Fixed test and checked using flake8

* Fixed ChatPhoto documentation

* Fix Flake8

* Add setChatAdminCstmTitle to Bot

* Rename MDV2 methods

* Change files id attrs to unique id

* correct id_attrs for chat_photo

* Revert "temporarily skip tests failing b/c missing api 4.5 (#1738)"

This reverts commit 7cde6ca268.

* Fix text_markdown_v2 for monospace and text_links

* closing remarks from pieter

* Minor fix in escape_markdown, improve tests for it

* Fix offset bug in Message._parse_*

* Add test_chatphoto.py

* remove debug print from test_message.py

* try making codecov happy

* Update readme

* all hail codecov

* Improve Link handling for MarkdownV1 and adjust tests. Closes #1654

* Dont use beginning of pre-entity as language in _parse_markdown

* Remove debug print

* Dummy commit to try fix codecov

Co-authored-by: Hoi Dmytro <dmytro.hoi@gmail.com>
Co-authored-by: Dmytro Hoi <code@dmytrohoi.com>
Co-authored-by: poolitzer <25934244+poolitzer@users.noreply.github.com>
2020-03-28 16:37:26 +01:00
Noam Meltzer
43bfebb150
Update copyright date to 2020 (#1746) 2020-02-02 23:08:54 +02:00
Eldinnie
4689a80c2e Bot API 4.0 (#1168)
Telegram Passport (#1174):

- Add full support for telegram passport.
    - New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
    - New bot method: set_passport_data_errors
    - New filter: Filters.passport_data
    - Field passport_data field on Message
    - PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
    - PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.

Inputfile rework (#1184):

- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.

Other Bot API 4.0 changes:

- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
    - Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
    - Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)


Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
Trainer Jono
94abf16a7f Add t.me links for User, Chat and Message if available and update User.mention_* (#1092)
* Add User.link and update User.mention_*
* Add Chat.link
* Add Message.link
* Link returns None on default
* Add test link
2018-05-09 11:42:12 +02:00
Trainer Jono
78fee3c1dc Fixed docstring of {User,Chat}.send_* methods (#1081)
* Changed all "User.chat_id"s to "User.id"
* Chat.chat_id --> Chat.id
2018-04-25 23:21:11 +03:00
Daniel Reed
cbfb7df643 Explicitly make Bot.full_name return a unicode object, rather than implicitly a unicode object in Python 3 and a str object on Python 2. (#1063) 2018-04-16 10:37:41 +02:00
Emilio Molinari
3ccf40e8cc Make chat_id a positional argument inside shortcut methods of Chat and User classes #1048 (#1050)
* Make chat_id a positional argument #1048

* Fixed tests
2018-03-17 00:10:11 +01:00
Jacob Bom
ebcc40ae92 More instance methods (#963)
* Bot.get_file now allows passing a file in addition to file_id

* Add .get_file() to Audio, Document, PhotoSize, Sticker, Video, VideoNote and Voice

* Add .send_*() methods to User and Chat
2018-02-18 17:49:52 +02:00
Jacob Bom
2ca7ff82ef Update headers to 2018 (#962)
Also add two missing headers.
[ci skip]
2018-01-04 17:16:06 +02:00
Noam Meltzer
a2c04313d3
Fix documentation & coding style of User.name & User.full_name (#956)
- Use string `format` instead of dict comprehension.
 - Better documentation to signify the semantics difference between
   `name` and `full_name`.

 - Use string `format` instead of dict comprehension.
 - Better documentation to signify the semantics difference between
   `name` and `full_name`.

* Removed the NOTE and mentinoed the "@" prefix.
2017-12-30 22:58:32 +02:00
graynk
d347c0d45e User.full_name convinience property (#949)
Fixes #943
2017-12-30 15:13:06 +02:00
Marco Túlio Zuquim
e362a5b59d Small documentation fix in user.py (#829) 2017-09-15 23:55:35 +02:00
Noam Meltzer
e018445513 Documentation update to PEP (#797) 2017-09-01 08:43:08 +02:00
Jeff
b6a0853896 Add Bot API 3.3 (#806)
* Bot API 3.3

* simpler helper methods (accept only custom names now)
attempt to fix circular import (not sure if its the correct way tho)
added helper methods into User object

* fix User objects in tests to contain is_bot required value

* fix User objects in tests to contain is_bot required value

* delete extra line that caused flake8 error

* fix swapped arguments
2017-09-01 08:40:05 +02:00
Eldinnie
b3b94240a5 Docs update (#728)
Amazing new documentation.
2017-07-23 23:33:08 +03:00
Ihor Polyakov
08d298eb60 TelegramObject.de_json became classmethod (#737)
Fixes #734
2017-07-23 22:14:38 +03:00
saschalalala
3863b4f371 Rename shortcut functions to snake_case (#661)
* Rename shortcut functions to snake_case

* More function renaming

* Example function rewrite

* Add myself to authors.rst

* More function renaming

* Rename mockbot test functions

* Break comment line for flake max line length
2017-06-14 00:07:03 +02:00
Jacob Bom
aa1c4e0e02 Fix most of "more than one target found for cross-reference" warnings 2017-06-07 12:53:02 +02:00