1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-03 17:55:52 +03:00

Сравнить коммиты

...

6 Коммитов

Автор SHA1 Сообщение Дата
Max Melentiev
8494c7df0c v0.14.4 2020-04-15 20:40:55 +03:00
Max Melentiev
a2659e00c2 Bump rake version to resolve vulnerability notification 2020-04-04 22:36:41 +03:00
Max Melentiev
e43c611d9d Merge pull request #131 from telegram-bot-rb/update_api
Update to Bot API 4.7
2020-04-04 22:35:33 +03:00
Max Melentiev
b84c48bc1d Update to Bot API 4.7 2020-04-04 22:26:26 +03:00
Max Melentiev
43cd096a21 Fix spelling in Async docs 2020-01-25 15:49:28 +03:00
Maximilian Haack
903e14a3e5 Fix make_telegram_request examples in README (#129) 2020-01-25 13:34:48 +03:00
15 изменённых файлов: 43 добавлений и 18 удалений

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

@@ -1,5 +1,11 @@
# Unreleased # Unreleased
# 0.14.4
- Update to Bot API 4.7
# 0.14.3
- Rails 6.0 support. - Rails 6.0 support.
- Update to Bot API 4.4. - Update to Bot API 4.4.

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

@@ -8,7 +8,7 @@ group :development do
gem 'pry-byebug', '~> 3.2.0' gem 'pry-byebug', '~> 3.2.0'
gem 'sdoc', '~> 0.4.1' 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', '~> 3.5.0'
gem 'rspec-its', '~> 1.1.0' gem 'rspec-its', '~> 1.1.0'

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

@@ -475,10 +475,11 @@ RSpec.describe TelegramWebhooksController, telegram_bot: :rails do
# dispatch_command(cmd, *args) # dispatch_command(cmd, *args)
# Available matchers can be found in Telegram::Bot::RSpec::ClientMatchers. # Available matchers can be found in Telegram::Bot::RSpec::ClientMatchers.
it 'shows usage of basic matchers' it 'shows usage of basic matchers' do
# The most basic one is #make_telegram_request(bot, endpoint, params_matcher) # The most basic one is #make_telegram_request(bot, action).
expect { dispatch_command(:start) }. # It works similar to `receive` matcher and supports chaining `.with(args).exactly(n).times`.
to make_telegram_request(bot, :sendMessage, hash_including(text: 'msg text')) 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. # There are some shortcuts for dispatching basic updates and testing responses.
expect { dispatch_message('Hi') }.to send_telegram_message(bot, /msg regexp/, some: :option) expect { dispatch_message('Hi') }.to send_telegram_message(bot, /msg regexp/, some: :option)

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

@@ -10,7 +10,7 @@ group :development do
gem "pry", "~> 0.10.1" gem "pry", "~> 0.10.1"
gem "pry-byebug", "~> 3.2.0" gem "pry-byebug", "~> 3.2.0"
gem "sdoc", "~> 0.4.1" 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", "~> 3.5.0"
gem "rspec-its", "~> 1.1.0" gem "rspec-its", "~> 1.1.0"
gem "rspec-rails", "~> 3.5.0" gem "rspec-rails", "~> 3.5.0"

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

@@ -10,7 +10,7 @@ group :development do
gem "pry", "~> 0.10.1" gem "pry", "~> 0.10.1"
gem "pry-byebug", "~> 3.2.0" gem "pry-byebug", "~> 3.2.0"
gem "sdoc", "~> 0.4.1" 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", "~> 3.5.0"
gem "rspec-its", "~> 1.1.0" gem "rspec-its", "~> 1.1.0"
gem "rspec-rails", "~> 3.5.0" gem "rspec-rails", "~> 3.5.0"

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

@@ -10,7 +10,7 @@ group :development do
gem "pry", "~> 0.10.1" gem "pry", "~> 0.10.1"
gem "pry-byebug", "~> 3.2.0" gem "pry-byebug", "~> 3.2.0"
gem "sdoc", "~> 0.4.1" 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", "~> 3.5.0"
gem "rspec-its", "~> 1.1.0" gem "rspec-its", "~> 1.1.0"
gem "rspec-rails", "~> 3.5.0" gem "rspec-rails", "~> 3.5.0"

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

@@ -10,7 +10,7 @@ group :development do
gem "pry", "~> 0.10.1" gem "pry", "~> 0.10.1"
gem "pry-byebug", "~> 3.2.0" gem "pry-byebug", "~> 3.2.0"
gem "sdoc", "~> 0.4.1" 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", "~> 3.5.0"
gem "rspec-its", "~> 1.1.0" gem "rspec-its", "~> 1.1.0"
gem "rspec-rails", "~> 3.5.0" gem "rspec-rails", "~> 3.5.0"

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

@@ -10,7 +10,7 @@ group :development do
gem "pry", "~> 0.10.1" gem "pry", "~> 0.10.1"
gem "pry-byebug", "~> 3.2.0" gem "pry-byebug", "~> 3.2.0"
gem "sdoc", "~> 0.4.1" 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", "~> 3.5.0"
gem "rspec-its", "~> 1.1.0" gem "rspec-its", "~> 1.1.0"
gem "rspec-rails", "~> 3.5.0" gem "rspec-rails", "~> 3.5.0"

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

@@ -12,7 +12,7 @@ group :development do
gem "pry", "~> 0.10.1" gem "pry", "~> 0.10.1"
gem "pry-byebug", "~> 3.2.0" gem "pry-byebug", "~> 3.2.0"
gem "sdoc", "~> 0.4.1" 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", "~> 3.5.0"
gem "rspec-its", "~> 1.1.0" gem "rspec-its", "~> 1.1.0"
gem "rspec-rails", "~> 3.5.0" gem "rspec-rails", "~> 3.5.0"

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

@@ -16,8 +16,8 @@ module Telegram
# accessible via `Teletgram.bots[id]` in job worker. Or just use # accessible via `Teletgram.bots[id]` in job worker. Or just use
# `Telegram.bots_config=` for configuration. # `Telegram.bots_config=` for configuration.
# #
# Being in async mode `#request` enqueues job instead to perform # Being in async mode `#request` enqueues job to perform
# http request instead of performing it directly. # http request instead of performing it immediately.
# Async behavior is controlled with `#async=` writer # Async behavior is controlled with `#async=` writer
# and can be enabled/disabled for the block with `#async`: # and can be enabled/disabled for the block with `#async`:
# #
@@ -29,7 +29,7 @@ module Telegram
# while `#async(val, &block)` is thread-safe. # while `#async(val, &block)` is thread-safe.
# #
# It can be set with custom job class or classname. By default it defines # 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 # 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)` # other job provider by defining a class with `.perform_later(bot_id, *args)`
# method. See Async::Job for implemetation. # method. See Async::Job for implemetation.

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

@@ -1,5 +1,5 @@
# Generated with bin/fetch-telegram-methods # Generated with bin/fetch-telegram-methods
# Bot API 4.4 # Bot API 4.7
getUpdates getUpdates
setWebhook setWebhook
@@ -23,6 +23,7 @@ stopMessageLiveLocation
sendVenue sendVenue
sendContact sendContact
sendPoll sendPoll
sendDice
sendChatAction sendChatAction
getUserProfilePhotos getUserProfilePhotos
getFile getFile
@@ -30,6 +31,7 @@ kickChatMember
unbanChatMember unbanChatMember
restrictChatMember restrictChatMember
promoteChatMember promoteChatMember
setChatAdministratorCustomTitle
setChatPermissions setChatPermissions
exportChatInviteLink exportChatInviteLink
setChatPhoto setChatPhoto
@@ -46,6 +48,8 @@ getChatMember
setChatStickerSet setChatStickerSet
deleteChatStickerSet deleteChatStickerSet
answerCallbackQuery answerCallbackQuery
setMyCommands
getMyCommands
editMessageText editMessageText
editMessageCaption editMessageCaption
@@ -61,6 +65,7 @@ createNewStickerSet
addStickerToSet addStickerToSet
setStickerPositionInSet setStickerPositionInSet
deleteStickerFromSet deleteStickerFromSet
setStickerSetThumb
answerInlineQuery answerInlineQuery

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

@@ -97,6 +97,8 @@ module Telegram
callback_query callback_query
shipping_query shipping_query
pre_checkout_query pre_checkout_query
poll
poll_answer
].freeze ].freeze
class << self class << self
@@ -148,7 +150,7 @@ module Telegram
# Accessor to `'from'` field of payload. Can be overriden with `from` option # Accessor to `'from'` field of payload. Can be overriden with `from` option
# for #initialize. # for #initialize.
def from def from
@_from ||= payload && payload['from'] @_from ||= payload.is_a?(Hash) ? payload['from'] : payload.try(:from)
end end
# Processes current update. # Processes current update.
@@ -206,6 +208,10 @@ module Telegram
[payload_type, [payload['data']]] [payload_type, [payload['data']]]
end 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 # Silently ignore unsupported messages to not fail when user crafts
# an update with usupported command, callback query context, etc. # an update with usupported command, callback query context, etc.
def action_missing(action, *_args) def action_missing(action, *_args)

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

