зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-08-28 15:26:18 +03:00
edit_message helper
Этот коммит содержится в:
14
README.md
14
README.md
@@ -168,6 +168,20 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController
|
||||
end
|
||||
```
|
||||
|
||||
#### Reply helpers
|
||||
|
||||
There are helpers to respond for basic actions. They just set chat/message/query
|
||||
identifiers from update. See `ReplyHelpers` method for more information.
|
||||
Here are this methods signatures:
|
||||
|
||||
```ruby
|
||||
def respond_with(type, params); end
|
||||
def reply_with(type, params); end
|
||||
def answer_inline_query(results, params = {}); end
|
||||
def answer_callback_query(text, params = {}); end
|
||||
def edit_message(type, params = {}); end
|
||||
```
|
||||
|
||||
#### Optional typecasting
|
||||
|
||||
You can enable typecasting of `update` with `telegram-bot-types` by including
|
||||
|
||||
@@ -38,6 +38,19 @@ module Telegram
|
||||
)
|
||||
bot.answer_callback_query(params)
|
||||
end
|
||||
|
||||
# Edit message from callback query.
|
||||
def edit_message(type, params = {})
|
||||
params =
|
||||
if query_id = payload['inline_message_id'] # rubocop:disable AssignmentInCondition
|
||||
params.merge(inline_query_id: query_id)
|
||||
elsif message = payload['message'] # rubocop:disable AssignmentInCondition
|
||||
params.merge(chat_id: message['chat']['id'], message_id: message['message_id'])
|
||||
else
|
||||
raise 'Can not edit message without `inline_message_id` or `message`'
|
||||
end
|
||||
bot.public_send("edit_message_#{type}", params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,4 +48,8 @@ RSpec.describe Telegram::Bot::UpdatesController do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#edit_message' do
|
||||
skip 'TODO'
|
||||
end
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user