зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-08-28 15:26:18 +03:00
Сравнить коммиты
10 Коммитов
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
8494c7df0c | ||
|
|
a2659e00c2 | ||
|
|
e43c611d9d | ||
|
|
b84c48bc1d | ||
|
|
43cd096a21 | ||
|
|
903e14a3e5 | ||
|
|
da31cd148a | ||
|
|
552f3b3353 | ||
|
|
e5f93f608b | ||
|
|
7e823b4354 |
14
.travis.yml
14
.travis.yml
@@ -1,27 +1,31 @@
|
||||
language: ruby
|
||||
cache: bundler
|
||||
rvm:
|
||||
- 2.6
|
||||
- 2.5
|
||||
- 2.4
|
||||
gemfile:
|
||||
- gemfiles/rails_60.gemfile
|
||||
- gemfiles/rails_52.gemfile
|
||||
- gemfiles/rails_51.gemfile
|
||||
matrix:
|
||||
include:
|
||||
# old rails
|
||||
- rvm: 2.5
|
||||
gemfile: gemfiles/rails_51.gemfile
|
||||
- rvm: 2.5
|
||||
gemfile: gemfiles/rails_50.gemfile
|
||||
- rvm: 2.5
|
||||
gemfile: gemfiles/rails_42.gemfile
|
||||
# old rubies
|
||||
- rvm: 2.4
|
||||
gemfile: gemfiles/rails_52.gemfile
|
||||
- rvm: 2.3
|
||||
gemfile: gemfiles/rails_52.gemfile
|
||||
# future rails
|
||||
- rvm: 2.5
|
||||
gemfile: gemfiles/rails_60.gemfile
|
||||
# Allow rails 6 to fail while master branch is used
|
||||
gemfile: gemfiles/rails_61.gemfile
|
||||
# Allow rails 6.1 to fail while master branch is used
|
||||
allow_failures:
|
||||
- rvm: 2.5
|
||||
gemfile: gemfiles/rails_60.gemfile
|
||||
gemfile: gemfiles/rails_61.gemfile
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
27
Appraisals
27
Appraisals
@@ -1,26 +1,31 @@
|
||||
appraise 'rails-60' do
|
||||
appraise 'rails-61' do
|
||||
git 'https://github.com/rails/rails.git' do
|
||||
gem 'actionpack', '~> 6.0.0.alpha'
|
||||
gem 'railties', '~> 6.0.0.alpha'
|
||||
gem 'actionpack', '~> 6.1.0.alpha'
|
||||
gem 'railties', '~> 6.1.0.alpha'
|
||||
end
|
||||
end
|
||||
|
||||
appraise 'rails-60' do
|
||||
gem 'actionpack', '~> 6.0.0'
|
||||
gem 'railties', '~> 6.0.0'
|
||||
end
|
||||
|
||||
appraise 'rails-52' do
|
||||
gem 'actionpack', '~> 5.2.0.beta2'
|
||||
gem 'railties', '~> 5.2.0.beta2'
|
||||
gem 'actionpack', '~> 5.2.0'
|
||||
gem 'railties', '~> 5.2.0'
|
||||
end
|
||||
|
||||
appraise 'rails-51' do
|
||||
gem 'actionpack', '~> 5.1'
|
||||
gem 'railties', '~> 5.1'
|
||||
gem 'actionpack', '~> 5.1.0'
|
||||
gem 'railties', '~> 5.1.0'
|
||||
end
|
||||
|
||||
appraise 'rails-50' do
|
||||
gem 'actionpack', '~> 5.0'
|
||||
gem 'railties', '~> 5.0'
|
||||
gem 'actionpack', '~> 5.0.0'
|
||||
gem 'railties', '~> 5.0.0'
|
||||
end
|
||||
|
||||
appraise 'rails-42' do
|
||||
gem 'actionpack', '~> 4.2'
|
||||
gem 'railties', '~> 4.2'
|
||||
gem 'actionpack', '~> 4.2.0'
|
||||
gem 'railties', '~> 4.2.0'
|
||||
end
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# Unreleased
|
||||
|
||||
# 0.14.4
|
||||
|
||||
- Update to Bot API 4.7
|
||||
|
||||
# 0.14.3
|
||||
|
||||
- Rails 6.0 support.
|
||||
- Update to Bot API 4.4.
|
||||
|
||||
# 0.14.2
|
||||
|
||||
- Add reply helpers: `answer_pre_checkout_query`, `answer_shipping_query`.
|
||||
|
||||
2
Gemfile
2
Gemfile
@@ -8,7 +8,7 @@ group :development do
|
||||
gem 'pry-byebug', '~> 3.2.0'
|
||||
gem 'sdoc', '~> 0.4.1'
|
||||
|
||||
gem 'telegram-bot-types', '~> 0.6.0'
|
||||
gem 'telegram-bot-types', '~> 0.6.2'
|
||||
|
||||
gem 'rspec', '~> 3.5.0'
|
||||
gem 'rspec-its', '~> 1.1.0'
|
||||
|
||||
@@ -475,10 +475,11 @@ RSpec.describe TelegramWebhooksController, telegram_bot: :rails do
|
||||
# dispatch_command(cmd, *args)
|
||||
|
||||
# Available matchers can be found in Telegram::Bot::RSpec::ClientMatchers.
|
||||
it 'shows usage of basic matchers'
|
||||
# The most basic one is #make_telegram_request(bot, endpoint, params_matcher)
|
||||
expect { dispatch_command(:start) }.
|
||||
to make_telegram_request(bot, :sendMessage, hash_including(text: 'msg text'))
|
||||
it 'shows usage of basic matchers' do
|
||||
# The most basic one is #make_telegram_request(bot, action).
|
||||
# It works similar to `receive` matcher and supports chaining `.with(args).exactly(n).times`.
|
||||
expect { dispatch_command(:start) }.to make_telegram_request(bot, :sendMessage).
|
||||
with(hash_including(text: 'msg text'))
|
||||
|
||||
# There are some shortcuts for dispatching basic updates and testing responses.
|
||||
expect { dispatch_message('Hi') }.to send_telegram_message(bot, /msg regexp/, some: :option)
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "actionpack", "~> 4.2"
|
||||
gem "railties", "~> 4.2"
|
||||
gem "actionpack", "~> 4.2.0"
|
||||
gem "railties", "~> 4.2.0"
|
||||
|
||||
group :development do
|
||||
gem "appraisal", "~> 2.2"
|
||||
gem "pry", "~> 0.10.1"
|
||||
gem "pry-byebug", "~> 3.2.0"
|
||||
gem "sdoc", "~> 0.4.1"
|
||||
gem "telegram-bot-types", "~> 0.6.0"
|
||||
gem "telegram-bot-types", "~> 0.6.2"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-its", "~> 1.1.0"
|
||||
gem "rspec-rails", "~> 3.5.0"
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "actionpack", "~> 5.0"
|
||||
gem "railties", "~> 5.0"
|
||||
gem "actionpack", "~> 5.0.0"
|
||||
gem "railties", "~> 5.0.0"
|
||||
|
||||
group :development do
|
||||
gem "appraisal", "~> 2.2"
|
||||
gem "pry", "~> 0.10.1"
|
||||
gem "pry-byebug", "~> 3.2.0"
|
||||
gem "sdoc", "~> 0.4.1"
|
||||
gem "telegram-bot-types", "~> 0.6.0"
|
||||
gem "telegram-bot-types", "~> 0.6.2"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-its", "~> 1.1.0"
|
||||
gem "rspec-rails", "~> 3.5.0"
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "actionpack", "~> 5.1"
|
||||
gem "railties", "~> 5.1"
|
||||
gem "actionpack", "~> 5.1.0"
|
||||
gem "railties", "~> 5.1.0"
|
||||
|
||||
group :development do
|
||||
gem "appraisal", "~> 2.2"
|
||||
gem "pry", "~> 0.10.1"
|
||||
gem "pry-byebug", "~> 3.2.0"
|
||||
gem "sdoc", "~> 0.4.1"
|
||||
gem "telegram-bot-types", "~> 0.6.0"
|
||||
gem "telegram-bot-types", "~> 0.6.2"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-its", "~> 1.1.0"
|
||||
gem "rspec-rails", "~> 3.5.0"
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "actionpack", "~> 5.2.0.beta2"
|
||||
gem "railties", "~> 5.2.0.beta2"
|
||||
gem "actionpack", "~> 5.2.0"
|
||||
gem "railties", "~> 5.2.0"
|
||||
|
||||
group :development do
|
||||
gem "appraisal", "~> 2.2"
|
||||
gem "pry", "~> 0.10.1"
|
||||
gem "pry-byebug", "~> 3.2.0"
|
||||
gem "sdoc", "~> 0.4.1"
|
||||
gem "telegram-bot-types", "~> 0.6.0"
|
||||
gem "telegram-bot-types", "~> 0.6.2"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-its", "~> 1.1.0"
|
||||
gem "rspec-rails", "~> 3.5.0"
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
git "https://github.com/rails/rails.git" do
|
||||
gem "actionpack", "~> 6.0.0.alpha"
|
||||
gem "railties", "~> 6.0.0.alpha"
|
||||
end
|
||||
gem "actionpack", "~> 6.0.0"
|
||||
gem "railties", "~> 6.0.0"
|
||||
|
||||
group :development do
|
||||
gem "appraisal", "~> 2.2"
|
||||
gem "pry", "~> 0.10.1"
|
||||
gem "pry-byebug", "~> 3.2.0"
|
||||
gem "sdoc", "~> 0.4.1"
|
||||
gem "telegram-bot-types", "~> 0.6.0"
|
||||
gem "telegram-bot-types", "~> 0.6.2"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-its", "~> 1.1.0"
|
||||
gem "rspec-rails", "~> 3.5.0"
|
||||
|
||||
23
gemfiles/rails_61.gemfile
Обычный файл
23
gemfiles/rails_61.gemfile
Обычный файл
@@ -0,0 +1,23 @@
|
||||
# This file was generated by Appraisal
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
git "https://github.com/rails/rails.git" do
|
||||
gem "actionpack", "~> 6.1.0.alpha"
|
||||
gem "railties", "~> 6.1.0.alpha"
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem "appraisal", "~> 2.2"
|
||||
gem "pry", "~> 0.10.1"
|
||||
gem "pry-byebug", "~> 3.2.0"
|
||||
gem "sdoc", "~> 0.4.1"
|
||||
gem "telegram-bot-types", "~> 0.6.2"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-its", "~> 1.1.0"
|
||||
gem "rspec-rails", "~> 3.5.0"
|
||||
gem "rubocop", "~> 0.52.1"
|
||||
gem "coveralls", "~> 0.8.2", require: false
|
||||
end
|
||||
|
||||
gemspec path: "../"
|
||||
@@ -16,8 +16,8 @@ module Telegram
|
||||
# accessible via `Teletgram.bots[id]` in job worker. Or just use
|
||||
# `Telegram.bots_config=` for configuration.
|
||||
#
|
||||
# Being in async mode `#request` enqueues job instead to perform
|
||||
# http request instead of performing it directly.
|
||||
# Being in async mode `#request` enqueues job to perform
|
||||
# http request instead of performing it immediately.
|
||||
# Async behavior is controlled with `#async=` writer
|
||||
# and can be enabled/disabled for the block with `#async`:
|
||||
#
|
||||
@@ -29,7 +29,7 @@ module Telegram
|
||||
# while `#async(val, &block)` is thread-safe.
|
||||
#
|
||||
# It can be set with custom job class or classname. By default it defines
|
||||
# job classes for every client class, inherited from ApplicationRecord, which
|
||||
# job classes inherited from ApplicationJob, which
|
||||
# can be accessed via `.default_async_job`. You can integrate it with any
|
||||
# other job provider by defining a class with `.perform_later(bot_id, *args)`
|
||||
# method. See Async::Job for implemetation.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Generated with bin/fetch-telegram-methods
|
||||
# Bot API 4.3
|
||||
# Bot API 4.7
|
||||
|
||||
getUpdates
|
||||
setWebhook
|
||||
@@ -23,6 +23,7 @@ stopMessageLiveLocation
|
||||
sendVenue
|
||||
sendContact
|
||||
sendPoll
|
||||
sendDice
|
||||
sendChatAction
|
||||
getUserProfilePhotos
|
||||
getFile
|
||||
@@ -30,6 +31,8 @@ kickChatMember
|
||||
unbanChatMember
|
||||
restrictChatMember
|
||||
promoteChatMember
|
||||
setChatAdministratorCustomTitle
|
||||
setChatPermissions
|
||||
exportChatInviteLink
|
||||
setChatPhoto
|
||||
deleteChatPhoto
|
||||
@@ -45,6 +48,8 @@ getChatMember
|
||||
setChatStickerSet
|
||||
deleteChatStickerSet
|
||||
answerCallbackQuery
|
||||
setMyCommands
|
||||
getMyCommands
|
||||
|
||||
editMessageText
|
||||
editMessageCaption
|
||||
@@ -60,6 +65,7 @@ createNewStickerSet
|
||||
addStickerToSet
|
||||
setStickerPositionInSet
|
||||
deleteStickerFromSet
|
||||
setStickerSetThumb
|
||||
|
||||
answerInlineQuery
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ module Telegram
|
||||
callback_query
|
||||
shipping_query
|
||||
pre_checkout_query
|
||||
poll
|
||||
poll_answer
|
||||
].freeze
|
||||
|
||||
class << self
|
||||
@@ -148,7 +150,7 @@ module Telegram
|
||||
# Accessor to `'from'` field of payload. Can be overriden with `from` option
|
||||
# for #initialize.
|
||||
def from
|
||||
@_from ||= payload && payload['from']
|
||||
@_from ||= payload.is_a?(Hash) ? payload['from'] : payload.try(:from)
|
||||
end
|
||||
|
||||
# Processes current update.
|
||||
@@ -206,6 +208,10 @@ module Telegram
|
||||
[payload_type, [payload['data']]]
|
||||
end
|
||||
|
||||
def action_for_poll_answer
|
||||
[payload_type, [payload['poll_id'], payload['option_ids']]]
|
||||
end
|
||||
|
||||
# Silently ignore unsupported messages to not fail when user crafts
|
||||
# an update with usupported command, callback query context, etc.
|
||||
def action_missing(action, *_args)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Telegram
|
||||
module Bot
|
||||
VERSION = '0.14.2'.freeze
|
||||
VERSION = '0.14.4'.freeze
|
||||
|
||||
def self.gem_version
|
||||
Gem::Version.new VERSION
|
||||
|
||||
@@ -26,6 +26,12 @@ RSpec.describe Telegram::Bot::UpdatesController do
|
||||
it { should eq [payload_type, payload.values_at(:data)] }
|
||||
end
|
||||
|
||||
context 'when payload is poll_answer' do
|
||||
let(:payload_type) { 'poll_answer' }
|
||||
let(:payload) { stub_payload(:poll_id, :user, :option_ids) }
|
||||
it { should eq [payload_type, payload.values_at(:poll_id, :option_ids)] }
|
||||
end
|
||||
|
||||
context 'when payload is not supported' do
|
||||
let(:payload_type) { '_unsupported_' }
|
||||
it { should eq [:unsupported_payload_type, []] }
|
||||
@@ -39,6 +45,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
|
||||
inline_query
|
||||
chosen_inline_result
|
||||
callback_query
|
||||
poll_answer
|
||||
]
|
||||
(described_class::PAYLOAD_TYPES - custom_payload_types).each do |type|
|
||||
context "when payload is #{type}" do
|
||||
|
||||
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
|
||||
|
||||
spec.required_ruby_version = '~> 2.0'
|
||||
|
||||
spec.add_dependency 'actionpack', '>= 4.0', '< 6.0'
|
||||
spec.add_dependency 'activesupport', '>= 4.0', '< 6.0'
|
||||
spec.add_dependency 'actionpack', '>= 4.0', '< 6.1'
|
||||
spec.add_dependency 'activesupport', '>= 4.0', '< 6.1'
|
||||
spec.add_dependency 'httpclient', '~> 2.7'
|
||||
|
||||
spec.add_development_dependency 'bundler', '> 1.16'
|
||||
spec.add_development_dependency 'rake', '~> 10.0'
|
||||
spec.add_development_dependency 'rake', '~> 13.0'
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user