From 8eb6e034fe9cd528fb62465d73a53e29346e6c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Conde=20G=C3=B3mez?= Date: Tue, 6 Oct 2015 12:11:42 +0200 Subject: [PATCH] Update README with webhooks information. --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5853544..e46ce0a 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ To start the bot, simply open up a terminal and enter `python echo_bot.py` to ru All types are defined in types.py. They are all completely in line with the [Telegram API's definition of the types](https://core.telegram.org/bots/api#available-types), except for the Message's `from` field, which is renamed to `from_user` (because `from` is a Python reserved token). Thus, attributes such as `message_id` can be accessed directly with `message.message_id`. Note that `message.chat` can be either an instance of `User` or `GroupChat` (see [How can I distinguish a User and a GroupChat in message.chat?](#how-can-i-distinguish-a-user-and-a-groupchat-in-messagechat)). -The Message object also has a `content_type`attribute, which defines the type of the Message. `content_type` can be one of the following strings: +The Message object also has a `content_type`attribute, which defines the type of the Message. `content_type` can be one of the following strings: 'text', 'audio', 'document', 'photo', 'sticker', 'video', 'location', 'contact', 'new_chat_participant', 'left_chat_participant', 'new_chat_title', 'new_chat_photo', 'delete_chat_photo', 'group_chat_created'. ### Methods @@ -208,7 +208,7 @@ tb.polling(none_stop=False, interval=0, block=True) user = tb.get_me() # setWebhook -tb.set_webhook(url="http://example.com", cert=open('mycert.pem')) +tb.set_webhook(url="http://example.com", certificate=open('mycert.pem')) # unset webhook tb.remove_webhook() @@ -373,8 +373,10 @@ bot.set_update_listener(handle_messages) bot.polling() ``` -### Using web hooks -If you prefer using web hooks to the getUpdates method, you can use the `process_new_messages(messages)` function in TeleBot to make it process the messages that you supply. It takes a list of Message objects. This function is still incubating. +### Using webhooks +When using webhooks telegram sends one Update per call, for processing it you should call process_new_messages([update.message]) when you recieve it. + +There are some examples using webhooks in the *examples/webhook_examples* directory. ### Logging @@ -423,4 +425,4 @@ We now have a Telegram Channel as well! Keep yourself up to date with API change ## Bots using this API * [SiteAlert bot](https://telegram.me/SiteAlert_bot) ([source](https://github.com/ilteoood/SiteAlert-Python)) by *ilteoood* - Monitors websites and sends a notification on changes -Want to have your bot listed here? Send a Telegram message to @eternnoir or @pevdh. \ No newline at end of file +Want to have your bot listed here? Send a Telegram message to @eternnoir or @pevdh.