Skip to content

Commit

Permalink
Update to Bot API 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
printercu committed Jan 15, 2025
1 parent 7c30022 commit cb973d9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

# 0.16.7

- Update to Bot API 8.2

# 0.16.6

- Fix poller rake task for Rails 8.0
Expand Down
21 changes: 21 additions & 0 deletions bin/fetch-telegram-methods
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,24 @@ puts result_txt
API_METHODS_FILE = File.expand_path('../lib/telegram/bot/client/api_methods.txt', __dir__).freeze
File.write(API_METHODS_FILE, result_txt)
puts '', "Updated #{API_METHODS_FILE}"


puts '', 'Payload types:'
update_tbody = doc.css('tbody').
find { |tbody| tbody.css('td').any? { |td| td.text == 'update_id' } }
payload_types = update_tbody.css('td:first-child').map(&:text).reject { |x| x == 'update_id' }

result = ['# Generated with bin/fetch-telegram-methods']
result << "# #{api_version[1]}" if api_version
result << payload_types.join("\n")
result << ''
result_txt = result.join("\n")

puts result_txt

PAYLOAD_TYPES_FILE = File.expand_path(
'../lib/telegram/bot/updates_controller/payload_types.txt',
__dir__,
).freeze
File.write(PAYLOAD_TYPES_FILE, result_txt)
puts '', "Updated #{PAYLOAD_TYPES_FILE}"
6 changes: 5 additions & 1 deletion lib/telegram/bot/client/api_methods.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated with bin/fetch-telegram-methods
# Bot API 8.0
# Bot API 8.2

getUpdates
setWebhook
Expand Down Expand Up @@ -121,6 +121,10 @@ setCustomEmojiStickerSetThumbnail
deleteStickerSet
getAvailableGifts
sendGift
verifyUser
verifyChat
removeUserVerification
removeChatVerification

answerInlineQuery
answerWebAppQuery
Expand Down
32 changes: 7 additions & 25 deletions lib/telegram/bot/updates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,13 @@ class UpdatesController < AbstractController::Base # rubocop:disable Metrics/Cla

extend Session::ConfigMethods

PAYLOAD_TYPES = Set.new(%w[
message
edited_message
channel_post
edited_channel_post
business_connection
business_message
edited_business_message
deleted_business_messages
message_reaction
message_reaction_count
inline_query
chosen_inline_result
callback_query
shipping_query
pre_checkout_query
purchased_paid_media
poll
poll_answer
my_chat_member
chat_member
chat_join_request
chat_boost
removed_chat_boost
].freeze)
PAYLOAD_TYPES_FILE = File.expand_path('updates_controller/payload_types.txt', __dir__)
PAYLOAD_TYPES = File.read(PAYLOAD_TYPES_FILE).
lines.
map(&:strip).
reject { |x| x.empty? || x.start_with?('#') }.
to_set.
freeze

class << self
# Initialize controller and process update.
Expand Down
25 changes: 25 additions & 0 deletions lib/telegram/bot/updates_controller/payload_types.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated with bin/fetch-telegram-methods
# Bot API 8.2
message
edited_message
channel_post
edited_channel_post
business_connection
business_message
edited_business_message
deleted_business_messages
message_reaction
message_reaction_count
inline_query
chosen_inline_result
callback_query
shipping_query
pre_checkout_query
purchased_paid_media
poll
poll_answer
my_chat_member
chat_member
chat_join_request
chat_boost
removed_chat_boost
2 changes: 1 addition & 1 deletion lib/telegram/bot/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Telegram
module Bot
VERSION = '0.16.6'
VERSION = '0.16.7'

def self.gem_version
Gem::Version.new VERSION
Expand Down

0 comments on commit cb973d9

Please sign in to comment.