README.md in telegram-bot-ruby-0.3.4 vs README.md in telegram-bot-ruby-0.3.5
- old
+ new
@@ -36,19 +36,19 @@
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
case message.text
when '/start'
- bot.api.sendMessage(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}")
+ bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}")
when '/stop'
- bot.api.sendMessage(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}")
+ bot.api.send_message(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}")
end
end
end
```
-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.
+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.
## Custom keyboards
@@ -61,15 +61,15 @@
question = 'London is a capital of which country?'
# See more: https://core.telegram.org/bots/api#replykeyboardmarkup
answers =
Telegram::Bot::Types::ReplyKeyboardMarkup
.new(keyboard: [%w(A B), %w(C D)], one_time_keyboard: true)
- bot.api.sendMessage(chat_id: message.chat.id, text: question, reply_markup: answers)
+ bot.api.send_message(chat_id: message.chat.id, text: question, reply_markup: answers)
when '/stop'
# See more: https://core.telegram.org/bots/api#replykeyboardhide
kb = Telegram::Bot::Types::ReplyKeyboardHide.new(hide_keyboard: true)
- bot.api.sendMessage(chat_id: message.chat.id, text: 'Sorry to see you go :(', reply_markup: kb)
+ bot.api.send_message(chat_id: message.chat.id, text: 'Sorry to see you go :(', reply_markup: kb)
end
end
```
## File upload
@@ -78,11 +78,11 @@
```ruby
bot.listen do |message|
case message.text
when '/photo'
- bot.api.sendPhoto(chat_id: message.chat.id, photo: File.new('~/Desktop/jennifer.jpg'))
+ bot.api.send_photo(chat_id: message.chat.id, photo: File.new('~/Desktop/jennifer.jpg'))
end
end
```
## Logging
@@ -125,10 +125,14 @@
- Telegram's user id (required)
- hash of additional properties (optional)
## Connection pool size
-Sometimes you need to do some heavy work in another thread and send response from where.
+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
+```
## Contributing
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)