diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..34bddf8 --- /dev/null +++ b/.env.sample @@ -0,0 +1,2 @@ +BOT_API_ENV=test +BOT_API_TOKEN= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5b133a..ac40ac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: matrix: ruby: - 2.7 - - 3.1 + - 3.2 steps: - name: Checkout uses: actions/checkout@v3 @@ -31,7 +31,7 @@ jobs: matrix: ruby: - 2.7 - - 3.1 + - 3.2 env: BOT_API_ENV: test BOT_API_TOKEN: ${{ secrets.BOT_API_TOKEN }} diff --git a/.gitignore b/.gitignore index 7eb3496..47b2637 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ Gemfile.lock .bundle/ +.env pkg/ vendor/bundle/ diff --git a/.rubocop.yml b/.rubocop.yml index 1e154bb..fbaa172 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,9 +15,10 @@ Style/FrozenStringLiteralComment: - bin/console Metrics/BlockLength: - IgnoredMethods: + AllowedMethods: - context - describe + - task Layout/LineLength: Max: 120 diff --git a/CHANGELOG.md b/CHANGELOG.md index fbfb92b..b367dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.0.0 + +- Replace [virtus](https://github.com/solnic/virtus) with [dry-struct](https://github.com/dry-rb/dry-struct) +- Use [zeitwerk](https://github.com/fxn/zeitwerk) for code loading +- Implement [Bot API 6.4](https://core.telegram.org/bots/api#december-30-2022) +- Implement [Bot API 6.5](https://core.telegram.org/bots/api#february-3-2023) + ## 0.23.0 - Rename `Telegram::Bot.configuration` options: diff --git a/Gemfile b/Gemfile index 7f4f5e9..55009c6 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,12 @@ source 'https://rubygems.org' gemspec + +gem 'dotenv', '~> 2.8' +gem 'nokogiri', '~> 1.13' +gem 'pry' +gem 'rake', '~> 13.0' +gem 'rspec', '~> 3.4' +gem 'rubocop', '~> 1.27' +gem 'rubocop-rake' +gem 'rubocop-rspec', '~> 2.10' diff --git a/README.md b/README.md index 30423f2..15ee21d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,21 @@ Ruby wrapper for [Telegram's Bot API](https://core.telegram.org/bots/api). [![Maintainability](https://api.codeclimate.com/v1/badges/7e61fbf5bec86e118fb1/maintainability)](https://codeclimate.com/github/atipugin/telegram-bot-ruby/maintainability) [![Say Thanks!](https://img.shields.io/badge/Say%20Thanks!-🦉-1EAEDB.svg)](https://saythanks.io/to/atipugin) +## 🚧 Upgrading to 1.0 + +Since v1.0 telegram-bot-ruby uses [dry-struct](https://github.com/dry-rb/dry-struct) instead of [virtus](https://github.com/solnic/virtus). This means that type objects are now immutable and you can't change them after initialization: + +```ruby +# This won't work +kb = Telegram::Bot::Types::ReplyKeyboardRemove.new +kb.remove_keyboard = true + +# You have to set attributes in constructor instead +kb = Telegram::Bot::Types::ReplyKeyboardRemove.new(remove_keyboard: true) +``` + +Please make sure it doesn't break your existing code before upgrading to 1.0. + ## Installation Add following line to your Gemfile: @@ -18,13 +33,13 @@ gem 'telegram-bot-ruby' And then execute: ```shell -$ bundle +bundle ``` Or install it system-wide: ```shell -$ gem install telegram-bot-ruby +gem install telegram-bot-ruby ``` ## Usage @@ -50,8 +65,13 @@ end Note that `bot.api` object implements [Telegram Bot API methods](https://core.telegram.org/bots/api#available-methods) as is. So you can invoke any method inside the block without any problems. All methods are available in both *snake_case* and *camelCase* notations. -If you need to start a bot on development mode you have to pass `enviroment: :test`
-example: `Telegram::Bot::Client.run(token, enviroment: :test)` +If you need to start a bot in development mode you have to pass `environment: :test`: + +```ruby +Telegram::Bot::Client.run(token, environment: :test) do |bot| + # ... +end +``` Same thing about `message` object - it implements [Message](https://core.telegram.org/bots/api#message) spec, so you always know what to expect from it. @@ -80,8 +100,13 @@ bot.listen do |message| question = 'London is a capital of which country?' # See more: https://core.telegram.org/bots/api#replykeyboardmarkup answers = - Telegram::Bot::Types::ReplyKeyboardMarkup - .new(keyboard: [%w(A B), %w(C D)], one_time_keyboard: true) + Telegram::Bot::Types::ReplyKeyboardMarkup.new( + keyboard: [ + [{ text: 'A' }, { text: 'B' }], + [{ text: 'C' }, { text: 'D' }] + ], + one_time_keyboard: true + ) bot.api.send_message(chat_id: message.chat.id, text: question, reply_markup: answers) when '/stop' # See more: https://core.telegram.org/bots/api#replykeyboardremove @@ -95,10 +120,10 @@ Furthermore, you can ask user to share location or phone number using `KeyboardB ```ruby bot.listen do |message| - kb = [ + kb = [[ Telegram::Bot::Types::KeyboardButton.new(text: 'Give me your phone number', request_contact: true), Telegram::Bot::Types::KeyboardButton.new(text: 'Show me your location', request_location: true) - ] + ]] markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: kb) bot.api.send_message(chat_id: message.chat.id, text: 'Hey!', reply_markup: markup) end @@ -117,11 +142,11 @@ bot.listen do |message| bot.api.send_message(chat_id: message.from.id, text: "Don't touch me!") end when Telegram::Bot::Types::Message - kb = [ + kb = [[ Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Go to Google', url: 'https://google.com'), Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Touch me', callback_data: 'touch'), Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Switch to inline', switch_inline_query: 'some text') - ] + ]] markup = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: kb) bot.api.send_message(chat_id: message.chat.id, text: 'Make a choice', reply_markup: markup) end @@ -137,8 +162,8 @@ bot.listen do |message| case message when Telegram::Bot::Types::InlineQuery results = [ - [1, 'First article', 'Very interesting text goes here.'], - [2, 'Second article', 'Another interesting text here.'] + ['1', 'First article', 'Very interesting text goes here.'], + ['2', 'Second article', 'Another interesting text here.'] ].map do |arr| Telegram::Bot::Types::InlineQueryResultArticle.new( id: arr[0], @@ -166,7 +191,8 @@ Your bot can even upload files ([photos](https://core.telegram.org/bots/api#send bot.listen do |message| case message.text when '/photo' - bot.api.send_photo(chat_id: message.chat.id, photo: Faraday::UploadIO.new('~/Desktop/jennifer.jpg', 'image/jpeg')) + path_to_photo = File.expand_path('~/Desktop/jennifer.jpg') + bot.api.send_photo(chat_id: message.chat.id, photo: Faraday::UploadIO.new(path_to_photo, 'image/jpeg')) end end ``` @@ -199,6 +225,7 @@ end ## Boilerplates If you don't know how to setup database for your bot or how to use it with different languages here are some boilerplates which can help you to start faster: + - [Ruby Telegram Bot boilerplate](https://github.com/telegram-bots/ruby-telegram-bot-boilerplate) ## Contributing diff --git a/Rakefile b/Rakefile index e56f475..de12133 100644 --- a/Rakefile +++ b/Rakefile @@ -15,3 +15,46 @@ end RSpec::Core::RakeTask.new(:spec) task default: :spec + +desc 'Dump type definitions from docs to YAML' +task :dump_type_attributes do + require File.expand_path('lib/telegram/bot', __dir__) + require 'nokogiri' + require 'open-uri' + require 'yaml' + + # Preload every type we have + Zeitwerk::Loader.eager_load_all + types = Telegram::Bot::Types::Base.descendants.map { |c| c.name.split('::').last } + + # Fetch and parse docs + doc = Nokogiri::HTML(URI.open('https://core.telegram.org/bots/api').read) + + result = types.to_h do |type| + # This is very hacky but working way to find table containing attributes for + # given type. Basic idea is to find heading with type and then iterate until + # we find table with attributes or next heading (because sometimes type + # doesn't have any attributes). + element = doc.at_xpath(%{//h4[text() = "#{type}"]}) + loop do + element = element.next_element + break if %w[table h4].include?(element.name) + end + + attributes = element.xpath('.//tbody//tr').map do |el| + cells = el.children.select { |c| c.name == 'td' } + { + 'name' => cells[0].text, + 'required' => !cells[2].text.start_with?('Optional.') + } + end + + [type, attributes] + end + + # Write everything to fixture file + File.write( + File.expand_path('spec/support/type_attributes.yml', __dir__), + result.to_yaml + ) +end diff --git a/lib/telegram/bot.rb b/lib/telegram/bot.rb index 1340e8d..12cbd4d 100644 --- a/lib/telegram/bot.rb +++ b/lib/telegram/bot.rb @@ -1,18 +1,11 @@ # frozen_string_literal: true -require 'virtus' require 'logger' require 'json' require 'faraday' require 'faraday/multipart' - -require 'telegram/bot/types' -require 'telegram/bot/exceptions' -require 'telegram/bot/api' -require 'telegram/bot/null_logger' -require 'telegram/bot/client' -require 'telegram/bot/version' -require 'telegram/bot/configuration' +require 'zeitwerk' +require 'dry-struct' module Telegram module Bot @@ -29,3 +22,8 @@ def self.configure end end end + +loader = Zeitwerk::Loader.new +loader.inflector = Zeitwerk::GemInflector.new(__FILE__) +loader.push_dir("#{__dir__}/bot", namespace: Telegram::Bot) +loader.setup diff --git a/lib/telegram/bot/api.rb b/lib/telegram/bot/api.rb index ea76bed..e656b14 100644 --- a/lib/telegram/bot/api.rb +++ b/lib/telegram/bot/api.rb @@ -26,7 +26,9 @@ class Api approveChatJoinRequest declineChatJoinRequest banChatSenderChat unbanChatSenderChat answerWebAppQuery setChatMenuButton getChatMenuButton setMyDefaultAdministratorRights - getMyDefaultAdministratorRights createInvoiceLink + getMyDefaultAdministratorRights createInvoiceLink editGeneralForumTopic + closeGeneralForumTopic reopenGeneralForumTopic hideGeneralForumTopic + unhideGeneralForumTopic ].freeze attr_reader :token, :url, :environment diff --git a/lib/telegram/bot/exceptions.rb b/lib/telegram/bot/exceptions.rb deleted file mode 100644 index 24fbda8..0000000 --- a/lib/telegram/bot/exceptions.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -require 'telegram/bot/exceptions/base' -require 'telegram/bot/exceptions/response_error' diff --git a/lib/telegram/bot/types.rb b/lib/telegram/bot/types.rb index 84e2a96..6c5410f 100644 --- a/lib/telegram/bot/types.rb +++ b/lib/telegram/bot/types.rb @@ -1,126 +1,9 @@ # frozen_string_literal: true -require 'telegram/bot/types/compactable' -require 'telegram/bot/types/pattern_matching' -require 'telegram/bot/types/base' -require 'telegram/bot/types/file' -require 'telegram/bot/types/user' -require 'telegram/bot/types/photo_size' -require 'telegram/bot/types/audio' -require 'telegram/bot/types/document' -require 'telegram/bot/types/mask_position' -require 'telegram/bot/types/sticker' -require 'telegram/bot/types/sticker_set' -require 'telegram/bot/types/video' -require 'telegram/bot/types/voice' -require 'telegram/bot/types/video_note' -require 'telegram/bot/types/contact' -require 'telegram/bot/types/dice' -require 'telegram/bot/types/location' -require 'telegram/bot/types/chat_photo' -require 'telegram/bot/types/chat_permissions' -require 'telegram/bot/types/chat_location' -require 'telegram/bot/types/chat' -require 'telegram/bot/types/message_entity' -require 'telegram/bot/types/venue' -require 'telegram/bot/types/animation' -require 'telegram/bot/types/game' -require 'telegram/bot/types/callback_game' -require 'telegram/bot/types/game_high_score' -require 'telegram/bot/types/invoice' -require 'telegram/bot/types/shipping_address' -require 'telegram/bot/types/order_info' -require 'telegram/bot/types/successful_payment' -require 'telegram/bot/types/poll_option' -require 'telegram/bot/types/poll_answer' -require 'telegram/bot/types/poll' -require 'telegram/bot/types/passport_file' -require 'telegram/bot/types/encrypted_passport_element' -require 'telegram/bot/types/encrypted_credentials' -require 'telegram/bot/types/passport_data' -require 'telegram/bot/types/passport_element_error_data_field' -require 'telegram/bot/types/passport_element_error_front_side' -require 'telegram/bot/types/passport_element_error_reverse_side' -require 'telegram/bot/types/passport_element_error_selfie' -require 'telegram/bot/types/passport_element_error_file' -require 'telegram/bot/types/passport_element_error_files' -require 'telegram/bot/types/passport_element_error_translation_file' -require 'telegram/bot/types/passport_element_error_translation_files' -require 'telegram/bot/types/passport_element_error_unspecified' -require 'telegram/bot/types/labeled_price' -require 'telegram/bot/types/input_message_content' -require 'telegram/bot/types/input_contact_message_content' -require 'telegram/bot/types/input_invoice_message_content' -require 'telegram/bot/types/input_location_message_content' -require 'telegram/bot/types/input_text_message_content' -require 'telegram/bot/types/input_venue_message_content' -require 'telegram/bot/types/login_url' -require 'telegram/bot/types/web_app_info' -require 'telegram/bot/types/inline_keyboard_button' -require 'telegram/bot/types/inline_keyboard_markup' -require 'telegram/bot/types/inline_query' -require 'telegram/bot/types/inline_query_result_article' -require 'telegram/bot/types/inline_query_result_audio' -require 'telegram/bot/types/inline_query_result_cached_audio' -require 'telegram/bot/types/inline_query_result_cached_document' -require 'telegram/bot/types/inline_query_result_cached_gif' -require 'telegram/bot/types/inline_query_result_cached_mpeg4_gif' -require 'telegram/bot/types/inline_query_result_cached_photo' -require 'telegram/bot/types/inline_query_result_cached_sticker' -require 'telegram/bot/types/inline_query_result_cached_video' -require 'telegram/bot/types/inline_query_result_cached_voice' -require 'telegram/bot/types/inline_query_result_contact' -require 'telegram/bot/types/inline_query_result_game' -require 'telegram/bot/types/inline_query_result_document' -require 'telegram/bot/types/inline_query_result_gif' -require 'telegram/bot/types/inline_query_result_location' -require 'telegram/bot/types/inline_query_result_mpeg4_gif' -require 'telegram/bot/types/inline_query_result_photo' -require 'telegram/bot/types/inline_query_result_venue' -require 'telegram/bot/types/inline_query_result_video' -require 'telegram/bot/types/inline_query_result_voice' -require 'telegram/bot/types/chosen_inline_result' -require 'telegram/bot/types/proximity_alert_triggered' -require 'telegram/bot/types/video_chat_scheduled' -require 'telegram/bot/types/video_chat_started' -require 'telegram/bot/types/video_chat_ended' -require 'telegram/bot/types/video_chat_participants_invited' -require 'telegram/bot/types/message_auto_delete_timer_changed' -require 'telegram/bot/types/web_app_data' -require 'telegram/bot/types/message' -require 'telegram/bot/types/callback_query' -require 'telegram/bot/types/shipping_query' -require 'telegram/bot/types/pre_checkout_query' -require 'telegram/bot/types/keyboard_button_poll_type' -require 'telegram/bot/types/keyboard_button' -require 'telegram/bot/types/reply_keyboard_markup' -require 'telegram/bot/types/reply_keyboard_remove' -require 'telegram/bot/types/force_reply' -require 'telegram/bot/types/shipping_option' -require 'telegram/bot/types/chat_invite_link' -require 'telegram/bot/types/chat_member' -require 'telegram/bot/types/chat_member_updated' -require 'telegram/bot/types/chat_join_request' -require 'telegram/bot/types/update' -require 'telegram/bot/types/user_profile_photos' -require 'telegram/bot/types/input_media_photo' -require 'telegram/bot/types/input_media_video' -require 'telegram/bot/types/input_media_animation' -require 'telegram/bot/types/input_media_audio' -require 'telegram/bot/types/input_media_document' -require 'telegram/bot/types/webhook_info' -require 'telegram/bot/types/bot_command' -require 'telegram/bot/types/bot_command_scope_all_chat_administrators' -require 'telegram/bot/types/bot_command_scope_all_group_chats' -require 'telegram/bot/types/bot_command_scope_all_private_chats' -require 'telegram/bot/types/bot_command_scope_chat_administrators' -require 'telegram/bot/types/bot_command_scope_chat_member' -require 'telegram/bot/types/bot_command_scope_chat' -require 'telegram/bot/types/bot_command_scope_default' -require 'telegram/bot/types/sent_web_app_message' -require 'telegram/bot/types/menu_button_commands' -require 'telegram/bot/types/menu_button_web_app' -require 'telegram/bot/types/menu_button_default' -require 'telegram/bot/types/chat_administrator_rights' - -Virtus.finalize +module Telegram + module Bot + module Types + include Dry.Types() + end + end +end diff --git a/lib/telegram/bot/types/animation.rb b/lib/telegram/bot/types/animation.rb index 576ad70..9f145fb 100644 --- a/lib/telegram/bot/types/animation.rb +++ b/lib/telegram/bot/types/animation.rb @@ -4,15 +4,15 @@ module Telegram module Bot module Types class Animation < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :width, Integer - attribute :height, Integer - attribute :duration, Integer - attribute :thumb, PhotoSize - attribute :file_name, String - attribute :mime_type, String - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :width, Types::Integer + attribute :height, Types::Integer + attribute :duration, Types::Integer + attribute? :thumb, PhotoSize + attribute? :file_name, Types::String + attribute? :mime_type, Types::String + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/audio.rb b/lib/telegram/bot/types/audio.rb index 0edf2cd..f4bf081 100644 --- a/lib/telegram/bot/types/audio.rb +++ b/lib/telegram/bot/types/audio.rb @@ -4,15 +4,15 @@ module Telegram module Bot module Types class Audio < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :duration, Integer - attribute :performer, String - attribute :title, String - attribute :file_name, String - attribute :mime_type, String - attribute :file_size, Integer - attribute :thumb, PhotoSize + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :duration, Types::Integer + attribute? :performer, Types::String + attribute? :title, Types::String + attribute? :file_name, Types::String + attribute? :mime_type, Types::String + attribute? :file_size, Types::Integer + attribute? :thumb, PhotoSize end end end diff --git a/lib/telegram/bot/types/base.rb b/lib/telegram/bot/types/base.rb index 440499b..4155f8c 100644 --- a/lib/telegram/bot/types/base.rb +++ b/lib/telegram/bot/types/base.rb @@ -3,10 +3,11 @@ module Telegram module Bot module Types - class Base - include Virtus.model + class Base < Dry::Struct include Compactable include PatternMatching + + transform_keys(&:to_sym) end end end diff --git a/lib/telegram/bot/types/bot_command.rb b/lib/telegram/bot/types/bot_command.rb index 09a0bde..c1c44a7 100644 --- a/lib/telegram/bot/types/bot_command.rb +++ b/lib/telegram/bot/types/bot_command.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class BotCommand < Base - attribute :command, String - attribute :description, String + attribute :command, Types::String + attribute :description, Types::String end end end diff --git a/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb b/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb index 2f97f69..8df8ee2 100644 --- a/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb +++ b/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeAllChatAdministrators < Base - attribute :type, String, default: 'all_chat_administrators' + attribute :type, Types::String.default('all_chat_administrators') end end end diff --git a/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb b/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb index 9295d3d..e952139 100644 --- a/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb +++ b/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeAllGroupChats < Base - attribute :type, String, default: 'all_group_chats' + attribute :type, Types::String.default('all_group_chats') end end end diff --git a/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb b/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb index 6341420..d3cb9d4 100644 --- a/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb +++ b/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeAllPrivateChats < Base - attribute :type, String, default: 'all_private_chats' + attribute :type, Types::String.default('all_private_chats') end end end diff --git a/lib/telegram/bot/types/bot_command_scope_chat.rb b/lib/telegram/bot/types/bot_command_scope_chat.rb index 70fadad..b620fd1 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class BotCommandScopeChat < Base - attribute :type, String, default: 'chat' - attribute :chat_id, String + attribute :type, Types::String.default('chat') + attribute :chat_id, Types::String end end end diff --git a/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb b/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb index 5b4a4ca..5132051 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class BotCommandScopeChatAdministrators < Base - attribute :type, String, default: 'chat_administrators' - attribute :chat_id, String + attribute :type, Types::String.default('chat_administrators') + attribute :chat_id, Types::String end end end diff --git a/lib/telegram/bot/types/bot_command_scope_chat_member.rb b/lib/telegram/bot/types/bot_command_scope_chat_member.rb index 0efdf7e..f5bd686 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat_member.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat_member.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class BotCommandScopeChatMember < Base - attribute :type, String, default: 'chat_member' - attribute :chat_id, String - attribute :user_id, Integer + attribute :type, Types::String.default('chat_member') + attribute :chat_id, Types::String + attribute :user_id, Types::Integer end end end diff --git a/lib/telegram/bot/types/bot_command_scope_default.rb b/lib/telegram/bot/types/bot_command_scope_default.rb index fca6772..acbb397 100644 --- a/lib/telegram/bot/types/bot_command_scope_default.rb +++ b/lib/telegram/bot/types/bot_command_scope_default.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeDefault < Base - attribute :type, String, default: 'default' + attribute :type, Types::String.default('default') end end end diff --git a/lib/telegram/bot/types/callback_query.rb b/lib/telegram/bot/types/callback_query.rb index efec40e..0023873 100644 --- a/lib/telegram/bot/types/callback_query.rb +++ b/lib/telegram/bot/types/callback_query.rb @@ -4,13 +4,13 @@ module Telegram module Bot module Types class CallbackQuery < Base - attribute :id, String + attribute :id, Types::String attribute :from, User - attribute :message, Message - attribute :inline_message_id, String - attribute :chat_instance, String - attribute :data, String - attribute :game_short_name, String + attribute? :message, Message + attribute? :inline_message_id, Types::String + attribute :chat_instance, Types::String + attribute? :data, Types::String + attribute? :game_short_name, Types::String end end end diff --git a/lib/telegram/bot/types/chat.rb b/lib/telegram/bot/types/chat.rb index 53c35c8..47da376 100644 --- a/lib/telegram/bot/types/chat.rb +++ b/lib/telegram/bot/types/chat.rb @@ -3,34 +3,35 @@ module Telegram module Bot module Types - class Chat - include Virtus.model(finalize: false) - include Compactable - include PatternMatching - - attribute :id, Integer - attribute :type, String - attribute :title, String - attribute :username, String - attribute :first_name, String - attribute :last_name, String - attribute :photo, ChatPhoto - attribute :bio, String - attribute :has_private_forwards, Boolean - attribute :has_restricted_voice_and_video_messages, Boolean - attribute :join_to_send_messages, Boolean - attribute :join_by_request, Boolean - attribute :description, String - attribute :invite_link, String - attribute :pinned_message, 'Telegram::Bot::Types::Message' - attribute :permissions, ChatPermissions - attribute :slow_mode_delay, Integer - attribute :message_auto_delete_time, Integer - attribute :has_protected_content, Boolean - attribute :sticker_set_name, String - attribute :can_set_sticker_set, Boolean - attribute :linked_chat_id, Integer - attribute :location, ChatLocation + class Chat < Base + attribute :id, Types::Integer + attribute :type, Types::String + attribute? :title, Types::String + attribute? :username, Types::String + attribute? :first_name, Types::String + attribute? :last_name, Types::String + attribute? :is_forum, Types::Bool + attribute? :photo, ChatPhoto + attribute? :active_usernames, Types::Array.of(Types::String) + attribute? :emoji_status_custom_emoji_id, Types::String + attribute? :bio, Types::String + attribute? :has_private_forwards, Types::Bool + attribute? :has_restricted_voice_and_video_messages, Types::Bool + attribute? :join_to_send_messages, Types::Bool + attribute? :join_by_request, Types::Bool + attribute? :description, Types::String + attribute? :invite_link, Types::String + attribute? :pinned_message, Message + attribute? :permissions, ChatPermissions + attribute? :slow_mode_delay, Types::Integer + attribute? :message_auto_delete_time, Types::Integer + attribute? :has_aggressive_anti_spam_enabled, Types::Bool + attribute? :has_hidden_members, Types::Bool + attribute? :has_protected_content, Types::Bool + attribute? :sticker_set_name, Types::String + attribute? :can_set_sticker_set, Types::Bool + attribute? :linked_chat_id, Types::Integer + attribute? :location, ChatLocation end end end diff --git a/lib/telegram/bot/types/chat_administrator_rights.rb b/lib/telegram/bot/types/chat_administrator_rights.rb index 6f4621a..e1708f7 100644 --- a/lib/telegram/bot/types/chat_administrator_rights.rb +++ b/lib/telegram/bot/types/chat_administrator_rights.rb @@ -3,18 +3,19 @@ module Telegram module Bot module Types - class ChatAdministratorRight < Base - attribute :is_anonymous, Boolean - attribute :can_manage_chat, Boolean - attribute :can_delete_messages, Boolean - attribute :can_manage_video_chats, Boolean - attribute :can_restrict_members, Boolean - attribute :can_promote_members, Boolean - attribute :can_change_info, Boolean - attribute :can_invite_users, Boolean - attribute :can_post_messages, Boolean - attribute :can_edit_messages, Boolean - attribute :can_pin_messages, Boolean + class ChatAdministratorRights < Base + attribute :is_anonymous, Types::Bool + attribute :can_manage_chat, Types::Bool + attribute :can_delete_messages, Types::Bool + attribute :can_manage_video_chats, Types::Bool + attribute :can_restrict_members, Types::Bool + attribute :can_promote_members, Types::Bool + attribute :can_change_info, Types::Bool + attribute :can_invite_users, Types::Bool + attribute? :can_post_messages, Types::Bool + attribute? :can_edit_messages, Types::Bool + attribute? :can_pin_messages, Types::Bool + attribute? :can_manage_topics, Types::Bool end end end diff --git a/lib/telegram/bot/types/chat_invite_link.rb b/lib/telegram/bot/types/chat_invite_link.rb index 21c192a..28d8349 100644 --- a/lib/telegram/bot/types/chat_invite_link.rb +++ b/lib/telegram/bot/types/chat_invite_link.rb @@ -4,15 +4,15 @@ module Telegram module Bot module Types class ChatInviteLink < Base - attribute :invite_link, String + attribute :invite_link, Types::String attribute :creator, User - attribute :creates_join_request, Boolean - attribute :is_primary, Boolean - attribute :is_revoked, Boolean - attribute :name, String - attribute :expire_date, Integer - attribute :member_limit, Integer - attribute :pending_join_request_count, Integer + attribute :creates_join_request, Types::Bool + attribute :is_primary, Types::Bool + attribute :is_revoked, Types::Bool + attribute? :name, Types::String + attribute? :expire_date, Types::Integer + attribute? :member_limit, Types::Integer + attribute? :pending_join_request_count, Types::Integer end end end diff --git a/lib/telegram/bot/types/chat_join_request.rb b/lib/telegram/bot/types/chat_join_request.rb index fd95eb9..d56c2f6 100644 --- a/lib/telegram/bot/types/chat_join_request.rb +++ b/lib/telegram/bot/types/chat_join_request.rb @@ -6,9 +6,10 @@ module Types class ChatJoinRequest < Base attribute :chat, Chat attribute :from, User - attribute :date, Integer - attribute :bio, String - attribute :invite_link, ChatInviteLink + attribute :user_chat_id, Types::Integer + attribute :date, Types::Integer + attribute? :bio, Types::String + attribute? :invite_link, ChatInviteLink end end end diff --git a/lib/telegram/bot/types/chat_location.rb b/lib/telegram/bot/types/chat_location.rb index a8c1c50..bf9d14d 100644 --- a/lib/telegram/bot/types/chat_location.rb +++ b/lib/telegram/bot/types/chat_location.rb @@ -5,7 +5,7 @@ module Bot module Types class ChatLocation < Base attribute :location, Location - attribute :address, String + attribute :address, Types::String end end end diff --git a/lib/telegram/bot/types/chat_member.rb b/lib/telegram/bot/types/chat_member.rb index 512a384..6efcd2e 100644 --- a/lib/telegram/bot/types/chat_member.rb +++ b/lib/telegram/bot/types/chat_member.rb @@ -4,28 +4,6 @@ module Telegram module Bot module Types class ChatMember < Base - attribute :user, User - attribute :status, String - attribute :custom_title, String - attribute :is_anonymous, Boolean - attribute :can_be_edited, Boolean - attribute :can_manage_chat, Boolean - attribute :can_post_messages, Boolean - attribute :can_edit_messages, Boolean - attribute :can_delete_messages, Boolean - attribute :can_manage_video_chats, Boolean - attribute :can_restrict_members, Boolean - attribute :can_promote_members, Boolean - attribute :can_change_info, Boolean - attribute :can_invite_users, Boolean - attribute :can_pin_messages, Boolean - attribute :is_member, Boolean - attribute :can_send_messages, Boolean - attribute :can_send_media_messages, Boolean - attribute :can_send_polls, Boolean - attribute :can_send_other_messages, Boolean - attribute :can_add_web_page_previews, Boolean - attribute :until_date, Integer end end end diff --git a/lib/telegram/bot/types/chat_member_administrator.rb b/lib/telegram/bot/types/chat_member_administrator.rb new file mode 100644 index 0000000..a5da396 --- /dev/null +++ b/lib/telegram/bot/types/chat_member_administrator.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatMemberAdministrator < ChatMember + attribute :status, Types::String + attribute :user, User + attribute :can_be_edited, Types::Bool + attribute :is_anonymous, Types::Bool + attribute :can_manage_chat, Types::Bool + attribute :can_delete_messages, Types::Bool + attribute :can_manage_video_chats, Types::Bool + attribute :can_restrict_members, Types::Bool + attribute :can_promote_members, Types::Bool + attribute :can_change_info, Types::Bool + attribute :can_invite_users, Types::Bool + attribute? :can_post_messages, Types::Bool + attribute? :can_edit_messages, Types::Integer + attribute? :can_pin_messages, Types::Integer + attribute? :can_manage_topics, Types::Integer + attribute? :custom_title, Types::String + end + end + end +end diff --git a/lib/telegram/bot/types/chat_member_banned.rb b/lib/telegram/bot/types/chat_member_banned.rb new file mode 100644 index 0000000..188b6fc --- /dev/null +++ b/lib/telegram/bot/types/chat_member_banned.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatMemberBanned < ChatMember + attribute :status, Types::String + attribute :user, User + attribute :until_date, Types::Integer + end + end + end +end diff --git a/lib/telegram/bot/types/chat_member_left.rb b/lib/telegram/bot/types/chat_member_left.rb new file mode 100644 index 0000000..3856351 --- /dev/null +++ b/lib/telegram/bot/types/chat_member_left.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatMemberLeft < ChatMember + attribute :status, Types::String + attribute :user, User + end + end + end +end diff --git a/lib/telegram/bot/types/chat_member_member.rb b/lib/telegram/bot/types/chat_member_member.rb new file mode 100644 index 0000000..6fc96ad --- /dev/null +++ b/lib/telegram/bot/types/chat_member_member.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatMemberMember < ChatMember + attribute :status, Types::String + attribute :user, User + end + end + end +end diff --git a/lib/telegram/bot/types/chat_member_owner.rb b/lib/telegram/bot/types/chat_member_owner.rb new file mode 100644 index 0000000..c6c99c4 --- /dev/null +++ b/lib/telegram/bot/types/chat_member_owner.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatMemberOwner < ChatMember + attribute :status, Types::String + attribute :user, User + attribute :is_anonymous, Types::Bool + attribute? :custom_title, Types::String + end + end + end +end diff --git a/lib/telegram/bot/types/chat_member_restricted.rb b/lib/telegram/bot/types/chat_member_restricted.rb new file mode 100644 index 0000000..40a947e --- /dev/null +++ b/lib/telegram/bot/types/chat_member_restricted.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatMemberRestricted < ChatMember + attribute :status, Types::String + attribute :user, User + attribute :is_member, Types::Bool + attribute :can_send_messages, Types::Bool + attribute :can_send_audios, Types::Bool + attribute :can_send_documents, Types::Bool + attribute :can_send_photos, Types::Bool + attribute :can_send_videos, Types::Bool + attribute :can_send_video_notes, Types::Bool + attribute :can_send_voice_notes, Types::Bool + attribute :can_send_polls, Types::Bool + attribute :can_send_other_messages, Types::Bool + attribute :can_add_web_page_previews, Types::Bool + attribute :can_change_info, Types::Bool + attribute :can_invite_users, Types::Bool + attribute :can_pin_messages, Types::Bool + attribute :can_manage_topics, Types::Bool + attribute :until_date, Types::Integer + end + end + end +end diff --git a/lib/telegram/bot/types/chat_member_updated.rb b/lib/telegram/bot/types/chat_member_updated.rb index 8c0267b..16c98f5 100644 --- a/lib/telegram/bot/types/chat_member_updated.rb +++ b/lib/telegram/bot/types/chat_member_updated.rb @@ -6,10 +6,10 @@ module Types class ChatMemberUpdated < Base attribute :chat, Chat attribute :from, User - attribute :date, Integer + attribute :date, Types::Integer attribute :old_chat_member, ChatMember attribute :new_chat_member, ChatMember - attribute :invite_link, ChatInviteLink + attribute? :invite_link, ChatInviteLink end end end diff --git a/lib/telegram/bot/types/chat_permissions.rb b/lib/telegram/bot/types/chat_permissions.rb index ed97490..5779553 100644 --- a/lib/telegram/bot/types/chat_permissions.rb +++ b/lib/telegram/bot/types/chat_permissions.rb @@ -4,14 +4,20 @@ module Telegram module Bot module Types class ChatPermissions < Base - attribute :can_send_messages, Boolean - attribute :can_send_media_messages, Boolean - attribute :can_send_polls, Boolean - attribute :can_send_other_messages, Boolean - attribute :can_add_web_page_previews, Boolean - attribute :can_change_info, Boolean - attribute :can_invite_users, Boolean - attribute :can_pin_messages, Boolean + attribute? :can_send_messages, Types::Bool + attribute? :can_send_audios, Types::Bool + attribute? :can_send_documents, Types::Bool + attribute? :can_send_photos, Types::Bool + attribute? :can_send_videos, Types::Bool + attribute? :can_send_video_notes, Types::Bool + attribute? :can_send_voice_notes, Types::Bool + attribute? :can_send_polls, Types::Bool + attribute? :can_send_other_messages, Types::Bool + attribute? :can_add_web_page_previews, Types::Bool + attribute? :can_change_info, Types::Bool + attribute? :can_invite_users, Types::Bool + attribute? :can_pin_messages, Types::Bool + attribute? :can_manage_topics, Types::Bool end end end diff --git a/lib/telegram/bot/types/chat_photo.rb b/lib/telegram/bot/types/chat_photo.rb index 834ea5e..11290ed 100644 --- a/lib/telegram/bot/types/chat_photo.rb +++ b/lib/telegram/bot/types/chat_photo.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class ChatPhoto < Base - attribute :small_file_id, String - attribute :small_file_unique_id, String - attribute :big_file_id, String - attribute :big_file_unique_id, String + attribute :small_file_id, Types::String + attribute :small_file_unique_id, Types::String + attribute :big_file_id, Types::String + attribute :big_file_unique_id, Types::String end end end diff --git a/lib/telegram/bot/types/chat_shared.rb b/lib/telegram/bot/types/chat_shared.rb new file mode 100644 index 0000000..97e1a3a --- /dev/null +++ b/lib/telegram/bot/types/chat_shared.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ChatShared < Base + attribute :request_id, Types::Integer + attribute :chat_id, Types::Integer + end + end + end +end diff --git a/lib/telegram/bot/types/chosen_inline_result.rb b/lib/telegram/bot/types/chosen_inline_result.rb index 5601599..bf2f1aa 100644 --- a/lib/telegram/bot/types/chosen_inline_result.rb +++ b/lib/telegram/bot/types/chosen_inline_result.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class ChosenInlineResult < Base - attribute :result_id, String + attribute :result_id, Types::String attribute :from, User - attribute :location, Location - attribute :inline_message_id, String - attribute :query, String + attribute? :location, Location + attribute? :inline_message_id, Types::String + attribute :query, Types::String alias to_s query end diff --git a/lib/telegram/bot/types/contact.rb b/lib/telegram/bot/types/contact.rb index fc3740c..e97959e 100644 --- a/lib/telegram/bot/types/contact.rb +++ b/lib/telegram/bot/types/contact.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class Contact < Base - attribute :phone_number, String - attribute :first_name, String - attribute :last_name, String - attribute :user_id, Integer - attribute :vcard, String + attribute :phone_number, Types::String + attribute :first_name, Types::String + attribute? :last_name, Types::String + attribute? :user_id, Types::Integer + attribute? :vcard, Types::String end end end diff --git a/lib/telegram/bot/types/dice.rb b/lib/telegram/bot/types/dice.rb index d18ed3d..82b34a6 100644 --- a/lib/telegram/bot/types/dice.rb +++ b/lib/telegram/bot/types/dice.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class Dice < Base - attribute :emoji, String - attribute :value, Integer + attribute :emoji, Types::String + attribute :value, Types::Integer end end end diff --git a/lib/telegram/bot/types/document.rb b/lib/telegram/bot/types/document.rb index 9215329..9725f9a 100644 --- a/lib/telegram/bot/types/document.rb +++ b/lib/telegram/bot/types/document.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class Document < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :thumb, PhotoSize - attribute :file_name, String - attribute :mime_type, String - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute? :thumb, PhotoSize + attribute? :file_name, Types::String + attribute? :mime_type, Types::String + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/encrypted_credentials.rb b/lib/telegram/bot/types/encrypted_credentials.rb index 60359ac..ff2fe75 100644 --- a/lib/telegram/bot/types/encrypted_credentials.rb +++ b/lib/telegram/bot/types/encrypted_credentials.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class EncryptedCredentials < Base - attribute :data, String - attribute :hash, String - attribute :secret, String + attribute :data, Types::String + attribute :hash, Types::String + attribute :secret, Types::String end end end diff --git a/lib/telegram/bot/types/encrypted_passport_element.rb b/lib/telegram/bot/types/encrypted_passport_element.rb index 180845c..82d36bf 100644 --- a/lib/telegram/bot/types/encrypted_passport_element.rb +++ b/lib/telegram/bot/types/encrypted_passport_element.rb @@ -4,16 +4,16 @@ module Telegram module Bot module Types class EncryptedPassportElement < Base - attribute :type, String - attribute :data, String - attribute :phone_number, String - attribute :email, String - attribute :files, Array[PassportFile] - attribute :front_side, PassportFile - attribute :reverse_side, PassportFile - attribute :selfie, PassportFile - attribute :translation, Array[PassportFile] - attribute :hash, String + attribute :type, Types::String + attribute? :data, Types::String + attribute? :phone_number, Types::String + attribute? :email, Types::String + attribute? :files, Types::Array.of(PassportFile) + attribute? :front_side, PassportFile + attribute? :reverse_side, PassportFile + attribute? :selfie, PassportFile + attribute? :translation, Types::Array.of(PassportFile) + attribute :hash, Types::String end end end diff --git a/lib/telegram/bot/types/file.rb b/lib/telegram/bot/types/file.rb index e2cbb76..404bf2b 100644 --- a/lib/telegram/bot/types/file.rb +++ b/lib/telegram/bot/types/file.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class File < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :file_size, Integer - attribute :file_path, String + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute? :file_size, Types::Integer + attribute? :file_path, Types::String end end end diff --git a/lib/telegram/bot/types/force_reply.rb b/lib/telegram/bot/types/force_reply.rb index aa8f7a4..5d154e5 100644 --- a/lib/telegram/bot/types/force_reply.rb +++ b/lib/telegram/bot/types/force_reply.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class ForceReply < Base - attribute :force_reply, Boolean - attribute :input_field_placeholder, String - attribute :selective, Boolean, default: false + attribute :force_reply, Types::Bool + attribute? :input_field_placeholder, Types::String + attribute? :selective, Types::Bool.default(false) end end end diff --git a/lib/telegram/bot/types/forum_topic.rb b/lib/telegram/bot/types/forum_topic.rb new file mode 100644 index 0000000..4069901 --- /dev/null +++ b/lib/telegram/bot/types/forum_topic.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ForumTopic < Base + attribute :message_thread_id, Types::Integer + attribute :name, Types::String + attribute :icon_color, Types::Integer + attribute? :icon_custom_emoji_id, Types::String + end + end + end +end diff --git a/lib/telegram/bot/types/forum_topic_closed.rb b/lib/telegram/bot/types/forum_topic_closed.rb new file mode 100644 index 0000000..9f1c632 --- /dev/null +++ b/lib/telegram/bot/types/forum_topic_closed.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ForumTopicClosed < Base + end + end + end +end diff --git a/lib/telegram/bot/types/forum_topic_created.rb b/lib/telegram/bot/types/forum_topic_created.rb new file mode 100644 index 0000000..561c572 --- /dev/null +++ b/lib/telegram/bot/types/forum_topic_created.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ForumTopicCreated < Base + attribute :name, Types::String + attribute :icon_color, Types::Integer + attribute? :icon_custom_emoji_id, Types::String + end + end + end +end diff --git a/lib/telegram/bot/types/forum_topic_edited.rb b/lib/telegram/bot/types/forum_topic_edited.rb new file mode 100644 index 0000000..7c48198 --- /dev/null +++ b/lib/telegram/bot/types/forum_topic_edited.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ForumTopicEdited < Base + attribute? :name, Types::String + attribute? :icon_custom_emoji_id, Types::String + end + end + end +end diff --git a/lib/telegram/bot/types/forum_topic_reopened.rb b/lib/telegram/bot/types/forum_topic_reopened.rb new file mode 100644 index 0000000..bb8d617 --- /dev/null +++ b/lib/telegram/bot/types/forum_topic_reopened.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class ForumTopicReopened < Base + end + end + end +end diff --git a/lib/telegram/bot/types/game.rb b/lib/telegram/bot/types/game.rb index 9507e26..42cdaba 100644 --- a/lib/telegram/bot/types/game.rb +++ b/lib/telegram/bot/types/game.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class Game < Base - attribute :title, String - attribute :description, String - attribute :photo, Array[PhotoSize] - attribute :text, String - attribute :text_entities, Array[MessageEntity] - attribute :animation, Animation + attribute :title, Types::String + attribute :description, Types::String + attribute :photo, Types::Array.of(PhotoSize) + attribute? :text, Types::String + attribute? :text_entities, Types::Array.of(MessageEntity) + attribute? :animation, Animation end end end diff --git a/lib/telegram/bot/types/game_high_score.rb b/lib/telegram/bot/types/game_high_score.rb index af7755d..d74dfed 100644 --- a/lib/telegram/bot/types/game_high_score.rb +++ b/lib/telegram/bot/types/game_high_score.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class GameHighScore < Base - attribute :position, Integer + attribute :position, Types::Integer attribute :user, User - attribute :score, Integer + attribute :score, Types::Integer end end end diff --git a/lib/telegram/bot/types/general_forum_topic_hidden.rb b/lib/telegram/bot/types/general_forum_topic_hidden.rb new file mode 100644 index 0000000..5992757 --- /dev/null +++ b/lib/telegram/bot/types/general_forum_topic_hidden.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class GeneralForumTopicHidden < Base + end + end + end +end diff --git a/lib/telegram/bot/types/general_forum_topic_unhidden.rb b/lib/telegram/bot/types/general_forum_topic_unhidden.rb new file mode 100644 index 0000000..83102b2 --- /dev/null +++ b/lib/telegram/bot/types/general_forum_topic_unhidden.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class GeneralForumTopicUnhidden < Base + end + end + end +end diff --git a/lib/telegram/bot/types/inline_keyboard_button.rb b/lib/telegram/bot/types/inline_keyboard_button.rb index cf7d768..57946cf 100644 --- a/lib/telegram/bot/types/inline_keyboard_button.rb +++ b/lib/telegram/bot/types/inline_keyboard_button.rb @@ -4,15 +4,15 @@ module Telegram module Bot module Types class InlineKeyboardButton < Base - attribute :text, String - attribute :url, String - attribute :callback_data, String - attribute :web_app, WebAppInfo - attribute :login_url, LoginUrl - attribute :switch_inline_query, String - attribute :switch_inline_query_current_chat, String - attribute :callback_game, CallbackGame - attribute :pay, Boolean + attribute :text, Types::String + attribute? :url, Types::String + attribute? :callback_data, Types::String + attribute? :web_app, WebAppInfo + attribute? :login_url, LoginUrl + attribute? :switch_inline_query, Types::String + attribute? :switch_inline_query_current_chat, Types::String + attribute? :callback_game, CallbackGame + attribute? :pay, Types::Bool end end end diff --git a/lib/telegram/bot/types/inline_keyboard_markup.rb b/lib/telegram/bot/types/inline_keyboard_markup.rb index c67144b..dbf21e8 100644 --- a/lib/telegram/bot/types/inline_keyboard_markup.rb +++ b/lib/telegram/bot/types/inline_keyboard_markup.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineKeyboardMarkup < Base - attribute :inline_keyboard, Array[Array[InlineKeyboardButton]] + attribute :inline_keyboard, Types::Array.of(Types::Array.of(InlineKeyboardButton)) def to_compact_hash hsh = super diff --git a/lib/telegram/bot/types/inline_query.rb b/lib/telegram/bot/types/inline_query.rb index 20e1e8f..cca722b 100644 --- a/lib/telegram/bot/types/inline_query.rb +++ b/lib/telegram/bot/types/inline_query.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class InlineQuery < Base - attribute :id, String + attribute :id, Types::String attribute :from, User - attribute :query, String - attribute :offset, String - attribute :chat_type, String - attribute :location, Location + attribute :query, Types::String + attribute :offset, Types::String + attribute? :chat_type, Types::String + attribute? :location, Location alias to_s query end diff --git a/lib/telegram/bot/types/inline_query_result_article.rb b/lib/telegram/bot/types/inline_query_result_article.rb index 4a47676..c6eca2d 100644 --- a/lib/telegram/bot/types/inline_query_result_article.rb +++ b/lib/telegram/bot/types/inline_query_result_article.rb @@ -4,17 +4,17 @@ module Telegram module Bot module Types class InlineQueryResultArticle < Base - attribute :type, String, default: 'article' - attribute :id, String - attribute :title, String + attribute :type, Types::String.default('article') + attribute :id, Types::String + attribute :title, Types::String attribute :input_message_content, InputMessageContent - attribute :reply_markup, InlineKeyboardMarkup - attribute :url, String - attribute :hide_url, Boolean - attribute :description, String - attribute :thumb_url, String - attribute :thumb_width, Integer - attribute :thumb_height, Integer + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :url, Types::String + attribute? :hide_url, Types::Bool + attribute? :description, Types::String + attribute? :thumb_url, Types::String + attribute? :thumb_width, Types::Integer + attribute? :thumb_height, Types::Integer end end end diff --git a/lib/telegram/bot/types/inline_query_result_audio.rb b/lib/telegram/bot/types/inline_query_result_audio.rb index 86e1904..5d2a961 100644 --- a/lib/telegram/bot/types/inline_query_result_audio.rb +++ b/lib/telegram/bot/types/inline_query_result_audio.rb @@ -4,16 +4,17 @@ module Telegram module Bot module Types class InlineQueryResultAudio < Base - attribute :type, String, default: 'audio' - attribute :id, String - attribute :audio_url, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :performer, String - attribute :audio_duration, Integer - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('audio') + attribute :id, Types::String + attribute :audio_url, Types::String + attribute :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :performer, Types::String + attribute? :audio_duration, Types::Integer + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_audio.rb b/lib/telegram/bot/types/inline_query_result_cached_audio.rb index e87690b..e918f88 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_audio.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_audio.rb @@ -4,13 +4,14 @@ module Telegram module Bot module Types class InlineQueryResultCachedAudio < Base - attribute :type, String, default: 'audio' - attribute :id, String - attribute :audio_file_id, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('audio') + attribute :id, Types::String + attribute :audio_file_id, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_document.rb b/lib/telegram/bot/types/inline_query_result_cached_document.rb index fba71f1..6a6a193 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_document.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_document.rb @@ -4,15 +4,16 @@ module Telegram module Bot module Types class InlineQueryResultCachedDocument < Base - attribute :type, String, default: 'document' - attribute :id, String - attribute :title, String - attribute :document_file_id, String - attribute :description, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('document') + attribute :id, Types::String + attribute :title, Types::String + attribute :document_file_id, Types::String + attribute? :description, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_gif.rb b/lib/telegram/bot/types/inline_query_result_cached_gif.rb index ce6c53f..11ceef1 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_gif.rb @@ -4,14 +4,15 @@ module Telegram module Bot module Types class InlineQueryResultCachedGif < Base - attribute :type, String, default: 'gif' - attribute :id, String - attribute :gif_file_id, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('gif') + attribute :id, Types::String + attribute :gif_file_id, Types::String + attribute? :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb b/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb index e17b944..99efb67 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb @@ -4,14 +4,15 @@ module Telegram module Bot module Types class InlineQueryResultCachedMpeg4Gif < Base - attribute :type, String, default: 'mpeg4_gif' - attribute :id, String - attribute :mpeg4_file_id, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('mpeg4_gif') + attribute :id, Types::String + attribute :mpeg4_file_id, Types::String + attribute? :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_photo.rb b/lib/telegram/bot/types/inline_query_result_cached_photo.rb index f27f32a..d745e74 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_photo.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_photo.rb @@ -4,15 +4,16 @@ module Telegram module Bot module Types class InlineQueryResultCachedPhoto < Base - attribute :type, String, default: 'photo' - attribute :id, String - attribute :photo_file_id, String - attribute :title, String - attribute :description, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('photo') + attribute :id, Types::String + attribute :photo_file_id, Types::String + attribute? :title, Types::String + attribute? :description, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_sticker.rb b/lib/telegram/bot/types/inline_query_result_cached_sticker.rb index dcfb0a5..cb84243 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_sticker.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_sticker.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class InlineQueryResultCachedSticker < Base - attribute :type, String, default: 'sticker' - attribute :id, String - attribute :sticker_file_id, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('sticker') + attribute :id, Types::String + attribute :sticker_file_id, Types::String + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_video.rb b/lib/telegram/bot/types/inline_query_result_cached_video.rb index e659ef0..c2a90cf 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_video.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_video.rb @@ -4,15 +4,16 @@ module Telegram module Bot module Types class InlineQueryResultCachedVideo < Base - attribute :type, String, default: 'video' - attribute :id, String - attribute :video_file_id, String - attribute :title, String - attribute :description, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('video') + attribute :id, Types::String + attribute :video_file_id, Types::String + attribute :title, Types::String + attribute? :description, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_cached_voice.rb b/lib/telegram/bot/types/inline_query_result_cached_voice.rb index b273d77..dc95afc 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_voice.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_voice.rb @@ -4,14 +4,15 @@ module Telegram module Bot module Types class InlineQueryResultCachedVoice < Base - attribute :type, String, default: 'voice' - attribute :id, String - attribute :voice_file_id, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('voice') + attribute :id, Types::String + attribute :voice_file_id, Types::String + attribute :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_contact.rb b/lib/telegram/bot/types/inline_query_result_contact.rb index 9848e79..41d0b12 100644 --- a/lib/telegram/bot/types/inline_query_result_contact.rb +++ b/lib/telegram/bot/types/inline_query_result_contact.rb @@ -4,17 +4,17 @@ module Telegram module Bot module Types class InlineQueryResultContact < Base - attribute :type, String, default: 'contact' - attribute :id, String - attribute :phone_number, String - attribute :first_name, String - attribute :last_name, String - attribute :vcard, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent - attribute :thumb_url, String - attribute :thumb_width, Integer - attribute :thumb_height, Integer + attribute :type, Types::String.default('contact') + attribute :id, Types::String + attribute :phone_number, Types::String + attribute :first_name, Types::String + attribute? :last_name, Types::String + attribute? :vcard, Types::String + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent + attribute? :thumb_url, Types::String + attribute? :thumb_width, Types::Integer + attribute? :thumb_height, Types::Integer end end end diff --git a/lib/telegram/bot/types/inline_query_result_document.rb b/lib/telegram/bot/types/inline_query_result_document.rb index 9931beb..aebe949 100644 --- a/lib/telegram/bot/types/inline_query_result_document.rb +++ b/lib/telegram/bot/types/inline_query_result_document.rb @@ -4,19 +4,20 @@ module Telegram module Bot module Types class InlineQueryResultDocument < Base - attribute :type, String, default: 'document' - attribute :id, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :document_url, String - attribute :mime_type, String - attribute :description, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent - attribute :thumb_url, String - attribute :thumb_width, Integer - attribute :thumb_height, Integer + attribute :type, Types::String.default('document') + attribute :id, Types::String + attribute :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute :document_url, Types::String + attribute :mime_type, Types::String + attribute? :description, Types::String + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent + attribute? :thumb_url, Types::String + attribute? :thumb_width, Types::Integer + attribute? :thumb_height, Types::Integer end end end diff --git a/lib/telegram/bot/types/inline_query_result_game.rb b/lib/telegram/bot/types/inline_query_result_game.rb index 22fb310..dd8a05d 100644 --- a/lib/telegram/bot/types/inline_query_result_game.rb +++ b/lib/telegram/bot/types/inline_query_result_game.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class InlineQueryResultGame < Base - attribute :type, String, default: 'game' - attribute :id, String - attribute :game_short_name, String - attribute :reply_markup, InlineKeyboardMarkup + attribute :type, Types::String.default('game') + attribute :id, Types::String + attribute :game_short_name, Types::String + attribute? :reply_markup, InlineKeyboardMarkup end end end diff --git a/lib/telegram/bot/types/inline_query_result_gif.rb b/lib/telegram/bot/types/inline_query_result_gif.rb index 899ccec..27cee11 100644 --- a/lib/telegram/bot/types/inline_query_result_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_gif.rb @@ -4,18 +4,20 @@ module Telegram module Bot module Types class InlineQueryResultGif < Base - attribute :type, String, default: 'gif' - attribute :id, String - attribute :gif_url, String - attribute :gif_width, Integer - attribute :gif_height, Integer - attribute :gif_duration, Integer - attribute :thumb_url, String - attribute :thumb_mime_type, String - attribute :title, String - attribute :caption, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('gif') + attribute :id, Types::String + attribute :gif_url, Types::String + attribute? :gif_width, Types::Integer + attribute? :gif_height, Types::Integer + attribute? :gif_duration, Types::Integer + attribute :thumb_url, Types::String + attribute? :thumb_mime_type, Types::String + attribute? :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_location.rb b/lib/telegram/bot/types/inline_query_result_location.rb index 3f660d0..eb95e4e 100644 --- a/lib/telegram/bot/types/inline_query_result_location.rb +++ b/lib/telegram/bot/types/inline_query_result_location.rb @@ -4,20 +4,20 @@ module Telegram module Bot module Types class InlineQueryResultLocation < Base - attribute :type, String, default: 'location' - attribute :id, String - attribute :latitude, Float - attribute :longitude, Float - attribute :title, String - attribute :horizontal_accuracy, Float - attribute :live_period, Integer - attribute :heading, Integer - attribute :proximity_alert_radius, Integer - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent - attribute :thumb_url, String - attribute :thumb_width, Integer - attribute :thumb_height, Integer + attribute :type, Types::String.default('location') + attribute :id, Types::String + attribute :latitude, Types::Float + attribute :longitude, Types::Float + attribute :title, Types::String + attribute? :horizontal_accuracy, Types::Float + attribute? :live_period, Types::Integer + attribute? :heading, Types::Integer + attribute? :proximity_alert_radius, Types::Integer + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent + attribute? :thumb_url, Types::String + attribute? :thumb_width, Types::Integer + attribute? :thumb_height, Types::Integer end end end diff --git a/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb b/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb index 5ba8702..a0e2b9d 100644 --- a/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb @@ -4,19 +4,20 @@ module Telegram module Bot module Types class InlineQueryResultMpeg4Gif < Base - attribute :type, String, default: 'mpeg4_gif' - attribute :id, String - attribute :mpeg4_url, String - attribute :mpeg4_width, Integer - attribute :mpeg4_height, Integer - attribute :mpeg4_duration, Integer - attribute :thumb_url, String - attribute :thumb_mime_type, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('mpeg4_gif') + attribute :id, Types::String + attribute :mpeg4_url, Types::String + attribute? :mpeg4_width, Types::Integer + attribute? :mpeg4_height, Types::Integer + attribute? :mpeg4_duration, Types::Integer + attribute :thumb_url, Types::String + attribute? :thumb_mime_type, Types::String + attribute? :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_photo.rb b/lib/telegram/bot/types/inline_query_result_photo.rb index 02e9398..4108373 100644 --- a/lib/telegram/bot/types/inline_query_result_photo.rb +++ b/lib/telegram/bot/types/inline_query_result_photo.rb @@ -4,18 +4,19 @@ module Telegram module Bot module Types class InlineQueryResultPhoto < Base - attribute :type, String, default: 'photo' - attribute :id, String - attribute :photo_url, String - attribute :thumb_url, String - attribute :photo_width, Integer - attribute :photo_height, Integer - attribute :title, String - attribute :description, String - attribute :caption, String - attribute :parse_mode, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('photo') + attribute :id, Types::String + attribute :photo_url, Types::String + attribute :thumb_url, Types::String + attribute? :photo_width, Types::Integer + attribute? :photo_height, Types::Integer + attribute? :title, Types::String + attribute? :description, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_venue.rb b/lib/telegram/bot/types/inline_query_result_venue.rb index 93e4943..609a381 100644 --- a/lib/telegram/bot/types/inline_query_result_venue.rb +++ b/lib/telegram/bot/types/inline_query_result_venue.rb @@ -4,21 +4,21 @@ module Telegram module Bot module Types class InlineQueryResultVenue < Base - attribute :type, String, default: 'venue' - attribute :id, String - attribute :latitude, Float - attribute :longitude, Float - attribute :title, String - attribute :address, String - attribute :foursquare_id, String - attribute :foursquare_type, String - attribute :google_place_id, String - attribute :google_place_type, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent - attribute :thumb_url, String - attribute :thumb_width, Integer - attribute :thumb_height, Integer + attribute :type, Types::String.default('venue') + attribute :id, Types::String + attribute :latitude, Types::Float + attribute :longitude, Types::Float + attribute :title, Types::String + attribute :address, Types::String + attribute? :foursquare_id, Types::String + attribute? :foursquare_type, Types::String + attribute? :google_place_id, Types::String + attribute? :google_place_type, Types::String + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent + attribute? :thumb_url, Types::String + attribute? :thumb_width, Types::Integer + attribute? :thumb_height, Types::Integer end end end diff --git a/lib/telegram/bot/types/inline_query_result_video.rb b/lib/telegram/bot/types/inline_query_result_video.rb index d031496..4069598 100644 --- a/lib/telegram/bot/types/inline_query_result_video.rb +++ b/lib/telegram/bot/types/inline_query_result_video.rb @@ -4,20 +4,21 @@ module Telegram module Bot module Types class InlineQueryResultVideo < Base - attribute :type, String, default: 'video' - attribute :id, String - attribute :video_url, String - attribute :mime_type, String - attribute :thumb_url, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :video_width, Integer - attribute :video_height, Integer - attribute :video_duration, Integer - attribute :description, String - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('video') + attribute :id, Types::String + attribute :video_url, Types::String + attribute :mime_type, Types::String + attribute :thumb_url, Types::String + attribute :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :video_width, Types::Integer + attribute? :video_height, Types::Integer + attribute? :video_duration, Types::Integer + attribute? :description, Types::String + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/inline_query_result_voice.rb b/lib/telegram/bot/types/inline_query_result_voice.rb index b6a075d..595c14f 100644 --- a/lib/telegram/bot/types/inline_query_result_voice.rb +++ b/lib/telegram/bot/types/inline_query_result_voice.rb @@ -4,15 +4,16 @@ module Telegram module Bot module Types class InlineQueryResultVoice < Base - attribute :type, String, default: 'voice' - attribute :id, String - attribute :voice_url, String - attribute :title, String - attribute :caption, String - attribute :parse_mode, String - attribute :voice_duration, Integer - attribute :reply_markup, InlineKeyboardMarkup - attribute :input_message_content, InputMessageContent + attribute :type, Types::String.default('voice') + attribute :id, Types::String + attribute :voice_url, Types::String + attribute :title, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :voice_duration, Types::Integer + attribute? :reply_markup, InlineKeyboardMarkup + attribute? :input_message_content, InputMessageContent end end end diff --git a/lib/telegram/bot/types/input_contact_message_content.rb b/lib/telegram/bot/types/input_contact_message_content.rb index fa701fa..7e4a647 100644 --- a/lib/telegram/bot/types/input_contact_message_content.rb +++ b/lib/telegram/bot/types/input_contact_message_content.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class InputContactMessageContent < InputMessageContent - attribute :phone_number, String - attribute :first_name, String - attribute :last_name, String - attribute :vcard, String + attribute :phone_number, Types::String + attribute :first_name, Types::String + attribute? :last_name, Types::String + attribute? :vcard, Types::String end end end diff --git a/lib/telegram/bot/types/input_invoice_message_content.rb b/lib/telegram/bot/types/input_invoice_message_content.rb index 0f8730e..42fef0e 100644 --- a/lib/telegram/bot/types/input_invoice_message_content.rb +++ b/lib/telegram/bot/types/input_invoice_message_content.rb @@ -4,26 +4,26 @@ module Telegram module Bot module Types class InputInvoiceMessageContent < InputMessageContent - attribute :title, String - attribute :description, String - attribute :payload, String - attribute :provider_token, String - attribute :currency, String - attribute :prices, Array[LabeledPrice] - attribute :max_tip_amount, Integer - attribute :suggested_tip_amounts, Array[Integer] - attribute :provider_data, String - attribute :photo_url, String - attribute :photo_size, Integer - attribute :photo_width, Integer - attribute :photo_height, Integer - attribute :need_name, Boolean - attribute :need_phone_number, Boolean - attribute :need_email, Boolean - attribute :need_shipping_address, Boolean - attribute :send_phone_number_to_provider, Boolean - attribute :send_email_to_provider, Boolean - attribute :is_flexible, Boolean + attribute :title, Types::String + attribute :description, Types::String + attribute :payload, Types::String + attribute :provider_token, Types::String + attribute :currency, Types::String + attribute :prices, Types::Array.of(LabeledPrice) + attribute? :max_tip_amount, Types::Integer + attribute? :suggested_tip_amounts, Types::Array.of(Types::Integer) + attribute? :provider_data, Types::String + attribute? :photo_url, Types::String + attribute? :photo_size, Types::Integer + attribute? :photo_width, Types::Integer + attribute? :photo_height, Types::Integer + attribute? :need_name, Types::Bool + attribute? :need_phone_number, Types::Bool + attribute? :need_email, Types::Bool + attribute? :need_shipping_address, Types::Bool + attribute? :send_phone_number_to_provider, Types::Bool + attribute? :send_email_to_provider, Types::Bool + attribute? :is_flexible, Types::Bool end end end diff --git a/lib/telegram/bot/types/input_location_message_content.rb b/lib/telegram/bot/types/input_location_message_content.rb index a5119a0..97da31a 100644 --- a/lib/telegram/bot/types/input_location_message_content.rb +++ b/lib/telegram/bot/types/input_location_message_content.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class InputLocationMessageContent < InputMessageContent - attribute :latitude, Float - attribute :longitude, Float - attribute :horizontal_accuracy, Float - attribute :live_period, Integer - attribute :heading, Integer - attribute :proximity_alert_radius, Integer + attribute :latitude, Types::Float + attribute :longitude, Types::Float + attribute? :horizontal_accuracy, Types::Float + attribute? :live_period, Types::Integer + attribute? :heading, Types::Integer + attribute? :proximity_alert_radius, Types::Integer end end end diff --git a/lib/telegram/bot/types/input_media_animation.rb b/lib/telegram/bot/types/input_media_animation.rb index 473a6e1..033352d 100644 --- a/lib/telegram/bot/types/input_media_animation.rb +++ b/lib/telegram/bot/types/input_media_animation.rb @@ -4,14 +4,16 @@ module Telegram module Bot module Types class InputMediaAnimation < Base - attribute :type, String, default: 'animation' - attribute :media, String - attribute :thumb, String - attribute :caption, String - attribute :parse_mode, String - attribute :width, Integer - attribute :height, Integer - attribute :duration, Integer + attribute :type, Types::String.default('animation') + attribute :media, Types::String + attribute? :thumb, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :width, Types::Integer + attribute? :height, Types::Integer + attribute? :duration, Types::Integer + attribute? :has_spoiler, Types::Bool end end end diff --git a/lib/telegram/bot/types/input_media_audio.rb b/lib/telegram/bot/types/input_media_audio.rb index 0019d7e..5b79778 100644 --- a/lib/telegram/bot/types/input_media_audio.rb +++ b/lib/telegram/bot/types/input_media_audio.rb @@ -4,14 +4,15 @@ module Telegram module Bot module Types class InputMediaAudio < Base - attribute :type, String, default: 'audio' - attribute :media, String - attribute :thumb, String - attribute :caption, String - attribute :parse_mode, String - attribute :duration, Integer - attribute :performer, String - attribute :title, String + attribute :type, Types::String.default('audio') + attribute :media, Types::String + attribute? :thumb, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :duration, Types::Integer + attribute? :performer, Types::String + attribute? :title, Types::String end end end diff --git a/lib/telegram/bot/types/input_media_document.rb b/lib/telegram/bot/types/input_media_document.rb index dbef461..4b8d2d7 100644 --- a/lib/telegram/bot/types/input_media_document.rb +++ b/lib/telegram/bot/types/input_media_document.rb @@ -4,13 +4,13 @@ module Telegram module Bot module Types class InputMediaDocument < Base - attribute :type, String, default: 'document' - attribute :media, String - attribute :thumb, String - attribute :caption, String - attribute :parse_mode, String - attribute :caption_entities, Array[MessageEntity] - attribute :disable_content_type_detection, Boolean + attribute :type, Types::String.default('document') + attribute :media, Types::String + attribute? :thumb, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :disable_content_type_detection, Types::Bool end end end diff --git a/lib/telegram/bot/types/input_media_photo.rb b/lib/telegram/bot/types/input_media_photo.rb index 427de4c..11d4dc3 100644 --- a/lib/telegram/bot/types/input_media_photo.rb +++ b/lib/telegram/bot/types/input_media_photo.rb @@ -4,10 +4,12 @@ module Telegram module Bot module Types class InputMediaPhoto < Base - attribute :type, String, default: 'photo' - attribute :media, String - attribute :caption, String - attribute :parse_mode, String + attribute :type, Types::String.default('photo') + attribute :media, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :has_spoiler, Types::Bool end end end diff --git a/lib/telegram/bot/types/input_media_video.rb b/lib/telegram/bot/types/input_media_video.rb index 2a19189..27d5340 100644 --- a/lib/telegram/bot/types/input_media_video.rb +++ b/lib/telegram/bot/types/input_media_video.rb @@ -4,14 +4,17 @@ module Telegram module Bot module Types class InputMediaVideo < Base - attribute :type, String, default: 'video' - attribute :media, String - attribute :caption, String - attribute :parse_mode, String - attribute :width, Integer - attribute :height, Integer - attribute :duration, Integer - attribute :supports_streaming, Boolean + attribute :type, Types::String.default('video') + attribute :media, Types::String + attribute? :thumb, Types::String + attribute? :caption, Types::String + attribute? :parse_mode, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :width, Types::Integer + attribute? :height, Types::Integer + attribute? :duration, Types::Integer + attribute? :supports_streaming, Types::Bool + attribute? :has_spoiler, Types::Bool end end end diff --git a/lib/telegram/bot/types/input_text_message_content.rb b/lib/telegram/bot/types/input_text_message_content.rb index ce8a0db..f014ad5 100644 --- a/lib/telegram/bot/types/input_text_message_content.rb +++ b/lib/telegram/bot/types/input_text_message_content.rb @@ -4,9 +4,10 @@ module Telegram module Bot module Types class InputTextMessageContent < InputMessageContent - attribute :message_text, String - attribute :parse_mode, String - attribute :disable_web_page_preview, Boolean + attribute :message_text, Types::String + attribute? :parse_mode, Types::String + attribute? :entities, Types::Array.of(MessageEntity) + attribute? :disable_web_page_preview, Types::Bool end end end diff --git a/lib/telegram/bot/types/input_venue_message_content.rb b/lib/telegram/bot/types/input_venue_message_content.rb index e87028b..9cc9b2b 100644 --- a/lib/telegram/bot/types/input_venue_message_content.rb +++ b/lib/telegram/bot/types/input_venue_message_content.rb @@ -4,14 +4,14 @@ module Telegram module Bot module Types class InputVenueMessageContent < InputMessageContent - attribute :latitude, Float - attribute :longitude, Float - attribute :title, String - attribute :address, String - attribute :foursquare_id, String - attribute :foursquare_type, String - attribute :google_place_id, String - attribute :google_place_type, String + attribute :latitude, Types::Float + attribute :longitude, Types::Float + attribute :title, Types::String + attribute :address, Types::String + attribute? :foursquare_id, Types::String + attribute? :foursquare_type, Types::String + attribute? :google_place_id, Types::String + attribute? :google_place_type, Types::String end end end diff --git a/lib/telegram/bot/types/invoice.rb b/lib/telegram/bot/types/invoice.rb index 78bc285..d7ca5ac 100644 --- a/lib/telegram/bot/types/invoice.rb +++ b/lib/telegram/bot/types/invoice.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class Invoice < Base - attribute :title, String - attribute :description, String - attribute :start_parameter, String - attribute :currency, String - attribute :total_amount, Integer + attribute :title, Types::String + attribute :description, Types::String + attribute :start_parameter, Types::String + attribute :currency, Types::String + attribute :total_amount, Types::Integer end end end diff --git a/lib/telegram/bot/types/keyboard_button.rb b/lib/telegram/bot/types/keyboard_button.rb index 4c673d5..4ac4c76 100644 --- a/lib/telegram/bot/types/keyboard_button.rb +++ b/lib/telegram/bot/types/keyboard_button.rb @@ -4,11 +4,13 @@ module Telegram module Bot module Types class KeyboardButton < Base - attribute :text, String - attribute :request_contact, Boolean - attribute :request_location, Boolean - attribute :request_poll, KeyboardButtonPollType - attribute :web_app, WebAppInfo + attribute :text, Types::String + attribute? :request_user, KeyboardButtonRequestUser + attribute? :request_chat, KeyboardButtonRequestChat + attribute? :request_contact, Types::Bool + attribute? :request_location, Types::Bool + attribute? :request_poll, KeyboardButtonPollType + attribute? :web_app, WebAppInfo end end end diff --git a/lib/telegram/bot/types/keyboard_button_poll_type.rb b/lib/telegram/bot/types/keyboard_button_poll_type.rb index 14d3637..3f09890 100644 --- a/lib/telegram/bot/types/keyboard_button_poll_type.rb +++ b/lib/telegram/bot/types/keyboard_button_poll_type.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class KeyboardButtonPollType < Base - attribute :type, String + attribute? :type, Types::String end end end diff --git a/lib/telegram/bot/types/keyboard_button_request_chat.rb b/lib/telegram/bot/types/keyboard_button_request_chat.rb new file mode 100644 index 0000000..cafe90e --- /dev/null +++ b/lib/telegram/bot/types/keyboard_button_request_chat.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class KeyboardButtonRequestChat < Base + attribute :request_id, Types::Integer + attribute :chat_is_channel, Types::Bool + attribute? :chat_is_forum, Types::Bool + attribute? :chat_has_username, Types::Bool + attribute? :chat_is_created, Types::Bool + attribute? :user_administrator_rights, ChatAdministratorRights + attribute? :bot_administrator_rights, ChatAdministratorRights + attribute? :bot_is_member, Types::Bool + end + end + end +end diff --git a/lib/telegram/bot/types/keyboard_button_request_user.rb b/lib/telegram/bot/types/keyboard_button_request_user.rb new file mode 100644 index 0000000..736ea77 --- /dev/null +++ b/lib/telegram/bot/types/keyboard_button_request_user.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class KeyboardButtonRequestUser < Base + attribute :request_id, Types::Integer + attribute? :user_is_bot, Types::Bool + attribute? :user_is_premium, Types::Bool + end + end + end +end diff --git a/lib/telegram/bot/types/labeled_price.rb b/lib/telegram/bot/types/labeled_price.rb index 56bb667..add83d0 100644 --- a/lib/telegram/bot/types/labeled_price.rb +++ b/lib/telegram/bot/types/labeled_price.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class LabeledPrice < Base - attribute :label, String - attribute :amount, Integer + attribute :label, Types::String + attribute :amount, Types::Integer end end end diff --git a/lib/telegram/bot/types/location.rb b/lib/telegram/bot/types/location.rb index 1eb3524..3a8eb00 100644 --- a/lib/telegram/bot/types/location.rb +++ b/lib/telegram/bot/types/location.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class Location < Base - attribute :longitude, Float - attribute :latitude, Float - attribute :horizontal_accuracy, Float - attribute :live_period, Integer - attribute :heading, Integer - attribute :proximity_alert_radius, Integer + attribute :longitude, Types::Float + attribute :latitude, Types::Float + attribute? :horizontal_accuracy, Types::Float + attribute? :live_period, Types::Integer + attribute? :heading, Types::Integer + attribute? :proximity_alert_radius, Types::Integer end end end diff --git a/lib/telegram/bot/types/login_url.rb b/lib/telegram/bot/types/login_url.rb index abc303a..bff9d54 100644 --- a/lib/telegram/bot/types/login_url.rb +++ b/lib/telegram/bot/types/login_url.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class LoginUrl < Base - attribute :url, String - attribute :forward_text, String - attribute :bot_username, String - attribute :request_write_access, Boolean + attribute :url, Types::String + attribute? :forward_text, Types::String + attribute? :bot_username, Types::String + attribute? :request_write_access, Types::Bool end end end diff --git a/lib/telegram/bot/types/mask_position.rb b/lib/telegram/bot/types/mask_position.rb index 0bc9afb..43a8a97 100644 --- a/lib/telegram/bot/types/mask_position.rb +++ b/lib/telegram/bot/types/mask_position.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class MaskPosition < Base - attribute :point, String - attribute :x_shift, Float - attribute :y_shift, Float - attribute :zoom, Float + attribute :point, Types::String + attribute :x_shift, Types::Float + attribute :y_shift, Types::Float + attribute :scale, Types::Float end end end diff --git a/lib/telegram/bot/types/menu_button_commands.rb b/lib/telegram/bot/types/menu_button_commands.rb index 9eb99c8..09463e8 100644 --- a/lib/telegram/bot/types/menu_button_commands.rb +++ b/lib/telegram/bot/types/menu_button_commands.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class MenuButtonCommands < Base - attribute :type, String, default: 'commands' + attribute :type, Types::String.default('commands') end end end diff --git a/lib/telegram/bot/types/menu_button_default.rb b/lib/telegram/bot/types/menu_button_default.rb index 7a63410..74b44f2 100644 --- a/lib/telegram/bot/types/menu_button_default.rb +++ b/lib/telegram/bot/types/menu_button_default.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class MenuButtonDefault < Base - attribute :type, String, default: 'default' + attribute :type, Types::String.default('default') end end end diff --git a/lib/telegram/bot/types/menu_button_web_app.rb b/lib/telegram/bot/types/menu_button_web_app.rb index 0bcd55c..b2fecf6 100644 --- a/lib/telegram/bot/types/menu_button_web_app.rb +++ b/lib/telegram/bot/types/menu_button_web_app.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class MenuButtonWebApp < Base - attribute :type, String, default: 'web_app' - attribute :text, String + attribute :type, Types::String.default('web_app') + attribute :text, Types::String attribute :web_app, WebAppInfo end end diff --git a/lib/telegram/bot/types/message.rb b/lib/telegram/bot/types/message.rb index b8e6f88..8fb9b01 100644 --- a/lib/telegram/bot/types/message.rb +++ b/lib/telegram/bot/types/message.rb @@ -4,65 +4,77 @@ module Telegram module Bot module Types class Message < Base - attribute :message_id, Integer - attribute :from, User - attribute :sender_chat, Chat - attribute :date, Integer + attribute :message_id, Types::Integer + attribute? :message_thread_id, Types::Integer + attribute? :from, User + attribute? :sender_chat, Chat + attribute :date, Types::Integer attribute :chat, Chat - attribute :forward_from, User - attribute :forward_from_chat, Chat - attribute :forward_from_message_id, Integer - attribute :forward_signature, String - attribute :forward_sender_name, String - attribute :forward_date, Integer - attribute :is_automatic_forward, Boolean - attribute :reply_to_message, Message - attribute :via_bot, User - attribute :edit_date, Integer - attribute :has_protected_content, Boolean - attribute :media_group_id, String - attribute :author_signature, String - attribute :text, String - attribute :entities, Array[MessageEntity] - attribute :animation, Animation - attribute :audio, Audio - attribute :document, Document - attribute :photo, Array[PhotoSize] - attribute :sticker, Sticker - attribute :video, Video - attribute :video_note, VideoNote - attribute :voice, Voice - attribute :caption, String - attribute :caption_entities, Array[MessageEntity] - attribute :contact, Contact - attribute :dice, Dice - attribute :game, Game - attribute :poll, Poll - attribute :venue, Venue - attribute :location, Location - attribute :new_chat_members, Array[User] - attribute :left_chat_member, User - attribute :new_chat_title, String - attribute :new_chat_photo, Array[PhotoSize] - attribute :delete_chat_photo, Boolean - attribute :group_chat_created, Boolean - attribute :supergroup_chat_created, Boolean - attribute :channel_chat_created, Boolean - attribute :message_auto_delete_timer_changed, MessageAutoDeleteTimerChanged - attribute :migrate_to_chat_id, Integer - attribute :migrate_from_chat_id, Integer - attribute :pinned_message, Message - attribute :invoice, Invoice - attribute :successful_payment, SuccessfulPayment - attribute :connected_website, String - attribute :passport_data, PassportData - attribute :proximity_alert_triggered, ProximityAlertTriggered - attribute :video_chat_scheduled, VideoChatScheduled - attribute :video_chat_started, VideoChatStarted - attribute :video_chat_ended, VideoChatEnded - attribute :video_chat_participants_invited, VideoChatParticipantsInvited - attribute :web_app_data, WebAppData - attribute :reply_markup, InlineKeyboardMarkup + attribute? :forward_from, User + attribute? :forward_from_chat, Chat + attribute? :forward_from_message_id, Types::Integer + attribute? :forward_signature, Types::String + attribute? :forward_sender_name, Types::String + attribute? :forward_date, Types::Integer + attribute? :is_topic_message, Types::Bool + attribute? :is_automatic_forward, Types::Bool + attribute? :reply_to_message, Message + attribute? :via_bot, User + attribute? :edit_date, Types::Integer + attribute? :has_protected_content, Types::Bool + attribute? :media_group_id, Types::String + attribute? :author_signature, Types::String + attribute? :text, Types::String + attribute? :entities, Types::Array.of(MessageEntity) + attribute? :animation, Animation + attribute? :audio, Audio + attribute? :document, Document + attribute? :photo, Types::Array.of(PhotoSize) + attribute? :sticker, Sticker + attribute? :video, Video + attribute? :video_note, VideoNote + attribute? :voice, Voice + attribute? :caption, Types::String + attribute? :caption_entities, Types::Array.of(MessageEntity) + attribute? :has_media_spoiler, Types::Bool + attribute? :contact, Contact + attribute? :dice, Dice + attribute? :game, Game + attribute? :poll, Poll + attribute? :venue, Venue + attribute? :location, Location + attribute? :new_chat_members, Types::Array.of(User) + attribute? :left_chat_member, User + attribute? :new_chat_title, Types::String + attribute? :new_chat_photo, Types::Array.of(PhotoSize) + attribute? :delete_chat_photo, Types::Bool + attribute? :group_chat_created, Types::Bool + attribute? :supergroup_chat_created, Types::Bool + attribute? :channel_chat_created, Types::Bool + attribute? :message_auto_delete_timer_changed, MessageAutoDeleteTimerChanged + attribute? :migrate_to_chat_id, Types::Integer + attribute? :migrate_from_chat_id, Types::Integer + attribute? :pinned_message, Message + attribute? :invoice, Invoice + attribute? :successful_payment, SuccessfulPayment + attribute? :user_shared, UserShared + attribute? :chat_shared, ChatShared + attribute? :connected_website, Types::String + attribute? :write_access_allowed, WriteAccessAllowed + attribute? :passport_data, PassportData + attribute? :proximity_alert_triggered, ProximityAlertTriggered + attribute? :forum_topic_created, ForumTopicCreated + attribute? :forum_topic_edited, ForumTopicEdited + attribute? :forum_topic_closed, ForumTopicClosed + attribute? :forum_topic_reopened, ForumTopicReopened + attribute? :general_forum_topic_hidden, GeneralForumTopicHidden + attribute? :general_forum_topic_unhidden, GeneralForumTopicUnhidden + attribute? :video_chat_scheduled, VideoChatScheduled + attribute? :video_chat_started, VideoChatStarted + attribute? :video_chat_ended, VideoChatEnded + attribute? :video_chat_participants_invited, VideoChatParticipantsInvited + attribute? :web_app_data, WebAppData + attribute? :reply_markup, InlineKeyboardMarkup alias to_s text end diff --git a/lib/telegram/bot/types/message_auto_delete_timer_changed.rb b/lib/telegram/bot/types/message_auto_delete_timer_changed.rb index d81a7a6..04397e2 100644 --- a/lib/telegram/bot/types/message_auto_delete_timer_changed.rb +++ b/lib/telegram/bot/types/message_auto_delete_timer_changed.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class MessageAutoDeleteTimerChanged < Base - attribute :message_auto_delete_time, Integer + attribute :message_auto_delete_time, Types::Integer end end end diff --git a/lib/telegram/bot/types/message_entity.rb b/lib/telegram/bot/types/message_entity.rb index b752476..f2499a3 100644 --- a/lib/telegram/bot/types/message_entity.rb +++ b/lib/telegram/bot/types/message_entity.rb @@ -4,13 +4,13 @@ module Telegram module Bot module Types class MessageEntity < Base - attribute :type, String - attribute :offset, Integer - attribute :length, Integer - attribute :url, String - attribute :user, User - attribute :language, String - attribute :custom_emoji_id, String + attribute :type, Types::String + attribute :offset, Types::Integer + attribute :length, Types::Integer + attribute? :url, Types::String + attribute? :user, User + attribute? :language, Types::String + attribute? :custom_emoji_id, Types::String end end end diff --git a/lib/telegram/bot/types/order_info.rb b/lib/telegram/bot/types/order_info.rb index c30433b..48b856f 100644 --- a/lib/telegram/bot/types/order_info.rb +++ b/lib/telegram/bot/types/order_info.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class OrderInfo < Base - attribute :name, String - attribute :phone_number, String - attribute :email, String - attribute :shipping_address, ShippingAddress + attribute? :name, Types::String + attribute? :phone_number, Types::String + attribute? :email, Types::String + attribute? :shipping_address, ShippingAddress end end end diff --git a/lib/telegram/bot/types/passport_data.rb b/lib/telegram/bot/types/passport_data.rb index c8af12d..f8658e7 100644 --- a/lib/telegram/bot/types/passport_data.rb +++ b/lib/telegram/bot/types/passport_data.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportData < Base - attribute :data, Array[EncryptedPassportElement] + attribute :data, Types::Array.of(EncryptedPassportElement) attribute :credentials, EncryptedCredentials end end diff --git a/lib/telegram/bot/types/passport_element_error_data_field.rb b/lib/telegram/bot/types/passport_element_error_data_field.rb index 011f972..45458dd 100644 --- a/lib/telegram/bot/types/passport_element_error_data_field.rb +++ b/lib/telegram/bot/types/passport_element_error_data_field.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class PassportElementErrorDataField < Base - attribute :source, String, default: 'data' - attribute :type, String - attribute :field_name, String - attribute :data_hash, String - attribute :message, String + attribute :source, Types::String.default('data') + attribute :type, Types::String + attribute :field_name, Types::String + attribute :data_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_file.rb b/lib/telegram/bot/types/passport_element_error_file.rb index 390797c..e0d1bd3 100644 --- a/lib/telegram/bot/types/passport_element_error_file.rb +++ b/lib/telegram/bot/types/passport_element_error_file.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorFile < Base - attribute :source, String, default: 'file' - attribute :type, String - attribute :file_hash, String - attribute :message, String + attribute :source, Types::String.default('file') + attribute :type, Types::String + attribute :file_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_files.rb b/lib/telegram/bot/types/passport_element_error_files.rb index b787b67..b801c55 100644 --- a/lib/telegram/bot/types/passport_element_error_files.rb +++ b/lib/telegram/bot/types/passport_element_error_files.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorFiles < Base - attribute :source, String, default: 'files' - attribute :type, String - attribute :file_hashes, Array[String] - attribute :message, String + attribute :source, Types::String.default('files') + attribute :type, Types::String + attribute :file_hashes, Types::Array.of(String) + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_front_side.rb b/lib/telegram/bot/types/passport_element_error_front_side.rb index 1af4454..182fc53 100644 --- a/lib/telegram/bot/types/passport_element_error_front_side.rb +++ b/lib/telegram/bot/types/passport_element_error_front_side.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorFrontSide < Base - attribute :source, String, default: 'front_side' - attribute :type, String - attribute :file_hash, String - attribute :message, String + attribute :source, Types::String.default('front_side') + attribute :type, Types::String + attribute :file_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_reverse_side.rb b/lib/telegram/bot/types/passport_element_error_reverse_side.rb index b41c24c..3dec85c 100644 --- a/lib/telegram/bot/types/passport_element_error_reverse_side.rb +++ b/lib/telegram/bot/types/passport_element_error_reverse_side.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorReverseSide < Base - attribute :source, String, default: 'reverse_side' - attribute :type, String - attribute :file_hash, String - attribute :message, String + attribute :source, Types::String.default('reverse_side') + attribute :type, Types::String + attribute :file_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_selfie.rb b/lib/telegram/bot/types/passport_element_error_selfie.rb index 7d3b2f9..53d9c56 100644 --- a/lib/telegram/bot/types/passport_element_error_selfie.rb +++ b/lib/telegram/bot/types/passport_element_error_selfie.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorSelfie < Base - attribute :source, String, default: 'selfie' - attribute :type, String - attribute :file_hash, String - attribute :message, String + attribute :source, Types::String.default('selfie') + attribute :type, Types::String + attribute :file_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_translation_file.rb b/lib/telegram/bot/types/passport_element_error_translation_file.rb index 6ca1149..4f6d98f 100644 --- a/lib/telegram/bot/types/passport_element_error_translation_file.rb +++ b/lib/telegram/bot/types/passport_element_error_translation_file.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorTranslationFile < Base - attribute :source, String, default: 'translation_file' - attribute :type, String - attribute :file_hash, String - attribute :message, String + attribute :source, Types::String.default('translation_file') + attribute :type, Types::String + attribute :file_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_translation_files.rb b/lib/telegram/bot/types/passport_element_error_translation_files.rb index 1f93bf9..93866dc 100644 --- a/lib/telegram/bot/types/passport_element_error_translation_files.rb +++ b/lib/telegram/bot/types/passport_element_error_translation_files.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorTranslationFiles < Base - attribute :source, String, default: 'translation_files' - attribute :type, String - attribute :file_hashes, Array[String] - attribute :message, String + attribute :source, Types::String.default('translation_files') + attribute :type, Types::String + attribute :file_hashes, Types::Array.of(String) + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_element_error_unspecified.rb b/lib/telegram/bot/types/passport_element_error_unspecified.rb index ec1f944..c4de8bf 100644 --- a/lib/telegram/bot/types/passport_element_error_unspecified.rb +++ b/lib/telegram/bot/types/passport_element_error_unspecified.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportElementErrorUnspecified < Base - attribute :source, String, default: 'unspecified' - attribute :type, String - attribute :element_hash, String - attribute :message, String + attribute :source, Types::String.default('unspecified') + attribute :type, Types::String + attribute :element_hash, Types::String + attribute :message, Types::String end end end diff --git a/lib/telegram/bot/types/passport_file.rb b/lib/telegram/bot/types/passport_file.rb index f9e6d20..cf00b5c 100644 --- a/lib/telegram/bot/types/passport_file.rb +++ b/lib/telegram/bot/types/passport_file.rb @@ -4,10 +4,10 @@ module Telegram module Bot module Types class PassportFile < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :file_size, Integer - attribute :file_date, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :file_size, Types::Integer + attribute :file_date, Types::Integer end end end diff --git a/lib/telegram/bot/types/photo_size.rb b/lib/telegram/bot/types/photo_size.rb index b682fba..1034401 100644 --- a/lib/telegram/bot/types/photo_size.rb +++ b/lib/telegram/bot/types/photo_size.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class PhotoSize < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :width, Integer - attribute :height, Integer - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :width, Types::Integer + attribute :height, Types::Integer + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/poll.rb b/lib/telegram/bot/types/poll.rb index 8d8cab1..70b6294 100644 --- a/lib/telegram/bot/types/poll.rb +++ b/lib/telegram/bot/types/poll.rb @@ -4,19 +4,19 @@ module Telegram module Bot module Types class Poll < Base - attribute :id, String - attribute :question, String - attribute :options, Array[PollOption] - attribute :total_voter_count, Integer - attribute :is_closed, Boolean - attribute :is_anonymous, Boolean - attribute :type, String - attribute :allows_multiple_answers, Boolean - attribute :correct_option_id, Integer - attribute :explanation, String - attribute :explanation_entities, Array[MessageEntity] - attribute :open_period, Integer - attribute :close_date, Integer + attribute :id, Types::String + attribute :question, Types::String + attribute :options, Types::Array.of(PollOption) + attribute :total_voter_count, Types::Integer + attribute :is_closed, Types::Bool + attribute :is_anonymous, Types::Bool + attribute :type, Types::String + attribute :allows_multiple_answers, Types::Bool + attribute? :correct_option_id, Types::Integer + attribute? :explanation, Types::String + attribute? :explanation_entities, Types::Array.of(MessageEntity) + attribute? :open_period, Types::Integer + attribute? :close_date, Types::Integer end end end diff --git a/lib/telegram/bot/types/poll_answer.rb b/lib/telegram/bot/types/poll_answer.rb index 64f1d36..21c57f5 100644 --- a/lib/telegram/bot/types/poll_answer.rb +++ b/lib/telegram/bot/types/poll_answer.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class PollAnswer < Base - attribute :poll_id, String + attribute :poll_id, Types::String attribute :user, User - attribute :option_ids, Array[Integer] + attribute :option_ids, Types::Array.of(Types::Integer) end end end diff --git a/lib/telegram/bot/types/poll_option.rb b/lib/telegram/bot/types/poll_option.rb index 41ef437..80e280a 100644 --- a/lib/telegram/bot/types/poll_option.rb +++ b/lib/telegram/bot/types/poll_option.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class PollOption < Base - attribute :text, String - attribute :voter_count, Integer + attribute :text, Types::String + attribute :voter_count, Types::Integer end end end diff --git a/lib/telegram/bot/types/pre_checkout_query.rb b/lib/telegram/bot/types/pre_checkout_query.rb index 2a6f465..5d0a7fb 100644 --- a/lib/telegram/bot/types/pre_checkout_query.rb +++ b/lib/telegram/bot/types/pre_checkout_query.rb @@ -4,13 +4,13 @@ module Telegram module Bot module Types class PreCheckoutQuery < Base - attribute :id, String + attribute :id, Types::String attribute :from, User - attribute :currency, String - attribute :total_amount, Integer - attribute :invoice_payload, String - attribute :shipping_option_id, String - attribute :order_info, OrderInfo + attribute :currency, Types::String + attribute :total_amount, Types::Integer + attribute :invoice_payload, Types::String + attribute? :shipping_option_id, Types::String + attribute? :order_info, OrderInfo end end end diff --git a/lib/telegram/bot/types/proximity_alert_triggered.rb b/lib/telegram/bot/types/proximity_alert_triggered.rb index 5603173..6bcc85a 100644 --- a/lib/telegram/bot/types/proximity_alert_triggered.rb +++ b/lib/telegram/bot/types/proximity_alert_triggered.rb @@ -6,7 +6,7 @@ module Types class ProximityAlertTriggered < Base attribute :traveler, User attribute :watcher, User - attribute :distance, Integer + attribute :distance, Types::Integer end end end diff --git a/lib/telegram/bot/types/reply_keyboard_markup.rb b/lib/telegram/bot/types/reply_keyboard_markup.rb index bb5861a..f44a5b4 100644 --- a/lib/telegram/bot/types/reply_keyboard_markup.rb +++ b/lib/telegram/bot/types/reply_keyboard_markup.rb @@ -4,11 +4,12 @@ module Telegram module Bot module Types class ReplyKeyboardMarkup < Base - attribute :keyboard, Array[Array[KeyboardButton]] - attribute :resize_keyboard, Boolean, default: false - attribute :one_time_keyboard, Boolean, default: false - attribute :input_field_placeholder, String - attribute :selective, Boolean, default: false + attribute :keyboard, Types::Array.of(Types::Array.of(KeyboardButton)) + attribute? :is_persistent, Types::Bool.default(false) + attribute? :resize_keyboard, Types::Bool.default(false) + attribute? :one_time_keyboard, Types::Bool.default(false) + attribute? :input_field_placeholder, Types::String + attribute? :selective, Types::Bool.default(false) def to_compact_hash hsh = super diff --git a/lib/telegram/bot/types/reply_keyboard_remove.rb b/lib/telegram/bot/types/reply_keyboard_remove.rb index 605ef02..1770043 100644 --- a/lib/telegram/bot/types/reply_keyboard_remove.rb +++ b/lib/telegram/bot/types/reply_keyboard_remove.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class ReplyKeyboardRemove < Base - attribute :remove_keyboard, Boolean - attribute :selective, Boolean, default: false + attribute :remove_keyboard, Types::Bool + attribute? :selective, Types::Bool.default(false) end end end diff --git a/lib/telegram/bot/types/sent_web_app_message.rb b/lib/telegram/bot/types/sent_web_app_message.rb index c4015e7..d3a2e25 100644 --- a/lib/telegram/bot/types/sent_web_app_message.rb +++ b/lib/telegram/bot/types/sent_web_app_message.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class SentWebAppMessage < Base - attribute :inline_message_id, String + attribute? :inline_message_id, Types::String end end end diff --git a/lib/telegram/bot/types/shipping_address.rb b/lib/telegram/bot/types/shipping_address.rb index 5727294..66deaf1 100644 --- a/lib/telegram/bot/types/shipping_address.rb +++ b/lib/telegram/bot/types/shipping_address.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class ShippingAddress < Base - attribute :country_code, String - attribute :state, String - attribute :city, String - attribute :street_line1, String - attribute :street_line2, String - attribute :post_code, String + attribute :country_code, Types::String + attribute :state, Types::String + attribute :city, Types::String + attribute :street_line1, Types::String + attribute :street_line2, Types::String + attribute :post_code, Types::String end end end diff --git a/lib/telegram/bot/types/shipping_option.rb b/lib/telegram/bot/types/shipping_option.rb index 2859ec5..a02521b 100644 --- a/lib/telegram/bot/types/shipping_option.rb +++ b/lib/telegram/bot/types/shipping_option.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class ShippingOption < Base - attribute :id, String - attribute :title, String - attribute :prices, Array[LabeledPrice] + attribute :id, Types::String + attribute :title, Types::String + attribute :prices, Types::Array.of(LabeledPrice) end end end diff --git a/lib/telegram/bot/types/shipping_query.rb b/lib/telegram/bot/types/shipping_query.rb index 88e2750..a9287bc 100644 --- a/lib/telegram/bot/types/shipping_query.rb +++ b/lib/telegram/bot/types/shipping_query.rb @@ -4,9 +4,9 @@ module Telegram module Bot module Types class ShippingQuery < Base - attribute :id, String + attribute :id, Types::String attribute :from, User - attribute :invoice_payload, String + attribute :invoice_payload, Types::String attribute :shipping_address, ShippingAddress end end diff --git a/lib/telegram/bot/types/sticker.rb b/lib/telegram/bot/types/sticker.rb index 5947c33..6d3dc93 100644 --- a/lib/telegram/bot/types/sticker.rb +++ b/lib/telegram/bot/types/sticker.rb @@ -4,20 +4,20 @@ module Telegram module Bot module Types class Sticker < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :type, String - attribute :width, Integer - attribute :height, Integer - attribute :is_animated, Boolean - attribute :is_video, Boolean - attribute :thumb, PhotoSize - attribute :emoji, String - attribute :set_name, String - attribute :premium_animation, File - attribute :mask_position, MaskPosition - attribute :custom_emoji_id, String - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :type, Types::String + attribute :width, Types::Integer + attribute :height, Types::Integer + attribute :is_animated, Types::Bool + attribute :is_video, Types::Bool + attribute? :thumb, PhotoSize + attribute? :emoji, Types::String + attribute? :set_name, Types::String + attribute? :premium_animation, File + attribute? :mask_position, MaskPosition + attribute? :custom_emoji_id, Types::String + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/sticker_set.rb b/lib/telegram/bot/types/sticker_set.rb index 6e857cf..e40f2d4 100644 --- a/lib/telegram/bot/types/sticker_set.rb +++ b/lib/telegram/bot/types/sticker_set.rb @@ -4,14 +4,13 @@ module Telegram module Bot module Types class StickerSet < Base - attribute :name, String - attribute :title, String - attribute :sticker_type, String - attribute :is_animated, Boolean - attribute :is_video, Boolean - attribute :contains_masks, Boolean - attribute :stickers, Array[Sticker] - attribute :thumb, PhotoSize + attribute :name, Types::String + attribute :title, Types::String + attribute :sticker_type, Types::String + attribute :is_animated, Types::Bool + attribute :is_video, Types::Bool + attribute :stickers, Types::Array.of(Sticker) + attribute? :thumb, PhotoSize end end end diff --git a/lib/telegram/bot/types/successful_payment.rb b/lib/telegram/bot/types/successful_payment.rb index 7a1a826..e6ef310 100644 --- a/lib/telegram/bot/types/successful_payment.rb +++ b/lib/telegram/bot/types/successful_payment.rb @@ -4,13 +4,13 @@ module Telegram module Bot module Types class SuccessfulPayment < Base - attribute :currency, String - attribute :total_amount, Integer - attribute :invoice_payload, String - attribute :shipping_option_id, String - attribute :order_info, OrderInfo - attribute :telegram_payment_charge_id, String - attribute :provider_payment_charge_id, String + attribute :currency, Types::String + attribute :total_amount, Types::Integer + attribute :invoice_payload, Types::String + attribute? :shipping_option_id, Types::String + attribute? :order_info, OrderInfo + attribute :telegram_payment_charge_id, Types::String + attribute :provider_payment_charge_id, Types::String end end end diff --git a/lib/telegram/bot/types/update.rb b/lib/telegram/bot/types/update.rb index 377df9c..81a2752 100644 --- a/lib/telegram/bot/types/update.rb +++ b/lib/telegram/bot/types/update.rb @@ -4,21 +4,21 @@ module Telegram module Bot module Types class Update < Base - attribute :update_id, Integer - attribute :message, Message - attribute :edited_message, Message - attribute :channel_post, Message - attribute :edited_channel_post, Message - attribute :inline_query, InlineQuery - attribute :chosen_inline_result, ChosenInlineResult - attribute :callback_query, CallbackQuery - attribute :shipping_query, ShippingQuery - attribute :pre_checkout_query, PreCheckoutQuery - attribute :poll, Poll - attribute :poll_answer, PollAnswer - attribute :my_chat_member, ChatMemberUpdated - attribute :chat_member, ChatMemberUpdated - attribute :chat_join_request, ChatJoinRequest + attribute :update_id, Types::Integer + attribute? :message, Message + attribute? :edited_message, Message + attribute? :channel_post, Message + attribute? :edited_channel_post, Message + attribute? :inline_query, InlineQuery + attribute? :chosen_inline_result, ChosenInlineResult + attribute? :callback_query, CallbackQuery + attribute? :shipping_query, ShippingQuery + attribute? :pre_checkout_query, PreCheckoutQuery + attribute? :poll, Poll + attribute? :poll_answer, PollAnswer + attribute? :my_chat_member, ChatMemberUpdated + attribute? :chat_member, ChatMemberUpdated + attribute? :chat_join_request, ChatJoinRequest def current_message @current_message ||= diff --git a/lib/telegram/bot/types/user.rb b/lib/telegram/bot/types/user.rb index d23d691..86db226 100644 --- a/lib/telegram/bot/types/user.rb +++ b/lib/telegram/bot/types/user.rb @@ -4,17 +4,17 @@ module Telegram module Bot module Types class User < Base - attribute :id, Integer - attribute :is_bot, Boolean - attribute :first_name, String - attribute :last_name, String - attribute :username, String - attribute :language_code, String - attribute :is_premium, Boolean - attribute :added_to_attachment_menu, Boolean - attribute :can_join_groups, Boolean - attribute :can_read_all_group_messages, Boolean - attribute :supports_inline_queries, Boolean + attribute :id, Types::Integer + attribute :is_bot, Types::Bool + attribute :first_name, Types::String + attribute? :last_name, Types::String + attribute? :username, Types::String + attribute? :language_code, Types::String + attribute? :is_premium, Types::Bool + attribute? :added_to_attachment_menu, Types::Bool + attribute? :can_join_groups, Types::Bool + attribute? :can_read_all_group_messages, Types::Bool + attribute? :supports_inline_queries, Types::Bool end end end diff --git a/lib/telegram/bot/types/user_profile_photos.rb b/lib/telegram/bot/types/user_profile_photos.rb index d83d008..f8be635 100644 --- a/lib/telegram/bot/types/user_profile_photos.rb +++ b/lib/telegram/bot/types/user_profile_photos.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class UserProfilePhotos < Base - attribute :total_count, Integer - attribute :photos, Array[Array[PhotoSize]] + attribute :total_count, Types::Integer + attribute :photos, Types::Array.of(Types::Array.of(PhotoSize)) end end end diff --git a/lib/telegram/bot/types/user_shared.rb b/lib/telegram/bot/types/user_shared.rb new file mode 100644 index 0000000..92940d7 --- /dev/null +++ b/lib/telegram/bot/types/user_shared.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class UserShared < Base + attribute :request_id, Types::Integer + attribute :user_id, Types::Integer + end + end + end +end diff --git a/lib/telegram/bot/types/venue.rb b/lib/telegram/bot/types/venue.rb index 1162089..0f90108 100644 --- a/lib/telegram/bot/types/venue.rb +++ b/lib/telegram/bot/types/venue.rb @@ -5,12 +5,12 @@ module Bot module Types class Venue < Base attribute :location, Location - attribute :title, String - attribute :address, String - attribute :foursquare_id, String - attribute :foursquare_type, String - attribute :google_place_id, String - attribute :google_place_type, String + attribute :title, Types::String + attribute :address, Types::String + attribute? :foursquare_id, Types::String + attribute? :foursquare_type, Types::String + attribute? :google_place_id, Types::String + attribute? :google_place_type, Types::String end end end diff --git a/lib/telegram/bot/types/video.rb b/lib/telegram/bot/types/video.rb index 332a244..6d1cc6c 100644 --- a/lib/telegram/bot/types/video.rb +++ b/lib/telegram/bot/types/video.rb @@ -4,15 +4,15 @@ module Telegram module Bot module Types class Video < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :width, Integer - attribute :height, Integer - attribute :duration, Integer - attribute :thumb, PhotoSize - attribute :file_name, String - attribute :mime_type, String - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :width, Types::Integer + attribute :height, Types::Integer + attribute :duration, Types::Integer + attribute? :thumb, PhotoSize + attribute? :file_name, Types::String + attribute? :mime_type, Types::String + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/video_chat_ended.rb b/lib/telegram/bot/types/video_chat_ended.rb index 68bde2f..11298de 100644 --- a/lib/telegram/bot/types/video_chat_ended.rb +++ b/lib/telegram/bot/types/video_chat_ended.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class VideoChatEnded < Base - attribute :duration, Integer + attribute :duration, Types::Integer end end end diff --git a/lib/telegram/bot/types/video_chat_participants_invited.rb b/lib/telegram/bot/types/video_chat_participants_invited.rb index d1e5f73..418ba37 100644 --- a/lib/telegram/bot/types/video_chat_participants_invited.rb +++ b/lib/telegram/bot/types/video_chat_participants_invited.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class VideoChatParticipantsInvited < Base - attribute :users, Array[User] + attribute :users, Types::Array.of(User) end end end diff --git a/lib/telegram/bot/types/video_chat_scheduled.rb b/lib/telegram/bot/types/video_chat_scheduled.rb index 7b2b574..a0b1114 100644 --- a/lib/telegram/bot/types/video_chat_scheduled.rb +++ b/lib/telegram/bot/types/video_chat_scheduled.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class VideoChatScheduled < Base - attribute :start_date, Integer + attribute :start_date, Types::Integer end end end diff --git a/lib/telegram/bot/types/video_note.rb b/lib/telegram/bot/types/video_note.rb index 8744e45..4e06cfc 100644 --- a/lib/telegram/bot/types/video_note.rb +++ b/lib/telegram/bot/types/video_note.rb @@ -4,12 +4,12 @@ module Telegram module Bot module Types class VideoNote < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :length, Integer - attribute :duration, Integer - attribute :thumb, PhotoSize - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :length, Types::Integer + attribute :duration, Types::Integer + attribute? :thumb, PhotoSize + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/voice.rb b/lib/telegram/bot/types/voice.rb index 1d38fac..62fa5c6 100644 --- a/lib/telegram/bot/types/voice.rb +++ b/lib/telegram/bot/types/voice.rb @@ -4,11 +4,11 @@ module Telegram module Bot module Types class Voice < Base - attribute :file_id, String - attribute :file_unique_id, String - attribute :duration, Integer - attribute :mime_type, String - attribute :file_size, Integer + attribute :file_id, Types::String + attribute :file_unique_id, Types::String + attribute :duration, Types::Integer + attribute? :mime_type, Types::String + attribute? :file_size, Types::Integer end end end diff --git a/lib/telegram/bot/types/web_app_data.rb b/lib/telegram/bot/types/web_app_data.rb index 90bdae0..9045eb7 100644 --- a/lib/telegram/bot/types/web_app_data.rb +++ b/lib/telegram/bot/types/web_app_data.rb @@ -4,8 +4,8 @@ module Telegram module Bot module Types class WebAppData < Base - attribute :data, String - attribute :button_text, String + attribute :data, Types::String + attribute :button_text, Types::String end end end diff --git a/lib/telegram/bot/types/web_app_info.rb b/lib/telegram/bot/types/web_app_info.rb index fa739d7..7900009 100644 --- a/lib/telegram/bot/types/web_app_info.rb +++ b/lib/telegram/bot/types/web_app_info.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class WebAppInfo < Base - attribute :url, String + attribute :url, Types::String end end end diff --git a/lib/telegram/bot/types/webhook_info.rb b/lib/telegram/bot/types/webhook_info.rb index 2101ef4..0f4ac85 100644 --- a/lib/telegram/bot/types/webhook_info.rb +++ b/lib/telegram/bot/types/webhook_info.rb @@ -4,15 +4,15 @@ module Telegram module Bot module Types class WebhookInfo < Base - attribute :url, String - attribute :has_custom_certificate, Boolean - attribute :pending_update_count, Integer - attribute :ip_address, String - attribute :last_error_date, Integer - attribute :last_error_message, String - attribute :last_synchronization_error_date, Integer - attribute :max_connections, Integer - attribute :allowed_updates, Array[String] + attribute :url, Types::String + attribute :has_custom_certificate, Types::Bool + attribute :pending_update_count, Types::Integer + attribute? :ip_address, Types::String + attribute? :last_error_date, Types::Integer + attribute? :last_error_message, Types::String + attribute? :last_synchronization_error_date, Types::Integer + attribute? :max_connections, Types::Integer + attribute? :allowed_updates, Types::Array.of(String) end end end diff --git a/lib/telegram/bot/types/write_access_allowed.rb b/lib/telegram/bot/types/write_access_allowed.rb new file mode 100644 index 0000000..001cc6f --- /dev/null +++ b/lib/telegram/bot/types/write_access_allowed.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Telegram + module Bot + module Types + class WriteAccessAllowed < Base + end + end + end +end diff --git a/lib/telegram/bot/version.rb b/lib/telegram/bot/version.rb index 456748b..7d16651 100644 --- a/lib/telegram/bot/version.rb +++ b/lib/telegram/bot/version.rb @@ -2,6 +2,6 @@ module Telegram module Bot - VERSION = '0.23.0' + VERSION = '1.0.0' end end diff --git a/spec/lib/telegram/bot/types_spec.rb b/spec/lib/telegram/bot/types_spec.rb new file mode 100644 index 0000000..ad6de70 --- /dev/null +++ b/spec/lib/telegram/bot/types_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'yaml' + +type_attributes = YAML.safe_load( + File.read(File.expand_path('../../../support/type_attributes.yml', __dir__)) +) + +RSpec.describe Telegram::Bot::Types do + type_attributes.each do |type, attributes| + describe type do + subject(:klass) { Object.const_get("Telegram::Bot::Types::#{type}") } + + it 'has correct attributes' do + expect(klass.schema.keys.map(&:name)).to eq(attributes.map { |e| e['name'].to_sym }) + end + + attributes.each do |attribute| + describe "##{attribute['name']}" do + it 'has correct optionality' do + expect(klass.schema.name_key_map[attribute['name'].to_sym]&.required?).to eq(attribute['required']) + end + end + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 47fe7c0..0ba8997 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true +require 'dotenv/load' require 'telegram/bot' diff --git a/spec/support/type_attributes.yml b/spec/support/type_attributes.yml new file mode 100644 index 0000000..2c88455 --- /dev/null +++ b/spec/support/type_attributes.yml @@ -0,0 +1,1868 @@ +--- +WebhookInfo: +- name: url + required: true +- name: has_custom_certificate + required: true +- name: pending_update_count + required: true +- name: ip_address + required: false +- name: last_error_date + required: false +- name: last_error_message + required: false +- name: last_synchronization_error_date + required: false +- name: max_connections + required: false +- name: allowed_updates + required: false +UserShared: +- name: request_id + required: true +- name: user_id + required: true +UserProfilePhotos: +- name: total_count + required: true +- name: photos + required: true +Update: +- name: update_id + required: true +- name: message + required: false +- name: edited_message + required: false +- name: channel_post + required: false +- name: edited_channel_post + required: false +- name: inline_query + required: false +- name: chosen_inline_result + required: false +- name: callback_query + required: false +- name: shipping_query + required: false +- name: pre_checkout_query + required: false +- name: poll + required: false +- name: poll_answer + required: false +- name: my_chat_member + required: false +- name: chat_member + required: false +- name: chat_join_request + required: false +StickerSet: +- name: name + required: true +- name: title + required: true +- name: sticker_type + required: true +- name: is_animated + required: true +- name: is_video + required: true +- name: stickers + required: true +- name: thumb + required: false +ShippingQuery: +- name: id + required: true +- name: from + required: true +- name: invoice_payload + required: true +- name: shipping_address + required: true +ShippingOption: +- name: id + required: true +- name: title + required: true +- name: prices + required: true +SentWebAppMessage: +- name: inline_message_id + required: false +ReplyKeyboardRemove: +- name: remove_keyboard + required: true +- name: selective + required: false +ReplyKeyboardMarkup: +- name: keyboard + required: true +- name: is_persistent + required: false +- name: resize_keyboard + required: false +- name: one_time_keyboard + required: false +- name: input_field_placeholder + required: false +- name: selective + required: false +PreCheckoutQuery: +- name: id + required: true +- name: from + required: true +- name: currency + required: true +- name: total_amount + required: true +- name: invoice_payload + required: true +- name: shipping_option_id + required: false +- name: order_info + required: false +PollAnswer: +- name: poll_id + required: true +- name: user + required: true +- name: option_ids + required: true +PassportElementErrorUnspecified: +- name: source + required: true +- name: type + required: true +- name: element_hash + required: true +- name: message + required: true +PassportElementErrorTranslationFiles: +- name: source + required: true +- name: type + required: true +- name: file_hashes + required: true +- name: message + required: true +PassportElementErrorTranslationFile: +- name: source + required: true +- name: type + required: true +- name: file_hash + required: true +- name: message + required: true +PassportElementErrorSelfie: +- name: source + required: true +- name: type + required: true +- name: file_hash + required: true +- name: message + required: true +PassportElementErrorReverseSide: +- name: source + required: true +- name: type + required: true +- name: file_hash + required: true +- name: message + required: true +PassportElementErrorFrontSide: +- name: source + required: true +- name: type + required: true +- name: file_hash + required: true +- name: message + required: true +PassportElementErrorFiles: +- name: source + required: true +- name: type + required: true +- name: file_hashes + required: true +- name: message + required: true +PassportElementErrorFile: +- name: source + required: true +- name: type + required: true +- name: file_hash + required: true +- name: message + required: true +PassportElementErrorDataField: +- name: source + required: true +- name: type + required: true +- name: field_name + required: true +- name: data_hash + required: true +- name: message + required: true +MenuButtonWebApp: +- name: type + required: true +- name: text + required: true +- name: web_app + required: true +MenuButtonDefault: +- name: type + required: true +MenuButtonCommands: +- name: type + required: true +KeyboardButtonRequestUser: +- name: request_id + required: true +- name: user_is_bot + required: false +- name: user_is_premium + required: false +KeyboardButtonRequestChat: +- name: request_id + required: true +- name: chat_is_channel + required: true +- name: chat_is_forum + required: false +- name: chat_has_username + required: false +- name: chat_is_created + required: false +- name: user_administrator_rights + required: false +- name: bot_administrator_rights + required: false +- name: bot_is_member + required: false +KeyboardButtonPollType: +- name: type + required: false +KeyboardButton: +- name: text + required: true +- name: request_user + required: false +- name: request_chat + required: false +- name: request_contact + required: false +- name: request_location + required: false +- name: request_poll + required: false +- name: web_app + required: false +InputVenueMessageContent: +- name: latitude + required: true +- name: longitude + required: true +- name: title + required: true +- name: address + required: true +- name: foursquare_id + required: false +- name: foursquare_type + required: false +- name: google_place_id + required: false +- name: google_place_type + required: false +InputTextMessageContent: +- name: message_text + required: true +- name: parse_mode + required: false +- name: entities + required: false +- name: disable_web_page_preview + required: false +InputMediaVideo: +- name: type + required: true +- name: media + required: true +- name: thumb + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: width + required: false +- name: height + required: false +- name: duration + required: false +- name: supports_streaming + required: false +- name: has_spoiler + required: false +InputMediaPhoto: +- name: type + required: true +- name: media + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: has_spoiler + required: false +InputMediaDocument: +- name: type + required: true +- name: media + required: true +- name: thumb + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: disable_content_type_detection + required: false +InputMediaAudio: +- name: type + required: true +- name: media + required: true +- name: thumb + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: duration + required: false +- name: performer + required: false +- name: title + required: false +InputMediaAnimation: +- name: type + required: true +- name: media + required: true +- name: thumb + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: width + required: false +- name: height + required: false +- name: duration + required: false +- name: has_spoiler + required: false +InputLocationMessageContent: +- name: latitude + required: true +- name: longitude + required: true +- name: horizontal_accuracy + required: false +- name: live_period + required: false +- name: heading + required: false +- name: proximity_alert_radius + required: false +LabeledPrice: +- name: label + required: true +- name: amount + required: true +InputInvoiceMessageContent: +- name: title + required: true +- name: description + required: true +- name: payload + required: true +- name: provider_token + required: true +- name: currency + required: true +- name: prices + required: true +- name: max_tip_amount + required: false +- name: suggested_tip_amounts + required: false +- name: provider_data + required: false +- name: photo_url + required: false +- name: photo_size + required: false +- name: photo_width + required: false +- name: photo_height + required: false +- name: need_name + required: false +- name: need_phone_number + required: false +- name: need_email + required: false +- name: need_shipping_address + required: false +- name: send_phone_number_to_provider + required: false +- name: send_email_to_provider + required: false +- name: is_flexible + required: false +InputContactMessageContent: +- name: phone_number + required: true +- name: first_name + required: true +- name: last_name + required: false +- name: vcard + required: false +InlineQueryResultVoice: +- name: type + required: true +- name: id + required: true +- name: voice_url + required: true +- name: title + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: voice_duration + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultVideo: +- name: type + required: true +- name: id + required: true +- name: video_url + required: true +- name: mime_type + required: true +- name: thumb_url + required: true +- name: title + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: video_width + required: false +- name: video_height + required: false +- name: video_duration + required: false +- name: description + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultVenue: +- name: type + required: true +- name: id + required: true +- name: latitude + required: true +- name: longitude + required: true +- name: title + required: true +- name: address + required: true +- name: foursquare_id + required: false +- name: foursquare_type + required: false +- name: google_place_id + required: false +- name: google_place_type + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +- name: thumb_url + required: false +- name: thumb_width + required: false +- name: thumb_height + required: false +InlineQueryResultPhoto: +- name: type + required: true +- name: id + required: true +- name: photo_url + required: true +- name: thumb_url + required: true +- name: photo_width + required: false +- name: photo_height + required: false +- name: title + required: false +- name: description + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultMpeg4Gif: +- name: type + required: true +- name: id + required: true +- name: mpeg4_url + required: true +- name: mpeg4_width + required: false +- name: mpeg4_height + required: false +- name: mpeg4_duration + required: false +- name: thumb_url + required: true +- name: thumb_mime_type + required: false +- name: title + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultLocation: +- name: type + required: true +- name: id + required: true +- name: latitude + required: true +- name: longitude + required: true +- name: title + required: true +- name: horizontal_accuracy + required: false +- name: live_period + required: false +- name: heading + required: false +- name: proximity_alert_radius + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +- name: thumb_url + required: false +- name: thumb_width + required: false +- name: thumb_height + required: false +InlineQueryResultGif: +- name: type + required: true +- name: id + required: true +- name: gif_url + required: true +- name: gif_width + required: false +- name: gif_height + required: false +- name: gif_duration + required: false +- name: thumb_url + required: true +- name: thumb_mime_type + required: false +- name: title + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultGame: +- name: type + required: true +- name: id + required: true +- name: game_short_name + required: true +- name: reply_markup + required: false +InlineQueryResultDocument: +- name: type + required: true +- name: id + required: true +- name: title + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: document_url + required: true +- name: mime_type + required: true +- name: description + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +- name: thumb_url + required: false +- name: thumb_width + required: false +- name: thumb_height + required: false +InlineQueryResultContact: +- name: type + required: true +- name: id + required: true +- name: phone_number + required: true +- name: first_name + required: true +- name: last_name + required: false +- name: vcard + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +- name: thumb_url + required: false +- name: thumb_width + required: false +- name: thumb_height + required: false +InlineQueryResultCachedVoice: +- name: type + required: true +- name: id + required: true +- name: voice_file_id + required: true +- name: title + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedVideo: +- name: type + required: true +- name: id + required: true +- name: video_file_id + required: true +- name: title + required: true +- name: description + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedSticker: +- name: type + required: true +- name: id + required: true +- name: sticker_file_id + required: true +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedPhoto: +- name: type + required: true +- name: id + required: true +- name: photo_file_id + required: true +- name: title + required: false +- name: description + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedMpeg4Gif: +- name: type + required: true +- name: id + required: true +- name: mpeg4_file_id + required: true +- name: title + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedGif: +- name: type + required: true +- name: id + required: true +- name: gif_file_id + required: true +- name: title + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedDocument: +- name: type + required: true +- name: id + required: true +- name: title + required: true +- name: document_file_id + required: true +- name: description + required: false +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultCachedAudio: +- name: type + required: true +- name: id + required: true +- name: audio_file_id + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InlineQueryResultAudio: +- name: type + required: true +- name: id + required: true +- name: audio_url + required: true +- name: title + required: true +- name: caption + required: false +- name: parse_mode + required: false +- name: caption_entities + required: false +- name: performer + required: false +- name: audio_duration + required: false +- name: reply_markup + required: false +- name: input_message_content + required: false +InputMessageContent: [] +InlineQueryResultArticle: +- name: type + required: true +- name: id + required: true +- name: title + required: true +- name: input_message_content + required: true +- name: reply_markup + required: false +- name: url + required: false +- name: hide_url + required: false +- name: description + required: false +- name: thumb_url + required: false +- name: thumb_width + required: false +- name: thumb_height + required: false +InlineQuery: +- name: id + required: true +- name: from + required: true +- name: query + required: true +- name: offset + required: true +- name: chat_type + required: false +- name: location + required: false +GameHighScore: +- name: position + required: true +- name: user + required: true +- name: score + required: true +ForumTopic: +- name: message_thread_id + required: true +- name: name + required: true +- name: icon_color + required: true +- name: icon_custom_emoji_id + required: false +ForceReply: +- name: force_reply + required: true +- name: input_field_placeholder + required: false +- name: selective + required: false +ChosenInlineResult: +- name: result_id + required: true +- name: from + required: true +- name: location + required: false +- name: inline_message_id + required: false +- name: query + required: true +ChatShared: +- name: request_id + required: true +- name: chat_id + required: true +ChatMemberUpdated: +- name: chat + required: true +- name: from + required: true +- name: date + required: true +- name: old_chat_member + required: true +- name: new_chat_member + required: true +- name: invite_link + required: false +ChatMemberRestricted: +- name: status + required: true +- name: user + required: true +- name: is_member + required: true +- name: can_send_messages + required: true +- name: can_send_audios + required: true +- name: can_send_documents + required: true +- name: can_send_photos + required: true +- name: can_send_videos + required: true +- name: can_send_video_notes + required: true +- name: can_send_voice_notes + required: true +- name: can_send_polls + required: true +- name: can_send_other_messages + required: true +- name: can_add_web_page_previews + required: true +- name: can_change_info + required: true +- name: can_invite_users + required: true +- name: can_pin_messages + required: true +- name: can_manage_topics + required: true +- name: until_date + required: true +ChatMemberOwner: +- name: status + required: true +- name: user + required: true +- name: is_anonymous + required: true +- name: custom_title + required: false +ChatMemberMember: +- name: status + required: true +- name: user + required: true +ChatMemberLeft: +- name: status + required: true +- name: user + required: true +ChatMemberBanned: +- name: status + required: true +- name: user + required: true +- name: until_date + required: true +ChatMemberAdministrator: +- name: status + required: true +- name: user + required: true +- name: can_be_edited + required: true +- name: is_anonymous + required: true +- name: can_manage_chat + required: true +- name: can_delete_messages + required: true +- name: can_manage_video_chats + required: true +- name: can_restrict_members + required: true +- name: can_promote_members + required: true +- name: can_change_info + required: true +- name: can_invite_users + required: true +- name: can_post_messages + required: false +- name: can_edit_messages + required: false +- name: can_pin_messages + required: false +- name: can_manage_topics + required: false +- name: custom_title + required: false +ChatMember: [] +ChatJoinRequest: +- name: chat + required: true +- name: from + required: true +- name: user_chat_id + required: true +- name: date + required: true +- name: bio + required: false +- name: invite_link + required: false +ChatInviteLink: +- name: invite_link + required: true +- name: creator + required: true +- name: creates_join_request + required: true +- name: is_primary + required: true +- name: is_revoked + required: true +- name: name + required: false +- name: expire_date + required: false +- name: member_limit + required: false +- name: pending_join_request_count + required: false +ChatAdministratorRights: +- name: is_anonymous + required: true +- name: can_manage_chat + required: true +- name: can_delete_messages + required: true +- name: can_manage_video_chats + required: true +- name: can_restrict_members + required: true +- name: can_promote_members + required: true +- name: can_change_info + required: true +- name: can_invite_users + required: true +- name: can_post_messages + required: false +- name: can_edit_messages + required: false +- name: can_pin_messages + required: false +- name: can_manage_topics + required: false +LoginUrl: +- name: url + required: true +- name: forward_text + required: false +- name: bot_username + required: false +- name: request_write_access + required: false +WebAppInfo: +- name: url + required: true +InlineKeyboardButton: +- name: text + required: true +- name: url + required: false +- name: callback_data + required: false +- name: web_app + required: false +- name: login_url + required: false +- name: switch_inline_query + required: false +- name: switch_inline_query_current_chat + required: false +- name: callback_game + required: false +- name: pay + required: false +InlineKeyboardMarkup: +- name: inline_keyboard + required: true +WebAppData: +- name: data + required: true +- name: button_text + required: true +VideoChatParticipantsInvited: +- name: users + required: true +VideoChatEnded: +- name: duration + required: true +VideoChatStarted: [] +VideoChatScheduled: +- name: start_date + required: true +GeneralForumTopicUnhidden: [] +GeneralForumTopicHidden: [] +ForumTopicReopened: [] +ForumTopicClosed: [] +ForumTopicEdited: +- name: name + required: false +- name: icon_custom_emoji_id + required: false +ForumTopicCreated: +- name: name + required: true +- name: icon_color + required: true +- name: icon_custom_emoji_id + required: false +ProximityAlertTriggered: +- name: traveler + required: true +- name: watcher + required: true +- name: distance + required: true +EncryptedCredentials: +- name: data + required: true +- name: hash + required: true +- name: secret + required: true +PassportFile: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: file_size + required: true +- name: file_date + required: true +EncryptedPassportElement: +- name: type + required: true +- name: data + required: false +- name: phone_number + required: false +- name: email + required: false +- name: files + required: false +- name: front_side + required: false +- name: reverse_side + required: false +- name: selfie + required: false +- name: translation + required: false +- name: hash + required: true +PassportData: +- name: data + required: true +- name: credentials + required: true +WriteAccessAllowed: [] +ShippingAddress: +- name: country_code + required: true +- name: state + required: true +- name: city + required: true +- name: street_line1 + required: true +- name: street_line2 + required: true +- name: post_code + required: true +OrderInfo: +- name: name + required: false +- name: phone_number + required: false +- name: email + required: false +- name: shipping_address + required: false +SuccessfulPayment: +- name: currency + required: true +- name: total_amount + required: true +- name: invoice_payload + required: true +- name: shipping_option_id + required: false +- name: order_info + required: false +- name: telegram_payment_charge_id + required: true +- name: provider_payment_charge_id + required: true +Invoice: +- name: title + required: true +- name: description + required: true +- name: start_parameter + required: true +- name: currency + required: true +- name: total_amount + required: true +MessageAutoDeleteTimerChanged: +- name: message_auto_delete_time + required: true +Venue: +- name: location + required: true +- name: title + required: true +- name: address + required: true +- name: foursquare_id + required: false +- name: foursquare_type + required: false +- name: google_place_id + required: false +- name: google_place_type + required: false +PollOption: +- name: text + required: true +- name: voter_count + required: true +Poll: +- name: id + required: true +- name: question + required: true +- name: options + required: true +- name: total_voter_count + required: true +- name: is_closed + required: true +- name: is_anonymous + required: true +- name: type + required: true +- name: allows_multiple_answers + required: true +- name: correct_option_id + required: false +- name: explanation + required: false +- name: explanation_entities + required: false +- name: open_period + required: false +- name: close_date + required: false +Game: +- name: title + required: true +- name: description + required: true +- name: photo + required: true +- name: text + required: false +- name: text_entities + required: false +- name: animation + required: false +Dice: +- name: emoji + required: true +- name: value + required: true +Contact: +- name: phone_number + required: true +- name: first_name + required: true +- name: last_name + required: false +- name: user_id + required: false +- name: vcard + required: false +Voice: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: duration + required: true +- name: mime_type + required: false +- name: file_size + required: false +VideoNote: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: length + required: true +- name: duration + required: true +- name: thumb + required: false +- name: file_size + required: false +Video: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: width + required: true +- name: height + required: true +- name: duration + required: true +- name: thumb + required: false +- name: file_name + required: false +- name: mime_type + required: false +- name: file_size + required: false +MaskPosition: +- name: point + required: true +- name: x_shift + required: true +- name: y_shift + required: true +- name: scale + required: true +File: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: file_size + required: false +- name: file_path + required: false +Sticker: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: type + required: true +- name: width + required: true +- name: height + required: true +- name: is_animated + required: true +- name: is_video + required: true +- name: thumb + required: false +- name: emoji + required: false +- name: set_name + required: false +- name: premium_animation + required: false +- name: mask_position + required: false +- name: custom_emoji_id + required: false +- name: file_size + required: false +Document: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: thumb + required: false +- name: file_name + required: false +- name: mime_type + required: false +- name: file_size + required: false +MessageEntity: +- name: type + required: true +- name: offset + required: true +- name: length + required: true +- name: url + required: false +- name: user + required: false +- name: language + required: false +- name: custom_emoji_id + required: false +Location: +- name: longitude + required: true +- name: latitude + required: true +- name: horizontal_accuracy + required: false +- name: live_period + required: false +- name: heading + required: false +- name: proximity_alert_radius + required: false +ChatLocation: +- name: location + required: true +- name: address + required: true +ChatPermissions: +- name: can_send_messages + required: false +- name: can_send_audios + required: false +- name: can_send_documents + required: false +- name: can_send_photos + required: false +- name: can_send_videos + required: false +- name: can_send_video_notes + required: false +- name: can_send_voice_notes + required: false +- name: can_send_polls + required: false +- name: can_send_other_messages + required: false +- name: can_add_web_page_previews + required: false +- name: can_change_info + required: false +- name: can_invite_users + required: false +- name: can_pin_messages + required: false +- name: can_manage_topics + required: false +ChatPhoto: +- name: small_file_id + required: true +- name: small_file_unique_id + required: true +- name: big_file_id + required: true +- name: big_file_unique_id + required: true +Chat: +- name: id + required: true +- name: type + required: true +- name: title + required: false +- name: username + required: false +- name: first_name + required: false +- name: last_name + required: false +- name: is_forum + required: false +- name: photo + required: false +- name: active_usernames + required: false +- name: emoji_status_custom_emoji_id + required: false +- name: bio + required: false +- name: has_private_forwards + required: false +- name: has_restricted_voice_and_video_messages + required: false +- name: join_to_send_messages + required: false +- name: join_by_request + required: false +- name: description + required: false +- name: invite_link + required: false +- name: pinned_message + required: false +- name: permissions + required: false +- name: slow_mode_delay + required: false +- name: message_auto_delete_time + required: false +- name: has_aggressive_anti_spam_enabled + required: false +- name: has_hidden_members + required: false +- name: has_protected_content + required: false +- name: sticker_set_name + required: false +- name: can_set_sticker_set + required: false +- name: linked_chat_id + required: false +- name: location + required: false +Message: +- name: message_id + required: true +- name: message_thread_id + required: false +- name: from + required: false +- name: sender_chat + required: false +- name: date + required: true +- name: chat + required: true +- name: forward_from + required: false +- name: forward_from_chat + required: false +- name: forward_from_message_id + required: false +- name: forward_signature + required: false +- name: forward_sender_name + required: false +- name: forward_date + required: false +- name: is_topic_message + required: false +- name: is_automatic_forward + required: false +- name: reply_to_message + required: false +- name: via_bot + required: false +- name: edit_date + required: false +- name: has_protected_content + required: false +- name: media_group_id + required: false +- name: author_signature + required: false +- name: text + required: false +- name: entities + required: false +- name: animation + required: false +- name: audio + required: false +- name: document + required: false +- name: photo + required: false +- name: sticker + required: false +- name: video + required: false +- name: video_note + required: false +- name: voice + required: false +- name: caption + required: false +- name: caption_entities + required: false +- name: has_media_spoiler + required: false +- name: contact + required: false +- name: dice + required: false +- name: game + required: false +- name: poll + required: false +- name: venue + required: false +- name: location + required: false +- name: new_chat_members + required: false +- name: left_chat_member + required: false +- name: new_chat_title + required: false +- name: new_chat_photo + required: false +- name: delete_chat_photo + required: false +- name: group_chat_created + required: false +- name: supergroup_chat_created + required: false +- name: channel_chat_created + required: false +- name: message_auto_delete_timer_changed + required: false +- name: migrate_to_chat_id + required: false +- name: migrate_from_chat_id + required: false +- name: pinned_message + required: false +- name: invoice + required: false +- name: successful_payment + required: false +- name: user_shared + required: false +- name: chat_shared + required: false +- name: connected_website + required: false +- name: write_access_allowed + required: false +- name: passport_data + required: false +- name: proximity_alert_triggered + required: false +- name: forum_topic_created + required: false +- name: forum_topic_edited + required: false +- name: forum_topic_closed + required: false +- name: forum_topic_reopened + required: false +- name: general_forum_topic_hidden + required: false +- name: general_forum_topic_unhidden + required: false +- name: video_chat_scheduled + required: false +- name: video_chat_started + required: false +- name: video_chat_ended + required: false +- name: video_chat_participants_invited + required: false +- name: web_app_data + required: false +- name: reply_markup + required: false +User: +- name: id + required: true +- name: is_bot + required: true +- name: first_name + required: true +- name: last_name + required: false +- name: username + required: false +- name: language_code + required: false +- name: is_premium + required: false +- name: added_to_attachment_menu + required: false +- name: can_join_groups + required: false +- name: can_read_all_group_messages + required: false +- name: supports_inline_queries + required: false +CallbackQuery: +- name: id + required: true +- name: from + required: true +- name: message + required: false +- name: inline_message_id + required: false +- name: chat_instance + required: true +- name: data + required: false +- name: game_short_name + required: false +CallbackGame: [] +BotCommandScopeDefault: +- name: type + required: true +BotCommandScopeChatMember: +- name: type + required: true +- name: chat_id + required: true +- name: user_id + required: true +BotCommandScopeChatAdministrators: +- name: type + required: true +- name: chat_id + required: true +BotCommandScopeChat: +- name: type + required: true +- name: chat_id + required: true +BotCommandScopeAllPrivateChats: +- name: type + required: true +BotCommandScopeAllGroupChats: +- name: type + required: true +BotCommandScopeAllChatAdministrators: +- name: type + required: true +BotCommand: +- name: command + required: true +- name: description + required: true +Audio: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: duration + required: true +- name: performer + required: false +- name: title + required: false +- name: file_name + required: false +- name: mime_type + required: false +- name: file_size + required: false +- name: thumb + required: false +PhotoSize: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: width + required: true +- name: height + required: true +- name: file_size + required: false +Animation: +- name: file_id + required: true +- name: file_unique_id + required: true +- name: width + required: true +- name: height + required: true +- name: duration + required: true +- name: thumb + required: false +- name: file_name + required: false +- name: mime_type + required: false +- name: file_size + required: false diff --git a/telegram-bot-ruby.gemspec b/telegram-bot-ruby.gemspec index c384c3e..375f3d3 100644 --- a/telegram-bot-ruby.gemspec +++ b/telegram-bot-ruby.gemspec @@ -22,15 +22,8 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.7' spec.metadata['rubygems_mfa_required'] = 'true' - spec.add_dependency 'dry-inflector' + spec.add_dependency 'dry-struct', '~> 1.6' spec.add_dependency 'faraday', '~> 2.0' spec.add_dependency 'faraday-multipart', '~> 1.0' - spec.add_dependency 'virtus', '~> 2.0' - - spec.add_development_dependency 'pry' - spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rspec', '~> 3.4' - spec.add_development_dependency 'rubocop', '~> 1.27' - spec.add_development_dependency 'rubocop-rake' - spec.add_development_dependency 'rubocop-rspec', '~> 2.10' + spec.add_dependency 'zeitwerk', '~> 2.6' end