зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-07 19:35:52 +03:00
Bot api 7.0 (#229)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
57b17f068c
Коммит
6140f7a68a
@@ -1,5 +1,6 @@
|
|||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- Update to Bot API 7.0
|
||||||
- Add `# frozen_string_literal: true` to all source files.
|
- Add `# frozen_string_literal: true` to all source files.
|
||||||
|
|
||||||
# 0.16.1
|
# 0.16.1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Generated with bin/fetch-telegram-methods
|
# Generated with bin/fetch-telegram-methods
|
||||||
# Bot API 6.8
|
# Bot API 7.0
|
||||||
|
|
||||||
getUpdates
|
getUpdates
|
||||||
setWebhook
|
setWebhook
|
||||||
@@ -11,7 +11,9 @@ logOut
|
|||||||
close
|
close
|
||||||
sendMessage
|
sendMessage
|
||||||
forwardMessage
|
forwardMessage
|
||||||
|
forwardMessages
|
||||||
copyMessage
|
copyMessage
|
||||||
|
copyMessages
|
||||||
sendPhoto
|
sendPhoto
|
||||||
sendAudio
|
sendAudio
|
||||||
sendDocument
|
sendDocument
|
||||||
@@ -26,6 +28,7 @@ sendContact
|
|||||||
sendPoll
|
sendPoll
|
||||||
sendDice
|
sendDice
|
||||||
sendChatAction
|
sendChatAction
|
||||||
|
setMessageReaction
|
||||||
getUserProfilePhotos
|
getUserProfilePhotos
|
||||||
getFile
|
getFile
|
||||||
banChatMember
|
banChatMember
|
||||||
@@ -70,6 +73,7 @@ hideGeneralForumTopic
|
|||||||
unhideGeneralForumTopic
|
unhideGeneralForumTopic
|
||||||
unpinAllGeneralForumTopicMessages
|
unpinAllGeneralForumTopicMessages
|
||||||
answerCallbackQuery
|
answerCallbackQuery
|
||||||
|
getUserChatBoosts
|
||||||
setMyCommands
|
setMyCommands
|
||||||
deleteMyCommands
|
deleteMyCommands
|
||||||
getMyCommands
|
getMyCommands
|
||||||
@@ -92,6 +96,7 @@ stopMessageLiveLocation
|
|||||||
editMessageReplyMarkup
|
editMessageReplyMarkup
|
||||||
stopPoll
|
stopPoll
|
||||||
deleteMessage
|
deleteMessage
|
||||||
|
deleteMessages
|
||||||
|
|
||||||
sendSticker
|
sendSticker
|
||||||
getStickerSet
|
getStickerSet
|
||||||
|
|||||||
@@ -89,11 +89,13 @@ module Telegram
|
|||||||
|
|
||||||
extend Session::ConfigMethods
|
extend Session::ConfigMethods
|
||||||
|
|
||||||
PAYLOAD_TYPES = %w[
|
PAYLOAD_TYPES = Set.new(%w[
|
||||||
message
|
message
|
||||||
edited_message
|
edited_message
|
||||||
channel_post
|
channel_post
|
||||||
edited_channel_post
|
edited_channel_post
|
||||||
|
message_reaction
|
||||||
|
message_reaction_count
|
||||||
inline_query
|
inline_query
|
||||||
chosen_inline_result
|
chosen_inline_result
|
||||||
callback_query
|
callback_query
|
||||||
@@ -104,7 +106,9 @@ module Telegram
|
|||||||
my_chat_member
|
my_chat_member
|
||||||
chat_member
|
chat_member
|
||||||
chat_join_request
|
chat_join_request
|
||||||
].freeze
|
chat_boost
|
||||||
|
removed_chat_boost
|
||||||
|
].freeze)
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
# Initialize controller and process update.
|
# Initialize controller and process update.
|
||||||
@@ -113,9 +117,28 @@ module Telegram
|
|||||||
end
|
end
|
||||||
|
|
||||||
def payload_from_update(update)
|
def payload_from_update(update)
|
||||||
update && PAYLOAD_TYPES.find do |type|
|
case update
|
||||||
|
when nil then nil
|
||||||
|
when Hash
|
||||||
|
# faster lookup for the case when telegram-bot-types is not used
|
||||||
|
update.find do |type, item|
|
||||||
|
return [item, type] if PAYLOAD_TYPES.include?(type)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
payload_from_typed_update(update)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def payload_from_typed_update(update)
|
||||||
|
PAYLOAD_TYPES.find do |type|
|
||||||
|
begin
|
||||||
item = update[type]
|
item = update[type]
|
||||||
return [item, type] if item
|
return [item, type] if item
|
||||||
|
rescue Exception # rubocop:disable Lint/RescueException
|
||||||
|
# dry-rb raises exception if field is not defined in schema
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ RSpec.describe Telegram::Bot::UpdatesController::TypedUpdate do
|
|||||||
my_chat_member
|
my_chat_member
|
||||||
chat_member
|
chat_member
|
||||||
chat_join_request
|
chat_join_request
|
||||||
|
|
||||||
|
# TODO: remove when added to telegram-bot-types
|
||||||
|
message_reaction
|
||||||
|
message_reaction_count
|
||||||
|
chat_boost
|
||||||
|
removed_chat_boost
|
||||||
]).
|
]).
|
||||||
map { |x| [x, Telegram::Bot::Types.const_get(x.camelize)] }.to_h.
|
map { |x| [x, Telegram::Bot::Types.const_get(x.camelize)] }.to_h.
|
||||||
merge(
|
merge(
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user