1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +03:00
Этот коммит содержится в:
Max Melentiev
2016-05-31 10:53:38 +03:00
родитель 33a1220c5f
Коммит e557a217eb
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@@ -50,7 +50,7 @@ module Telegram
# ControllerClass.new(bot, from: telegram_user, chat: telegram_chat).
# process(:help, *args)
#
class UpdatesController < AbstractController::Base
class UpdatesController < AbstractController::Base # rubocop:disable ClassLength
abstract!
require 'telegram/bot/updates_controller/session'
@@ -84,6 +84,7 @@ module Telegram
inline_query
chosen_inline_result
callback_query
edited_message
).freeze
CMD_REGEX = %r{\A/([a-z\d_]{,31})(@(\S+))?(\s|$)}i
CONFLICT_CMD_REGEX = Regexp.new("^(#{PAYLOAD_TYPES.join('|')}|\\d)")
@@ -180,6 +181,11 @@ module Telegram
[true, cmd, args] if cmd
end
# It doesn't extract commands from edited messages. Just process
# them as usual ones.
def action_for_edited_message
end
def action_for_inline_query
[false, payload_type, [payload['query'], payload['offset']]]
end

Просмотреть файл

@@ -102,6 +102,11 @@ RSpec.describe Telegram::Bot::UpdatesController do
it { should eq [false, payload_type, payload.values_at(:data)] }
end
context 'when payload is edited_message' do
let(:payload_type) { 'edited_message' }
it { should eq [false, payload_type, [payload]] }
end
context 'when payload is not supported' do
let(:payload_type) { '_unsupported_' }
it { should eq [false, :unsupported_payload_type, []] }