From a52e7ff31b82d983c14b652db6d63fad8c5eead0 Mon Sep 17 00:00:00 2001 From: Max Melentiev Date: Thu, 12 May 2016 14:35:36 +0300 Subject: [PATCH] Updated readme, prepare to 0.7.0 --- CHANGELOG.md | 2 ++ README.md | 16 +++++++++++++--- lib/telegram/bot/client_stub.rb | 3 ++- lib/telegram/bot/version.rb | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 509edb8..9a1adc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - Changed action methods signature - `#inline_query(payload) -> #inline_query(query, offset)` - `#chosen_inline_result(payload)` -> `#chosen_inline_result(result_id, query)` +- MessageContext doesn't use second #process call to run contextual action. +- Botan.io metrics. # 0.6.0 diff --git a/README.md b/README.md index f4e5d4f..779b2a3 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ Package contains: - Poller with automatic source-reloader for development env. - Rake tasks to update webhook urls. -Here is sample [telegram_bot_app](https://github.com/telegram-bot-rb/telegram_bot_app). +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! ## Installation @@ -151,6 +152,8 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController end ``` +#### Optional typecasting + You can enable typecasting of `update` with `telegram-bot-types` by including `Telegram::Bot::UpdatesPoller::TypedUpdate`: @@ -164,6 +167,8 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController end ``` +#### Session + There is support for sessions using `ActiveSupport::Cache` stores. ```ruby @@ -197,6 +202,8 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController end ``` +#### Message context + It's usual to support chain of messages like BotFather: after receiving command it asks you for additional argument. There is `MessageContext` for this: @@ -242,6 +249,8 @@ data. If data has a prefix with colon like this `my_ctx:smth...` it'll call `my_ctx_callback_query('smth...')` when there is such action method. Otherwise it'll call `callback_query('my_ctx:smth...')` as usual. +#### Processesing updates + To process update run: ```ruby @@ -283,7 +292,8 @@ telegram_webhooks bot => TelegramChatController, # You can override this options or specify others: telegram_webhooks TelegramController, as: :my_webhook telegram_webhooks bot => [TelegramChatController, as: :chat_webhook], - other_bot => [TelegramAuctionController, + other_bot => TelegramAuctionController, + admin_chat: TelegramAdminChatController ``` For Rack applications you can also use `Telegram::Bot::Middleware` or just @@ -328,7 +338,7 @@ Certificate can be specified with `CERT=path/to/cert`. ### Botan.io metrics -Initialize with `bot = Bot.new(token, botan: 'botan token')` +Initialize with `bot = Telegram::Bot::Client.new(token, botan: 'botan token')` or just add `botan` key in `secrets.yml`: ```yml diff --git a/lib/telegram/bot/client_stub.rb b/lib/telegram/bot/client_stub.rb index 6f9ef22..5a590b9 100644 --- a/lib/telegram/bot/client_stub.rb +++ b/lib/telegram/bot/client_stub.rb @@ -15,7 +15,8 @@ module Telegram end class << self - # Makes all + # Any call to Client.new will return ClientStub instance when `enabled` is true. + # Can be used with a block. def stub_all!(enabled = true) Client.extend(StubbedConstructor) unless Client < StubbedConstructor return @_stub_all = enabled unless block_given? diff --git a/lib/telegram/bot/version.rb b/lib/telegram/bot/version.rb index e33c1ee..d1439db 100644 --- a/lib/telegram/bot/version.rb +++ b/lib/telegram/bot/version.rb @@ -1,6 +1,6 @@ module Telegram module Bot - VERSION = '0.6.0'.freeze + VERSION = '0.7.0'.freeze def self.gem_version Gem::Version.new VERSION