Commit graph

245 commits

Author SHA1 Message Date
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
Jacob Bom
0afe83ac30 Merge branch 'master' into official-test 2017-06-20 21:42:33 +02:00
Jacob Bom
faddb92395 Clean up Bot code a bit (#673)
* Clean up Bot code a bit

- Move decorators to module. It really wasn't clear how decorators inside classes work, and why they didn't have a self parameter, but still wasn't static. This also makes them effectively private without having to underscore them, which I think we should have done long time ago atm. Note that this might break backwards compatibility slightly (only if people are daft enough to have used the decorators themselves)
- Don't call _message_wrapper directly. Ever. Instead always use the message decorator, since it's what it's there for. Closes #627
- Don't use the message decorator if the method isn't supposed to return a message. The decorator could handle values like True (which is often the return value), but to someone reading the code, it seems like it's a message returning method even when it wasn't.
- Always document timeout and **kwargs
- Log all methods

* Add test to make sure timeout propagates properly despite decorators
2017-06-18 12:14:24 +02:00
saschalalala
9b5e014a0a Simplification of boolean checks (#662)
* Simplification of boolean checks

* Cast ok to bool for Telegram API json encoding
2017-06-18 12:09:32 +02:00
Jacob Bom
9b84a558fb Fix width+height in sendVideo + game in Message
First errors found by the official test thingy
2017-06-14 13:48:45 +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
alateas
6877886f7d Change hard-coded 20. to timeout parameter (#663)
* Change hard-coded 20. to timeout paramter

Passing timeout parameter to _message_wrapper in send_audio instead of hard-coded 20 seconds

* add myself to contributors
2017-06-14 00:01:38 +02:00
Jeff
a68e0ad044 bugfixes on error in answer_shipping_query and answer_precheckout_query 2017-06-11 03:45:48 +08:00
Jeff
4247dc0e21 tiny changes upon PR review 2017-06-08 09:47:19 +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
Noam Meltzer
cd24bb4ba5 payment: Small fixes
- Semantic fixes bot.py (if XXX is not None: ...).
 - Documentation fixes (arguments which are optional).
2017-05-26 20:02:18 +03:00
Noam Meltzer
a5bfc52326 videonote: Semantic fix according to CR 2017-05-26 18:36:21 +03:00
Jacob Bom
a7044562af Fix stuff as per @tsnoam's comments 2017-05-25 14:16:53 +02:00
Jeff
f314915954 fix typo again 2017-05-23 16:26:04 +08:00
Jeff
1bf0078573 add missing "need_email" in sendInvoice, fix pep8/flake 2017-05-23 16:21:45 +08:00
Jeff
43f4128b31 fix answer* methods not sending api requests 2017-05-22 22:55:19 +08:00
Jeff
1142953108 add checks for answer* methods 2017-05-22 22:47:35 +08:00
Jeff
1e250f2415 add kwargs to answer* methods 2017-05-22 21:37:15 +08:00
Jeff
8f2f29c7d4 fix typo, add bot and kwargs to class init 2017-05-22 21:32:42 +08:00
Jacob Bom
48fa3d975b Merge branch 'videonote' into beta
# Conflicts:
#	telegram/__init__.py
#	telegram/message.py
2017-05-21 15:45:20 +02:00
Jacob Bom
2746ab77e5 Add sendVideoNote to Bot 2017-05-20 19:35:55 +02:00
Jacob Bom
76db279624 We have to send and array... that's new... 2017-05-20 18:46:39 +02:00
Jacob Bom
834c1ab3c5 Merge branch 'master' into payment 2017-05-19 20:25:46 +02:00
Evgen
c2c5452829 Updated docstring in deleteMessage methods (#618)
* Removed "undocumented" notice

* Updated docstring according to Bot API documentation

* Removed extra line
2017-05-19 20:21:20 +02:00
Jacob Bom
8be57198b4 New payment bot methods
sendInvoice, answerShippingQuery, and answerPreCheckoutQuery
2017-05-19 19:46:42 +02:00
evgfilim1
578627feca Fixed and added some type hints in docstrings 2017-05-17 21:41:08 +05: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
f3b75d95c4 Implemented undocumented 'deleteMessage' method (#602)
* Implemented `Bot.delete_message()` and `Message.delete()` methods

* Added tests for `Bot.delete_message()` and `Messsage.delete()`

* Added myself to `AUTHORS.rst`

* Using `assertRaisesRegexp` instead of `assertRaisesRegex` in tests

Now tests can run on Python 2.7 without raising 'AttributeError'

* Fix docstring

Added a warning to the docstring describing that this method is undocumented and not guaranteed to work
2017-05-12 17:40:57 +02:00
Rahiel Kasim
9f3afa5fa2 prefer snake_case for telegram.Bot methods 2017-05-07 16:09:58 +02:00
Noam Meltzer
4c8d1c9a5e Fix Bot.sendDocument 2017-03-11 23:55:26 +02:00
Noam Meltzer
2b930c221d Sane default for sending files timeout 2017-03-11 16:23:43 +02:00
Jannes Höke
a1ade408b0 🔀 Merge master into dec04
#483
2017-02-27 14:39:18 +01:00
Jannes Höke
2954ca2bad 🔀 Merge master into fix-460
#494
2017-02-27 14:33:58 +01:00
Jannes Höke
cd38bdbed5 bot.py: add delete_webhook alias 2017-01-16 00:28:26 +01:00
Jannes Höke
975d193441 Merge branch 'master' into dec04 2017-01-16 00:15:09 +01:00
Jacob Bom
27b2fd64b7 More IDE friendliness 2017-01-09 19:29:05 +01:00
Noam Meltzer
bd96771a7a Fix typo 2017-01-07 23:05:58 +02:00
Noam Meltzer
58dddfd9c3 Control the read timeout from telegram servers
refs #495
refs #364
2017-01-07 20:13:08 +02:00
Jannes Höke
a1a8628c75 bot.py: fix argument order, setWebhook: make 'url' and 'webhook_url' mutually exclusive 2016-12-14 17:38:06 +01:00
Jannes Höke
92dc9b81ce bot.py: implement changes of december 04 (bot api 2.3.1) 2016-12-14 00:50:34 +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
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
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
Noam Meltzer
78088f4f6a Fix grammer: 'a object' -> 'an object' 2016-10-17 01:22:40 +03:00
Noam Meltzer
59fa717023 Documentation improvements + small style fixes 2016-10-17 01:11:20 +03:00
Noam Meltzer
31cab0d1b4 editMessageCaption & editMessageReplyMarkup: more validation on input 2016-10-17 01:09:44 +03:00
Jacob Bom
b610316667 Use explicit kwargs for all bot methods.
This improves support for many IDEs' autocompletion.
2016-10-16 15:54:48 +02:00
Jacob Bom
3754cdafb2 send_game has differnt kwargs. 2016-10-16 12:41:12 +02:00
Jacob Bom
305ff93018 set_game_score might return True 2016-10-16 12:41:12 +02:00
Noam Meltzer
53a574bbbb Improve unitests coverage 2016-10-13 22:52:53 +03:00
Noam Meltzer
5b8efe0c14 upgrade yapf to ver 0.12.2 2016-10-12 23:56:57 +03:00
Patrick Hofmann
8cab735342 small fix for game related parts
* bot.py fix copy paste error in url
* callbackquery.py make data field optional
* message.py introduce optional game field
2016-10-06 17:52:53 +02:00
Noam Meltzer
d70fc48e94 getGameHighScores(): added documentation + fixed copy-paste errors 2016-10-04 01:57:19 +03:00
Noam Meltzer
36192912c2 setGameScore: fixes
- fix copy/paste errors
 - return Message object
2016-10-04 01:56:05 +03:00
Noam Meltzer
d5567cd9cd sendGame(): mall fixes 2016-10-04 01:37:44 +03:00
Noam Meltzer
9b74625d4a answerCallbackQuery: fix copy/paste: show_alert -> url 2016-10-04 00:55:29 +03:00
Jacob Bom
358dd795c7 Add the rest of game_ methods to bot. 2016-10-03 20:43:02 +02:00
Jacob Bom
151a441af7 Add send_game 2016-10-03 20:40:17 +02:00
Noam Meltzer
e8a34d8eef cosmetic fixes and documentation for getWebhookInfo 2016-10-03 20:43:10 +03:00
Jacob Bom
34c62a633b Add url to answerCallbackQuery 2016-10-03 15:25:07 +02:00
Jacob Bom
868d9217bc Add WebhookInfo and getWebhookInfo
Still needs tests though
2016-10-03 15:16:43 +02:00
Jacob Bom
f7ede4baea Add caption fields to voice and audio
Or at least the methods/classes for sending.
2016-10-03 15:05:49 +02:00
Jannes Höke
5116a77221 Class methods (#362)
* bot.py: add create_references method

* create bot reference in webhook handler, use create_references on new updates

* message.py: implement reply_text

* echobot2.py: use Message.reply_text

* fix create_references in webhook handler

* add some more instance methods

* Chat.kick_member and unban_member

* bot.py: Create bot references in outgoing messages

* add tests for everything testable

* test_updater.py: add create_references method to MockBot

* remove Bot.create_references and refactor TelegramObject.de_json to take the additional parameter bot

* List bot as named kwarg where used

* file.py: Use Bot.request property instead of Bot._request attr
2016-09-20 06:36:55 +02:00
Noam Meltzer
e4a132c0e4 Reusable dispatcher (#402)
* Create a Request class which maintains its own connection pool
* When creating a Bot instance a new Request instance will be created if one wasn't supplied.
* Updater is responsible for creating a Request instance if a Bot instance wasn't provided.
* Dispatcher: add method to run async functions without decorator
* Dispatcher can now run as a singleton (allowing run_async decorator to work) as it always did and as multiple instances (where run_async decorator will raise RuntimeError)
2016-09-06 16:38:07 +03:00
Rahiel Kasim
da87d4ba78 fix yapf 2016-08-26 11:17:05 +02:00
Rahiel Kasim
00bba73673 drop Python 2.6 support (closes #245) (#386)
* drop Python 2.6 support (closes #245)

* fix NullHandler import

* README: explicitly mention Py3 and PyPy compatibility
2016-08-20 22:01:07 +02:00
leandrotoledo
bbbc622517 Adds @message decorator to editMessageText #320 2016-06-03 13:28:29 -04:00
Noam Meltzer
7e7acdeb23 set default network_delay to 5 seconds
fixes #309
2016-05-28 19:34:16 +03:00
Leandro Toledo
9a13de4a96 Merge remote-tracking branch 'origin/master' into bot2.1
Conflicts:
	telegram/bot.py
	tests/test_bot.py
2016-05-26 16:15:50 -03:00
Noam Meltzer
561f1c3f02 bot: validate token does not contain white spaces (#306)
in addition move validation code from validate.py into bot.py and delete
the former file
2016-05-26 22:09:14 +03:00
Rahiel Kasim
1abbca3324 bot.py: fix snake_case alias 2016-05-26 15:32:02 +02:00
Leandro Toledo
37c7af2e14 Add docstrings #302 2016-05-25 21:41:12 -03:00
Leandro Toledo
ab2f6e13c9 Add kwargs to API calls #302 2016-05-23 20:43:17 -03:00
Leandro Toledo
d7e226ec0f Add new Bot methods and ChatMember class #302 2016-05-23 20:22:31 -03:00
Leandro Toledo
49122d6a99 Remove \ from base code #259 2016-05-14 23:26:56 -03:00
Leandro Toledo
d445d35ceb Running yapf for codebase #259 2016-05-14 22:46:40 -03:00
Rahiel Kasim
6e9f30ca6e fix merge conflict snakes 2016-05-02 16:37:45 +02:00
Djaler
4b0be65a76 Fix Bot.getUpdates() docstring 2016-05-01 15:25:07 +03:00
Rahiel Kasim
5971cb35f8 fix merge conflict snakes with master 2016-04-30 14:56:48 +02:00
Jannes Höke
d940afa718 merge master into cr4.0 2016-04-29 18:37:41 +02:00
Rahiel Kasim
ec15e866be add snake_case aliases for CamelCase methods 2016-04-28 12:20:42 +02:00
Noam Meltzer
0c74b3cfb9 bot.py + request.py: network_delay is unique for getUpdates 2016-04-28 01:41:32 +03:00
Jannes Höke
7f463131aa re-order imports 2016-04-27 00:28:21 +02:00
Noam Meltzer
a686db2c6f bot.Bot: fix class docstring 2016-04-26 23:31:29 +03:00
leandrotoledo
1f29093027 Merge branch 'unittest-bot2.0' of https://github.com/python-telegram-bot/python-telegram-bot into unittest-bot2.0 2016-04-26 14:17:59 -03:00
Noam Meltzer
49385493f4 bot: 'if X is not None' is cleaner approach 2016-04-26 17:47:37 +03:00
Leandro Toledo
fc7c161018 Merge remote-tracking branch 'origin/master' into unittest-bot2.0 2016-04-24 14:33:17 -03:00
Andrea Giove
39ba575a4d
Missing a comma 2016-04-24 17:54:36 +02:00
Andrea Giove
87ac962805
Added caption paramenter to sendDocument method 2016-04-24 17:51:15 +02:00
Leandro Toledo
14cb13acfd Adds @message decorator to editMessageText 2016-04-24 11:19:37 -03:00
Leandro Toledo
4ecb4911db Adds @message decorator to editMessageText 2016-04-24 11:18:16 -03:00
Leandro Toledo
adc3104214 Add timeout and network_delay kwargs to all bot methods. 2016-04-24 10:06:59 -03:00
Leandro Toledo
b444cd7bce Adding new modules to docs #232 2016-04-22 11:07:44 -03:00
Leandro Toledo
0669c72fe3 Fixing little princes Python 2.6 string format arg #232 2016-04-21 12:18:51 -03:00
Leandro Toledo
5315e072cb PEP8 for Py2 #232 2016-04-21 11:59:18 -03:00
Leandro Toledo
bb36c725af More refactoring and docstrings #232 2016-04-21 09:21:12 -03:00
Leandro Toledo
ba7e1cada7 Bot class refactor and its docstrings #232 2016-04-21 08:15:38 -03:00
Leandro Toledo
9a96ad8efd Unused import #232 2016-04-19 09:12:22 -03:00
Leandro Toledo
fc277d7393 Refactor of telegram.Bot class and docstrings #232 2016-04-19 09:04:25 -03:00