@@ -1,6 +1,6 @@
module Telegram module Telegram
module Bot module Bot
VERSION = '0.14.3'.freeze VERSION = '0.14.4'.freeze
def self.gem_version def self.gem_version
Gem::Version.new VERSION Gem::Version.new VERSION

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

@@ -26,6 +26,12 @@ RSpec.describe Telegram::Bot::UpdatesController do
it { should eq [payload_type, payload.values_at(:data)] } it { should eq [payload_type, payload.values_at(:data)] }
end 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 context 'when payload is not supported' do
let(:payload_type) { '_unsupported_' } let(:payload_type) { '_unsupported_' }
it { should eq [:unsupported_payload_type, []] } it { should eq [:unsupported_payload_type, []] }
@@ -39,6 +45,7 @@ RSpec.describe Telegram::Bot::UpdatesController do
inline_query inline_query
chosen_inline_result chosen_inline_result
callback_query callback_query
poll_answer
] ]
(described_class::PAYLOAD_TYPES - custom_payload_types).each do |type| (described_class::PAYLOAD_TYPES - custom_payload_types).each do |type|
context "when payload is #{type}" do context "when payload is #{type}" do

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

@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
spec.add_dependency 'httpclient', '~> 2.7' spec.add_dependency 'httpclient', '~> 2.7'
spec.add_development_dependency 'bundler', '> 1.16' spec.add_development_dependency 'bundler', '> 1.16'
spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rake', '~> 13.0'
end end