From f5e475e31adf3b995ae1bf3f594324b26e3707c6 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 9 Sep 2023 19:35:01 +0300 Subject: [PATCH 01/11] Small improvements for Types specs, especially variables naming --- spec/lib/telegram/bot/types_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/lib/telegram/bot/types_spec.rb b/spec/lib/telegram/bot/types_spec.rb index ad6de703..075af0b6 100644 --- a/spec/lib/telegram/bot/types_spec.rb +++ b/spec/lib/telegram/bot/types_spec.rb @@ -7,18 +7,20 @@ ) RSpec.describe Telegram::Bot::Types do - type_attributes.each do |type, attributes| - describe type do - subject(:klass) { Object.const_get("Telegram::Bot::Types::#{type}") } + type_attributes.each do |parsed_type, parsed_attributes| + describe parsed_type do + subject(:klass) { Object.const_get("Telegram::Bot::Types::#{parsed_type}") } it 'has correct attributes' do - expect(klass.schema.keys.map(&:name)).to eq(attributes.map { |e| e['name'].to_sym }) + expect(klass.schema.keys.map(&:name)).to eq(parsed_attributes.map { |e| e['name'].to_sym }) end - attributes.each do |attribute| - describe "##{attribute['name']}" do + parsed_attributes.each do |parsed_attribute| + describe "##{parsed_attribute['name']}" do + subject(:klass_attribute) { klass.schema.name_key_map[parsed_attribute['name'].to_sym] } + it 'has correct optionality' do - expect(klass.schema.name_key_map[attribute['name'].to_sym]&.required?).to eq(attribute['required']) + expect(klass_attribute&.required?).to eq(parsed_attribute['required']) end end end From 80e6634c65a3da18dfc0d71f9bdbac482e13df47 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 9 Sep 2023 19:36:15 +0300 Subject: [PATCH 02/11] Remake `Object.const_get` into `described_class.const_get` with `false` argument --- spec/lib/telegram/bot/types_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/telegram/bot/types_spec.rb b/spec/lib/telegram/bot/types_spec.rb index 075af0b6..a7f927b4 100644 --- a/spec/lib/telegram/bot/types_spec.rb +++ b/spec/lib/telegram/bot/types_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Telegram::Bot::Types do type_attributes.each do |parsed_type, parsed_attributes| describe parsed_type do - subject(:klass) { Object.const_get("Telegram::Bot::Types::#{parsed_type}") } + subject(:klass) { described_class.const_get(parsed_type, false) } it 'has correct attributes' do expect(klass.schema.keys.map(&:name)).to eq(parsed_attributes.map { |e| e['name'].to_sym }) From 05a6c5fe838a0bdb4f8c7a922812a94e37d9a6a2 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 01:54:02 +0300 Subject: [PATCH 03/11] Dump more data from Telegram API docs About attribute type and required value (if there is such). --- .rubocop.yml | 5 +++++ Rakefile | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2998bfa9..a132c560 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -19,9 +19,14 @@ Metrics/BlockLength: Metrics/ClassLength: Exclude: - lib/telegram/bot/api/endpoints.rb +Metrics/MethodLength: + Exclude: + - spec/**/* Layout/LineLength: Max: 120 RSpec/MultipleMemoizedHelpers: Enabled: false +RSpec/NestedGroups: + Enabled: false diff --git a/Rakefile b/Rakefile index afb5a65a..62e4ce2e 100644 --- a/Rakefile +++ b/Rakefile @@ -47,8 +47,11 @@ task :dump_type_attributes do cells = el.children.select { |c| c.name == 'td' } { 'name' => cells[0].text, - 'required' => !cells[2].text.start_with?('Optional.') - } + 'type' => cells[1].text, + 'required' => !cells[2].text.start_with?('Optional.'), + 'required_value' => + cells[2].text.match(/^.+, (?:must be (?\w+)|always “(?\w+)”)$/)&.[](:found_type) + }.compact end [type, attributes] From 2661547b63efdd05558bf257d6fcf21a8d24dc61 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 01:58:17 +0300 Subject: [PATCH 04/11] Add specs for attributes Types (and required data) Avoid `default` value for now as a work-around. --- spec/lib/telegram/bot/types_spec.rb | 62 ++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/spec/lib/telegram/bot/types_spec.rb b/spec/lib/telegram/bot/types_spec.rb index a7f927b4..27b28796 100644 --- a/spec/lib/telegram/bot/types_spec.rb +++ b/spec/lib/telegram/bot/types_spec.rb @@ -19,8 +19,66 @@ describe "##{parsed_attribute['name']}" do subject(:klass_attribute) { klass.schema.name_key_map[parsed_attribute['name'].to_sym] } - it 'has correct optionality' do - expect(klass_attribute&.required?).to eq(parsed_attribute['required']) + describe 'type' do + subject do + klass_attribute_type = klass_attribute&.type + + ## We need to get rid of `default` values + ## https://discourse.dry-rb.org/t/how-to-remove-a-default-from-dry-types-custom-class-attribute/1727 + klass_attribute_type = klass_attribute_type.type if klass_attribute_type.default? + + klass_attribute_type + end + + def parse_string_type(type_string) + if (match_data = type_string.match(/^Array of (?.+)$/)) + ## Call a recursion for `Array of Array of Something` + return described_class::Array.of(send(__method__, match_data[:inner_type])) + end + + ## We have no examples of `or` with 3 or more types + if (match_data = type_string.match(/^(\w+) or (\w+)$/)) + ## `uniq` for `InputFile`, for example + return match_data[1..].map { |matched_type| send(__method__, matched_type) }.uniq.reduce(:|) + end + + type_string = + case type_string + ## `dry-types` has no `Boolean` type (or alias) + when 'Boolean' then 'Bool' + when 'Float number' then 'Float' + ## It's a `file_id`, URL or `multipart/form-data`: + ## https://core.telegram.org/bots/api#inputfile + when 'InputFile' then 'String' + ## I'm not sure about this. It's like "True is optional to send" and "We can response with False" + # when 'True' && !parsed_attribute['required'] then 'Boolean' + else type_string + end + + # binding.irb if type_string == 'Bool' + + ## Without `false` for `const_get` because base types inhereted from the `dry-types` + described_class.const_get(type_string) + end + + let(:expected_type) do + result = parse_string_type(parsed_attribute['type']) + + ## Sometimes there are required values for attributes, like `BotCommandScope` or `MenuButton` + if (required_value = parsed_attribute['required_value']) + result = result.constrained(eql: required_value) + end + + result + end + + it { is_expected.to eq expected_type } + end + + describe 'optionality' do + subject { klass_attribute&.required? } + + it { is_expected.to eq parsed_attribute['required'] } end end end From d3a8fcbb49fe46bce58dbbc5765d375f5df168fc Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 01:58:44 +0300 Subject: [PATCH 05/11] Populate `type_attributes` YAML file for specs --- spec/support/type_attributes.yml | 949 ++++++++++++++++++++++++++++++- 1 file changed, 940 insertions(+), 9 deletions(-) diff --git a/spec/support/type_attributes.yml b/spec/support/type_attributes.yml index a36a0ad8..e5b37f64 100644 --- a/spec/support/type_attributes.yml +++ b/spec/support/type_attributes.yml @@ -1,1218 +1,1827 @@ --- ShippingOption: - name: id + type: String required: true - name: title + type: String required: true - name: prices + type: Array of LabeledPrice required: true ReplyKeyboardRemove: - name: remove_keyboard + type: 'True' required: true - name: selective + type: Boolean required: false ReplyKeyboardMarkup: - name: keyboard + type: Array of Array of KeyboardButton required: true - name: is_persistent + type: Boolean required: false - name: resize_keyboard + type: Boolean required: false - name: one_time_keyboard + type: Boolean required: false - name: input_field_placeholder + type: String required: false - name: selective + type: Boolean required: false PassportElementErrorUnspecified: - name: source + type: String required: true + required_value: unspecified - name: type + type: String required: true - name: element_hash + type: String required: true - name: message + type: String required: true PassportElementErrorTranslationFiles: - name: source + type: String required: true + required_value: translation_files - name: type + type: String required: true - name: file_hashes + type: Array of String required: true - name: message + type: String required: true PassportElementErrorTranslationFile: - name: source + type: String required: true + required_value: translation_file - name: type + type: String required: true - name: file_hash + type: String required: true - name: message + type: String required: true PassportElementErrorSelfie: - name: source + type: String required: true + required_value: selfie - name: type + type: String required: true - name: file_hash + type: String required: true - name: message + type: String required: true PassportElementErrorReverseSide: - name: source + type: String required: true + required_value: reverse_side - name: type + type: String required: true - name: file_hash + type: String required: true - name: message + type: String required: true PassportElementErrorFrontSide: - name: source + type: String required: true + required_value: front_side - name: type + type: String required: true - name: file_hash + type: String required: true - name: message + type: String required: true PassportElementErrorFiles: - name: source + type: String required: true + required_value: files - name: type + type: String required: true - name: file_hashes + type: Array of String required: true - name: message + type: String required: true PassportElementErrorFile: - name: source + type: String required: true + required_value: file - name: type + type: String required: true - name: file_hash + type: String required: true - name: message + type: String required: true PassportElementErrorDataField: - name: source + type: String required: true + required_value: data - name: type + type: String required: true - name: field_name + type: String required: true - name: data_hash + type: String required: true - name: message + type: String required: true KeyboardButtonPollType: - name: type + type: String required: false KeyboardButtonRequestChat: - name: request_id + type: Integer required: true - name: chat_is_channel + type: Boolean required: true - name: chat_is_forum + type: Boolean required: false - name: chat_has_username + type: Boolean required: false - name: chat_is_created + type: Boolean required: false - name: user_administrator_rights + type: ChatAdministratorRights required: false - name: bot_administrator_rights + type: ChatAdministratorRights required: false - name: bot_is_member + type: Boolean required: false KeyboardButtonRequestUser: - name: request_id + type: Integer required: true - name: user_is_bot + type: Boolean required: false - name: user_is_premium + type: Boolean required: false KeyboardButton: - name: text + type: String required: true - name: request_user + type: KeyboardButtonRequestUser required: false - name: request_chat + type: KeyboardButtonRequestChat required: false - name: request_contact + type: Boolean required: false - name: request_location + type: Boolean required: false - name: request_poll + type: KeyboardButtonPollType required: false - name: web_app + type: WebAppInfo required: false InputVenueMessageContent: - name: latitude + type: Float required: true - name: longitude + type: Float required: true - name: title + type: String required: true - name: address + type: String required: true - name: foursquare_id + type: String required: false - name: foursquare_type + type: String required: false - name: google_place_id + type: String required: false - name: google_place_type + type: String required: false InputTextMessageContent: - name: message_text + type: String required: true - name: parse_mode + type: String required: false - name: entities + type: Array of MessageEntity required: false - name: disable_web_page_preview + type: Boolean required: false InputMediaVideo: - name: type + type: String required: true + required_value: video - name: media + type: String required: true - name: thumbnail + type: InputFile or String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: width + type: Integer required: false - name: height + type: Integer required: false - name: duration + type: Integer required: false - name: supports_streaming + type: Boolean required: false - name: has_spoiler + type: Boolean required: false InputMediaPhoto: - name: type + type: String required: true + required_value: photo - name: media + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: has_spoiler + type: Boolean required: false InputMediaDocument: - name: type + type: String required: true + required_value: document - name: media + type: String required: true - name: thumbnail + type: InputFile or String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: disable_content_type_detection + type: Boolean required: false InputMediaAudio: - name: type + type: String required: true + required_value: audio - name: media + type: String required: true - name: thumbnail + type: InputFile or String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: duration + type: Integer required: false - name: performer + type: String required: false - name: title + type: String required: false InputMediaAnimation: - name: type + type: String required: true + required_value: animation - name: media + type: String required: true - name: thumbnail + type: InputFile or String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: width + type: Integer required: false - name: height + type: Integer required: false - name: duration + type: Integer required: false - name: has_spoiler + type: Boolean required: false InputLocationMessageContent: - name: latitude + type: Float required: true - name: longitude + type: Float required: true - name: horizontal_accuracy + type: Float number required: false - name: live_period + type: Integer required: false - name: heading + type: Integer required: false - name: proximity_alert_radius + type: Integer required: false LabeledPrice: - name: label + type: String required: true - name: amount + type: Integer required: true InputInvoiceMessageContent: - name: title + type: String required: true - name: description + type: String required: true - name: payload + type: String required: true - name: provider_token + type: String required: true - name: currency + type: String required: true - name: prices + type: Array of LabeledPrice required: true - name: max_tip_amount + type: Integer required: false - name: suggested_tip_amounts + type: Array of Integer required: false - name: provider_data + type: String required: false - name: photo_url + type: String required: false - name: photo_size + type: Integer required: false - name: photo_width + type: Integer required: false - name: photo_height + type: Integer required: false - name: need_name + type: Boolean required: false - name: need_phone_number + type: Boolean required: false - name: need_email + type: Boolean required: false - name: need_shipping_address + type: Boolean required: false - name: send_phone_number_to_provider + type: Boolean required: false - name: send_email_to_provider + type: Boolean required: false - name: is_flexible + type: Boolean required: false InputContactMessageContent: - name: phone_number + type: String required: true - name: first_name + type: String required: true - name: last_name + type: String required: false - name: vcard + type: String required: false InlineQueryResultVoice: - name: type + type: String required: true + required_value: voice - name: id + type: String required: true - name: voice_url + type: String required: true - name: title + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: voice_duration + type: Integer required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultVideo: - name: type + type: String required: true + required_value: video - name: id + type: String required: true - name: video_url + type: String required: true - name: mime_type + type: String required: true - name: thumbnail_url + type: String required: true - name: title + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: video_width + type: Integer required: false - name: video_height + type: Integer required: false - name: video_duration + type: Integer required: false - name: description + type: String required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultVenue: - name: type + type: String required: true + required_value: venue - name: id + type: String required: true - name: latitude + type: Float required: true - name: longitude + type: Float required: true - name: title + type: String required: true - name: address + type: String required: true - name: foursquare_id + type: String required: false - name: foursquare_type + type: String required: false - name: google_place_id + type: String required: false - name: google_place_type + type: String required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false - name: thumbnail_url + type: String required: false - name: thumbnail_width + type: Integer required: false - name: thumbnail_height + type: Integer required: false InlineQueryResultPhoto: - name: type + type: String required: true + required_value: photo - name: id + type: String required: true - name: photo_url + type: String required: true - name: thumbnail_url + type: String required: true - name: photo_width + type: Integer required: false - name: photo_height + type: Integer required: false - name: title + type: String required: false - name: description + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultMpeg4Gif: - name: type + type: String required: true + required_value: mpeg4_gif - name: id + type: String required: true - name: mpeg4_url + type: String required: true - name: mpeg4_width + type: Integer required: false - name: mpeg4_height + type: Integer required: false - name: mpeg4_duration + type: Integer required: false - name: thumbnail_url + type: String required: true - name: thumbnail_mime_type + type: String required: false - name: title + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultLocation: - name: type + type: String required: true + required_value: location - name: id + type: String required: true - name: latitude + type: Float number required: true - name: longitude + type: Float number required: true - name: title + type: String required: true - name: horizontal_accuracy + type: Float number required: false - name: live_period + type: Integer required: false - name: heading + type: Integer required: false - name: proximity_alert_radius + type: Integer required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false - name: thumbnail_url + type: String required: false - name: thumbnail_width + type: Integer required: false - name: thumbnail_height + type: Integer required: false InlineQueryResultGif: - name: type + type: String required: true + required_value: gif - name: id + type: String required: true - name: gif_url + type: String required: true - name: gif_width + type: Integer required: false - name: gif_height + type: Integer required: false - name: gif_duration + type: Integer required: false - name: thumbnail_url + type: String required: true - name: thumbnail_mime_type + type: String required: false - name: title + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultGame: - name: type + type: String required: true + required_value: game - name: id + type: String required: true - name: game_short_name + type: String required: true - name: reply_markup + type: InlineKeyboardMarkup required: false InlineQueryResultDocument: - name: type + type: String required: true + required_value: document - name: id + type: String required: true - name: title + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: document_url + type: String required: true - name: mime_type + type: String required: true - name: description + type: String required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false - name: thumbnail_url + type: String required: false - name: thumbnail_width + type: Integer required: false - name: thumbnail_height + type: Integer required: false InlineQueryResultContact: - name: type + type: String required: true + required_value: contact - name: id + type: String required: true - name: phone_number + type: String required: true - name: first_name + type: String required: true - name: last_name + type: String required: false - name: vcard + type: String required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false - name: thumbnail_url + type: String required: false - name: thumbnail_width + type: Integer required: false - name: thumbnail_height + type: Integer required: false InlineQueryResultCachedVoice: - name: type + type: String required: true + required_value: voice - name: id + type: String required: true - name: voice_file_id + type: String required: true - name: title + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedVideo: - name: type + type: String required: true + required_value: video - name: id + type: String required: true - name: video_file_id + type: String required: true - name: title + type: String required: true - name: description + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedSticker: - name: type + type: String required: true + required_value: sticker - name: id + type: String required: true - name: sticker_file_id + type: String required: true - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedPhoto: - name: type + type: String required: true + required_value: photo - name: id + type: String required: true - name: photo_file_id + type: String required: true - name: title + type: String required: false - name: description + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedMpeg4Gif: - name: type + type: String required: true + required_value: mpeg4_gif - name: id + type: String required: true - name: mpeg4_file_id + type: String required: true - name: title + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedGif: - name: type + type: String required: true + required_value: gif - name: id + type: String required: true - name: gif_file_id + type: String required: true - name: title + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedDocument: - name: type + type: String required: true + required_value: document - name: id + type: String required: true - name: title + type: String required: true - name: document_file_id + type: String required: true - name: description + type: String required: false - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultCachedAudio: - name: type + type: String required: true + required_value: audio - name: id + type: String required: true - name: audio_file_id + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InlineQueryResultAudio: - name: type + type: String required: true + required_value: audio - name: id + type: String required: true - name: audio_url + type: String required: true - name: title + type: String required: true - name: caption + type: String required: false - name: parse_mode + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: performer + type: String required: false - name: audio_duration + type: Integer required: false - name: reply_markup + type: InlineKeyboardMarkup required: false - name: input_message_content + type: InputMessageContent required: false InputMessageContent: [] InlineQueryResultArticle: - name: type + type: String required: true + required_value: article - name: id + type: String required: true - name: title + type: String required: true - name: input_message_content + type: InputMessageContent required: true - name: reply_markup + type: InlineKeyboardMarkup required: false - name: url + type: String required: false - name: hide_url + type: Boolean required: false - name: description + type: String required: false - name: thumbnail_url + type: String required: false - name: thumbnail_width + type: Integer required: false - name: thumbnail_height + type: Integer required: false ForumTopic: - name: message_thread_id + type: Integer required: true - name: name + type: String required: true - name: icon_color + type: Integer required: true - name: icon_custom_emoji_id + type: String required: false ForceReply: - name: force_reply + type: 'True' required: true - name: input_field_placeholder + type: String required: false - name: selective + type: Boolean required: false -BotShortDescription: -- name: short_description - required: true -BotName: -- name: name - required: true -BotDescription: -- name: description - required: true BotCommandScopeDefault: - name: type + type: String required: true + required_value: default BotCommandScopeChatMember: - name: type + type: String required: true + required_value: chat_member - name: chat_id + type: Integer or String required: true - name: user_id + type: Integer required: true BotCommandScopeChatAdministrators: - name: type + type: String required: true + required_value: chat_administrators - name: chat_id + type: Integer or String required: true BotCommandScopeChat: - name: type + type: String required: true + required_value: chat - name: chat_id + type: Integer or String required: true BotCommandScopeAllPrivateChats: - name: type + type: String required: true + required_value: all_private_chats BotCommandScopeAllGroupChats: - name: type + type: String required: true + required_value: all_group_chats BotCommandScopeAllChatAdministrators: - name: type + type: String + required: true + required_value: all_chat_administrators +BotShortDescription: +- name: short_description + type: String + required: true +BotDescription: +- name: description + type: String + required: true +BotName: +- name: name + type: String required: true ChatAdministratorRights: - name: is_anonymous + type: Boolean required: true - name: can_manage_chat + type: Boolean required: true - name: can_delete_messages + type: Boolean required: true - name: can_manage_video_chats + type: Boolean required: true - name: can_restrict_members + type: Boolean required: true - name: can_promote_members + type: Boolean required: true - name: can_change_info + type: Boolean required: true - name: can_invite_users + type: Boolean required: true - name: can_post_messages + type: Boolean required: false - name: can_edit_messages + type: Boolean required: false - name: can_pin_messages + type: Boolean required: false - name: can_manage_topics + type: Boolean required: false MenuButtonWebApp: - name: type + type: String required: true + required_value: web_app - name: text + type: String required: true - name: web_app + type: WebAppInfo required: true MenuButtonCommands: - name: type + type: String required: true + required_value: commands MenuButtonDefault: - name: type + type: String required: true + required_value: default SentWebAppMessage: - name: inline_message_id + type: String required: false MessageId: - name: message_id + type: Integer required: true BotCommand: - name: command + type: String required: true - name: description + type: String required: true GameHighScore: - name: position + type: Integer required: true - name: user + type: User required: true - name: score + type: Integer required: true StickerSet: - name: name + type: String required: true - name: title + type: String required: true - name: sticker_type + type: String required: true - name: is_animated + type: Boolean required: true - name: is_video + type: Boolean required: true - name: stickers + type: Array of Sticker required: true - name: thumbnail + type: PhotoSize required: false UserProfilePhotos: - name: total_count + type: Integer required: true - name: photos + type: Array of Array of PhotoSize required: true WebhookInfo: - name: url + type: String required: true - name: has_custom_certificate + type: Boolean required: true - name: pending_update_count + type: Integer required: true - name: ip_address + type: String required: false - name: last_error_date + type: Integer required: false - name: last_error_message + type: String required: false - name: last_synchronization_error_date + type: Integer required: false - name: max_connections + type: Integer required: false - name: allowed_updates + type: Array of String required: false ChatJoinRequest: - name: chat + type: Chat required: true - name: from + type: User required: true - name: user_chat_id + type: Integer required: true - name: date + type: Integer required: true - name: bio + type: String required: false - name: invite_link + type: ChatInviteLink required: false ChatInviteLink: - name: invite_link + type: String required: true - name: creator + type: User required: true - name: creates_join_request + type: Boolean required: true - name: is_primary + type: Boolean required: true - name: is_revoked + type: Boolean required: true - name: name + type: String required: false - name: expire_date + type: Integer required: false - name: member_limit + type: Integer required: false - name: pending_join_request_count + type: Integer required: false ChatMemberRestricted: - name: status + type: String required: true + required_value: restricted - name: user + type: User required: true - name: is_member + type: Boolean required: true - name: can_send_messages + type: Boolean required: true - name: can_send_audios + type: Boolean required: true - name: can_send_documents + type: Boolean required: true - name: can_send_photos + type: Boolean required: true - name: can_send_videos + type: Boolean required: true - name: can_send_video_notes + type: Boolean required: true - name: can_send_voice_notes + type: Boolean required: true - name: can_send_polls + type: Boolean required: true - name: can_send_other_messages + type: Boolean required: true - name: can_add_web_page_previews + type: Boolean required: true - name: can_change_info + type: Boolean required: true - name: can_invite_users + type: Boolean required: true - name: can_pin_messages + type: Boolean required: true - name: can_manage_topics + type: Boolean required: true - name: until_date + type: Integer required: true ChatMemberOwner: - name: status + type: String required: true + required_value: creator - name: user + type: User required: true - name: is_anonymous + type: Boolean required: true - name: custom_title + type: String required: false ChatMemberMember: - name: status + type: String required: true + required_value: member - name: user + type: User required: true ChatMemberLeft: - name: status + type: String required: true + required_value: left - name: user + type: User required: true ChatMemberBanned: - name: status + type: String required: true + required_value: kicked - name: user + type: User required: true - name: until_date + type: Integer required: true ChatMemberAdministrator: - name: status + type: String required: true + required_value: administrator - name: user + type: User required: true - name: can_be_edited + type: Boolean required: true - name: is_anonymous + type: Boolean required: true - name: can_manage_chat + type: Boolean required: true - name: can_delete_messages + type: Boolean required: true - name: can_manage_video_chats + type: Boolean required: true - name: can_restrict_members + type: Boolean required: true - name: can_promote_members + type: Boolean required: true - name: can_change_info + type: Boolean required: true - name: can_invite_users + type: Boolean required: true - name: can_post_messages + type: Boolean required: false - name: can_edit_messages + type: Boolean required: false - name: can_pin_messages + type: Boolean required: false - name: can_manage_topics + type: Boolean required: false - name: custom_title + type: String required: false ChatMemberUpdated: - name: chat + type: Chat required: true - name: from + type: User required: true - name: date + type: Integer required: true - name: old_chat_member + type: ChatMember required: true - name: new_chat_member + type: ChatMember required: true - name: invite_link + type: ChatInviteLink required: false - name: via_chat_folder_invite_link + type: Boolean required: false PollAnswer: - name: poll_id + type: String required: true - name: voter_chat + type: Chat required: false - name: user + type: User required: false - name: option_ids + type: Array of Integer required: true PreCheckoutQuery: - name: id + type: String required: true - name: from + type: User required: true - name: currency + type: String required: true - name: total_amount + type: Integer required: true - name: invoice_payload + type: String required: true - name: shipping_option_id + type: String required: false - name: order_info + type: OrderInfo required: false ShippingQuery: - name: id + type: String required: true - name: from + type: User required: true - name: invoice_payload + type: String required: true - name: shipping_address + type: ShippingAddress required: true CallbackQuery: - name: id + type: String required: true - name: from + type: User required: true - name: message + type: Message required: false - name: inline_message_id + type: String required: false - name: chat_instance + type: String required: true - name: data + type: String required: false - name: game_short_name + type: String required: false ChosenInlineResult: - name: result_id + type: String required: true - name: from + type: User required: true - name: location + type: Location required: false - name: inline_message_id + type: String required: false - name: query + type: String required: true InlineQuery: - name: id + type: String required: true - name: from + type: User required: true - name: query + type: String required: true - name: offset + type: String required: true - name: chat_type + type: String required: false - name: location + type: Location required: false CallbackGame: [] SwitchInlineQueryChosenChat: - name: query + type: String required: false - name: allow_user_chats + type: Boolean required: false - name: allow_bot_chats + type: Boolean required: false - name: allow_group_chats + type: Boolean required: false - name: allow_channel_chats + type: Boolean required: false LoginUrl: - name: url + type: String required: true - name: forward_text + type: String required: false - name: bot_username + type: String required: false - name: request_write_access + type: Boolean required: false WebAppInfo: - name: url + type: String required: true InlineKeyboardButton: - name: text + type: String required: true - name: url + type: String required: false - name: callback_data + type: String required: false - name: web_app + type: WebAppInfo required: false - name: login_url + type: LoginUrl required: false - name: switch_inline_query + type: String required: false - name: switch_inline_query_current_chat + type: String required: false - name: switch_inline_query_chosen_chat + type: SwitchInlineQueryChosenChat required: false - name: callback_game + type: CallbackGame required: false - name: pay + type: Boolean required: false InlineKeyboardMarkup: - name: inline_keyboard + type: Array of Array of InlineKeyboardButton required: true WebAppData: - name: data + type: String required: true - name: button_text + type: String required: true VideoChatParticipantsInvited: - name: users + type: Array of User required: true VideoChatEnded: - name: duration + type: Integer required: true VideoChatStarted: [] VideoChatScheduled: - name: start_date + type: Integer required: true GeneralForumTopicUnhidden: [] GeneralForumTopicHidden: [] @@ -1220,686 +1829,1008 @@ ForumTopicReopened: [] ForumTopicClosed: [] ForumTopicEdited: - name: name + type: String required: false - name: icon_custom_emoji_id + type: String required: false ForumTopicCreated: - name: name + type: String required: true - name: icon_color + type: Integer required: true - name: icon_custom_emoji_id + type: String required: false ProximityAlertTriggered: - name: traveler + type: User required: true - name: watcher + type: User required: true - name: distance + type: Integer required: true EncryptedCredentials: - name: data + type: String required: true - name: hash + type: String required: true - name: secret + type: String required: true PassportFile: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: file_size + type: Integer required: true - name: file_date + type: Integer required: true EncryptedPassportElement: - name: type + type: String required: true - name: data + type: String required: false - name: phone_number + type: String required: false - name: email + type: String required: false - name: files + type: Array of PassportFile required: false - name: front_side + type: PassportFile required: false - name: reverse_side + type: PassportFile required: false - name: selfie + type: PassportFile required: false - name: translation + type: Array of PassportFile required: false - name: hash + type: String required: true PassportData: - name: data + type: Array of EncryptedPassportElement required: true - name: credentials + type: EncryptedCredentials required: true WriteAccessAllowed: - name: web_app_name + type: String required: false ChatShared: - name: request_id + type: Integer required: true - name: chat_id + type: Integer required: true UserShared: - name: request_id + type: Integer required: true - name: user_id + type: Integer required: true ShippingAddress: - name: country_code + type: String required: true - name: state + type: String required: true - name: city + type: String required: true - name: street_line1 + type: String required: true - name: street_line2 + type: String required: true - name: post_code + type: String required: true OrderInfo: - name: name + type: String required: false - name: phone_number + type: String required: false - name: email + type: String required: false - name: shipping_address + type: ShippingAddress required: false SuccessfulPayment: - name: currency + type: String required: true - name: total_amount + type: Integer required: true - name: invoice_payload + type: String required: true - name: shipping_option_id + type: String required: false - name: order_info + type: OrderInfo required: false - name: telegram_payment_charge_id + type: String required: true - name: provider_payment_charge_id + type: String required: true Invoice: - name: title + type: String required: true - name: description + type: String required: true - name: start_parameter + type: String required: true - name: currency + type: String required: true - name: total_amount + type: Integer required: true MessageAutoDeleteTimerChanged: - name: message_auto_delete_time + type: Integer required: true Venue: - name: location + type: Location required: true - name: title + type: String required: true - name: address + type: String required: true - name: foursquare_id + type: String required: false - name: foursquare_type + type: String required: false - name: google_place_id + type: String required: false - name: google_place_type + type: String required: false PollOption: - name: text + type: String required: true - name: voter_count + type: Integer required: true Poll: - name: id + type: String required: true - name: question + type: String required: true - name: options + type: Array of PollOption required: true - name: total_voter_count + type: Integer required: true - name: is_closed + type: Boolean required: true - name: is_anonymous + type: Boolean required: true - name: type + type: String required: true - name: allows_multiple_answers + type: Boolean required: true - name: correct_option_id + type: Integer required: false - name: explanation + type: String required: false - name: explanation_entities + type: Array of MessageEntity required: false - name: open_period + type: Integer required: false - name: close_date + type: Integer required: false Game: - name: title + type: String required: true - name: description + type: String required: true - name: photo + type: Array of PhotoSize required: true - name: text + type: String required: false - name: text_entities + type: Array of MessageEntity required: false - name: animation + type: Animation required: false Dice: - name: emoji + type: String required: true - name: value + type: Integer required: true Contact: - name: phone_number + type: String required: true - name: first_name + type: String required: true - name: last_name + type: String required: false - name: user_id + type: Integer required: false - name: vcard + type: String required: false Voice: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: duration + type: Integer required: true - name: mime_type + type: String required: false - name: file_size + type: Integer required: false VideoNote: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: length + type: Integer required: true - name: duration + type: Integer required: true - name: thumbnail + type: PhotoSize required: false - name: file_size + type: Integer required: false Video: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: width + type: Integer required: true - name: height + type: Integer required: true - name: duration + type: Integer required: true - name: thumbnail + type: PhotoSize required: false - name: file_name + type: String required: false - name: mime_type + type: String required: false - name: file_size + type: Integer required: false Story: [] MaskPosition: - name: point + type: String required: true - name: x_shift + type: Float number required: true - name: y_shift + type: Float number required: true - name: scale + type: Float number required: true File: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: file_size + type: Integer required: false - name: file_path + type: String required: false Sticker: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: type + type: String required: true - name: width + type: Integer required: true - name: height + type: Integer required: true - name: is_animated + type: Boolean required: true - name: is_video + type: Boolean required: true - name: thumbnail + type: PhotoSize required: false - name: emoji + type: String required: false - name: set_name + type: String required: false - name: premium_animation + type: File required: false - name: mask_position + type: MaskPosition required: false - name: custom_emoji_id + type: String required: false - name: needs_repainting + type: 'True' required: false - name: file_size + type: Integer required: false Document: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: thumbnail + type: PhotoSize required: false - name: file_name + type: String required: false - name: mime_type + type: String required: false - name: file_size + type: Integer required: false Audio: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: duration + type: Integer required: true - name: performer + type: String required: false - name: title + type: String required: false - name: file_name + type: String required: false - name: mime_type + type: String required: false - name: file_size + type: Integer required: false - name: thumbnail + type: PhotoSize required: false PhotoSize: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: width + type: Integer required: true - name: height + type: Integer required: true - name: file_size + type: Integer required: false Animation: - name: file_id + type: String required: true - name: file_unique_id + type: String required: true - name: width + type: Integer required: true - name: height + type: Integer required: true - name: duration + type: Integer required: true - name: thumbnail + type: PhotoSize required: false - name: file_name + type: String required: false - name: mime_type + type: String required: false - name: file_size + type: Integer required: false MessageEntity: - name: type + type: String required: true - name: offset + type: Integer required: true - name: length + type: Integer required: true - name: url + type: String required: false - name: user + type: User required: false - name: language + type: String required: false - name: custom_emoji_id + type: String required: false Location: - name: longitude + type: Float required: true - name: latitude + type: Float required: true - name: horizontal_accuracy + type: Float number required: false - name: live_period + type: Integer required: false - name: heading + type: Integer required: false - name: proximity_alert_radius + type: Integer required: false ChatLocation: - name: location + type: Location required: true - name: address + type: String required: true ChatPermissions: - name: can_send_messages + type: Boolean required: false - name: can_send_audios + type: Boolean required: false - name: can_send_documents + type: Boolean required: false - name: can_send_photos + type: Boolean required: false - name: can_send_videos + type: Boolean required: false - name: can_send_video_notes + type: Boolean required: false - name: can_send_voice_notes + type: Boolean required: false - name: can_send_polls + type: Boolean required: false - name: can_send_other_messages + type: Boolean required: false - name: can_add_web_page_previews + type: Boolean required: false - name: can_change_info + type: Boolean required: false - name: can_invite_users + type: Boolean required: false - name: can_pin_messages + type: Boolean required: false - name: can_manage_topics + type: Boolean required: false ChatPhoto: - name: small_file_id + type: String required: true - name: small_file_unique_id + type: String required: true - name: big_file_id + type: String required: true - name: big_file_unique_id + type: String required: true Chat: - name: id + type: Integer required: true - name: type + type: String required: true - name: title + type: String required: false - name: username + type: String required: false - name: first_name + type: String required: false - name: last_name + type: String required: false - name: is_forum + type: 'True' required: false - name: photo + type: ChatPhoto required: false - name: active_usernames + type: Array of String required: false - name: emoji_status_custom_emoji_id + type: String required: false - name: emoji_status_expiration_date + type: Integer required: false - name: bio + type: String required: false - name: has_private_forwards + type: 'True' required: false - name: has_restricted_voice_and_video_messages + type: 'True' required: false - name: join_to_send_messages + type: 'True' required: false - name: join_by_request + type: 'True' required: false - name: description + type: String required: false - name: invite_link + type: String required: false - name: pinned_message + type: Message required: false - name: permissions + type: ChatPermissions required: false - name: slow_mode_delay + type: Integer required: false - name: message_auto_delete_time + type: Integer required: false - name: has_aggressive_anti_spam_enabled + type: 'True' required: false - name: has_hidden_members + type: 'True' required: false - name: has_protected_content + type: 'True' required: false - name: sticker_set_name + type: String required: false - name: can_set_sticker_set + type: 'True' required: false - name: linked_chat_id + type: Integer required: false - name: location + type: ChatLocation required: false User: - name: id + type: Integer required: true - name: is_bot + type: Boolean required: true - name: first_name + type: String required: true - name: last_name + type: String required: false - name: username + type: String required: false - name: language_code + type: String required: false - name: is_premium + type: 'True' required: false - name: added_to_attachment_menu + type: 'True' required: false - name: can_join_groups + type: Boolean required: false - name: can_read_all_group_messages + type: Boolean required: false - name: supports_inline_queries + type: Boolean required: false Message: - name: message_id + type: Integer required: true - name: message_thread_id + type: Integer required: false - name: from + type: User required: false - name: sender_chat + type: Chat required: false - name: date + type: Integer required: true - name: chat + type: Chat required: true - name: forward_from + type: User required: false - name: forward_from_chat + type: Chat required: false - name: forward_from_message_id + type: Integer required: false - name: forward_signature + type: String required: false - name: forward_sender_name + type: String required: false - name: forward_date + type: Integer required: false - name: is_topic_message + type: 'True' required: false - name: is_automatic_forward + type: 'True' required: false - name: reply_to_message + type: Message required: false - name: via_bot + type: User required: false - name: edit_date + type: Integer required: false - name: has_protected_content + type: 'True' required: false - name: media_group_id + type: String required: false - name: author_signature + type: String required: false - name: text + type: String required: false - name: entities + type: Array of MessageEntity required: false - name: animation + type: Animation required: false - name: audio + type: Audio required: false - name: document + type: Document required: false - name: photo + type: Array of PhotoSize required: false - name: sticker + type: Sticker required: false - name: story + type: Story required: false - name: video + type: Video required: false - name: video_note + type: VideoNote required: false - name: voice + type: Voice required: false - name: caption + type: String required: false - name: caption_entities + type: Array of MessageEntity required: false - name: has_media_spoiler + type: 'True' required: false - name: contact + type: Contact required: false - name: dice + type: Dice required: false - name: game + type: Game required: false - name: poll + type: Poll required: false - name: venue + type: Venue required: false - name: location + type: Location required: false - name: new_chat_members + type: Array of User required: false - name: left_chat_member + type: User required: false - name: new_chat_title + type: String required: false - name: new_chat_photo + type: Array of PhotoSize required: false - name: delete_chat_photo + type: 'True' required: false - name: group_chat_created + type: 'True' required: false - name: supergroup_chat_created + type: 'True' required: false - name: channel_chat_created + type: 'True' required: false - name: message_auto_delete_timer_changed + type: MessageAutoDeleteTimerChanged required: false - name: migrate_to_chat_id + type: Integer required: false - name: migrate_from_chat_id + type: Integer required: false - name: pinned_message + type: Message required: false - name: invoice + type: Invoice required: false - name: successful_payment + type: SuccessfulPayment required: false - name: user_shared + type: UserShared required: false - name: chat_shared + type: ChatShared required: false - name: connected_website + type: String required: false - name: write_access_allowed + type: WriteAccessAllowed required: false - name: passport_data + type: PassportData required: false - name: proximity_alert_triggered + type: ProximityAlertTriggered required: false - name: forum_topic_created + type: ForumTopicCreated required: false - name: forum_topic_edited + type: ForumTopicEdited required: false - name: forum_topic_closed + type: ForumTopicClosed required: false - name: forum_topic_reopened + type: ForumTopicReopened required: false - name: general_forum_topic_hidden + type: GeneralForumTopicHidden required: false - name: general_forum_topic_unhidden + type: GeneralForumTopicUnhidden required: false - name: video_chat_scheduled + type: VideoChatScheduled required: false - name: video_chat_started + type: VideoChatStarted required: false - name: video_chat_ended + type: VideoChatEnded required: false - name: video_chat_participants_invited + type: VideoChatParticipantsInvited required: false - name: web_app_data + type: WebAppData required: false - name: reply_markup + type: InlineKeyboardMarkup required: false Update: - name: update_id + type: Integer required: true - name: message + type: Message required: false - name: edited_message + type: Message required: false - name: channel_post + type: Message required: false - name: edited_channel_post + type: Message required: false - name: inline_query + type: InlineQuery required: false - name: chosen_inline_result + type: ChosenInlineResult required: false - name: callback_query + type: CallbackQuery required: false - name: shipping_query + type: ShippingQuery required: false - name: pre_checkout_query + type: PreCheckoutQuery required: false - name: poll + type: Poll required: false - name: poll_answer + type: PollAnswer required: false - name: my_chat_member + type: ChatMemberUpdated required: false - name: chat_member + type: ChatMemberUpdated required: false - name: chat_join_request + type: ChatJoinRequest required: false From 19b58c2f0c90efef768a6d22475e0315fc3216e7 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 02:01:20 +0300 Subject: [PATCH 06/11] Add `constrained(eql: '...')` alongside to `default` where it's necessary --- .../bot/types/bot_command_scope_all_chat_administrators.rb | 2 +- lib/telegram/bot/types/bot_command_scope_all_group_chats.rb | 2 +- lib/telegram/bot/types/bot_command_scope_all_private_chats.rb | 2 +- lib/telegram/bot/types/bot_command_scope_chat.rb | 2 +- lib/telegram/bot/types/bot_command_scope_chat_administrators.rb | 2 +- lib/telegram/bot/types/bot_command_scope_chat_member.rb | 2 +- lib/telegram/bot/types/bot_command_scope_default.rb | 2 +- lib/telegram/bot/types/inline_query_result_article.rb | 2 +- lib/telegram/bot/types/inline_query_result_audio.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_audio.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_document.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_gif.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_photo.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_sticker.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_video.rb | 2 +- lib/telegram/bot/types/inline_query_result_cached_voice.rb | 2 +- lib/telegram/bot/types/inline_query_result_contact.rb | 2 +- lib/telegram/bot/types/inline_query_result_document.rb | 2 +- lib/telegram/bot/types/inline_query_result_game.rb | 2 +- lib/telegram/bot/types/inline_query_result_gif.rb | 2 +- lib/telegram/bot/types/inline_query_result_location.rb | 2 +- lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb | 2 +- lib/telegram/bot/types/inline_query_result_photo.rb | 2 +- lib/telegram/bot/types/inline_query_result_venue.rb | 2 +- lib/telegram/bot/types/inline_query_result_video.rb | 2 +- lib/telegram/bot/types/inline_query_result_voice.rb | 2 +- lib/telegram/bot/types/input_media_animation.rb | 2 +- lib/telegram/bot/types/input_media_audio.rb | 2 +- lib/telegram/bot/types/input_media_document.rb | 2 +- lib/telegram/bot/types/input_media_photo.rb | 2 +- lib/telegram/bot/types/input_media_video.rb | 2 +- lib/telegram/bot/types/passport_element_error_data_field.rb | 2 +- lib/telegram/bot/types/passport_element_error_file.rb | 2 +- lib/telegram/bot/types/passport_element_error_files.rb | 2 +- lib/telegram/bot/types/passport_element_error_front_side.rb | 2 +- lib/telegram/bot/types/passport_element_error_reverse_side.rb | 2 +- lib/telegram/bot/types/passport_element_error_selfie.rb | 2 +- .../bot/types/passport_element_error_translation_file.rb | 2 +- .../bot/types/passport_element_error_translation_files.rb | 2 +- lib/telegram/bot/types/passport_element_error_unspecified.rb | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) 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 8df8ee27..2c4e8ba0 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, Types::String.default('all_chat_administrators') + attribute :type, Types::String.constrained(eql: 'all_chat_administrators').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 e9521392..c45e5172 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, Types::String.default('all_group_chats') + attribute :type, Types::String.constrained(eql: 'all_group_chats').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 d3cb9d4e..34ea1cf4 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, Types::String.default('all_private_chats') + attribute :type, Types::String.constrained(eql: 'all_private_chats').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 b620fd18..d390f8e4 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeChat < Base - attribute :type, Types::String.default('chat') + attribute :type, Types::String.constrained(eql: 'chat').default('chat') attribute :chat_id, Types::String 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 5132051a..47e9a8e1 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeChatAdministrators < Base - attribute :type, Types::String.default('chat_administrators') + attribute :type, Types::String.constrained(eql: 'chat_administrators').default('chat_administrators') attribute :chat_id, Types::String 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 f5bd686e..196597bc 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat_member.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat_member.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class BotCommandScopeChatMember < Base - attribute :type, Types::String.default('chat_member') + attribute :type, Types::String.constrained(eql: 'chat_member').default('chat_member') attribute :chat_id, Types::String attribute :user_id, Types::Integer end diff --git a/lib/telegram/bot/types/bot_command_scope_default.rb b/lib/telegram/bot/types/bot_command_scope_default.rb index acbb397b..4d39da7e 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, Types::String.default('default') + attribute :type, Types::String.constrained(eql: 'default').default('default') end end end diff --git a/lib/telegram/bot/types/inline_query_result_article.rb b/lib/telegram/bot/types/inline_query_result_article.rb index b8a9f1e3..b206cb64 100644 --- a/lib/telegram/bot/types/inline_query_result_article.rb +++ b/lib/telegram/bot/types/inline_query_result_article.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultArticle < Base - attribute :type, Types::String.default('article') + attribute :type, Types::String.constrained(eql: 'article').default('article') attribute :id, Types::String attribute :title, Types::String attribute :input_message_content, InputMessageContent diff --git a/lib/telegram/bot/types/inline_query_result_audio.rb b/lib/telegram/bot/types/inline_query_result_audio.rb index 5d2a961e..a55f87b1 100644 --- a/lib/telegram/bot/types/inline_query_result_audio.rb +++ b/lib/telegram/bot/types/inline_query_result_audio.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultAudio < Base - attribute :type, Types::String.default('audio') + attribute :type, Types::String.constrained(eql: 'audio').default('audio') attribute :id, Types::String attribute :audio_url, Types::String attribute :title, Types::String 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 e918f88f..5d69822f 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_audio.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_audio.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedAudio < Base - attribute :type, Types::String.default('audio') + attribute :type, Types::String.constrained(eql: 'audio').default('audio') attribute :id, Types::String attribute :audio_file_id, Types::String attribute? :caption, Types::String 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 6a6a1930..ef95022f 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_document.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_document.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedDocument < Base - attribute :type, Types::String.default('document') + attribute :type, Types::String.constrained(eql: 'document').default('document') attribute :id, Types::String attribute :title, Types::String attribute :document_file_id, Types::String 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 11ceef17..dd707e49 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_gif.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedGif < Base - attribute :type, Types::String.default('gif') + attribute :type, Types::String.constrained(eql: 'gif').default('gif') attribute :id, Types::String attribute :gif_file_id, Types::String attribute? :title, Types::String 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 99efb67d..e9f0dc89 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,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedMpeg4Gif < Base - attribute :type, Types::String.default('mpeg4_gif') + attribute :type, Types::String.constrained(eql: 'mpeg4_gif').default('mpeg4_gif') attribute :id, Types::String attribute :mpeg4_file_id, Types::String attribute? :title, Types::String 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 d745e74e..eeb2ff5c 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_photo.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_photo.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedPhoto < Base - attribute :type, Types::String.default('photo') + attribute :type, Types::String.constrained(eql: 'photo').default('photo') attribute :id, Types::String attribute :photo_file_id, Types::String attribute? :title, Types::String 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 cb842433..9b7787c7 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_sticker.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_sticker.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedSticker < Base - attribute :type, Types::String.default('sticker') + attribute :type, Types::String.constrained(eql: 'sticker').default('sticker') attribute :id, Types::String attribute :sticker_file_id, Types::String attribute? :reply_markup, InlineKeyboardMarkup 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 c2a90cff..40768760 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_video.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_video.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedVideo < Base - attribute :type, Types::String.default('video') + attribute :type, Types::String.constrained(eql: 'video').default('video') attribute :id, Types::String attribute :video_file_id, Types::String attribute :title, Types::String 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 dc95afc7..2a36e4c6 100644 --- a/lib/telegram/bot/types/inline_query_result_cached_voice.rb +++ b/lib/telegram/bot/types/inline_query_result_cached_voice.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultCachedVoice < Base - attribute :type, Types::String.default('voice') + attribute :type, Types::String.constrained(eql: 'voice').default('voice') attribute :id, Types::String attribute :voice_file_id, Types::String attribute :title, Types::String diff --git a/lib/telegram/bot/types/inline_query_result_contact.rb b/lib/telegram/bot/types/inline_query_result_contact.rb index 4c729a19..9066ca1e 100644 --- a/lib/telegram/bot/types/inline_query_result_contact.rb +++ b/lib/telegram/bot/types/inline_query_result_contact.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultContact < Base - attribute :type, Types::String.default('contact') + attribute :type, Types::String.constrained(eql: 'contact').default('contact') attribute :id, Types::String attribute :phone_number, Types::String attribute :first_name, Types::String diff --git a/lib/telegram/bot/types/inline_query_result_document.rb b/lib/telegram/bot/types/inline_query_result_document.rb index 7eeca28f..2b1d3c49 100644 --- a/lib/telegram/bot/types/inline_query_result_document.rb +++ b/lib/telegram/bot/types/inline_query_result_document.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultDocument < Base - attribute :type, Types::String.default('document') + attribute :type, Types::String.constrained(eql: 'document').default('document') attribute :id, Types::String attribute :title, Types::String attribute? :caption, Types::String diff --git a/lib/telegram/bot/types/inline_query_result_game.rb b/lib/telegram/bot/types/inline_query_result_game.rb index dd8a05dd..c34da155 100644 --- a/lib/telegram/bot/types/inline_query_result_game.rb +++ b/lib/telegram/bot/types/inline_query_result_game.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultGame < Base - attribute :type, Types::String.default('game') + attribute :type, Types::String.constrained(eql: 'game').default('game') attribute :id, Types::String attribute :game_short_name, Types::String attribute? :reply_markup, InlineKeyboardMarkup diff --git a/lib/telegram/bot/types/inline_query_result_gif.rb b/lib/telegram/bot/types/inline_query_result_gif.rb index 8409b88e..183c12a3 100644 --- a/lib/telegram/bot/types/inline_query_result_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_gif.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultGif < Base - attribute :type, Types::String.default('gif') + attribute :type, Types::String.constrained(eql: 'gif').default('gif') attribute :id, Types::String attribute :gif_url, Types::String attribute? :gif_width, Types::Integer diff --git a/lib/telegram/bot/types/inline_query_result_location.rb b/lib/telegram/bot/types/inline_query_result_location.rb index bb3fbbcd..72d6de1c 100644 --- a/lib/telegram/bot/types/inline_query_result_location.rb +++ b/lib/telegram/bot/types/inline_query_result_location.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultLocation < Base - attribute :type, Types::String.default('location') + attribute :type, Types::String.constrained(eql: 'location').default('location') attribute :id, Types::String attribute :latitude, Types::Float attribute :longitude, Types::Float 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 bf01e0bf..03a1b089 100644 --- a/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb +++ b/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultMpeg4Gif < Base - attribute :type, Types::String.default('mpeg4_gif') + attribute :type, Types::String.constrained(eql: 'mpeg4_gif').default('mpeg4_gif') attribute :id, Types::String attribute :mpeg4_url, Types::String attribute? :mpeg4_width, Types::Integer diff --git a/lib/telegram/bot/types/inline_query_result_photo.rb b/lib/telegram/bot/types/inline_query_result_photo.rb index 2463f1c7..bc9f5e81 100644 --- a/lib/telegram/bot/types/inline_query_result_photo.rb +++ b/lib/telegram/bot/types/inline_query_result_photo.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultPhoto < Base - attribute :type, Types::String.default('photo') + attribute :type, Types::String.constrained(eql: 'photo').default('photo') attribute :id, Types::String attribute :photo_url, Types::String attribute :thumbnail_url, Types::String diff --git a/lib/telegram/bot/types/inline_query_result_venue.rb b/lib/telegram/bot/types/inline_query_result_venue.rb index 7905e79b..7f9eb6f0 100644 --- a/lib/telegram/bot/types/inline_query_result_venue.rb +++ b/lib/telegram/bot/types/inline_query_result_venue.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultVenue < Base - attribute :type, Types::String.default('venue') + attribute :type, Types::String.constrained(eql: 'venue').default('venue') attribute :id, Types::String attribute :latitude, Types::Float attribute :longitude, Types::Float diff --git a/lib/telegram/bot/types/inline_query_result_video.rb b/lib/telegram/bot/types/inline_query_result_video.rb index 9cae8598..5bd8a5c6 100644 --- a/lib/telegram/bot/types/inline_query_result_video.rb +++ b/lib/telegram/bot/types/inline_query_result_video.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultVideo < Base - attribute :type, Types::String.default('video') + attribute :type, Types::String.constrained(eql: 'video').default('video') attribute :id, Types::String attribute :video_url, Types::String attribute :mime_type, Types::String diff --git a/lib/telegram/bot/types/inline_query_result_voice.rb b/lib/telegram/bot/types/inline_query_result_voice.rb index 595c14f6..384d856d 100644 --- a/lib/telegram/bot/types/inline_query_result_voice.rb +++ b/lib/telegram/bot/types/inline_query_result_voice.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InlineQueryResultVoice < Base - attribute :type, Types::String.default('voice') + attribute :type, Types::String.constrained(eql: 'voice').default('voice') attribute :id, Types::String attribute :voice_url, Types::String attribute :title, Types::String diff --git a/lib/telegram/bot/types/input_media_animation.rb b/lib/telegram/bot/types/input_media_animation.rb index 20426ab5..006bd0f3 100644 --- a/lib/telegram/bot/types/input_media_animation.rb +++ b/lib/telegram/bot/types/input_media_animation.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InputMediaAnimation < Base - attribute :type, Types::String.default('animation') + attribute :type, Types::String.constrained(eql: 'animation').default('animation') attribute :media, Types::String attribute? :thumbnail, Types::String attribute? :caption, Types::String diff --git a/lib/telegram/bot/types/input_media_audio.rb b/lib/telegram/bot/types/input_media_audio.rb index 12ea5ee6..f0e151c0 100644 --- a/lib/telegram/bot/types/input_media_audio.rb +++ b/lib/telegram/bot/types/input_media_audio.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InputMediaAudio < Base - attribute :type, Types::String.default('audio') + attribute :type, Types::String.constrained(eql: 'audio').default('audio') attribute :media, Types::String attribute? :thumbnail, Types::String attribute? :caption, Types::String diff --git a/lib/telegram/bot/types/input_media_document.rb b/lib/telegram/bot/types/input_media_document.rb index e12d5796..ec4694f2 100644 --- a/lib/telegram/bot/types/input_media_document.rb +++ b/lib/telegram/bot/types/input_media_document.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InputMediaDocument < Base - attribute :type, Types::String.default('document') + attribute :type, Types::String.constrained(eql: 'document').default('document') attribute :media, Types::String attribute? :thumbnail, Types::String attribute? :caption, Types::String diff --git a/lib/telegram/bot/types/input_media_photo.rb b/lib/telegram/bot/types/input_media_photo.rb index 11d4dc36..f59e7cb2 100644 --- a/lib/telegram/bot/types/input_media_photo.rb +++ b/lib/telegram/bot/types/input_media_photo.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InputMediaPhoto < Base - attribute :type, Types::String.default('photo') + attribute :type, Types::String.constrained(eql: 'photo').default('photo') attribute :media, Types::String attribute? :caption, Types::String attribute? :parse_mode, Types::String diff --git a/lib/telegram/bot/types/input_media_video.rb b/lib/telegram/bot/types/input_media_video.rb index aaf1b9cc..aafb8166 100644 --- a/lib/telegram/bot/types/input_media_video.rb +++ b/lib/telegram/bot/types/input_media_video.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class InputMediaVideo < Base - attribute :type, Types::String.default('video') + attribute :type, Types::String.constrained(eql: 'video').default('video') attribute :media, Types::String attribute? :thumbnail, Types::String attribute? :caption, Types::String 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 45458dd9..4636ed5d 100644 --- a/lib/telegram/bot/types/passport_element_error_data_field.rb +++ b/lib/telegram/bot/types/passport_element_error_data_field.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorDataField < Base - attribute :source, Types::String.default('data') + attribute :source, Types::String.constrained(eql: 'data').default('data') attribute :type, Types::String attribute :field_name, Types::String attribute :data_hash, Types::String diff --git a/lib/telegram/bot/types/passport_element_error_file.rb b/lib/telegram/bot/types/passport_element_error_file.rb index e0d1bd32..b54c132e 100644 --- a/lib/telegram/bot/types/passport_element_error_file.rb +++ b/lib/telegram/bot/types/passport_element_error_file.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorFile < Base - attribute :source, Types::String.default('file') + attribute :source, Types::String.constrained(eql: 'file').default('file') attribute :type, Types::String attribute :file_hash, Types::String attribute :message, Types::String diff --git a/lib/telegram/bot/types/passport_element_error_files.rb b/lib/telegram/bot/types/passport_element_error_files.rb index b801c55a..bdefeb6e 100644 --- a/lib/telegram/bot/types/passport_element_error_files.rb +++ b/lib/telegram/bot/types/passport_element_error_files.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorFiles < Base - attribute :source, Types::String.default('files') + attribute :source, Types::String.constrained(eql: 'files').default('files') attribute :type, Types::String attribute :file_hashes, Types::Array.of(String) attribute :message, Types::String 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 182fc535..5bfebead 100644 --- a/lib/telegram/bot/types/passport_element_error_front_side.rb +++ b/lib/telegram/bot/types/passport_element_error_front_side.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorFrontSide < Base - attribute :source, Types::String.default('front_side') + attribute :source, Types::String.constrained(eql: 'front_side').default('front_side') attribute :type, Types::String attribute :file_hash, Types::String attribute :message, Types::String 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 3dec85c2..2647879f 100644 --- a/lib/telegram/bot/types/passport_element_error_reverse_side.rb +++ b/lib/telegram/bot/types/passport_element_error_reverse_side.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorReverseSide < Base - attribute :source, Types::String.default('reverse_side') + attribute :source, Types::String.constrained(eql: 'reverse_side').default('reverse_side') attribute :type, Types::String attribute :file_hash, Types::String attribute :message, Types::String diff --git a/lib/telegram/bot/types/passport_element_error_selfie.rb b/lib/telegram/bot/types/passport_element_error_selfie.rb index 53d9c561..d61ae8bf 100644 --- a/lib/telegram/bot/types/passport_element_error_selfie.rb +++ b/lib/telegram/bot/types/passport_element_error_selfie.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorSelfie < Base - attribute :source, Types::String.default('selfie') + attribute :source, Types::String.constrained(eql: 'selfie').default('selfie') attribute :type, Types::String attribute :file_hash, Types::String attribute :message, Types::String 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 4f6d98f1..ad3a2212 100644 --- a/lib/telegram/bot/types/passport_element_error_translation_file.rb +++ b/lib/telegram/bot/types/passport_element_error_translation_file.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorTranslationFile < Base - attribute :source, Types::String.default('translation_file') + attribute :source, Types::String.constrained(eql: 'translation_file').default('translation_file') attribute :type, Types::String attribute :file_hash, Types::String attribute :message, Types::String 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 93866dcb..0b25a57c 100644 --- a/lib/telegram/bot/types/passport_element_error_translation_files.rb +++ b/lib/telegram/bot/types/passport_element_error_translation_files.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorTranslationFiles < Base - attribute :source, Types::String.default('translation_files') + attribute :source, Types::String.constrained(eql: 'translation_files').default('translation_files') attribute :type, Types::String attribute :file_hashes, Types::Array.of(String) attribute :message, Types::String diff --git a/lib/telegram/bot/types/passport_element_error_unspecified.rb b/lib/telegram/bot/types/passport_element_error_unspecified.rb index c4de8bfa..deb896b2 100644 --- a/lib/telegram/bot/types/passport_element_error_unspecified.rb +++ b/lib/telegram/bot/types/passport_element_error_unspecified.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class PassportElementErrorUnspecified < Base - attribute :source, Types::String.default('unspecified') + attribute :source, Types::String.constrained(eql: 'unspecified').default('unspecified') attribute :type, Types::String attribute :element_hash, Types::String attribute :message, Types::String From 45d82c8548df935f5de3ad265676aa52d15f3ce2 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 02:02:02 +0300 Subject: [PATCH 07/11] Allow `Integer` as `chat_id` for some places alongside with `String` --- lib/telegram/bot/types/bot_command_scope_chat.rb | 2 +- lib/telegram/bot/types/bot_command_scope_chat_administrators.rb | 2 +- lib/telegram/bot/types/bot_command_scope_chat_member.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/telegram/bot/types/bot_command_scope_chat.rb b/lib/telegram/bot/types/bot_command_scope_chat.rb index d390f8e4..461cba01 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat.rb @@ -5,7 +5,7 @@ module Bot module Types class BotCommandScopeChat < Base attribute :type, Types::String.constrained(eql: 'chat').default('chat') - attribute :chat_id, Types::String + attribute :chat_id, Types::Integer | 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 47e9a8e1..24d4b5b6 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb @@ -5,7 +5,7 @@ module Bot module Types class BotCommandScopeChatAdministrators < Base attribute :type, Types::String.constrained(eql: 'chat_administrators').default('chat_administrators') - attribute :chat_id, Types::String + attribute :chat_id, Types::Integer | 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 196597bc..5513b82d 100644 --- a/lib/telegram/bot/types/bot_command_scope_chat_member.rb +++ b/lib/telegram/bot/types/bot_command_scope_chat_member.rb @@ -5,7 +5,7 @@ module Bot module Types class BotCommandScopeChatMember < Base attribute :type, Types::String.constrained(eql: 'chat_member').default('chat_member') - attribute :chat_id, Types::String + attribute :chat_id, Types::Integer | Types::String attribute :user_id, Types::Integer end end From dbd5790a09775b5b98d2f2bf3cc209972ca38728 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 02:03:35 +0300 Subject: [PATCH 08/11] Require `True` value instead of `Boolean` It's still questionable for me, but so says the Telegram API docs. It seems like there should be `true` value or no value at all. I'm not sure if they accept `false` value. But they don't response, as I checked. --- lib/telegram/bot/types/chat.rb | 18 +++++++++--------- lib/telegram/bot/types/force_reply.rb | 2 +- lib/telegram/bot/types/message.rb | 16 ++++++++-------- .../bot/types/reply_keyboard_remove.rb | 2 +- lib/telegram/bot/types/sticker.rb | 2 +- lib/telegram/bot/types/user.rb | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/telegram/bot/types/chat.rb b/lib/telegram/bot/types/chat.rb index 7f66c46d..11cef653 100644 --- a/lib/telegram/bot/types/chat.rb +++ b/lib/telegram/bot/types/chat.rb @@ -10,27 +10,27 @@ class Chat < Base attribute? :username, Types::String attribute? :first_name, Types::String attribute? :last_name, Types::String - attribute? :is_forum, Types::Bool + attribute? :is_forum, Types::True attribute? :photo, ChatPhoto attribute? :active_usernames, Types::Array.of(Types::String) attribute? :emoji_status_custom_emoji_id, Types::String attribute? :emoji_status_expiration_date, Types::Integer 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? :has_private_forwards, Types::True + attribute? :has_restricted_voice_and_video_messages, Types::True + attribute? :join_to_send_messages, Types::True + attribute? :join_by_request, Types::True 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? :has_aggressive_anti_spam_enabled, Types::True + attribute? :has_hidden_members, Types::True + attribute? :has_protected_content, Types::True attribute? :sticker_set_name, Types::String - attribute? :can_set_sticker_set, Types::Bool + attribute? :can_set_sticker_set, Types::True attribute? :linked_chat_id, Types::Integer attribute? :location, ChatLocation end diff --git a/lib/telegram/bot/types/force_reply.rb b/lib/telegram/bot/types/force_reply.rb index 5d154e50..9af4e3fb 100644 --- a/lib/telegram/bot/types/force_reply.rb +++ b/lib/telegram/bot/types/force_reply.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class ForceReply < Base - attribute :force_reply, Types::Bool + attribute :force_reply, Types::True attribute? :input_field_placeholder, Types::String attribute? :selective, Types::Bool.default(false) end diff --git a/lib/telegram/bot/types/message.rb b/lib/telegram/bot/types/message.rb index 1843e439..377f3aa2 100644 --- a/lib/telegram/bot/types/message.rb +++ b/lib/telegram/bot/types/message.rb @@ -16,12 +16,12 @@ class Message < Base 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? :is_topic_message, Types::True + attribute? :is_automatic_forward, Types::True attribute? :reply_to_message, Message attribute? :via_bot, User attribute? :edit_date, Types::Integer - attribute? :has_protected_content, Types::Bool + attribute? :has_protected_content, Types::True attribute? :media_group_id, Types::String attribute? :author_signature, Types::String attribute? :text, Types::String @@ -37,7 +37,7 @@ class Message < Base attribute? :voice, Voice attribute? :caption, Types::String attribute? :caption_entities, Types::Array.of(MessageEntity) - attribute? :has_media_spoiler, Types::Bool + attribute? :has_media_spoiler, Types::True attribute? :contact, Contact attribute? :dice, Dice attribute? :game, Game @@ -48,10 +48,10 @@ class Message < Base 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? :delete_chat_photo, Types::True + attribute? :group_chat_created, Types::True + attribute? :supergroup_chat_created, Types::True + attribute? :channel_chat_created, Types::True attribute? :message_auto_delete_timer_changed, MessageAutoDeleteTimerChanged attribute? :migrate_to_chat_id, Types::Integer attribute? :migrate_from_chat_id, Types::Integer diff --git a/lib/telegram/bot/types/reply_keyboard_remove.rb b/lib/telegram/bot/types/reply_keyboard_remove.rb index 17700438..d45e4075 100644 --- a/lib/telegram/bot/types/reply_keyboard_remove.rb +++ b/lib/telegram/bot/types/reply_keyboard_remove.rb @@ -4,7 +4,7 @@ module Telegram module Bot module Types class ReplyKeyboardRemove < Base - attribute :remove_keyboard, Types::Bool + attribute :remove_keyboard, Types::True attribute? :selective, Types::Bool.default(false) end end diff --git a/lib/telegram/bot/types/sticker.rb b/lib/telegram/bot/types/sticker.rb index 222d12d2..c4a7dbf4 100644 --- a/lib/telegram/bot/types/sticker.rb +++ b/lib/telegram/bot/types/sticker.rb @@ -17,7 +17,7 @@ class Sticker < Base attribute? :premium_animation, File attribute? :mask_position, MaskPosition attribute? :custom_emoji_id, Types::String - attribute? :needs_repainting, Types::Bool + attribute? :needs_repainting, Types::True attribute? :file_size, Types::Integer end end diff --git a/lib/telegram/bot/types/user.rb b/lib/telegram/bot/types/user.rb index 86db226c..3cf217e6 100644 --- a/lib/telegram/bot/types/user.rb +++ b/lib/telegram/bot/types/user.rb @@ -10,8 +10,8 @@ class User < Base 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? :is_premium, Types::True + attribute? :added_to_attachment_menu, Types::True attribute? :can_join_groups, Types::Bool attribute? :can_read_all_group_messages, Types::Bool attribute? :supports_inline_queries, Types::Bool From 56f2c5156d4d830534b0398685185d7aeb8487f5 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 02:03:59 +0300 Subject: [PATCH 09/11] Fix stupid error with `Integer` instead of `Bool` --- lib/telegram/bot/types/chat_member_administrator.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/telegram/bot/types/chat_member_administrator.rb b/lib/telegram/bot/types/chat_member_administrator.rb index c70c7078..42aabade 100644 --- a/lib/telegram/bot/types/chat_member_administrator.rb +++ b/lib/telegram/bot/types/chat_member_administrator.rb @@ -16,9 +16,9 @@ class ChatMemberAdministrator < Base 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? :can_edit_messages, Types::Bool + attribute? :can_pin_messages, Types::Bool + attribute? :can_manage_topics, Types::Bool attribute? :custom_title, Types::String end end From 2a1f8695807803bf38c1368a5f6460793635533a Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 10 Sep 2023 02:04:27 +0300 Subject: [PATCH 10/11] Fix a small error with `Array.of(String)` instead of `(Types::String)` --- lib/telegram/bot/types/passport_element_error_files.rb | 2 +- .../bot/types/passport_element_error_translation_files.rb | 2 +- lib/telegram/bot/types/webhook_info.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/telegram/bot/types/passport_element_error_files.rb b/lib/telegram/bot/types/passport_element_error_files.rb index bdefeb6e..37a5ca82 100644 --- a/lib/telegram/bot/types/passport_element_error_files.rb +++ b/lib/telegram/bot/types/passport_element_error_files.rb @@ -6,7 +6,7 @@ module Types class PassportElementErrorFiles < Base attribute :source, Types::String.constrained(eql: 'files').default('files') attribute :type, Types::String - attribute :file_hashes, Types::Array.of(String) + attribute :file_hashes, Types::Array.of(Types::String) attribute :message, Types::String 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 0b25a57c..bd78b407 100644 --- a/lib/telegram/bot/types/passport_element_error_translation_files.rb +++ b/lib/telegram/bot/types/passport_element_error_translation_files.rb @@ -6,7 +6,7 @@ module Types class PassportElementErrorTranslationFiles < Base attribute :source, Types::String.constrained(eql: 'translation_files').default('translation_files') attribute :type, Types::String - attribute :file_hashes, Types::Array.of(String) + attribute :file_hashes, Types::Array.of(Types::String) attribute :message, Types::String end end diff --git a/lib/telegram/bot/types/webhook_info.rb b/lib/telegram/bot/types/webhook_info.rb index 0f4ac857..d778daf3 100644 --- a/lib/telegram/bot/types/webhook_info.rb +++ b/lib/telegram/bot/types/webhook_info.rb @@ -12,7 +12,7 @@ class WebhookInfo < Base 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) + attribute? :allowed_updates, Types::Array.of(Types::String) end end end From 0c07ae8a1e27d52c8c3e184d84f0bc9f01d378ea Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 30 Dec 2023 22:40:12 +0300 Subject: [PATCH 11/11] Resolve attributes types specs with the new changes --- spec/support/type_attributes.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/support/type_attributes.yml b/spec/support/type_attributes.yml index 71203711..0eb523ab 100644 --- a/spec/support/type_attributes.yml +++ b/spec/support/type_attributes.yml @@ -1275,12 +1275,15 @@ BotName: required: true BotShortDescription: - name: short_description + type: String required: true BotDescription: - name: description + type: String required: true BotName: - name: name + type: String required: true ChatAdministratorRights: - name: is_anonymous @@ -1317,10 +1320,13 @@ ChatAdministratorRights: type: Boolean required: false - name: can_post_stories + type: Boolean required: false - name: can_edit_stories + type: Boolean required: false - name: can_delete_stories + type: Boolean required: false - name: can_manage_topics type: Boolean @@ -1617,10 +1623,13 @@ ChatMemberAdministrator: type: Boolean required: false - name: can_post_stories + type: Boolean required: false - name: can_edit_stories + type: Boolean required: false - name: can_delete_stories + type: Boolean required: false - name: can_manage_topics type: Boolean @@ -1938,11 +1947,13 @@ PassportData: required: true WriteAccessAllowed: - name: from_request + type: Boolean required: false - name: web_app_name type: String required: false - name: from_attachment_menu + type: Boolean required: false ChatShared: - name: request_id