Commit graph

354 commits

Author SHA1 Message Date
Jasmin Bom
e08afe7fb2 Fix flake8 errors that only show in CI?? 2019-01-30 20:20:35 +01:00
Ambro
23fe991b85 Fix bug: unable to save jobs with timezone aware dates (#1308)
* Fix bug on jobs with timezone aware dates

* Add Ambro17 as colaborator
2019-01-04 20:29:07 +01:00
Bibo-Joshi
7eeb670a59 Fix check for effective chat/user in persistence (#1303) 2018-12-05 00:12:43 +01:00
Steve Sandke
0cf0cccbc5 Fix description for JobQueue's run_daily and run_repeating methods. (#1299) 2018-11-22 13:03:58 +01:00
Jasmin Bom
378784f55e
Fix persistence with non telegram.Update updates (#1271)
* Allow persistence with no telegram.Update updates

For use with TypeHandler

* Add test
2018-11-09 11:44:20 +01:00
Pieter Schutz
384173115f Merge branch 'master' into V12 2018-11-01 11:45:51 +01:00
Noam Meltzer
9596343efd pep8 fixes 2018-11-01 11:18:07 +02:00
Noam Meltzer
30cc0f8cf9 pep8 fixes 2018-11-01 11:18:07 +02:00
Pieter Schutz
f252436cd4 Merge remote-tracking branch 'origin/master' into V12 2018-11-01 09:32:55 +01:00
Pavel Shakhov
9ece7fdb1c Mistake in MessageQueue.__call__'s docstring (#1249) 2018-10-08 15:36:59 +02:00
Evan Haberecht
4861d1a20d Removed unneccessary else and replaced with comment (#1247)
* Resolved issue #1163: Removed unneccessary else and replaced with comment

* Added myself to AUTHORS.rst
2018-10-08 08:18:33 +02:00
simonvorobjev
dbf364e168 Allowed to use Handlers on conversation timeout (#1217)
* handler for ConversationHandler.END (timeout one) #1136

* review fixes

* review fixes

* review fixes

* review fixes

* docs and tests

* fixing stuff

* Fix problem

* fix conftest

* now it should work

* Add ConversationTimeoutContext

As discussed in the developers group. Use a class as the jobs context over using a dict.

* less verbosity
2018-10-04 08:58:40 +02:00
dbxnr
d6d0dec6e0 remove extra else clause (#1239)
Fix #1236
2018-10-02 11:29:30 +02:00
Jasmin Bom
5252a493cb Pass check result into handle_update
Missed during merge
2018-09-21 09:20:35 +02:00
Jasmin Bom
e75615cbf6 Revert "Revert "CommandHandler overhaul and PrefixHandler added (#1114)""
This reverts commit 9e2357b
2018-09-21 08:57:43 +02:00
Jasmin Bom
cf95027308 Revert "Revert "Context based callbacks (#1100)""
This reverts commit f8a17cd
2018-09-21 08:57:01 +02:00
Eldinnie
439790375e Persistence (#1017)
* BasePersistence

* basic construct

* Keep working

* Continue work

Add tests for Basepersistence

* Finish up BasePersistence and implementation

* PickelPersistence and start tests

* Finishing up

* Oops, left in some typings

* Compatibilty issues regarding py2 solved

For Py2 compatibility

* increasing coverage

* Small changes due to CR

* All persistence tests in one file

* add DictPersistence

* Last changes per CR

* forgot change

* changes per CR

* call update_* only with relevant data

As discussed with @jsmnbom

* Add conversationbot Example

* should not have committed API-key
2018-09-20 22:50:40 +02:00
Kirill Vasin
b8c288ff4a Make ConversationHandler and run_async work together properly (#1176)
* #1175

* fix issue with timeout

* exception in promise resolve is treated as None result

* removed useless variables
2018-09-10 20:05:45 +02:00
Kirill Vasin
f2b06728e9 Replace http.server with Tornado (#1191)
Fixes #1189
2018-09-08 23:25:48 +03: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
Jannes Höke
353410242f 🐛 Use '==' operator for integer comparison (#1147) 2018-08-26 20:39:19 +02:00
Dmitry Grigoryev
8acff56145 Fix Filters.regex failing on non-text message (#1158)
* Fix #1115

* Improve regex filter test
2018-08-26 20:39:01 +02:00
Jacob Bom
f8a17cddcb Revert "Context based callbacks (#1100)"
This reverts commit 247577b2e2.
2018-05-31 14:22:57 +02:00
Eldinnie
9e2357bc33 Revert "CommandHandler overhaul and PrefixHandler added (#1114)"
This reverts commit 87afd98e02.
2018-05-31 14:22:43 +02:00
Eldinnie
87afd98e02
CommandHandler overhaul and PrefixHandler added (#1114)
* Commandhandler reworked

* Make CommandHandler strict

Only register valid botcommands, else raise ValueError

* Add PrefixHandler

* declare encoding on test_commandhandler

* Fix some tests dependend on CommandHandler

* CR changes

* small docfix.

* Test all possibilities for PrefixHandler
2018-05-22 21:44:20 +02:00
Jacob Bom
247577b2e2
Context based callbacks (#1100)
See https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-11.0 under Context based callbacks and Filters in handlers for a good guide on the changes in this commit.

* Change handlers so context is supported

* Attempt to make parameter "guessing" work on py < 3.5

* Document use_context in all handlers

* Add Context to docs

* Minor fixes to context handling

* Add tests for context stuff

* Allow the signature check to work on py<3.5 with methods

* Fix order of operations

* Address most issues raised in CR

* Make CommandHandler no longer support filter lists

* Fix indent

(pycharm can be an arse sometimes)

* Improve readability in conversationhandler

* Make context have Match instead of groups & groupdict

* Remove filter list support from messagehandler too

* Small fix to StringCommandHandler

* More small fixes to handlers

* Amend CHANGES

* Fix tests and fix bugs raised by tests

* Don't allow users to ignore errors without messing with the warning filters themselves

* Ignore our own deprecation warnings when testing

* Skipping deprecationwarning test on py2

* Forgot some changes

* Handler: Improved documentation and text of deprecation warnings

* HandlerContext: Keep only dispatcher and use properties; improved doc

* Complete fixing the documentation.

 - Fixes per Eldinnie's comments.
 - Fixes per warnings when running sphinx.

* Some small doc fixes (interlinks and optionals)

* Change add_error_handler to use HandlerContext too

* More context based changes

Context Based Handlers -> Context Based Callbacks

No longer use_context args on every single Handler

Instead set dispatcher/updater .use_context=True to use

Works with
- Handler callbacks
- Error handler callbacks
- Job callbacks

Change examples to context based callbacks so new users are not confused

Rename and move the context object from Handlers.HandlerContext to CallbackContext, since it doesn't only apply to handlers anymore.

Fix tests by adding a new fixture `cpd` which is a dispatcher with use_context=True

* Forgot about conversationhandler

* Forgot jobqueue

* Add tests for callbackcontext & for context based callback job

* Fix as per review :)
2018-05-21 15:00:47 +02:00
Paul Larsen
b5196f00b2 Add a caption_entity filter for filtering caption entities (#1068)
* Add a caption_entity filter for filtering caption entities

* remove unneeded list comprehensions
2018-04-20 13:24:40 +02:00
Joel Williams
42497367c1 Correct documentation of Dispatcher.add_handler (#1071) 2018-04-17 07:42:09 +03:00
Wagner Macedo
5efd5e2586 CommandHandler faster check (#1074)
Fixes #1073
2018-04-17 07:37:29 +03:00
Or Bin
712baf0c07 Added video note filter (#1067) 2018-04-14 21:53:54 +02:00
Jannik
38e3b91a87 Filters for Category and file types (#1046)
* Added extra Filters for File Type and Category

Added extra Filters for File Type and Category, based on the provided Mime-Type

* Added tests for the new Filters

Added Tests for the Category and File Types Filters.

* Fixed Tests

Fixed the Tests from the last commit

* Little Fix

* Revert of unwanted changes

* Update filters.py

* Changed the strings

* Changed file_type to mime_type

* Fixed Tests
2018-03-16 23:41:48 +01:00
Joscha Götzer
1530ed20e5 New filter: regex (#1028) 2018-03-15 06:59:27 +02:00
Eldinnie
698a91427a
Fix conversationhandler timeout (#1032)
* Fix conversationhandler

As found by @nmlorg and described in #1031

closes #1031

* adding another test and definitely finish conversationhandler

It seems another problem was when the job executed the timeout, it wasn;t removed from `self.conversation_timeouts` which made it still fail because job would be present in the handler dict, although it was already disabled.
This should fix it properly.
2018-03-05 12:18:40 +01:00
Noam Meltzer
a6bf456645
Updater improvements (#1018)
- Refactor bootstrap phase to be resilient for network errors
 - Retry bootstrap phase indefinitely (by default) on network errors
 - Improved logs
 - Improved unitests for polling updater

fixes #605
2018-03-02 23:11:16 +02:00
Evgen
811369d1a0 Added conversation timeout in ConversationHandler (#895) 2018-03-01 11:34:47 +02:00
Paul Larsen
b67ea7a691 CommandHandler - ignore strings in entities and "/" followed by whitespace (#1020) 2018-03-01 10:11:16 +02:00
Noam Meltzer
3762792cca
Remove deprecated code (#1012)
* JobQueue: Remove deprecated prevent_autostart & put()

* Bot, Updater: Remove deprecated network_delay

* Remove deprecated Message.new_chat_member

closes #795
2018-02-22 14:17:06 +02:00
Noam Meltzer
baec1bb554 flake8 revamp
- Use pre-commit v1.2.0 flake8
 - Make sure we're running flake8 on examples and tests
 - Fix what had to be fixed
2018-02-19 12:41:38 +02:00
Noam Meltzer
746ae0caf3
Get jobs by name (#1011) 2018-02-19 10:36:40 +02:00
Noam Meltzer
91ae35e26c
updater.py: Better handling of timeouts during getUpdates (#1007)
TimedOut exception is an expected an normal event. To reduce noise and
make things more "fluent" we now:
 - Make sure that we don't sleep after the timeout but rather retry
immediately.
 - Log debug instead of error level.

Fixes #802
2018-02-18 17:50:38 +02:00
Jannik
c152d6583e Support v3.6 API (#1006)
* Added support for new field `telegram.Message.connected_message`

* Added support for new field `telegram.Message.connected_message`

* Added support for parse_mode in captions

* Added parse_mode parameter for captions in InlineQueryResult*

* Added supports_streaming parameter in telegram.Bot.send_video and telegram.InputMediaVideo
Fixed Docstrings for parse_mode in captions

* pypy3.5 unitests are now running with a new version due internal errors on travis.

closes #1005
2018-02-18 17:11:04 +02:00
Daniel Reed
063704c0b9 Explicitly check update.effective_chat in ConversationHandler.check_update (#959)
Fixes #927
2018-02-12 16:09:51 +02:00
Noam Meltzer
ddf3a1fcad
jobqueue: Thread safety fixes (#977)
- Fix JobQueue.jobs to obtain a lock on the internal queue object prior
   to iterating over it.

 - Rename JobQueue.queue to JobQueue._queue. This shouldn't be
   accessible by the user directly, but rather only with sanitized
   thread safe methods.

 - JobQueue.interval_seconds - access self.interval only once to avoid
   race conditions.

Fixes #968
2018-01-20 15:27:01 +02:00
Mischa Krüger
eb67c039f1 Updater: Issue INFO log upon received signal (#951)
Fixes #946
2018-01-09 17:54:07 +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
4b3315db6f Fix race condition in dispatcher start/stop (#887)
fixes #881
2017-10-21 14:40:24 +03:00
Jannes Höke
3ed05991ad log error trace if there is no error handler registered (#694) 2017-10-21 12:35:11 +03:00
Simon Schürrle
bb5357a815 Fix typo in the docstring (#878)
Changed `Filters.status_update.new_chat_member` to `Filters.status_update.new_chat_members`
Thanks to @ajbvn for pointing it out.

[ci skip]
2017-10-18 22:00:17 +03:00
Jacob Bom
8df35fd53b Fix for crashes on 8.1 (#873)
* Make Commandhandler not crash on single char messages

* Bump release and update CHANGES.rst for 8.1.1

* No error on single / and test
2017-10-15 16:59:10 +02:00
Eldinnie
28680ac1d5 edited_updates also for channel_posts (#832) 2017-10-14 23:48:06 +03:00
Jannes Höke
ec9b16ac7b Fix command not recognized if it is directly followed by a newline (#869)
fixes #868
2017-10-14 21:04:02 +03:00
Noam Meltzer
8a8b1215c8 Fix documentation of Request object initialization (for advanced users) (#866)
fixes #676
2017-10-12 00:39:09 +03:00
Eldinnie
d75e0f6014 Stabilize Coverage (#846)
* test_error added

* ignore unstables for coverage
2017-09-25 20:58:10 +02:00
Jeff
dbb3b16edc Add Job Class to docs (#845)
* fix job class missing from docs

* fix typo
2017-09-25 20:57:53 +02:00
Jeff
5614af1847 Docstring Fix for ext/filters.py (#830) 2017-09-15 23:56:16 +02:00
Pieter Schutz
ef9dbacf7e Fix last issues for new release 2017-09-01 10:38:04 +02:00
Jannes Höke
1f5311b473 catch exceptions in error handlerfor errors that happen during polling (2) (#810)
* catch exceptions in error handlerfor errors that happen during polling

* add tests for error handlers that raise exceptions
2017-09-01 08:46:21 +02:00
Noam Meltzer
e018445513 Documentation update to PEP (#797) 2017-09-01 08:43:08 +02:00
Eldinnie
4601eedf0f Show status_updates in docs (#798)
* Show status_updates in docs

* Show status_updates in docs
2017-09-01 08:41:15 +02:00
Noam Meltzer
16a49ec659 Remove DispatcherHandlerContinue + more unitests for dispatcher (#792)
The idea was nice, but it really complicated things for us and for the
user.
If a user wants to run more than one handler on an update, he can put
the handlers in different groups or he can have a single handler.
If a user wants to have multiple handlers in the same group which only
one of them should run on the update, he should use check_update().

Since we haven't released this code yet, there's no problem with
backward compatability.
2017-08-12 18:57:12 +03:00
Noam Meltzer
ee34d57521 Warn on small con_pool_size during custom initalization of Updater (#793)
fixes #787
2017-08-12 16:45:38 +03:00
Jacob Bom
5d7c6ad541 Switch to pytest + required fixes to code (#788)
Required fixes:
 - CallbackQuery is now comparable.
 - Message.effective_attachment, Message.photo,
   Message.new_chat_members, Message.new_chat_photo &
   Game.text_entitties semantic fixes - when they are not defined,
   return an empty list.
 - Docstring fix to Update class.
2017-08-12 00:58:41 +03:00
Eldinnie
b04869f36a docstring correction (#775)
[ci skip]
2017-08-08 00:11:44 +03:00
Noam Meltzer
5ceb6f8f36 Docs fixes (#765)
* Clean warnings during build_sphinx

* fix documentation types
2017-08-02 05:56:07 +03:00
Ihor Polyakov
6aacde189e Flow control ability in Dispatcher (#738)
fixes #666
2017-07-29 20:15:43 +03:00
Eldinnie
2ba7505eaf Fix TypeError exception in RegexHandler (#751)
fixes #750
2017-07-28 20:47:42 +03:00
Eldinnie
b3b94240a5 Docs update (#728)
Amazing new documentation.
2017-07-23 23:33:08 +03:00
Jelle Besseling
8320227b2a ConvesationHandler - check if a user exist before using it (#699)
Fixes #695
2017-07-23 22:29:52 +03:00
thodnev
f72f4090c6 Fixed args dispatching in messagequeue decorator (#705) 2017-07-08 07:18:10 +03:00
Jacob Bom
94ed4cb38d Bot api 3.1 (#698) + minor improvements
- Added all the new and shiny features from API 3.1.
 - Not API 3.1 changes:
   - Use future.utils.string_types for string isinstance checks.
   - Stall between retries of test_set_webhook_get_webhook_info() &
     test_delete_webhook().
2017-07-01 18:08:45 +03:00
Noam Meltzer
470ee86497 Merge pull request #677 from evgfilim1/new-filters
New filters for handling messages from specific chat/user id
2017-06-22 21:25:39 +03:00
evgfilim1
7e81a1510d Added ability to process list of ids/usernames 2017-06-22 15:19:49 +05:00
evgfilim1
ca9068f2b5 Simplified if statement, fixed docs 2017-06-22 13:39:41 +05:00
Jacob Bom
04acbc4117 Remove the need for calling super() in filters 2017-06-21 13:46:03 +02:00
Jacob Bom
6cc84b2c32 Only write repr as str will invoke it implicitly 2017-06-20 21:41:23 +02:00
evgfilim1
9bccbdab2a Added ability to filter by username 2017-06-20 12:43:07 +05:00
Jacob Bom
a964b7bfd0 Okay, so not even *args followed by a kwarg is allowed on py2...
So just remove it for now. Better than doing annoying stuff with parsing a **kwargs dict in my opinion. It didn't even *really* need to be kwarg only anyways I guess...
2017-06-19 21:46:34 +02:00
evgfilim1
5a62255675 Added new filters for handling specific chat id and user id 2017-06-19 22:50:44 +05:00
Jacob Bom
2b871e6f93 * for keyword only arguments isn't supported on py2 it seems... 2017-06-18 16:22:59 +02:00
Jacob Bom
788b9dab0c Fill in super() calls 2017-06-18 16:03:32 +02:00
Jacob Bom
4c41f3870c Allow filters to have a name.
So their string representation is user friendly.
2017-06-18 15:28:48 +02: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
Noam Meltzer
da8a3cee44 Merge pull request #631 from jeffffc/paymenthandlers
Add both handlers for queries from new Payment API
2017-06-09 18:23:29 +03:00
Eldin
bc3669fa4b make commandhandler case insensitive 2017-06-09 17:45:15 +03:00
Jeff
4247dc0e21 tiny changes upon PR review 2017-06-08 09:47:19 +08:00
Jacob Bom
896392d01e Merge branch 'master' into fix-docs 2017-06-07 13:12:32 +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
Jeff
eaf765dcbc Remove duplicated/useless codes, added Filters.invoice test 2017-06-03 01:48:30 +08:00
Jeff
e9d08c6f7a Merge branch 'master' into paymenthandlers-new
# Conflicts:
#	telegram/bot.py
#	telegram/message.py
#	telegram/precheckoutquery.py
#	telegram/shippingquery.py
2017-06-03 01:09:17 +08:00
Noam Meltzer
137ffe2e73 Merge remote-tracking branch 'origin/master' into payment 2017-06-01 22:01:04 +03:00
evgfilim1
5b1252ac2d Perfomance optimizations
Using `or` instead of `|`
2017-06-01 16:36:32 +05:00
evgfilim1
d98b18d1e3 Added new status_update filters 2017-06-01 07:09:30 +05:00
Jacob Bom
f4c6197c5f Update filters to new_chat_members instead of new_chat_member 2017-05-25 14:45:47 +02:00
Jeff
96171112bf fix crucial typo in filters 2017-05-22 23:42:09 +08:00
Jeff
27238c52e2 add successful_payment filter under message 2017-05-22 23:39:28 +08:00
Jeff
3767d26fc8 Add both handlers for queries from new Payment API (#630)
* add handlers for new payment API

* fix typo

* fix docstring mistakes

* added missing 'from_user'
2017-05-22 14:07:53 +02:00
Jacob Bom
630b63ec10 Add payment filters 2017-05-22 12:13:00 +02:00
Jannes Höke
1c4c228cf1 add support for User.language_code (#624)
* add support for User.language_code

* Add language filter

Useful is you wanna do something like restrict your shop to a single or a few locales or something like that.
2017-05-21 14:00:53 +02:00
Eldinnie
e2a651afc8 Allow edited as seperate input (#608)
* Allow edited as seperate input

In short made it possible to tune messagehandler more to your wishes. and choose exactly what updates to receive. messages, edited_message or channel_post or a combination.

- Added the edited_updates argument to MessageHandler
- Added DepricationWarning when using allow_edited
- replaced _is_allowed_message and _is_allowed_channel_post with _is_allowed_update
- Modified tests to reflect new way

* oops

Spelled deprecation wrong
made an error in the _is_allowed_update.

* Python 2 does not have assertWarns.

* remove unneeded statements
2017-05-19 20:26:10 +02:00
Evgen
33512ffd2e Improved CommandHandler (#613)
* Improved CommandHandler

Now you can pass list of commands instead of one command

* Added tests for list of commands

* Return backward compatibility

Renamed `commands` to `command` in CommandHandler

* Added test for a command not in the list

* Fixed py2 unicode command support in `CommandHandler`
2017-05-19 20:21:37 +02:00
Jacob Bom
1b7f83625c Update copyright notice to include 2017
Not strictly needed, but it helps show that the project is being actively
developed which I find important.
2017-05-15 00:36:49 +03:00
Evgen
752b64769d Fix for #601 (#603) 2017-05-12 17:42:02 +02:00
Joscha Götzer
cdf36a20b7 Fixed deprecation warning (#586) 2017-04-29 19:56:27 +02:00
manorom
c5598b96bc Fix Bug #571 (second try) (#574)
* Fix Bug #571
ConversationHandler will not process CallbackQuery if per_chat=True and
the CallbackQuery has no message attached to it (as is the case with
buttons on inline results)

* Adds test case for CallbackQuery without Chat
2017-04-29 15:51:48 +02:00
Jannes Höke
c7dbdce3dc Allow CallbackQueryHandler in ConversationHandler with per_mess… (#561)
* 🐛 Allow CallbackQueryHandler in ConversationHandler with per_message=False

but show a warning #556

*  warning logs instead of ValueErrors

 #556
2017-04-29 15:15:17 +03:00
Dickson Tan
11a3de67ea Remove deprecated code #408 part 1 (#564)
* Remove non-pep8 dispatcher methods

* callbackqueryhandler: Remove non-pep8 compliant methods

* commandhandler: Remove non-pep8 compliant methods

* handler: Remove non-pep8 compliant methods

* messagehandler: Remove non-pep8 compliant methods

* stringcommandhandler: Remove non-pep8 compliant methods

* stringregexhandler: Remove non-pep8 compliant methods

* test_updater: fix usage of deprecated methods

* dispatcher: fix accidental misalignment of comments by pre-commit hook

* Add myself to list of contributors
2017-04-25 10:39:02 +02:00
Eldinnie
90bf26c09b Issue 566 (#577)
* stripping token of whitespaces before starting bot

* Line feed

* - Case insensitivity for commandhandler
- Ignore pylint case on windows.
2017-04-25 10:37:06 +02:00
Eldinnie
b5b09884b1 Group filters (#575)
* stripping token of whitespaces before starting bot

* Line feed

* show exception that's caused (fixes flake8 failing)

* Add private/group filters

Add filters:
 - Filters.private (for messages in private chats)
 - Filters.group   (for messages in group chats)

* use constants
2017-04-23 23:22:05 +02:00
Jacob Bom
ad5f009ce7 Add the ability to invert (not) filters (#552)
* Add InvertedFilter and use it from __invert__

* Add docstrings and __str__ for inverting filters

* Tests for inverted filters
2017-03-28 18:38:44 +02:00
Jannes Höke
8fe6e13ff2 Update handlers (#532)
* 🔨 Refactor `Update.extract_` methods to `Update.effective_` properties
 #507

*  Update RegexHandler to work with edited messages and channel posts

* 🔨 messagehandler.py: refactor channel_posts_updates -> channel_post_updates

* 🔨 handler.py: use effective_ properties
2017-03-26 14:36:45 +02:00
Jannes Höke
ff39e2436e Refactor Update.extract_ methods to Update.effective_ properties (#531)
* 🔨 Refactor `Update.extract_` methods to `Update.effective_` properties
 #507

* 🔨 handler.py: use effective_ properties
2017-03-26 14:36:34 +02:00
Alex Hirschfeld
5b14b134dc Added user defined function for updater's signalHandler (#512)
* Added user defined function for updater's signalHandler

* Added test_userSignal to test_updater

* Added test_userSignal to test_updater
Fixing paren
2017-03-26 14:36:13 +02:00
Jannes Höke
5897affa07 add missing allowed_updates to start_webhook (#549)
* 🐛 add missing allowed_updates to start_webhook
 #548

* 🔨 fix webhook-related tests
 #548
2017-03-25 12:46:37 +01:00
thodnev
22142e7cbd Introduce MessageQueue (#537)
* Introduce MessageQueue

* minor documentation and terminology fixes according to the review

* minor documentation and terminology fixes according to the review

* minor documentation and terminology fixes according to the review

* pep8 fix
2017-03-15 17:35:33 +01:00
Jose Luis Salazar Gonzalez
e78d11a99b Add filters to commandHandler (#536)
* Add filters to commandHandler

* Add commandHandler tests with filters

* Add myself to authors
2017-02-28 15:44:55 +01:00
Jannes Höke
cc73469dab Issue 502 (#530)
* conversationhandler.py: add per_chat, per_user and per_message

* test_conversationhandler.py: test case per_user=False

* test_conversationhandler.py: add test for callbackqueryhandlers

* ✏️ Fix accidental typo in logging format
2017-02-27 17:52:58 +01:00
Jannes Höke
6b7144bbab 🚨 fix yapf 2017-02-27 14:53:28 +01:00
Jannes Höke
f8b13440c1 🔀 Merge thodnev/ptb into ptb/promises-with-exceptions
#529
2017-02-27 14:45:12 +01:00
Jannes Höke
a1ade408b0 🔀 Merge master into dec04
#483
2017-02-27 14:39:18 +01:00
Eldinnie
78094b796d Fix commandhandler (#515)
* stripping token of whitespaces before starting bot

* Line feed

* CommandHandler checks if message is for this bot

* CommandHandler checks if message is for this bot
- Added tests

* Fixed tests in test_conversationHandler to work with new commandhandler structure

* type in conversationhandler test
2017-02-27 14:26:53 +01:00
thodnev
fb378775a4 Changed promises to handle exceptions 2017-02-26 23:27:03 +02:00
Joscha Götzer
ac59f2f37c Added methods to generate the original markdown/html string from entities contained in Message (#507)
* Added methods to generate the original markdown/html formatted string from the entities contained in an update

* Added

* Moved the html/markdown parsing methods to `Message`

* Moved extract_* methods from helpers to the appropriate location

* Refactored text_markdown and text_html

* Refactored text_markdown and text_html for efficiency

* Fixed method call in conversationhandler

* Fixed method call in handler

* Fixed `make test` command on windows systems

* Improved method documentation
2017-01-20 20:13:58 +01:00
Jannes Höke
975d193441 Merge branch 'master' into dec04 2017-01-16 00:15:09 +01:00
Jannes Höke
728ffa432d updater.py: add allowed_updates parameter to start_polling 2017-01-16 00:07:46 +01:00
Jannes Höke
fc9f36d4db use deleteWebhook in Updater._bootstrap 2017-01-16 00:00:27 +01:00
Noam Meltzer
58dddfd9c3 Control the read timeout from telegram servers
refs #495
refs #364
2017-01-07 20:13:08 +02:00
Joscha Götzer
6a01164897 ConversationHandler breaks when bot is also used in Channels (#487)
* ConversationHandler now ignores channel posts
2016-12-25 22:36:01 +02:00
Jannes Höke
09cb33f52d rename Job.is_removed to removed 2016-12-20 22:37:36 +01:00
Noam Meltzer
423251f66c Change Job.is_removed to be a property instead of a method 2016-12-20 00:14:03 +02:00
Noam Meltzer
93bf21a0a4 jobqueue.py: stability improvments
- Job.job_queue is now weakref.proxy reducing the risk of cyclic
   pointers preventing Job object from being deleted.
 - JobQueue._put(): raise if both next_t and job.interval are None
 - Don't put repeating job back to queue if user had disabled it was
   disabled during the time of execution.
 - New method: Job.is_removed() - promising a consistent API (instead of
   access to private member Job._remove)
 - Documentation fixes.
2016-12-15 00:17:57 +02:00
Jannes Höke
cbf93e1046 switch to run_x naming scheme 2016-12-14 18:01:44 +01:00
Jannes Höke
d5ce32c672 removed Job.run_immediately and related code 2016-12-14 17:15:52 +01:00
Jannes Höke
09ddc1b1a8 DAAAANGER ZOOOONE 2016-12-14 16:27:45 +01:00
Jannes Höke
c7cd379016 jobqueue.py: move the check for job.interval types into Job.__init__ 2016-12-14 06:30:18 +01:00
Jannes Höke
8ead72e3ef jobqueue: add support for specifying next_t in datetime.datetime or datetime.time 2016-12-13 23:38:13 +01:00
Jeong Arm
c5f9e53d44 Add "reply" filter (#465)
* Add "reply" filter

This filter will filter messages that reply to other's message.

* Add test for "reply" filter

* Add "Kjwon15" to AUTHORS.rst
2016-12-11 22:45:51 +01:00
Noam Meltzer
acf1541395 Botapi2.3 (#471)
* New fields channel_post and edited_channel_post for Update

refs #468

* setGameScore() changes

 - Changed behaviour: messages with high scores will be update with new
   high scores by default. (documentation fix)
 - Use (new) disable_edit_message in setGameScore to disable the above new
   behaviour.
 - The edit_message parameter from setGameScore is no longer in use. For
   backward compatibility, it will be taken into account for a while,
   unless disable_edit_message is passed explicitly.

refs #468

* New field forward_from_message_id for Message.

refs #468

* New parameter cache_time for answerCallbackQuery

refs #468

* replykeyboardhide renamed to replykeyboardremove

refs #468

* Unitests for updated setGameScore semantics

refs #468

* Backward compatibility for ReplyKeyboardHide

refs #468

* Fix docstrings of wrapper methods in Message

* Unitest new field forward_from_message_id of Message

refs #468

* Fix testMaxCaptionLength

Telegram servers changed their behaviour - now they truncate a long
caption instead of returning an error.

* MessageHandler: Added support for channel posts

* Fix flake8 complaints in a manner which yapf will like it too.

* fix rst markup
2016-12-11 22:44:52 +01:00
Wesley Gahr
68e87db909 Job queue time units (#452)
* Adding timeunit and day support to the jobqueue

* Adding tests

* Changed the file permission back to 644.

* Changed AssertEqual argument order to (actual, expectd).

* Removed the TimeUnit enum and unit param, instead use datetime.time for interval.

* Removing the TimeUnits enum and unit param in favour of optionally using a datetime.time as the interval.

* Removing the TimeUnits enumeration, forgot the remove it in the last one.

* Removed some old docstrings refering to the TimeUnits enum.

* Removed the old TimeUnits import.

* Adding some error handling for the 'days' argument (only a 'tuple' with 'Days')

* Writing the error message directly in the exception.

* Moving a debug statement wrongfully saying a job would be running on days it wouldn't.

* Writing error messages directly in the exceptions instead of making an extra variable.

* Replacing datetime.time in favour of datetime.timedelta because of the get_seconds() method.

* Adding error handling for the method .

* Splitting the tests up in multiple ones, no float test because I haven't found a reliable way to test it.

* Excluding .exrc file.

* Removing \ at EOF of ValueError.

* Replacing Enums with plain new-style classes.

* Using numbers.number to check for ints/floats instead of seperate int/float checks.

* Fixing typo, number -> Number.

* Changed lower_case Days attributes to UPPER_CASE.

* Different formatting for Days class, removed the get_days function in favour of a tuple.

* Removed redundant function get_days.

* Edited the docstring for next_t to also take datetime.timedelta.

* Removed for-loop in favour of any().

* Changed docstring for interval.

* Removed debug print.

* Changing some docstrings.

* Changing some docstrings (again).
2016-11-08 23:39:25 +01:00
Jannes Höke
aa3ca38837 Sphinx restructuring: Now builds PDF and better HTML docs (#449)
* update sphinx source files to properly build latexpdf and improve html build

* fix docstrings and sphinx sources to get rid of warnings

* add telegram.contrib.rst
2016-11-01 06:53:51 +01:00
neutronnnate
761547e71d Issue 422: Fixed start_polling with clean=True can cause 'Too Many Requests' error from Telegram. (#437) 2016-10-25 19:30:05 +02:00
Jannes Höke
10bdf8212c Add pass_user_data and pass_chat_data to Handler (#436)
* initial commit for user_data

* add chat_data and use defaultdict

* fix chat_data copy-paste error

* add test for user_data and chat_data

* fix case where chat is None

* remove braces from import line
2016-10-25 19:28:34 +02:00
Kristofer Kirss
45936c9982 Remove deprecated argument from Updater docstring (#444)
Argument (job_queue_tick_interval) was removed with commit 3aedd78 but the docstring in updater.py wasn't.
2016-10-23 00:31:44 +03:00
Jacob Bom
960862ccb1 Merge branch 'master' into october3
# Conflicts:
#	telegram/bot.py
#	telegram/callbackquery.py
#	telegram/chat.py
#	telegram/ext/messagehandler.py
#	telegram/inlinekeyboardbutton.py
#	telegram/inlinequeryresultcachedaudio.py
#	telegram/message.py
#	tests/test_filters.py
2016-10-19 12:35:50 +02:00
Jacob Bom
4e5f4582dd Merge pull request #411 from python-telegram-bot/bitwise-filters
Make filters and/or-able using bitwise operators.
2016-10-19 11:40:35 +02:00
Jacob Bom
c626044a30 Add "all" filter
Since and empty list cannot (in the future, currently only deprecated) be used.
2016-10-15 22:58:55 +02:00
Noam Meltzer
a68cf8d464 Respect RetryAfter with polling Updater 2016-10-15 23:39:50 +03:00
Jacob Bom
ca5e3146c6 Fix docstring according to Jannes' commentns. 2016-10-14 10:32:12 +02:00
Jacob Bom
b7c7612b3f Add game filter 2016-10-07 22:37:29 +02:00
Jacob Bom
79bdfe4c5d Allow filters to be passed without list.
Also deprecates actually using a list.
2016-09-29 19:10:22 +02:00
Michael Elovskikh
46657afa95 Start additional threads only when necessary (#415)
* Start all additional threads only when necessary.

* Deprecate prevent_autostart in the c'tor of JobQueue.
2016-09-27 10:21:35 +03:00