1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +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
# 0.14.4
- Update to Bot API 4.7
# 0.14.3
- Rails 6.0 support.
- Update to Bot API 4.4.

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

@@ -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)

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

@@ -10,7 +10,7 @@ group :development do
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"

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

@@ -10,7 +10,7 @@ group :development do
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"

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

@@ -10,7 +10,7 @@ group :development do
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"

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

@@ -10,7 +10,7 @@ group :development do
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"

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

@@ -10,7 +10,7 @@ group :development do
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"

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

@@ -12,7 +12,7 @@ group :development do
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"

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

@@ -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.4
# Bot API 4.7
getUpdates
setWebhook
@@ -23,6 +23,7 @@ stopMessageLiveLocation
sendVenue
sendContact
sendPoll
sendDice
sendChatAction
getUserProfilePhotos
getFile
@@ -30,6 +31,7 @@ kickChatMember
unbanChatMember
restrictChatMember
promoteChatMember
setChatAdministratorCustomTitle
setChatPermissions
exportChatInviteLink
setChatPhoto
@@ -46,6 +48,8 @@ getChatMember
setChatStickerSet
deleteChatStickerSet
answerCallbackQuery
setMyCommands
getMyCommands
editMessageText
editMessageCaption
@@ -61,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.3'.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

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

@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
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