Commit graph

798 commits

Author SHA1 Message Date
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
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
ikkemaniac
e60318166e
Add test for clean argument of Updater.start_polling/webhook (#2002)
* added test for 'clean' argument passed to 'start_polling()'

* remove TODO

* prettify

* remove bool from func name

* improve name-ing of fake update func

* cleanup class and nameing

* replace while for for

* swap valueerror for runtimeerror

* remove all other code to reduce testing

* add comments

* don't raise error, complete cycle and assert

* remove inf loop protection

* Revert "remove all other code to reduce testing"

This reverts commit 4566a1debd.

* remove error parametrization

* remove comment

* remove pass from class

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

* rename test func to match original func

* fix comment

* shorten for loop

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

* remove other functions to reduce testing

* replicate original get_updates()

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

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

* update comments

* Revert "remove other functions to reduce testing"

This reverts commit 1fb498a6cc.

* fix typo

* Revert "fix typo"

This reverts commit ade9fec609.

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

This reverts commit 734de1371c.

* Revert "update comments"

This reverts commit f3a032e75e.

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

This reverts commit 0c6881d8a1.

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

This reverts commit 71de999300.

* Revert "replicate original get_updates()"

This reverts commit 5d0710ac3a.

* Revert "remove other functions to reduce testing"

This reverts commit 1fb498a6cc.

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

This reverts commit 8c727ba1e8.

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

Co-authored-by: ikkemaniac <ikkemaniac@localhost>
2020-06-24 00:25:58 +02:00
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
Bibo-Joshi
6005861f46
Stabilize CI (#2000) 2020-06-15 18:45:38 +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
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
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
8427346a0d
Add supegroup for each test bot (#1919) 2020-05-01 21:29:18 +03:00
Bibo-Joshi
632b989d90
Use @abstractmethod instead of raising NotImplementedError (#1905) 2020-05-01 21:27:34 +03:00
Bibo-Joshi
76567ba635
Stabilize CI (#1931) 2020-05-01 13:27:46 +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
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
Bibo-Joshi
61a66a32c8
Add tests for empty string as switch_inline_query(_current_chat) (#1635) 2020-03-31 00:03:45 +02:00
Andrej730
9cb34af65a
Fix UTC as default tzinfo for Jobs (#1696)
1. Made sure that default tzinfo in JobQueue is UTC #1693.
2. Added test that checks that all methods by default set job.tzinfo as UTC.
2020-03-30 18:10:27 +02:00
Bibo-Joshi
e9cb6675ca
PrefixHandlers command and prefix editable (#1636)
* Rename internal list of PrefixHandler

* Make PFH.prefix and .command setable attributes

* Improve coverage
2020-03-30 17:49:50 +02:00
Bibo-Joshi
982f6707e1
Make ConversationHandler attributes immutable (#1756)
* Make ConversationHandler attributes immutable

* Add forgotten name property to test_immutable
2020-03-30 17:37:37 +02:00
Rys Artem
d55d981e22
Reorder tests to make them more stable (#1835) 2020-03-30 17:06:24 +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
Bibo-Joshi
2d3357bfeb
Ignore Message.default_quote in test_official (#1848) 2020-03-28 14:32:16 +01:00
Ak4zh
28ded6718e
Add link property to Bot (#1770)
* added link property to bot

link property was available in User and Chat objects but not in Bot which was inconsistent.

* added 'link' property to Bot object

Bot will always have username so it does not require hasattr check

* add tests

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-03-09 23:17:05 +02:00
Noam Meltzer
13a641b3d7
Python 3.8 support (#1614)
* github workflow: Add python-3.8

* workaround for tornado issue on win with py>=3.8

* add workaround to webhookhandler

* Try making codecov and codacy happy

* Fix stupid mistake

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
2020-03-09 23:13:16 +02:00
Noam Meltzer
f7ec7a7c4c
Use temporary directories in test_persistence (#1808) 2020-03-04 23:58:19 +02:00
Bibo-Joshi
8d6970ab02
Remove references to travis and appveyor (#1791) 2020-02-23 23:04:56 +02:00
Bibo-Joshi
1dc67dcbda
Remove builtin names where possible (#1792) 2020-02-23 23:03:58 +02:00
Bibo-Joshi
a447760411 Make sure PP can read files that dont have bot_data (#1760)
* Make sure PP can read files that dont have bot_data

* Improve workaround
2020-02-08 19:24:35 +02:00
Bibo-Joshi
6da529c46b Pass correct parse_mode to InlineResults if bot.defaults is None (#1763)
* Pass correct parse_mode to InlineResults if bot.defaults is None

* Add tests for inlinequeryresults with (default)parse_mode

* enhance tests
2020-02-08 18:52:22 +02:00
Bibo-Joshi
f9a8cd924c
Make Filters.command only accept MessageEntity commands (#1744)
* Make Filters.command only accept MessageEntitie commands

* Add option to filters.command to allow cmds anywhere in the message

* Make codecov happy, also retroactive for #1631
2020-02-08 14:54:21 +02:00
Bibo-Joshi
cf3635d408
make test_webhook_invalid_posts flaky (#1758) 2020-02-07 18:32:38 +02:00
Bibo-Joshi
bf06fa2c18
Skip test relying on ordered dicts for 3.5 (#1752) 2020-02-06 11:28:27 +01:00
Bibo-Joshi
960c7a0c70
Add default values (#1490)
* added parse_mode parameter in Updater and in Bot class to set a default parse mode for bot

* DefaultValue

* Add default parse_mode everywhere

* Renome to default_parse_mode

* Test def parse_mode for send_*, edit_message_*

* Remove duplicate code in Input* classes

* Improve handling of def_p_m for Bot methods

* Remove unneeded deletion of kwargs

* Make @log preserve signature, add bots with defaults to tests

* Fix Codacy

* Fix Travis Error

* Add default_disable_notification

* Add default_disable_web_page_preview

* Add default_disable_timeout

* add default_disable_web_page_preview for InputTextMessageContent

* add default_quote

* Try fixing test_pin_and_unpin

* Just run 3.5 tests for paranoia

* add tests for Defaults

* Revert "Just run 3.5 tests for paranoia"

This reverts commit 1baa91a3a1.

* Tidy up parameters, move Defaults to ext

* Stage new files, because im an idiot

* remove debug prints

* change equality checks for DEFAULT_NONE

* Some last changes

* fix S&R error so that tests actually run

Co-authored-by: Ak4zh <agwl.akash@gmail.com>
Co-authored-by: Eldinnie <Eldinnie@users.noreply.github.com>
2020-02-06 11:22:56 +01:00
Gabriel Simonetto
bacabbe767
fix download without path arguments (#1591)
* fix download without path arguments

* fix download without path arguments

* solved downloading a file without file_path or custom_path

* if no file_path, download as file_id

* Add test case

* Elaborate doc string

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
2020-02-06 11:21:21 +01:00
Eldinnie
d8dcdeea75
fix test_pin_and_unpin_message (#1749)
Make it flaky and timeout
2020-02-02 23:39:08 +01:00
isinstance
818475bd93
Fix Server response could not be decoded using UTF-8 (#1623)
Co-authored-by: Noam Meltzer <tsnoam@gmail.com>
2020-02-03 00:12:27 +02:00
Bibo-Joshi
f97ac90af7
skip test_json on TestDictPersistence on py3.5 (#1748) 2020-02-03 00:10:48 +02:00
Bibo-Joshi
6d9d11b8bd
Handler persistence for nested ConversationHandlers (#1711)
* Handler persistence for nested ConversationHandlers

* Add tests for persistence w/ nested CHs
2020-02-02 22:31:56 +01:00
Bibo-Joshi
f6b663f175
bot_data as global memory (V12 version of #1322) (#1325)
* Update AUTHORS.rst

* Update AUTHORS.rst

* Add bot_data to CallbackContext as global memory

* Minor fixes in docstrings

* Incorp. req. changes, Flake8 Fixes

* Persist before stop

* Fix CI errors

* Implement #1342 for bot_data

* Add check pickle_persistence_only_bot similar to #1462

* Fix test_persistence

* Try dispatching error before logging it

* Fix test

Co-authored-by: Eldinnie <Eldinnie@users.noreply.github.com>
2020-02-02 22:20:31 +01:00
Noam Meltzer
43bfebb150
Update copyright date to 2020 (#1746) 2020-02-02 23:08:54 +02:00
Poolitzer
423794f473
fixing message.link (#1741)
* fixing message.link

* improving if clause
2020-02-02 20:27:53 +01:00
Bibo-Joshi
7cde6ca268
temporarily skip tests failing b/c missing api 4.5 (#1738) 2020-01-30 20:57:16 +02:00
Bibo-Joshi
3eb2cef600 Make Filters.text accept leading slash (#1680)
Fixes #1678
2020-01-26 23:19:38 +02:00
Bibo-Joshi
cb9af36937 Fix None check in JobQueue._put() (#1707)
fixes #1701
2020-01-26 23:07:17 +02:00
Eana Hufwe
d9d65cc2ac Add poll messages support to filters (#1673) 2020-01-26 22:57:48 +02:00
Bibo-Joshi
62f514f068 CallbackContext: Expose dispatcher as a property (#1684)
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
2020-01-26 22:55:00 +02:00
rizlas
e3c8466e41 Rename enocde_conversations_to_json() -> enocde_conversations_to_json() (#1661)
Fixes #1660
2020-01-26 22:24:00 +02:00
Bibo-Joshi
883c6b5901 Add dispatcher argument to Updater (#1484) 2020-01-26 21:59:47 +02:00
tobiaswicker
940b42e048 ConversationHandler: Fix wrong signature call for timeout handlers
Fixes #1652

Co-authored-by: Eldinnie <Eldinnie@users.noreply.github.com>
2020-01-11 20:51:31 +02:00
Poolitzer
2c67a9833b add private /c links to message.links object (#1619)
* add private /c links to message.links object

* fixing ids for basic groups

* fixing ids for non basic chats and the test

* Improve tests for Message.link

* Simplify id_to_link
2019-11-29 13:50:44 +01:00
Bibo-Joshi
5e8a961669 Refactor msg_in (#1631)
* Revert "Add msg_in filter (new) (#1570)"

This reverts commit 34bdbc632a.

* Refactor msg_in, add Filters.caption on the fly

* Update docstrings

* Fix copy-paste typo
2019-11-29 13:09:44 +01:00
Noam Meltzer
2fdf48023b
github workflow: give pre-commit its own job (#1612) 2019-11-15 23:35:44 +02:00
Paolo Lammens
4e717a172b Fix UTC/local inconsistencies for naive datetimes (#1506) 2019-11-15 22:51:22 +02:00
Noam Meltzer
e9d9f01bd4
Fix windows actions (#1605)
* Stop testing with ujson

* Fix timing issue with test_delete_message

* ignore pip deprecation warning. hopefully it will fix windows+py2.7

* telegram replies to deleteing old messages are not consistent
2019-11-09 20:33:51 +02:00
Jasmin Bom
8b4b22cc89
Implement Github Actions CI (#1556)
* Add test workflow

* Attempt github grouping

* Improve bot info fetching

- Add support for b64+json encoded github secret with all the vars
- Add bot_name and bot_username since it's needed for a proper get_me test

* Improve test workflow a lot

- Add coverage
- Install ujson
- test_official only run on in single job
- Pass bot info to pytest

* Improve github grouping by having shorter titles

* Run pytest with coverage

* Improve coverage report

* Proper exitcode behaviour for pytest

* Proper test official handling

* Proper error handling

* Skip jobqueue tests on windows

* run coverage tests even if nocoverage ones fail

* Skip messagequeue tests on windows

* Clean up to satisfy flake8

* Run meta tests
2019-10-27 14:28:33 +01:00
Bibo-Joshi
34bdbc632a Add msg_in filter (new) (#1570)
Closes #1144
2019-10-27 01:12:54 +03:00
Lorenzo Rossi
3d8771bbdf 🔀 Add mutex protection on ConversationHandler (#1533)
* Add mutex protection on ConversationHandler

* Remove timeout job before child update

* Make locks private

* Add conversation timeout conflict test
2019-10-17 00:03:53 +02:00
Poolitzer
3545139dd7 adding to_dict test (#1544)
fixes #1541
2019-10-12 23:40:42 +03:00
Paolo Lammens
3318239cf6 tests: refactor `test_commandhandler.py` (#1408)
- Improved usage of fixtures
    - Replaced fixtures for directly callable factories where
    multiple mock objects were needed in the same test function
    - Extracted fixtures where possible (in place of literals or
    global constants)
  - Moved some fixtures to ``conftest.py`` to be used by other
  modules
  - Made a common base class for both ``TestCommandHandler`` and
  ``TestPrefixHandler``, extracting common methods, patterns and
  signatures
    - The extracted patterns in test methods have been named with
    leading ``_test``
  - Extracted other repeatedly used test utilities into functions
  (e.g. ``is_match``) and methods (e.g. ``make_default_handler``)
2019-10-12 16:11:09 +03:00
Bibo-Joshi
aadb6df271 Nested ConversationHandlers (#1512)
Fixes #405
2019-10-11 22:59:36 +03:00
Joscha Götzer
ccf5e6c692 Implemented Tools for deep linking (#1049) 2019-09-13 22:09:05 +03:00
zeshuaro
32dd415fb8 Add instance methods to Animation and ChatPhoto (#1489)
get_file, get_small_file, get_big_file
2019-09-13 22:07:56 +03:00
Bibo-Joshi
fba3cc90d9 API 4.4 small code cleanup (#1510) 2019-09-07 12:42:26 +03:00
Bibo-Joshi
965ad17af8 API 4.4 (#1464) 2019-09-06 22:41:43 +03:00
Poolitzer
d5399de99b raise attribute errors when someone tries to assign values to chat/us… (#1495)
* raise attribute errors when someone tries to assign values to chat/user_data (closes #1402)

* fix test

* something something not switching entirely and using a messy patch and no not anymore and argh
2019-09-05 22:48:28 +02:00
Poolitzer
ec6dc7fa10 fix typo in PicklePersistence (#1488)
* fix single typo

* fix unitests for picle singe_file -> single_file
2019-08-29 19:09:38 +02:00
Noam Meltzer
b71196dad3
Run test_official in a seperate travis job (#1491) 2019-08-28 22:58:58 +03:00
Poolitzer
2c92c356b8 Error handlers now handle all errors (#1483)
* python3.4 is no longer supported

* Prepare CHANGES.RST & README.rst for v12.0.0 release

* CHANGES.rst: small fix

* Add Bibo-Joshi to Credits

* improving error_handler

* fixing affected tests
2019-08-27 09:09:02 +02:00
Noam Meltzer
f379a34ccd Run test_official only on py3.7 2019-08-24 01:13:40 +03:00
Noam Meltzer
4328eaefb2
Fix test_photo.py (#1479)
Telegram had changed their server behaviour again
2019-08-24 01:10:30 +03:00
Noam Meltzer
79dc6edf25 Merge remote-tracking branch 'origin/V12' 2019-08-24 01:04:10 +03:00
Bibo-Joshi
c7e9281068 Make MessageEntity objects comparable (#1465) 2019-08-24 00:54:04 +03:00
Eldinnie
edad6e8b53
Add a prefix to threads (#1358)
* Add a prefix to worker thread

This adds a prefix of `Bot:<id>:worker:` to the name of the worker threads.
Fixes #1332

* Also prefix other threads

* Fix test

* Fix test and remove helper method.
2019-08-23 22:57:08 +02:00
Eldinnie
ac60d057a5 All api 4.2 and 4.3 changes (#1418) 2019-08-23 22:20:41 +03:00
Bibo-Joshi
a1eabc0cae Fix for #1452 (#1462)
Dispatcher force updating persistence object's chat data attribute
2019-08-23 21:52:14 +03:00
Pieter Schutz
3fc57479f3 Merge branch '4.3' into RC1 2019-06-05 22:19:48 +02:00
Pieter Schutz
e11efa2e5b Add bot api 4.3
Add LoginUrl to InlineKeyboardButton

Add reply_markup to message
2019-06-05 22:15:32 +02:00
Pieter Schutz
cebd2d6a86 test poll de_json 2019-06-05 22:11:28 +02:00
Pieter Schutz
725c21b88d API 4.2 changes
actually works now

Add tests

Fix flake8 issues.

Add poll argument to Update.

Fix pre-commit config
Finalizing 4.2

No notify on pin
2019-06-05 15:00:07 +02:00
Jasmin Bom
7944805627 Fix bot tests
- telegram how throws an error if you try to reply to nonexistent msg
- telegram also changed the message when you try to delete old msg
2019-04-01 13:05:45 +02:00
Jasmin Bom
b5891a6a61 Making merged filters short-circuit (#1350)
* Making merged filters short-circuit

* Add notes to docs about short-circuiting
2019-03-14 09:03:21 +01:00
Eldinnie
36a74da4f4
fix setting bot on ShippingQuery (#1355)
* fix setting bot on ShippingQuery

* Fix test to test de_json
2019-02-23 21:33:03 +01:00
Kirill Vasin
60f2044bbd Entry returns None ends conversation (#1270)
* Fix unresolvable promises

* added async test and description

* added test_none_on_first_message for conv_handler

* Small change in ConversationHandler docstring

* Fix test to work with new commandhandler
2019-02-14 12:29:58 +01:00
Jasmin Bom
9f1eccf569 Merge branch 'master' into V12 2019-02-14 11:52:31 +01:00
Bibo-Joshi
f7abb21323 Adjust persistence on exit behaviour (#1312)
* Adjust persistence of exit behaviour

* Fix binary operators in on_flush

* Fix docstring

* Add test
2019-02-13 23:30:29 +01:00
Jasmin Bom
b64698e4b6
Use warnings.warn for conversationhandler warnings. (#1343)
* FIXED: ConversationHandler errors were logged to root logger

* Use warnings.warn instead of self.logger.warning.
2019-02-13 23:28:23 +01:00
Ambro
d0936f76ad Only one warning for multiple CallbackqueryHandler's on ConversationHandler (#1319) 2019-02-13 22:08:49 +01:00
Jasmin Bom
da342af7ed Small flake8 fixes 2019-02-13 16:04:48 +01:00
Eldinnie
b02b68880f Make dispatcher use one context per update (#1283)
* Make dispatcher use one context per update

It gives user the option to `overload` context with their own properties in a lower group handler if they like

* Improve callbackcontext & run_async docstring

- Add note about how you can add custom attributes to context.
- Add warnings about how run_async and custom attributes should not be used together.

* Small documentation improvements. [ci skip]
2019-02-13 12:18:37 +01:00
Eldinnie
2c5eade4f0 Update Filters, CommandHandler and MessageHandler (#1221)
* update_filter attribute on filters

Makes it possible to have filters work on an update instead of message, while keeping behavior for current filters

* add update_type filter

* Messagehandler rework

- remove allow_edited (deprecated for a while)
- set deprecated defaults to None
- Raise deprecation warning when they're used
- add sensible defaults for filters.
- rework tests

* Commandhandler rework

* Remove deprecation test from new handler

* Some tweaks per CR

- rename update_types -> updates
- added some clarification to docstrings

* run webhook set test only on 3.6 on appveyor

* update_filter attribute on filters

Makes it possible to have filters work on an update instead of message, while keeping behavior for current filters

* add update_type filter

* Messagehandler rework

- remove allow_edited (deprecated for a while)
- set deprecated defaults to None
- Raise deprecation warning when they're used
- add sensible defaults for filters.
- rework tests

* Commandhandler rework

* Remove deprecation test from new handler

* Some tweaks per CR

- rename update_types -> updates
- added some clarification to docstrings

* run webhook set test only on 3.6 on appveyor

* Changes per CR

* Update travis to build v12

* small doc update

* try to make ci build version branches

* doc for BaseFilter

* Modify regexfilter and mergedfilter

Now returns a list of match objects for every regexfilter

* Change callbackcontext (+ docs)

* integrate in CommandHandler and PrefixHandler

* integrate in MessageHandler

* cbqhandler, iqhandler and srhandler

* make regexhandler a shell over MessageHandler

And raise deprecationWarning on creation

* clean up code and add some comments

* Rework based on internal group feedback

- use data_filter instead of regex_filter on BaseFilter
- have these filters return a dict that is then updated onto CallbackContext instead of using a list is before
- Add a .match property on CallbackContext that returns .matches[0] or None

* Fix and add test for callbackcontext.match

* Lots of documentation fixes and improvements [ci skip]
2019-02-13 12:07:25 +01:00
Jasmin Bom
950ec35970
Remove message decorator to fix default timeouts. (#1156)
* Remove message decorator to fix default timeouts.

* Make message wrapper method private.

* Make tests pass

* Fix callbackquery shortcuts

Closes #1180

* Fix callbackquery shortcut tests

* Fix merge

* Address CR

* Add missing default timeout=20 for some bot file uploads

* Fix wrong return value in convhandler

Probably stems from a combination of bad merge plus quickly merged hacktoberfest PR.
2019-02-13 11:37:13 +01:00
Jasmin Bom
d33e1d9913 Small flake8 fix 2019-02-09 18:45:34 +01:00
Jasmin Bom
2e203e41e4 Merge branch 'master' into V12 2019-02-09 18:45:00 +01:00
Jasmin Bom
e54a3188ce Revert "Fix bug: unable to save jobs with timezone aware dates (#1308)"
This reverts commit 23fe991b

See https://github.com/python-telegram-bot/python-telegram-bot/pull/1308 for more details.

NOTE: Keeping Ambro17 in AUTHORS.rst as I'm pretty sure they've contributed more since then :)
2019-02-09 18:44:04 +01:00
Jasmin Bom
27b757df32 Reorder some stickset tests to hopefully make them pass 2019-02-09 18:21:12 +01:00
Jasmin Bom
66e43c5932 Fix a bunch of flake8 W504 errors 2019-02-08 20:55:40 +01:00
Jasmin Bom
7fcbfc19f5 Mark location sending test as xfail as it seems to fail randomly 2019-02-08 20:22:44 +01:00
Jasmin Bom
a60c07f549 Update test animation size
Telegram must've again chagned internal stuff
2019-02-08 20:21:24 +01:00
Jasmin Bom
1b52e6148e Merge branch 'master' into V12 2019-02-08 12:49:28 +01:00
Ambro
487bce18dd Improve regex filter docstring and avoid compiling compiled regex (#1314)
* Improve regex docstring and add test case

* Add Ambro17 as contributor

* rename regex filter

* Fix sphinx documentation for Filters.regex

* Add spacing to render Note with blue background
2019-02-08 11:12:49 +01:00
Gregory Petukhov
5c45e469d5 Fix #1335: Message.MESSAGE_TYPES does not contain "left_chat_member" (#1336) 2019-02-08 11:02:54 +01:00
Jasmin Bom
25e5449e97 Fix TestDispatcher::test_error_handler using pytest >= 4.0 2019-01-30 20:56:15 +01:00
Jasmin Bom
a8bade4d73 Fix a bunch of tests
Looks like it's once again time for: Telegram changed some weird internal stuff and how thumbnails take up either 4 times as much space or half as much space. Oh and they also seemingly randomized the width and height of said thumbnails....
2019-01-30 20:40:53 +01:00
Jasmin Bom
e08afe7fb2 Fix flake8 errors that only show in CI?? 2019-01-30 20:20:35 +01:00
Gregory Petukhov
3e8d71582d Fix #1328: custom timeout argument does not work (#1330)
* Fix #1328: custom timeout argument does not work

* Remove unused import
2019-01-30 19:38:15 +01:00
Tanuj
c03160c07f Add convenience classmethods for InlineKeyboardMarkup (fixes #1186) (#1260)
* Add convenience classmethods for InlineKeyboardMarkup (#1186)

* Switch to row and column methods

* Also add convenience classmethods for ReplyKeyboardMarkup

* Add some simple tests
2019-01-04 21:04:45 +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
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
Pieter Schutz
d2e2fe9ccc fix last flake8 errors 2018-11-01 10:52:36 +01:00
Pieter Schutz
76a72e9742 fix last flake8 errors 2018-11-01 10:52:36 +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
Jasmin Bom
c9630ee8c5
Add Conflict error (HTTP error code 409) (#1154)
* Add conflicting bot id to conflict error message.

* Add test and comment to conflict error

* Don't extract bot id in Conflict exception per PR comments
2018-10-29 22:08:52 +01:00
Eldinnie
9d99660ba9 Change MAX_CAPTION_LENGTH to 1024 (#1262)
* update MAX_CAPTION_LENGTH

Telegram silently changed the max length for captions to 1024 chars.

* Update test_constants.py

* change docstrings to reflect new length

* remove message

* clear message and proper match
2018-10-16 19:51:57 +02:00
Jasmin Bom
eca0ccf6b3 Update tests to support new test bots 2018-10-14 12:15:27 +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
Eldinnie
0bbca65a95
add sleep to bailout error test (#1241)
Hopefully it won;t hit the race condition so often on appveyor
2018-10-02 09:00:38 +02:00
Pieter Schutz
8731365911 Merge branch 'master' into V12 2018-10-01 21:12:21 +02:00
Jasmin Bom
4c66ba3a8d
Allow filenames without dots in them when sending files (#1228)
* Fix issue 1227 by allowing filenames without dots in them

* Touch new test data file

* Satisfy flake8
2018-09-30 12:07:17 +02:00
Ehsan
3829666a53 add text mention for message parse (#1206)
* add text mention for message parse

* add author

* Update .gitignore
2018-09-25 20:07:55 +02:00
Pieter Schutz
af2d716129 Fix test_persistence
* To work with new CommandHandler
* To make tests context-based
2018-09-21 13:57:36 +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
Jasmin Bom
e247fa7c2c
Fix uploading files with unicode filenames (#1214)
* Patch urllib3RequestField to make it *not* support RFC2231

* Add new required test data file

* Fix on py2

* Remove weird legacy code from inputfile

Not needed anymore, and also makes it not work... so that was not great
2018-09-10 21:08:05 +02:00
Kirill Vasin
f2b06728e9 Replace http.server with Tornado (#1191)
Fixes #1189
2018-09-08 23:25:48 +03:00
Jasmin Bom
b2fb4264a3 Small test fixes to make them more stable on travis CI 2018-09-07 16:07:27 +02:00
Jasmin Bom
09bdb88822
Bot api 4.1 (#1198)
* Fix passport decryption failing at random times

Sometimes a decrypted secret was being treated as b64 and therefore got decoded even further. Fix by decoding b64 right before call to decrypt so we have better control of when not to do it

* Bot api 4.1

Telegram passport 1.1
Added support for middle names.
Added support for translations for documents
Add errors for translations for documents
Added support for requesting names in the language of the user's country of residence
Replaced the payload parameter with the new parameter nonce

NOTE: Scope stuff is NOT implemented, as we wanna STRONGLY encourage users to use the telegram provided SDKs anyway (and not generate telegram auth links in their bot, but rather on a server)

* Minor fixes

* Add hash to EncryptedPassportElement

For use with PassportElementErrorUnspecified apparently
2018-09-01 16:58:08 +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
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
Marcos Del Sol Vives
d2059ed184 Fix ProcessLookupError if process finishes before we kill it (#1126) 2018-06-01 23:27:09 +03: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
42daf96d20 mention_markdown/html py2 fixes + unitests (#1112)
Fixes #1108
2018-05-28 23:51:39 +03: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
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
Noam Meltzer
0a8abccc78
InputFile: Fix proper naming of file when reading from subprocess.PIPE (#1079) 2018-05-03 00:17:54 +03:00
Noam Meltzer
38d6f4d9f2
Inputfile encode filenames (#1086)
* Unitest to recreate issue #1083

* InputFile: Encode unicode filenames

Fixes #1083
2018-04-25 23:13:00 +03: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
Jannes Höke
b77b329dd6 Handle utf8 decoding errors (#1076) 2018-04-17 07:40:02 +03:00
Wagner Macedo
5efd5e2586 CommandHandler faster check (#1074)
Fixes #1073
2018-04-17 07:37:29 +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
Or Bin
712baf0c07 Added video note filter (#1067) 2018-04-14 21:53:54 +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
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
Eldinnie
e182046376 Fix in telegram.Message (#1042)
* Fix in telegram.Message

The `_parse_(html|markdown)` methods now properly return `None` on an empty `Message.text` or an empty `Message.caption`

* As per CR
2018-03-16 21:42:39 +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
f6332d45a8
Improved File.download (#1019)
- File.download_as_bytearray - new method to get a d/led file as bytearray
   This is much more convenient and straight forward than using a file
   object.

 - File.download(): Now returns a meaningful return value

 - File.download*(): New and/or better unitests
2018-03-01 10:10:04 +02:00
Eldinnie
b275031a16 Add Message caption html/markdown methods (#1013)
Closes #1010
2018-02-22 17:38:54 +02:00
Eldinnie
a9a503b9c3 Increase timeouts on creation of fixtures in tests (#1015) 2018-02-22 15:13:57 +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
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
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
Joscha Götzer
9338dc4697 Added utils.helpers.effective_message_type (#826) 2018-02-15 11:21:19 +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
Oleg
62e76f1fba bot.py: Add shortcut method reply_media_group (#994)
fixes #936
2018-02-12 15:51:18 +02:00
Joscha Götzer
f0dfdfb203 bot.py: Add shortcut methods reply_{markdown,html} (#827) 2018-02-12 15:39:46 +02:00
Eldinnie
d5c9212f2e Add two arguments to send_invoice (#986)
Telegram silently added `send_phone_number_to_provider` and `send_email_to_provider` to the send_invoice method.
2018-02-10 17:54:09 +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
Eldinnie
820f4e1d59 Fix user profile photo unitests (#967)
Telegram changed something again.
2018-01-09 17:56:43 +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
graynk
d347c0d45e User.full_name convinience property (#949)
Fixes #943
2017-12-30 15:13:06 +02:00
Daniel Reed
5c8470e552 Store bot in PreCheckoutQuery (#953)
Fixes #937
2017-12-30 14:48:38 +02:00
Eldinnie
042d4bb2a4
add support for 3.5 api (#920)
* add support for 3.5 api

* removed "unused" import by accident

* Hardcoded values

Appearantly TG decided to change the size of a send image (again)

* test_official

* Improve coverage

* Finishing up

* spelling error

* pytest fixed tot < than 3.3 for python 3.3 support

* flake8

* rollback requirements

* as per CR

* object for provider_data

Make it possible to send an object that will be json-serialized for send_invoice + tests

* shorten error message

* using string_types
2017-12-08 22:38:59 +01: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
Eldinnie
bfad2fa1f3 support 3.4 API (#865) 2017-10-14 21:03:02 +03:00
Eldinnie
d75e0f6014 Stabilize Coverage (#846)
* test_error added

* ignore unstables for coverage
2017-09-25 20:58:10 +02:00
Eldinnie
dd20237f55 Enable appveyor (#823)
* modify tests and appveyor.yml

* modify test_meta

* Add pytest-cov to requirements

* appveyor.yaml adjustment

* another try

* oops

* skipping jobqueue tests on appveyor

appveyor is terrible at precise timings.

* adding reasons to skips

* modify test_official

* coverage trouble

* Make it look good

* appveyor.yml

* codecov flags

* oops

* update appveyor.yml

* shorten decorators

* removed redundant quotes
2017-09-14 17:54:00 +02:00
Eldinnie
4fe4eea893 only run coverage for relevant test (#818)
* fix test troubles

* another try

* testing travis build?

* trying pytestmark
2017-09-09 23:37:07 +02:00
Eldinnie
e13cd58773 Fix sticker tests (#807)
* Fix sticker tests

Added flaky, timeout and xfails to the stickerset bot method tests.

* Make sure the first stickersettest worked before modifying in test 2

* some mor changes to make the deletion more stable
2017-09-01 08:47:34 +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
Eldinnie
eae139d3e9 remove de_json() (#789)
* remove de_json()

* Remove or rename obsolete tests

* fixes according to rc
2017-09-01 08:45:22 +02:00
Jacob Bom
8cda3f7a71 Turn on branch coverage (#790)
* Run pre commit hook tests on all platforms TEMPORARILY

* Use os.system instead of subprocess.call

* Turn on branch coverage

* Let's try this then

* More testing!

* Update test_meta.py
2017-09-01 08:44:45 +02:00
Jacob Bom
d7929a8de4 Test UserProfilePhotos (#796) 2017-09-01 08:44:26 +02:00
Eldinnie
6cd0c14c02 Show what parameter/attribute is missing in test_offical (#808)
* Show what parameter/attribute is missing in test_offical

* Only run test_official on py3.6

Down from 3.5 and 3.6
2017-09-01 08:40:52 +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
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