зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 17:55:52 +03:00
Сравнить коммиты
1 Коммитов
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
99fbe41b16 |
@@ -1,4 +1,4 @@
|
|||||||
# 0.10.1
|
# 0.10.2
|
||||||
|
|
||||||
- Support `(edited_)channel_post` updates.
|
- Support `(edited_)channel_post` updates.
|
||||||
- New methods from 2.3, 2.3.1 API updates.
|
- New methods from 2.3, 2.3.1 API updates.
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ module Telegram
|
|||||||
# ControllerClass.new(bot, from: telegram_user, chat: telegram_chat).
|
# ControllerClass.new(bot, from: telegram_user, chat: telegram_chat).
|
||||||
# process(:help, *args)
|
# process(:help, *args)
|
||||||
#
|
#
|
||||||
class UpdatesController < AbstractController::Base
|
class UpdatesController < AbstractController::Base # rubocop:disable ClassLength
|
||||||
abstract!
|
abstract!
|
||||||
|
|
||||||
require 'telegram/bot/updates_controller/session'
|
require 'telegram/bot/updates_controller/session'
|
||||||
@@ -183,11 +183,13 @@ module Telegram
|
|||||||
cmd &&= self.class.action_for_command(cmd)
|
cmd &&= self.class.action_for_command(cmd)
|
||||||
[true, cmd, args] if cmd
|
[true, cmd, args] if cmd
|
||||||
end
|
end
|
||||||
|
alias_method :action_for_channel_post, :action_for_message
|
||||||
|
|
||||||
# It doesn't extract commands from edited messages. Just process
|
# It doesn't extract commands from edited messages. Just process
|
||||||
# them as usual ones.
|
# them as usual ones.
|
||||||
def action_for_edited_message
|
def action_for_edited_message
|
||||||
end
|
end
|
||||||
|
alias_method :action_for_edited_channel_post, :action_for_edited_message
|
||||||
|
|
||||||
def action_for_inline_query
|
def action_for_inline_query
|
||||||
[false, payload_type, [payload['query'], payload['offset']]]
|
[false, payload_type, [payload['query'], payload['offset']]]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Telegram
|
module Telegram
|
||||||
module Bot
|
module Bot
|
||||||
VERSION = '0.10.1'.freeze
|
VERSION = '0.10.2'.freeze
|
||||||
|
|
||||||
def self.gem_version
|
def self.gem_version
|
||||||
Gem::Version.new VERSION
|
Gem::Version.new VERSION
|
||||||
|
|||||||
@@ -102,42 +102,44 @@ RSpec.describe Telegram::Bot::UpdatesController do
|
|||||||
it { should eq [false, payload_type, payload.values_at(:data)] }
|
it { should eq [false, payload_type, payload.values_at(:data)] }
|
||||||
end
|
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
|
context 'when payload is not supported' do
|
||||||
let(:payload_type) { '_unsupported_' }
|
let(:payload_type) { '_unsupported_' }
|
||||||
it { should eq [false, :unsupported_payload_type, []] }
|
it { should eq [false, :unsupported_payload_type, []] }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when payload is message' do
|
%w(message channel_post).each do |type|
|
||||||
let(:payload_type) { 'message' }
|
context 'when payload is edited_message' do
|
||||||
let(:payload) { {'text' => text} }
|
let(:payload_type) { "edited_#{type}" }
|
||||||
let(:text) { 'test' }
|
it { should eq [false, payload_type, [payload]] }
|
||||||
|
|
||||||
it { should eq [false, payload_type, [payload]] }
|
|
||||||
|
|
||||||
context 'with command' do
|
|
||||||
let(:text) { "/test#{"@#{mention}" if mention} arg 1 2" }
|
|
||||||
let(:mention) {}
|
|
||||||
it { should eq [true, 'test', %w(arg 1 2)] }
|
|
||||||
|
|
||||||
context 'with mention' do
|
|
||||||
let(:mention) { bot.username }
|
|
||||||
it { should eq [true, 'test', %w(arg 1 2)] }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with mention for other bot' do
|
|
||||||
let(:mention) { other_bot_name }
|
|
||||||
it { should eq [false, 'message', [payload]] }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without text' do
|
context 'when payload is message' do
|
||||||
let(:payload) { {'audio' => {'file_id' => 123}} }
|
let(:payload_type) { type }
|
||||||
|
let(:payload) { {'text' => text} }
|
||||||
|
let(:text) { 'test' }
|
||||||
|
|
||||||
it { should eq [false, payload_type, [payload]] }
|
it { should eq [false, payload_type, [payload]] }
|
||||||
|
|
||||||
|
context 'with command' do
|
||||||
|
let(:text) { "/test#{"@#{mention}" if mention} arg 1 2" }
|
||||||
|
let(:mention) {}
|
||||||
|
it { should eq [true, 'test', %w(arg 1 2)] }
|
||||||
|
|
||||||
|
context 'with mention' do
|
||||||
|
let(:mention) { bot.username }
|
||||||
|
it { should eq [true, 'test', %w(arg 1 2)] }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with mention for other bot' do
|
||||||
|
let(:mention) { other_bot_name }
|
||||||
|
it { should eq [false, payload_type, [payload]] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'without text' do
|
||||||
|
let(:payload) { {'audio' => {'file_id' => 123}} }
|
||||||
|
it { should eq [false, payload_type, [payload]] }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user