telegram-bot-ruby 2.8.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.agents/skills/commit/SKILL.md +18 -0
- data/.agents/skills/update-api/SKILL.md +70 -0
- data/.claude/skills +1 -0
- data/.rubocop.yml +0 -14
- data/CHANGELOG.md +16 -0
- data/README.md +16 -2
- data/lib/telegram/bot/api/endpoints.rb +9 -0
- data/lib/telegram/bot/types/area_position.rb +16 -0
- data/lib/telegram/bot/types/chat_administrator_rights.rb +1 -0
- data/lib/telegram/bot/types/chat_full_info.rb +2 -0
- data/lib/telegram/bot/types/chat_member_administrator.rb +1 -0
- data/lib/telegram/bot/types/chat_share_theme.rb +15 -0
- data/lib/telegram/bot/types/chat_share_theme_backdrop.rb +13 -0
- data/lib/telegram/bot/types/chat_share_theme_backdrops.rb +11 -0
- data/lib/telegram/bot/types/chat_share_theme_emoji.rb +13 -0
- data/lib/telegram/bot/types/chat_share_theme_unique_gift.rb +12 -0
- data/lib/telegram/bot/types/community_chat_joined.rb +11 -0
- data/lib/telegram/bot/types/disabled_button.rb +10 -0
- data/lib/telegram/bot/types/emoji_type.rb +15 -0
- data/lib/telegram/bot/types/emoji_type_custom_emoji.rb +12 -0
- data/lib/telegram/bot/types/emoji_type_emoji.rb +12 -0
- data/lib/telegram/bot/types/ephemeral_message_parameters.rb +13 -0
- data/lib/telegram/bot/types/external_reply_info.rb +1 -0
- data/lib/telegram/bot/types/game.rb +1 -1
- data/lib/telegram/bot/types/inline_keyboard_button.rb +1 -0
- data/lib/telegram/bot/types/inline_keyboard_markup.rb +1 -0
- data/lib/telegram/bot/types/input_checklist.rb +1 -1
- data/lib/telegram/bot/types/input_checklist_task.rb +1 -1
- data/lib/telegram/bot/types/input_message_content.rb +3 -1
- data/lib/telegram/bot/types/input_rich_block.rb +3 -0
- data/lib/telegram/bot/types/input_rich_block_buttons.rb +13 -0
- data/lib/telegram/bot/types/input_rich_block_document.rb +13 -0
- data/lib/telegram/bot/types/input_rich_block_expandable_block_quotation.rb +13 -0
- data/lib/telegram/bot/types/input_rich_block_map.rb +3 -3
- data/lib/telegram/bot/types/input_rich_block_table.rb +1 -0
- data/lib/telegram/bot/types/input_rich_message_media.rb +2 -1
- data/lib/telegram/bot/types/input_shared_widget_message_content.rb +16 -0
- data/lib/telegram/bot/types/input_widget_message_content.rb +21 -0
- data/lib/telegram/bot/types/message.rb +4 -0
- data/lib/telegram/bot/types/message_generation_stopped.rb +13 -0
- data/lib/telegram/bot/types/paid_messages_waived.rb +10 -0
- data/lib/telegram/bot/types/poll.rb +1 -1
- data/lib/telegram/bot/types/reply_keyboard_markup.rb +1 -0
- data/lib/telegram/bot/types/reply_parameters.rb +1 -0
- data/lib/telegram/bot/types/rich_block.rb +3 -0
- data/lib/telegram/bot/types/rich_block_buttons.rb +13 -0
- data/lib/telegram/bot/types/rich_block_document.rb +13 -0
- data/lib/telegram/bot/types/rich_block_expandable_block_quotation.rb +13 -0
- data/lib/telegram/bot/types/rich_block_table.rb +1 -0
- data/lib/telegram/bot/types/rich_message_button.rb +21 -0
- data/lib/telegram/bot/types/rich_text.rb +2 -0
- data/lib/telegram/bot/types/rich_text_button.rb +12 -0
- data/lib/telegram/bot/types/rich_text_ton_address.rb +13 -0
- data/lib/telegram/bot/types/shared_widget_query.rb +15 -0
- data/lib/telegram/bot/types/story_area.rb +1 -1
- data/lib/telegram/bot/types/text_quote.rb +1 -0
- data/lib/telegram/bot/types/ton_nft.rb +17 -0
- data/lib/telegram/bot/types/ton_nft_attribute.rb +12 -0
- data/lib/telegram/bot/types/ton_wallet_card.rb +14 -0
- data/lib/telegram/bot/types/ton_wallet_card_sticker.rb +12 -0
- data/lib/telegram/bot/types/ton_wallet_transfer.rb +14 -0
- data/lib/telegram/bot/types/unique_gift_info.rb +3 -0
- data/lib/telegram/bot/types/update.rb +3 -0
- data/lib/telegram/bot/types/widget.rb +16 -0
- data/lib/telegram/bot/types/widget_query.rb +20 -0
- data/lib/telegram/bot/types/widget_query_type.rb +16 -0
- data/lib/telegram/bot/types/widget_query_type_data.rb +12 -0
- data/lib/telegram/bot/types/widget_query_type_sent_transaction.rb +13 -0
- data/lib/telegram/bot/types/widget_query_type_sign_data.rb +13 -0
- data/lib/telegram/bot/types/widget_query_wallet.rb +14 -0
- data/lib/telegram/bot/version.rb +1 -1
- data/rakelib/README.md +116 -0
- data/rakelib/builders/type_builder.rb +3 -4
- data/rakelib/docs.rake +15 -0
- data/rakelib/parse.rake +8 -25
- data/rakelib/parsers/api_method.rb +26 -0
- data/rakelib/parsers/description.rb +62 -0
- data/rakelib/parsers/docs_page.rb +62 -0
- data/rakelib/parsers/entry.rb +45 -0
- data/rakelib/parsers/entry_grammar.rb +48 -0
- data/rakelib/parsers/error.rb +5 -0
- data/rakelib/parsers/field.rb +30 -0
- data/rakelib/parsers/object_type.rb +29 -0
- data/rakelib/parsers/page_object.rb +41 -0
- data/rakelib/parsers/readers.rb +16 -0
- data/rakelib/parsers/return_type.rb +36 -0
- data/rakelib/parsers/serializer.rb +93 -0
- data/rakelib/parsers/table.rb +14 -0
- data/rakelib/parsers/type_ref.rb +42 -0
- data/rakelib/parsers/union_type.rb +42 -0
- metadata +60 -5
- data/.claude/skills/update-api/SKILL.md +0 -70
- data/rakelib/parsers/methods_parser.rb +0 -115
- data/rakelib/parsers/types_parser.rb +0 -283
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: telegram-bot-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Tipugin
|
|
@@ -71,7 +71,9 @@ executables: []
|
|
|
71
71
|
extensions: []
|
|
72
72
|
extra_rdoc_files: []
|
|
73
73
|
files:
|
|
74
|
-
- ".
|
|
74
|
+
- ".agents/skills/commit/SKILL.md"
|
|
75
|
+
- ".agents/skills/update-api/SKILL.md"
|
|
76
|
+
- ".claude/skills"
|
|
75
77
|
- ".editorconfig"
|
|
76
78
|
- ".env.sample"
|
|
77
79
|
- ".github/workflows/ci.yml"
|
|
@@ -99,6 +101,7 @@ files:
|
|
|
99
101
|
- lib/telegram/bot/types/accepted_gift_types.rb
|
|
100
102
|
- lib/telegram/bot/types/affiliate_info.rb
|
|
101
103
|
- lib/telegram/bot/types/animation.rb
|
|
104
|
+
- lib/telegram/bot/types/area_position.rb
|
|
102
105
|
- lib/telegram/bot/types/audio.rb
|
|
103
106
|
- lib/telegram/bot/types/background_fill.rb
|
|
104
107
|
- lib/telegram/bot/types/background_fill_freeform_gradient.rb
|
|
@@ -161,6 +164,11 @@ files:
|
|
|
161
164
|
- lib/telegram/bot/types/chat_owner_left.rb
|
|
162
165
|
- lib/telegram/bot/types/chat_permissions.rb
|
|
163
166
|
- lib/telegram/bot/types/chat_photo.rb
|
|
167
|
+
- lib/telegram/bot/types/chat_share_theme.rb
|
|
168
|
+
- lib/telegram/bot/types/chat_share_theme_backdrop.rb
|
|
169
|
+
- lib/telegram/bot/types/chat_share_theme_backdrops.rb
|
|
170
|
+
- lib/telegram/bot/types/chat_share_theme_emoji.rb
|
|
171
|
+
- lib/telegram/bot/types/chat_share_theme_unique_gift.rb
|
|
164
172
|
- lib/telegram/bot/types/chat_shared.rb
|
|
165
173
|
- lib/telegram/bot/types/checklist.rb
|
|
166
174
|
- lib/telegram/bot/types/checklist_task.rb
|
|
@@ -169,6 +177,7 @@ files:
|
|
|
169
177
|
- lib/telegram/bot/types/chosen_inline_result.rb
|
|
170
178
|
- lib/telegram/bot/types/community.rb
|
|
171
179
|
- lib/telegram/bot/types/community_chat_added.rb
|
|
180
|
+
- lib/telegram/bot/types/community_chat_joined.rb
|
|
172
181
|
- lib/telegram/bot/types/community_chat_removed.rb
|
|
173
182
|
- lib/telegram/bot/types/compactable.rb
|
|
174
183
|
- lib/telegram/bot/types/contact.rb
|
|
@@ -176,9 +185,14 @@ files:
|
|
|
176
185
|
- lib/telegram/bot/types/dice.rb
|
|
177
186
|
- lib/telegram/bot/types/direct_message_price_changed.rb
|
|
178
187
|
- lib/telegram/bot/types/direct_messages_topic.rb
|
|
188
|
+
- lib/telegram/bot/types/disabled_button.rb
|
|
179
189
|
- lib/telegram/bot/types/document.rb
|
|
190
|
+
- lib/telegram/bot/types/emoji_type.rb
|
|
191
|
+
- lib/telegram/bot/types/emoji_type_custom_emoji.rb
|
|
192
|
+
- lib/telegram/bot/types/emoji_type_emoji.rb
|
|
180
193
|
- lib/telegram/bot/types/encrypted_credentials.rb
|
|
181
194
|
- lib/telegram/bot/types/encrypted_passport_element.rb
|
|
195
|
+
- lib/telegram/bot/types/ephemeral_message_parameters.rb
|
|
182
196
|
- lib/telegram/bot/types/error.rb
|
|
183
197
|
- lib/telegram/bot/types/external_reply_info.rb
|
|
184
198
|
- lib/telegram/bot/types/file.rb
|
|
@@ -260,9 +274,12 @@ files:
|
|
|
260
274
|
- lib/telegram/bot/types/input_rich_block_animation.rb
|
|
261
275
|
- lib/telegram/bot/types/input_rich_block_audio.rb
|
|
262
276
|
- lib/telegram/bot/types/input_rich_block_block_quotation.rb
|
|
277
|
+
- lib/telegram/bot/types/input_rich_block_buttons.rb
|
|
263
278
|
- lib/telegram/bot/types/input_rich_block_collage.rb
|
|
264
279
|
- lib/telegram/bot/types/input_rich_block_details.rb
|
|
265
280
|
- lib/telegram/bot/types/input_rich_block_divider.rb
|
|
281
|
+
- lib/telegram/bot/types/input_rich_block_document.rb
|
|
282
|
+
- lib/telegram/bot/types/input_rich_block_expandable_block_quotation.rb
|
|
266
283
|
- lib/telegram/bot/types/input_rich_block_footer.rb
|
|
267
284
|
- lib/telegram/bot/types/input_rich_block_list.rb
|
|
268
285
|
- lib/telegram/bot/types/input_rich_block_list_item.rb
|
|
@@ -281,12 +298,14 @@ files:
|
|
|
281
298
|
- lib/telegram/bot/types/input_rich_message.rb
|
|
282
299
|
- lib/telegram/bot/types/input_rich_message_content.rb
|
|
283
300
|
- lib/telegram/bot/types/input_rich_message_media.rb
|
|
301
|
+
- lib/telegram/bot/types/input_shared_widget_message_content.rb
|
|
284
302
|
- lib/telegram/bot/types/input_sticker.rb
|
|
285
303
|
- lib/telegram/bot/types/input_story_content.rb
|
|
286
304
|
- lib/telegram/bot/types/input_story_content_photo.rb
|
|
287
305
|
- lib/telegram/bot/types/input_story_content_video.rb
|
|
288
306
|
- lib/telegram/bot/types/input_text_message_content.rb
|
|
289
307
|
- lib/telegram/bot/types/input_venue_message_content.rb
|
|
308
|
+
- lib/telegram/bot/types/input_widget_message_content.rb
|
|
290
309
|
- lib/telegram/bot/types/invoice.rb
|
|
291
310
|
- lib/telegram/bot/types/keyboard_button.rb
|
|
292
311
|
- lib/telegram/bot/types/keyboard_button_poll_type.rb
|
|
@@ -311,6 +330,7 @@ files:
|
|
|
311
330
|
- lib/telegram/bot/types/message.rb
|
|
312
331
|
- lib/telegram/bot/types/message_auto_delete_timer_changed.rb
|
|
313
332
|
- lib/telegram/bot/types/message_entity.rb
|
|
333
|
+
- lib/telegram/bot/types/message_generation_stopped.rb
|
|
314
334
|
- lib/telegram/bot/types/message_id.rb
|
|
315
335
|
- lib/telegram/bot/types/message_origin.rb
|
|
316
336
|
- lib/telegram/bot/types/message_origin_channel.rb
|
|
@@ -332,6 +352,7 @@ files:
|
|
|
332
352
|
- lib/telegram/bot/types/paid_media_purchased.rb
|
|
333
353
|
- lib/telegram/bot/types/paid_media_video.rb
|
|
334
354
|
- lib/telegram/bot/types/paid_message_price_changed.rb
|
|
355
|
+
- lib/telegram/bot/types/paid_messages_waived.rb
|
|
335
356
|
- lib/telegram/bot/types/passport_data.rb
|
|
336
357
|
- lib/telegram/bot/types/passport_element_error.rb
|
|
337
358
|
- lib/telegram/bot/types/passport_element_error_data_field.rb
|
|
@@ -375,10 +396,13 @@ files:
|
|
|
375
396
|
- lib/telegram/bot/types/rich_block_animation.rb
|
|
376
397
|
- lib/telegram/bot/types/rich_block_audio.rb
|
|
377
398
|
- lib/telegram/bot/types/rich_block_block_quotation.rb
|
|
399
|
+
- lib/telegram/bot/types/rich_block_buttons.rb
|
|
378
400
|
- lib/telegram/bot/types/rich_block_caption.rb
|
|
379
401
|
- lib/telegram/bot/types/rich_block_collage.rb
|
|
380
402
|
- lib/telegram/bot/types/rich_block_details.rb
|
|
381
403
|
- lib/telegram/bot/types/rich_block_divider.rb
|
|
404
|
+
- lib/telegram/bot/types/rich_block_document.rb
|
|
405
|
+
- lib/telegram/bot/types/rich_block_expandable_block_quotation.rb
|
|
382
406
|
- lib/telegram/bot/types/rich_block_footer.rb
|
|
383
407
|
- lib/telegram/bot/types/rich_block_list.rb
|
|
384
408
|
- lib/telegram/bot/types/rich_block_list_item.rb
|
|
@@ -396,12 +420,14 @@ files:
|
|
|
396
420
|
- lib/telegram/bot/types/rich_block_video.rb
|
|
397
421
|
- lib/telegram/bot/types/rich_block_voice_note.rb
|
|
398
422
|
- lib/telegram/bot/types/rich_message.rb
|
|
423
|
+
- lib/telegram/bot/types/rich_message_button.rb
|
|
399
424
|
- lib/telegram/bot/types/rich_text.rb
|
|
400
425
|
- lib/telegram/bot/types/rich_text_anchor.rb
|
|
401
426
|
- lib/telegram/bot/types/rich_text_anchor_link.rb
|
|
402
427
|
- lib/telegram/bot/types/rich_text_bank_card_number.rb
|
|
403
428
|
- lib/telegram/bot/types/rich_text_bold.rb
|
|
404
429
|
- lib/telegram/bot/types/rich_text_bot_command.rb
|
|
430
|
+
- lib/telegram/bot/types/rich_text_button.rb
|
|
405
431
|
- lib/telegram/bot/types/rich_text_cashtag.rb
|
|
406
432
|
- lib/telegram/bot/types/rich_text_code.rb
|
|
407
433
|
- lib/telegram/bot/types/rich_text_custom_emoji.rb
|
|
@@ -420,11 +446,13 @@ files:
|
|
|
420
446
|
- lib/telegram/bot/types/rich_text_subscript.rb
|
|
421
447
|
- lib/telegram/bot/types/rich_text_superscript.rb
|
|
422
448
|
- lib/telegram/bot/types/rich_text_text_mention.rb
|
|
449
|
+
- lib/telegram/bot/types/rich_text_ton_address.rb
|
|
423
450
|
- lib/telegram/bot/types/rich_text_underline.rb
|
|
424
451
|
- lib/telegram/bot/types/rich_text_url.rb
|
|
425
452
|
- lib/telegram/bot/types/sent_guest_message.rb
|
|
426
453
|
- lib/telegram/bot/types/sent_web_app_message.rb
|
|
427
454
|
- lib/telegram/bot/types/shared_user.rb
|
|
455
|
+
- lib/telegram/bot/types/shared_widget_query.rb
|
|
428
456
|
- lib/telegram/bot/types/shipping_address.rb
|
|
429
457
|
- lib/telegram/bot/types/shipping_option.rb
|
|
430
458
|
- lib/telegram/bot/types/shipping_query.rb
|
|
@@ -453,6 +481,11 @@ files:
|
|
|
453
481
|
- lib/telegram/bot/types/suggested_post_refunded.rb
|
|
454
482
|
- lib/telegram/bot/types/switch_inline_query_chosen_chat.rb
|
|
455
483
|
- lib/telegram/bot/types/text_quote.rb
|
|
484
|
+
- lib/telegram/bot/types/ton_nft.rb
|
|
485
|
+
- lib/telegram/bot/types/ton_nft_attribute.rb
|
|
486
|
+
- lib/telegram/bot/types/ton_wallet_card.rb
|
|
487
|
+
- lib/telegram/bot/types/ton_wallet_card_sticker.rb
|
|
488
|
+
- lib/telegram/bot/types/ton_wallet_transfer.rb
|
|
456
489
|
- lib/telegram/bot/types/transaction_partner.rb
|
|
457
490
|
- lib/telegram/bot/types/transaction_partner_affiliate_program.rb
|
|
458
491
|
- lib/telegram/bot/types/transaction_partner_chat.rb
|
|
@@ -487,15 +520,37 @@ files:
|
|
|
487
520
|
- lib/telegram/bot/types/web_app_data.rb
|
|
488
521
|
- lib/telegram/bot/types/web_app_info.rb
|
|
489
522
|
- lib/telegram/bot/types/webhook_info.rb
|
|
523
|
+
- lib/telegram/bot/types/widget.rb
|
|
524
|
+
- lib/telegram/bot/types/widget_query.rb
|
|
525
|
+
- lib/telegram/bot/types/widget_query_type.rb
|
|
526
|
+
- lib/telegram/bot/types/widget_query_type_data.rb
|
|
527
|
+
- lib/telegram/bot/types/widget_query_type_sent_transaction.rb
|
|
528
|
+
- lib/telegram/bot/types/widget_query_type_sign_data.rb
|
|
529
|
+
- lib/telegram/bot/types/widget_query_wallet.rb
|
|
490
530
|
- lib/telegram/bot/types/write_access_allowed.rb
|
|
491
531
|
- lib/telegram/bot/version.rb
|
|
492
532
|
- mise.toml
|
|
533
|
+
- rakelib/README.md
|
|
493
534
|
- rakelib/builders/endpoints_builder.rb
|
|
494
535
|
- rakelib/builders/type_builder.rb
|
|
495
536
|
- rakelib/builders/type_dependencies.rb
|
|
537
|
+
- rakelib/docs.rake
|
|
496
538
|
- rakelib/parse.rake
|
|
497
|
-
- rakelib/parsers/
|
|
498
|
-
- rakelib/parsers/
|
|
539
|
+
- rakelib/parsers/api_method.rb
|
|
540
|
+
- rakelib/parsers/description.rb
|
|
541
|
+
- rakelib/parsers/docs_page.rb
|
|
542
|
+
- rakelib/parsers/entry.rb
|
|
543
|
+
- rakelib/parsers/entry_grammar.rb
|
|
544
|
+
- rakelib/parsers/error.rb
|
|
545
|
+
- rakelib/parsers/field.rb
|
|
546
|
+
- rakelib/parsers/object_type.rb
|
|
547
|
+
- rakelib/parsers/page_object.rb
|
|
548
|
+
- rakelib/parsers/readers.rb
|
|
549
|
+
- rakelib/parsers/return_type.rb
|
|
550
|
+
- rakelib/parsers/serializer.rb
|
|
551
|
+
- rakelib/parsers/table.rb
|
|
552
|
+
- rakelib/parsers/type_ref.rb
|
|
553
|
+
- rakelib/parsers/union_type.rb
|
|
499
554
|
- rakelib/rebuild.rake
|
|
500
555
|
- rakelib/templates/empty_type.erb
|
|
501
556
|
- rakelib/templates/endpoints.erb
|
|
@@ -519,7 +574,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
519
574
|
- !ruby/object:Gem::Version
|
|
520
575
|
version: '0'
|
|
521
576
|
requirements: []
|
|
522
|
-
rubygems_version: 4.0.
|
|
577
|
+
rubygems_version: 4.0.20
|
|
523
578
|
specification_version: 4
|
|
524
579
|
summary: Ruby wrapper for Telegram's Bot API
|
|
525
580
|
test_files: []
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: update-api
|
|
3
|
-
description: Parse Telegram Bot API docs and rebuild generated Ruby types and endpoints
|
|
4
|
-
disable-model-invocation: true
|
|
5
|
-
allowed-tools: Bash, Read, Edit, Grep, WebFetch
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
Update generated types and API endpoints from the latest Telegram Bot API documentation.
|
|
9
|
-
|
|
10
|
-
## Step 1: Check for updates
|
|
11
|
-
|
|
12
|
-
1. Fetch <https://core.telegram.org/bots/api-changelog> and identify the most recent Bot API version and all version entries listed.
|
|
13
|
-
2. Read `CHANGELOG.md` and find the highest Bot API version mentioned to determine which version this lib currently supports.
|
|
14
|
-
3. List all Bot API versions that are newer than the lib's current version, with a summary of changes for each.
|
|
15
|
-
4. If the lib is already up to date, stop here and inform the user.
|
|
16
|
-
|
|
17
|
-
## Step 2: Parse
|
|
18
|
-
|
|
19
|
-
Run both parse tasks to scrape the latest Telegram Bot API docs:
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
bundle exec rake parse:types
|
|
23
|
-
bundle exec rake parse:methods
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Step 3: Rebuild
|
|
27
|
-
|
|
28
|
-
Before rebuilding, read the custom method files listed in Step 4 so you have a snapshot of their current content.
|
|
29
|
-
|
|
30
|
-
Regenerate Ruby source files from the parsed JSON data:
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
bundle exec rake rebuild:types
|
|
34
|
-
bundle exec rake rebuild:methods
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Step 4: Restore custom methods
|
|
38
|
-
|
|
39
|
-
The rebuild overwrites type files from templates, losing hand-written methods. After rebuild, read each file below and restore the custom method if it's missing:
|
|
40
|
-
|
|
41
|
-
| File | Method to restore |
|
|
42
|
-
|---|---|
|
|
43
|
-
| `lib/telegram/bot/types/callback_query.rb` | `def to_s` returning `data.to_s` |
|
|
44
|
-
| `lib/telegram/bot/types/message.rb` | `def to_s` returning `text.to_s` |
|
|
45
|
-
| `lib/telegram/bot/types/chosen_inline_result.rb` | `alias to_s query` |
|
|
46
|
-
| `lib/telegram/bot/types/inline_query.rb` | `alias to_s query` |
|
|
47
|
-
| `lib/telegram/bot/types/inline_keyboard_markup.rb` | `def to_compact_hash` that calls `to_compact_hash` on nested `InlineKeyboardButton` items |
|
|
48
|
-
| `lib/telegram/bot/types/reply_keyboard_markup.rb` | `def to_compact_hash` that calls `to_compact_hash` on nested `KeyboardButton` items |
|
|
49
|
-
| `lib/telegram/bot/types/update.rb` | `def current_message` that finds the first non-`update_id` attribute value |
|
|
50
|
-
|
|
51
|
-
For each file:
|
|
52
|
-
|
|
53
|
-
1. Read the current file content
|
|
54
|
-
2. Check if the custom method/alias is already present
|
|
55
|
-
3. If missing, add it back before the closing `end` of the class, with one blank line before it
|
|
56
|
-
|
|
57
|
-
## Step 5: Review changes
|
|
58
|
-
|
|
59
|
-
Run `git diff --stat` and then `git diff` to review all changes. Summarize what was added/modified/removed compared to the previous version.
|
|
60
|
-
|
|
61
|
-
## Step 6: Lint and test
|
|
62
|
-
|
|
63
|
-
Run linting and tests to verify everything is correct:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
bundle exec rubocop
|
|
67
|
-
bundle exec rake spec
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
If rubocop or tests fail, fix the issues before finishing.
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'nokogiri'
|
|
4
|
-
require 'net/http'
|
|
5
|
-
|
|
6
|
-
module Parsers
|
|
7
|
-
class MethodsParser
|
|
8
|
-
API_URL = 'https://core.telegram.org/bots/api'
|
|
9
|
-
|
|
10
|
-
def parse
|
|
11
|
-
doc = fetch_document
|
|
12
|
-
result = {}
|
|
13
|
-
|
|
14
|
-
method_headers(doc).each do |header|
|
|
15
|
-
method_name = extract_method_name(header)
|
|
16
|
-
next unless method_name
|
|
17
|
-
|
|
18
|
-
return_type = extract_return_type(header)
|
|
19
|
-
result[method_name] = return_type if return_type
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
result
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def fetch_document
|
|
28
|
-
uri = URI.parse(API_URL)
|
|
29
|
-
response = Net::HTTP.get(uri)
|
|
30
|
-
Nokogiri::HTML(response)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def method_headers(doc)
|
|
34
|
-
doc.css('h4')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def extract_method_name(header)
|
|
38
|
-
name = header.text.strip
|
|
39
|
-
# Methods start with lowercase letter (camelCase)
|
|
40
|
-
# Types start with uppercase (PascalCase) - skip those
|
|
41
|
-
return nil unless name.match?(/\A[a-z][a-zA-Z0-9]*\z/)
|
|
42
|
-
|
|
43
|
-
name
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def extract_return_type(header)
|
|
47
|
-
# Find description paragraphs after the header
|
|
48
|
-
sibling = header.next_element
|
|
49
|
-
|
|
50
|
-
while sibling
|
|
51
|
-
break if sibling.name == 'h4' # Next section
|
|
52
|
-
|
|
53
|
-
if sibling.name == 'p'
|
|
54
|
-
return_type = parse_return_statement(sibling)
|
|
55
|
-
return return_type if return_type
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
sibling = sibling.next_element
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
nil
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def parse_return_statement(paragraph)
|
|
65
|
-
html = paragraph.inner_html
|
|
66
|
-
|
|
67
|
-
# Pattern: Returns an Array of <a>Type</a>
|
|
68
|
-
if (match = html.match(%r{Returns an Array of <a[^>]*>([^<]+)</a>}i))
|
|
69
|
-
return "Array<#{match[1]}>"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Pattern: On success, an array of <a>Type</a> (lowercase)
|
|
73
|
-
if (match = html.match(%r{On success,? an array of <a[^>]*>([^<]+)</a>}i))
|
|
74
|
-
return "Array<#{match[1]}>"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Pattern: Returns a <a>Type</a> or Returns the <a>Type</a>
|
|
78
|
-
if (match = html.match(%r{Returns (?:a |the )?.*?<a[^>]*>([^<]+)</a>}i))
|
|
79
|
-
return match[1]
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Pattern: Returns basic information ... in form of a <a>Type</a>
|
|
83
|
-
if (match = html.match(%r{in form of a <a[^>]*>([^<]+)</a>}i))
|
|
84
|
-
return match[1]
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Pattern: <a>Type</a> is returned, otherwise True is returned (union type)
|
|
88
|
-
# e.g., "the edited Message is returned, otherwise True is returned"
|
|
89
|
-
if (match = html.match(%r{<a[^>]*>([^<]+)</a> is returned,? otherwise <em>True</em> is returned}i))
|
|
90
|
-
return "#{match[1]} | Boolean"
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Pattern: Returns <em>True</em> or On success, <em>True</em> is returned
|
|
94
|
-
return 'Boolean' if html.match?(%r{<em>True</em>(?:\s+(?:is|on)|\s*\.)}i)
|
|
95
|
-
|
|
96
|
-
# Pattern: On success, a <a>Type</a> object is returned
|
|
97
|
-
if (match = html.match(%r{On success,? a <a[^>]*>([^<]+)</a> object is returned}i))
|
|
98
|
-
return match[1]
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# Pattern: On success, the <a>Type</a> is returned / the edited/sent/stopped <a>X</a> is returned
|
|
102
|
-
if (match = html.match(%r{the (?:sent |edited |stopped )?<a[^>]*>([^<]+)</a> is returned}i))
|
|
103
|
-
return match[1]
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# Pattern: Returns <em>Int</em> or Integer
|
|
107
|
-
return 'Integer' if html.match?(%r{Returns <em>Int</em>}i)
|
|
108
|
-
|
|
109
|
-
# Pattern: Returns ... as <em>String</em>
|
|
110
|
-
return 'String' if html.match?(%r{as <em>String</em>}i)
|
|
111
|
-
|
|
112
|
-
nil
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'nokogiri'
|
|
4
|
-
require 'net/http'
|
|
5
|
-
|
|
6
|
-
module Parsers
|
|
7
|
-
class TypesParser
|
|
8
|
-
API_URL = 'https://core.telegram.org/bots/api'
|
|
9
|
-
|
|
10
|
-
PRIMITIVE_TYPES = {
|
|
11
|
-
'String' => 'string',
|
|
12
|
-
'Integer' => 'integer',
|
|
13
|
-
'Boolean' => 'boolean',
|
|
14
|
-
'Float' => 'number',
|
|
15
|
-
'True' => 'boolean'
|
|
16
|
-
}.freeze
|
|
17
|
-
|
|
18
|
-
def parse
|
|
19
|
-
doc = fetch_document
|
|
20
|
-
result = {}
|
|
21
|
-
|
|
22
|
-
type_headers(doc).each do |header|
|
|
23
|
-
type_name = extract_type_name(header)
|
|
24
|
-
next unless type_name
|
|
25
|
-
|
|
26
|
-
type_data = parse_type(header, type_name)
|
|
27
|
-
result[type_name] = type_data if type_data
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
result
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def fetch_document
|
|
36
|
-
uri = URI.parse(API_URL)
|
|
37
|
-
response = Net::HTTP.get(uri)
|
|
38
|
-
Nokogiri::HTML(response)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def type_headers(doc)
|
|
42
|
-
doc.css('h4')
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def extract_type_name(header)
|
|
46
|
-
name = header.text.strip
|
|
47
|
-
# Types start with uppercase letter (CapitalCase)
|
|
48
|
-
# Methods start with lowercase (camelCase) - skip those
|
|
49
|
-
return nil unless name.match?(/\A[A-Z][a-zA-Z0-9]*\z/)
|
|
50
|
-
|
|
51
|
-
name
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def parse_type(header, type_name)
|
|
55
|
-
# Check if this is a union type (list of types without a table)
|
|
56
|
-
description = first_description_paragraph(header)
|
|
57
|
-
next_sibling = find_next_significant_sibling(header)
|
|
58
|
-
|
|
59
|
-
if union_type?(next_sibling)
|
|
60
|
-
parse_union_type(next_sibling, description, type_name)
|
|
61
|
-
else
|
|
62
|
-
parse_table_type(header)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def first_description_paragraph(header)
|
|
67
|
-
sibling = header.next_element
|
|
68
|
-
sibling if sibling&.name == 'p'
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def find_next_significant_sibling(header)
|
|
72
|
-
sibling = header.next_element
|
|
73
|
-
# Skip description paragraphs
|
|
74
|
-
sibling = sibling.next_element while sibling && sibling.name == 'p'
|
|
75
|
-
sibling
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def union_type?(element)
|
|
79
|
-
element&.name == 'ul'
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def parse_union_type(ul_element, description, type_name)
|
|
83
|
-
types = []
|
|
84
|
-
desc_text = description&.text.to_s
|
|
85
|
-
types << 'string' if desc_text.match?(/String for plain text/i)
|
|
86
|
-
types << "array:#{type_name}" if desc_text.match?(/an Array of #{type_name}/i)
|
|
87
|
-
types.concat(ul_element.css('li a').map { |a| a.text.strip })
|
|
88
|
-
{ 'type' => types.uniq }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def parse_table_type(header)
|
|
92
|
-
table = find_attribute_table(header)
|
|
93
|
-
return {} unless table
|
|
94
|
-
|
|
95
|
-
attributes = {}
|
|
96
|
-
table.css('tbody tr').each do |row|
|
|
97
|
-
cells = row.css('td')
|
|
98
|
-
next unless cells.length >= 3
|
|
99
|
-
|
|
100
|
-
field_name = cells[0].text.strip
|
|
101
|
-
type_info = cells[1]
|
|
102
|
-
description_cell = cells[2]
|
|
103
|
-
|
|
104
|
-
attributes[field_name] = parse_attribute(type_info, description_cell)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
attributes
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def find_attribute_table(header)
|
|
111
|
-
sibling = header.next_element
|
|
112
|
-
while sibling
|
|
113
|
-
return sibling if sibling.name == 'table'
|
|
114
|
-
# Stop if we hit another h4 (next type/method)
|
|
115
|
-
break if sibling.name == 'h4'
|
|
116
|
-
|
|
117
|
-
sibling = sibling.next_element
|
|
118
|
-
end
|
|
119
|
-
nil
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def parse_attribute(type_cell, description_cell)
|
|
123
|
-
attribute = {}
|
|
124
|
-
raw_type = type_cell.text.strip
|
|
125
|
-
description = description_cell.text.strip
|
|
126
|
-
description_html = description_cell.inner_html
|
|
127
|
-
|
|
128
|
-
# Parse type
|
|
129
|
-
type_value = parse_type_value(type_cell)
|
|
130
|
-
if type_value.is_a?(Hash)
|
|
131
|
-
attribute.merge!(type_value)
|
|
132
|
-
else
|
|
133
|
-
attribute['type'] = type_value
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
# Parse required (absence of "Optional" at start of description)
|
|
137
|
-
attribute['required'] = true unless description.start_with?('Optional')
|
|
138
|
-
|
|
139
|
-
# Parse required_value (always "X" or must be <em>X</em>)
|
|
140
|
-
required_value = extract_required_value(description, description_html)
|
|
141
|
-
if required_value
|
|
142
|
-
attribute['required_value'] = required_value
|
|
143
|
-
attribute['default'] = required_value
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# Parse size constraints (N-M characters or must be between)
|
|
147
|
-
min_size, max_size = extract_size_constraints(description)
|
|
148
|
-
attribute['min_size'] = min_size if min_size
|
|
149
|
-
attribute['max_size'] = max_size if max_size
|
|
150
|
-
|
|
151
|
-
# Parse default value (Defaults to X)
|
|
152
|
-
# If HTML type is 'True' (not 'Boolean'), it means the field only exists when true
|
|
153
|
-
if raw_type == 'True' && !attribute.key?('default')
|
|
154
|
-
attribute['default'] = true
|
|
155
|
-
elsif !attribute.key?('default')
|
|
156
|
-
default = extract_default_value(description, description_html, attribute['type'])
|
|
157
|
-
attribute['default'] = default unless default.nil?
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# Clean up: remove required if false
|
|
161
|
-
attribute.delete('required') unless attribute['required']
|
|
162
|
-
|
|
163
|
-
attribute
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def parse_type_value(type_cell)
|
|
167
|
-
text = type_cell.text.strip
|
|
168
|
-
links = type_cell.css('a')
|
|
169
|
-
|
|
170
|
-
# Check for "Array of X"
|
|
171
|
-
if text.start_with?('Array of')
|
|
172
|
-
items_type = parse_array_items(type_cell, text)
|
|
173
|
-
return { 'type' => 'array', 'items' => items_type }
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
# Check for union type "X or Y"
|
|
177
|
-
if text.include?(' or ')
|
|
178
|
-
types = parse_union_types(type_cell, text)
|
|
179
|
-
return types.length == 1 ? normalize_type(types.first) : types.map { |t| normalize_type(t) }
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
# Single type
|
|
183
|
-
if links.any?
|
|
184
|
-
normalize_type(links.first.text.strip)
|
|
185
|
-
else
|
|
186
|
-
normalize_type(text)
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def parse_array_items(type_cell, text)
|
|
191
|
-
# Handle "Array of Array of X"
|
|
192
|
-
if text.include?('Array of Array of')
|
|
193
|
-
inner_type = type_cell.css('a').last&.text&.strip || text.split('Array of Array of').last.strip
|
|
194
|
-
return { 'type' => 'array', 'items' => normalize_type(inner_type) }
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# Regular "Array of X"
|
|
198
|
-
link = type_cell.css('a').first
|
|
199
|
-
if link
|
|
200
|
-
normalize_type(link.text.strip)
|
|
201
|
-
else
|
|
202
|
-
# Primitive array like "Array of String"
|
|
203
|
-
items_text = text.sub('Array of ', '').strip
|
|
204
|
-
normalize_type(items_text)
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def parse_union_types(type_cell, text)
|
|
209
|
-
links = type_cell.css('a')
|
|
210
|
-
if links.any?
|
|
211
|
-
links.map { |l| l.text.strip }
|
|
212
|
-
else
|
|
213
|
-
text.split(' or ').map(&:strip)
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
def normalize_type(type)
|
|
218
|
-
PRIMITIVE_TYPES[type] || type
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
def extract_required_value(description, description_html)
|
|
222
|
-
# Pattern: always "X" or always "X" (smart quotes)
|
|
223
|
-
match = description.match(/always ["\u201c]([^"\u201d]+)["\u201d]/i)
|
|
224
|
-
return match[1].delete('\\') if match
|
|
225
|
-
|
|
226
|
-
# Pattern: must be <em>X</em> (check inner HTML)
|
|
227
|
-
match = description_html.match(%r{must be <em>([^<]+)</em>}i)
|
|
228
|
-
return match[1] if match
|
|
229
|
-
|
|
230
|
-
nil
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
def extract_size_constraints(description)
|
|
234
|
-
min_size = nil
|
|
235
|
-
max_size = nil
|
|
236
|
-
|
|
237
|
-
# Pattern: N-M characters (covers 0-N and 1-N cases)
|
|
238
|
-
if (match = description.match(/(\d+)-(\d+) characters/))
|
|
239
|
-
min_val = match[1].to_i
|
|
240
|
-
max_size = match[2].to_i
|
|
241
|
-
min_size = min_val if min_val.positive?
|
|
242
|
-
# Pattern: must be between N and M
|
|
243
|
-
elsif (match = description.match(/must be between (\d+) and (\d+)/))
|
|
244
|
-
min_size = match[1].to_i
|
|
245
|
-
max_size = match[2].to_i
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
[min_size, max_size]
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
def extract_default_value(description, description_html, type)
|
|
252
|
-
# Pattern: Defaults to "X" (with smart quotes U+201C/U+201D)
|
|
253
|
-
if (match = description.match(/Defaults to \u201c([^\u201d]+)\u201d/i))
|
|
254
|
-
return cast_default_value(match[1], type)
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
# Pattern: Defaults to <em>X</em> (check inner HTML for em-wrapped values)
|
|
258
|
-
if (match = description_html.match(%r{Defaults to <em>([^<]+)</em>}i))
|
|
259
|
-
return cast_default_value(match[1], type)
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
# Pattern: Defaults to <number> (plain numeric values)
|
|
263
|
-
if (match = description.match(/Defaults to (\d+)/i))
|
|
264
|
-
return cast_default_value(match[1], type)
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
nil
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
def cast_default_value(value, type)
|
|
271
|
-
case type
|
|
272
|
-
when 'integer'
|
|
273
|
-
value.to_i
|
|
274
|
-
when 'boolean'
|
|
275
|
-
value.downcase == 'true'
|
|
276
|
-
when 'number'
|
|
277
|
-
value.to_f
|
|
278
|
-
else
|
|
279
|
-
value
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
end
|