зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-07 11:25:52 +03:00
Updated readme, prepare to 0.7.0
Этот коммит содержится в:
@@ -5,6 +5,8 @@
|
|||||||
- Changed action methods signature
|
- Changed action methods signature
|
||||||
- `#inline_query(payload) -> #inline_query(query, offset)`
|
- `#inline_query(payload) -> #inline_query(query, offset)`
|
||||||
- `#chosen_inline_result(payload)` -> `#chosen_inline_result(result_id, query)`
|
- `#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
|
# 0.6.0
|
||||||
|
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -17,7 +17,8 @@ Package contains:
|
|||||||
- Poller with automatic source-reloader for development env.
|
- Poller with automatic source-reloader for development env.
|
||||||
- Rake tasks to update webhook urls.
|
- 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!
|
Run it on your local machine in 1 minute!
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -151,6 +152,8 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Optional typecasting
|
||||||
|
|
||||||
You can enable typecasting of `update` with `telegram-bot-types` by including
|
You can enable typecasting of `update` with `telegram-bot-types` by including
|
||||||
`Telegram::Bot::UpdatesPoller::TypedUpdate`:
|
`Telegram::Bot::UpdatesPoller::TypedUpdate`:
|
||||||
|
|
||||||
@@ -164,6 +167,8 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Session
|
||||||
|
|
||||||
There is support for sessions using `ActiveSupport::Cache` stores.
|
There is support for sessions using `ActiveSupport::Cache` stores.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -197,6 +202,8 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Message context
|
||||||
|
|
||||||
It's usual to support chain of messages like BotFather: after receiving command
|
It's usual to support chain of messages like BotFather: after receiving command
|
||||||
it asks you for additional argument. There is `MessageContext` for this:
|
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
|
`my_ctx_callback_query('smth...')` when there is such action method. Otherwise
|
||||||
it'll call `callback_query('my_ctx:smth...')` as usual.
|
it'll call `callback_query('my_ctx:smth...')` as usual.
|
||||||
|
|
||||||
|
#### Processesing updates
|
||||||
|
|
||||||
To process update run:
|
To process update run:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -283,7 +292,8 @@ telegram_webhooks bot => TelegramChatController,
|
|||||||
# You can override this options or specify others:
|
# You can override this options or specify others:
|
||||||
telegram_webhooks TelegramController, as: :my_webhook
|
telegram_webhooks TelegramController, as: :my_webhook
|
||||||
telegram_webhooks bot => [TelegramChatController, as: :chat_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
|
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
|
### 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`:
|
or just add `botan` key in `secrets.yml`:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ module Telegram
|
|||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
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)
|
def stub_all!(enabled = true)
|
||||||
Client.extend(StubbedConstructor) unless Client < StubbedConstructor
|
Client.extend(StubbedConstructor) unless Client < StubbedConstructor
|
||||||
return @_stub_all = enabled unless block_given?
|
return @_stub_all = enabled unless block_given?
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Telegram
|
module Telegram
|
||||||
module Bot
|
module Bot
|
||||||
VERSION = '0.6.0'.freeze
|
VERSION = '0.7.0'.freeze
|
||||||
|
|
||||||
def self.gem_version
|
def self.gem_version
|
||||||
Gem::Version.new VERSION
|
Gem::Version.new VERSION
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user