README.md in telegram-bot-0.15.3 vs README.md in telegram-bot-0.15.4
- old
+ new
@@ -1,10 +1,10 @@
# Telegram::Bot
[![Gem Version](https://badge.fury.io/rb/telegram-bot.svg)](http://badge.fury.io/rb/telegram-bot)
[![Code Climate](https://codeclimate.com/github/telegram-bot-rb/telegram-bot/badges/gpa.svg)](https://codeclimate.com/github/telegram-bot-rb/telegram-bot)
-[![Build Status](https://travis-ci.org/telegram-bot-rb/telegram-bot.svg)](https://travis-ci.org/telegram-bot-rb/telegram-bot)
+[![Build Status](https://travis-ci.com/telegram-bot-rb/telegram-bot.svg)](https://travis-ci.com/telegram-bot-rb/telegram-bot)
Tools for developing Telegram bots. Best used with Rails, but can be used in
[standalone app](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application).
Supposed to be used in webhook-mode in production, and poller-mode
in development, but you can use poller in production if you want.
@@ -23,29 +23,57 @@
Here is sample [telegram_bot_app](https://github.com/telegram-bot-rb/telegram_bot_app)
with session, keyboards and inline queries.
Run it on your local machine in 1 minute!
And here is [app template](https://github.com/telegram-bot-rb/rails_template)
-to generate clean app in seconds.
+to generate new rails app in seconds.
-Examples and cookbook in [wiki](https://github.com/telegram-bot-rb/telegram-bot/wiki).
+See examples and cookbook in [the wiki](https://github.com/telegram-bot-rb/telegram-bot/wiki).
+## Table of Contents
+
+* [Installation](#installation)
+* [Usage](#usage)
+ * [Configuration](#configuration)
+ * [Configuration in Rails app](#configuration-in-rails-app)
+ * [Client](#client)
+ * [Typed responses](#typed-responses)
+ * [Controller](#controller)
+ * [Reply helpers](#reply-helpers)
+ * [Optional typecasting](#optional-typecasting)
+ * [Session](#session)
+ * [Message context](#message-context)
+ * [Callback queries](#callback-queries)
+ * [Routes in Rails app](#routes-in-rails-app)
+ * [Processing updates](#processing-updates)
+ * [Development & Debugging](#development--debugging)
+ * [Testing](#testing)
+ * [Deployment](#deployment)
+ * [Async mode](#async-mode)
+ * [Limitations](#limitations)
+* [Development](#development)
+* [Contributing](#contributing)
+
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'telegram-bot'
```
And then execute:
- $ bundle
+```
+bundle
+```
Or install it yourself as:
- $ gem install telegram-bot
+```
+gem install telegram-bot
+```
Require if necessary:
```ruby
require 'telegram/bot'
@@ -168,41 +196,45 @@
Bot controllers like usual rails controllers provides features like callbacks,
`rescue_from` and instrumentation.
```ruby
class Telegram::WebhookController < Telegram::Bot::UpdatesController
- # use callbacks like in any other controllers
+ # use callbacks like in any other controller
around_action :with_locale
- # Every update can have one of: message, inline_query, chosen_inline_result,
+ # Every update has one of: message, inline_query, chosen_inline_result,
# callback_query, etc.
- # Define method with same name to respond to this updates.
+ # Define method with the same name to handle this type of update.
def message(message)
- # message can be also accessed via instance method
- message == self.payload # true
# store_message(message['text'])
end
- # This basic methods receives commonly used params:
+ # For the following types of updates commonly used params are passed as arguments,
+ # full payload object is available with `payload` instance method.
#
# message(payload)
# inline_query(query, offset)
# chosen_inline_result(result_id, query)
# callback_query(data)
# Define public methods ending with `!` to handle commands.
# Command arguments will be parsed and passed to the method.
# Be sure to use splat args and default values to not get errors when
# someone passed more or less arguments in the message.
- def start!(data = nil, *)
- # do_smth_with(data)
+ def start!(word = nil, *other_words)
+ # do_smth_with(word)
+ # full message object is also available via `payload` instance method:
+ # process_raw_message(payload['text'])
+
# There are `chat` & `from` shortcut methods.
- # For callback queries `chat` if taken from `message` when it's available.
+ # For callback queries `chat` is taken from `message` when it's available.
response = from ? "Hello #{from['username']}!" : 'Hi there!'
+
# There is `respond_with` helper to set `chat_id` from received message:
respond_with :message, text: response
+
# `reply_with` also sets `reply_to_message_id`:
reply_with :photo, photo: File.open('party.jpg')
end
private
@@ -221,14 +253,14 @@
end
```
#### Reply helpers
-There are helpers to respond for basic actions. They just set chat/message/query
-identifiers from update. See
+There are helpers for basic responses. They just set chat/message/query
+identifiers from the update. See
[`ReplyHelpers`](https://github.com/telegram-bot-rb/telegram-bot/blob/master/lib/telegram/bot/updates_controller/reply_helpers.rb)
-module for more information. Here are this methods signatures:
+module for more information. Here are these methods signatures:
```ruby
def respond_with(type, params); end
def reply_with(type, params); end
def answer_inline_query(results, params = {}); end
@@ -387,10 +419,10 @@
# (eg. `chat_telegram_webhook`).
# You can override this with `as` option:
telegram_webhook TelegramController, as: :custom_telegram_webhook
```
-#### Processesing updates
+#### Processing updates
To process update with controller call `.dispatch(bot, update)` on it.
There are several options to run it automatically:
- Use webhooks with routes helper (described above).