README.md in telegram-bot-ruby-0.3.11 vs README.md in telegram-bot-ruby-0.4.0
- old
+ new
@@ -48,10 +48,14 @@
Note that `bot.api` object implements [Telegram Bot API methods](https://core.telegram.org/bots/api#available-methods) as is. So you can invoke any method inside the block without any problems. All methods are available in both *snake_case* and *camelCase* notations.
Same thing about `message` object - it implements [Message](https://core.telegram.org/bots/api#message) spec, so you always know what to expect from it.
+## Webhooks
+
+If you are going to use [webhooks](https://core.telegram.org/bots/api#setwebhook) instead of [long polling](https://core.telegram.org/bots/api#getupdates), you need to implement your own webhook callbacks server. Take a look at [this repo](https://github.com/solyaris/BOTServer) as an example.
+
## Custom keyboards
You can use your own [custom keyboards](https://core.telegram.org/bots#keyboards). Here is an example:
```ruby
@@ -70,10 +74,35 @@
bot.api.send_message(chat_id: message.chat.id, text: 'Sorry to see you go :(', reply_markup: kb)
end
end
```
+## Inline bots
+
+If you are going to create [inline bot](https://core.telegram.org/bots/inline), check the example below:
+
+```ruby
+bot.listen do |message|
+ case message
+ when Telegram::Bot::Types::InlineQuery
+ results = [
+ Telegram::Bot::Types::InlineQueryResultArticle
+ .new(id: 1, title: 'First article', message_text: 'Very interesting text goes here.'),
+ Telegram::Bot::Types::InlineQueryResultArticle
+ .new(id: 2, title: 'Second article', message_text: 'Another interesting text here.')
+ ]
+ bot.api.answer_inline_query(inline_query_id: message.id, results: results)
+ when Telegram::Bot::Types::Message
+ bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}!")
+ end
+end
+```
+
+Now, with `inline` mode enabled, your `message` object can be an instance of [Message](https://core.telegram.org/bots/api#message), [InlineQuery](https://core.telegram.org/bots/api#inlinequery) or [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). That's why you need to check type of each message and decide how to handle it.
+
+Using `answer_inline_query` you can send query results to user. `results` field must be an array of [query result objects](https://core.telegram.org/bots/api#inlinequeryresult).
+
## File upload
Your bot can even upload files ([photos](https://core.telegram.org/bots/api#sendphoto), [audio](https://core.telegram.org/bots/api#sendaudio), [documents](https://core.telegram.org/bots/api#senddocument), [stickers](https://core.telegram.org/bots/api#sendsticker), [video](https://core.telegram.org/bots/api#sendvideo)) to Telegram servers. Just like this:
```ruby
@@ -130,9 +159,14 @@
Sometimes you need to do some heavy work in another thread and send response from there. In this case you have to increase your connection pool size (by default it's *1*). You can do it by setting env variable `TELEGRAM_BOT_POOL_SIZE`:
```shell
$ TELEGRAM_BOT_POOL_SIZE=4 ruby bot.rb
```
+
+## Boilerplates
+
+If you don't know how to setup database for your bot or how to use it with different languages here are some boilerplates which can help you to start faster:
+- [Ruby Telegram Bot boilerplate](https://github.com/telegram-bots/ruby-telegram-bot-boilerplate)
## Contributing
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)