telegram-bot-ruby 2.4.0 → 2.6.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/.claude/skills/update-api/SKILL.md +70 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +19 -0
- data/CHANGELOG.md +16 -0
- data/README.md +40 -23
- data/lib/telegram/bot/api/endpoints.rb +110 -62
- data/lib/telegram/bot/api.rb +13 -1
- data/lib/telegram/bot/configuration.rb +2 -1
- data/lib/telegram/bot/types/accepted_gift_types.rb +15 -0
- data/lib/telegram/bot/types/business_bot_rights.rb +24 -0
- data/lib/telegram/bot/types/business_connection.rb +1 -1
- data/lib/telegram/bot/types/callback_query.rb +4 -0
- data/lib/telegram/bot/types/chat.rb +1 -0
- data/lib/telegram/bot/types/chat_administrator_rights.rb +2 -0
- data/lib/telegram/bot/types/chat_full_info.rb +7 -1
- data/lib/telegram/bot/types/chat_member_administrator.rb +2 -0
- data/lib/telegram/bot/types/chat_member_member.rb +1 -0
- data/lib/telegram/bot/types/chat_member_restricted.rb +2 -0
- data/lib/telegram/bot/types/chat_owner_changed.rb +11 -0
- data/lib/telegram/bot/types/chat_owner_left.rb +11 -0
- data/lib/telegram/bot/types/chat_permissions.rb +1 -0
- data/lib/telegram/bot/types/checklist.rb +15 -0
- data/lib/telegram/bot/types/checklist_task.rb +16 -0
- data/lib/telegram/bot/types/checklist_tasks_added.rb +12 -0
- data/lib/telegram/bot/types/checklist_tasks_done.rb +13 -0
- data/lib/telegram/bot/types/direct_message_price_changed.rb +12 -0
- data/lib/telegram/bot/types/direct_messages_topic.rb +12 -0
- data/lib/telegram/bot/types/external_reply_info.rb +1 -0
- data/lib/telegram/bot/types/forum_topic.rb +1 -0
- data/lib/telegram/bot/types/forum_topic_created.rb +1 -0
- data/lib/telegram/bot/types/gift.rb +7 -0
- data/lib/telegram/bot/types/gift_background.rb +13 -0
- data/lib/telegram/bot/types/gift_info.rb +20 -0
- data/lib/telegram/bot/types/inline_keyboard_button.rb +2 -0
- data/lib/telegram/bot/types/input_checklist.rb +16 -0
- data/lib/telegram/bot/types/input_checklist_task.rb +14 -0
- data/lib/telegram/bot/types/input_file.rb +10 -0
- data/lib/telegram/bot/types/input_profile_photo.rb +15 -0
- data/lib/telegram/bot/types/input_profile_photo_animated.rb +13 -0
- data/lib/telegram/bot/types/input_profile_photo_static.rb +12 -0
- data/lib/telegram/bot/types/input_story_content.rb +15 -0
- data/lib/telegram/bot/types/input_story_content_photo.rb +12 -0
- data/lib/telegram/bot/types/input_story_content_video.rb +15 -0
- data/lib/telegram/bot/types/keyboard_button.rb +2 -0
- data/lib/telegram/bot/types/location_address.rb +14 -0
- data/lib/telegram/bot/types/message.rb +24 -1
- data/lib/telegram/bot/types/message_entity.rb +2 -0
- data/lib/telegram/bot/types/owned_gift.rb +15 -0
- data/lib/telegram/bot/types/owned_gift_regular.rb +25 -0
- data/lib/telegram/bot/types/owned_gift_unique.rb +19 -0
- data/lib/telegram/bot/types/owned_gifts.rb +13 -0
- data/lib/telegram/bot/types/paid_message_price_changed.rb +11 -0
- data/lib/telegram/bot/types/reply_parameters.rb +1 -0
- data/lib/telegram/bot/types/star_amount.rb +12 -0
- data/lib/telegram/bot/types/story_area.rb +12 -0
- data/lib/telegram/bot/types/story_area_position.rb +16 -0
- data/lib/telegram/bot/types/story_area_type.rb +18 -0
- data/lib/telegram/bot/types/story_area_type_link.rb +12 -0
- data/lib/telegram/bot/types/story_area_type_location.rb +14 -0
- data/lib/telegram/bot/types/story_area_type_suggested_reaction.rb +14 -0
- data/lib/telegram/bot/types/story_area_type_unique_gift.rb +12 -0
- data/lib/telegram/bot/types/story_area_type_weather.rb +14 -0
- data/lib/telegram/bot/types/suggested_post_approval_failed.rb +12 -0
- data/lib/telegram/bot/types/suggested_post_approved.rb +13 -0
- data/lib/telegram/bot/types/suggested_post_declined.rb +12 -0
- data/lib/telegram/bot/types/suggested_post_info.rb +13 -0
- data/lib/telegram/bot/types/suggested_post_paid.rb +14 -0
- data/lib/telegram/bot/types/suggested_post_parameters.rb +12 -0
- data/lib/telegram/bot/types/suggested_post_price.rb +12 -0
- data/lib/telegram/bot/types/suggested_post_refunded.rb +12 -0
- data/lib/telegram/bot/types/transaction_partner_user.rb +2 -0
- data/lib/telegram/bot/types/unique_gift.rb +22 -0
- data/lib/telegram/bot/types/unique_gift_backdrop.rb +13 -0
- data/lib/telegram/bot/types/unique_gift_backdrop_colors.rb +14 -0
- data/lib/telegram/bot/types/unique_gift_colors.rb +16 -0
- data/lib/telegram/bot/types/unique_gift_info.rb +17 -0
- data/lib/telegram/bot/types/unique_gift_model.rb +14 -0
- data/lib/telegram/bot/types/unique_gift_symbol.rb +13 -0
- data/lib/telegram/bot/types/user.rb +2 -0
- data/lib/telegram/bot/types/user_profile_audios.rb +12 -0
- data/lib/telegram/bot/types/user_rating.rb +14 -0
- data/lib/telegram/bot/types/video.rb +1 -0
- data/lib/telegram/bot/types/video_quality.rb +16 -0
- data/lib/telegram/bot/version.rb +1 -1
- data/rakelib/builders/endpoints_builder.rb +51 -0
- data/rakelib/builders/type_builder.rb +140 -0
- data/rakelib/parse.rake +31 -0
- data/rakelib/parsers/methods_parser.rb +115 -0
- data/rakelib/parsers/types_parser.rb +273 -0
- data/rakelib/rebuild.rake +30 -0
- data/rakelib/templates/endpoints.erb +13 -0
- metadata +65 -9
- data/rakelib/parse_schema.rake +0 -73
- data/rakelib/rebuild_types.rake +0 -90
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 357f5a74cde39f07315db2cd4235600f5e67a2aaa3fed93a8ad9d9fe87be3710
|
|
4
|
+
data.tar.gz: 041b6041f45a36d8a8e976f251449c5c70bfbf045c89e9c359955bcc45d08c45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d248ef2b807c9d9a8b5192e10daf9c4bbbb881ca62caecf29189714636d264f9e2f0ef49533bf6e60eb26406e05ed1b6766dab99303e3595fdf1febe3000428f
|
|
7
|
+
data.tar.gz: 7974d0f32a1b1d4560db47212097358ddba3d5a2d13f2e596d9dff88e9aa3a0c3e1249574e4df5b3217da77a8a529a04bdf266e63d9f0285636bbd0327711809
|
|
@@ -0,0 +1,70 @@
|
|
|
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.
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -16,17 +16,36 @@ Metrics/BlockLength:
|
|
|
16
16
|
- context
|
|
17
17
|
- describe
|
|
18
18
|
- task
|
|
19
|
+
|
|
19
20
|
Metrics/ClassLength:
|
|
20
21
|
Exclude:
|
|
21
22
|
- lib/telegram/bot/api/endpoints.rb
|
|
23
|
+
- lib/telegram/bot/types/message.rb
|
|
24
|
+
- rakelib/builders/type_builder.rb
|
|
25
|
+
- rakelib/parsers/**/*
|
|
26
|
+
|
|
22
27
|
Metrics/MethodLength:
|
|
23
28
|
Exclude:
|
|
24
29
|
- spec/**/*
|
|
30
|
+
- rakelib/parsers/**/*
|
|
31
|
+
|
|
32
|
+
Metrics/AbcSize:
|
|
33
|
+
Exclude:
|
|
34
|
+
- rakelib/parsers/**/*
|
|
35
|
+
|
|
36
|
+
Metrics/CyclomaticComplexity:
|
|
37
|
+
Exclude:
|
|
38
|
+
- rakelib/parsers/**/*
|
|
39
|
+
|
|
40
|
+
Metrics/PerceivedComplexity:
|
|
41
|
+
Exclude:
|
|
42
|
+
- rakelib/parsers/**/*
|
|
25
43
|
|
|
26
44
|
Layout/LineLength:
|
|
27
45
|
Max: 120
|
|
28
46
|
|
|
29
47
|
RSpec/MultipleMemoizedHelpers:
|
|
30
48
|
Enabled: false
|
|
49
|
+
|
|
31
50
|
RSpec/NestedGroups:
|
|
32
51
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [Bot API 9.4](https://core.telegram.org/bots/api-changelog#february-9-2026) + [Bot API 9.5](https://core.telegram.org/bots/api-changelog#march-1-2026) [#334](https://github.com/atipugin/telegram-bot-ruby/pull/334)
|
|
8
|
+
- Support for configuring Faraday adapter options [#333](https://github.com/atipugin/telegram-bot-ruby/pull/333) (thx [@dmeremyanin](https://github.com/dmeremyanin))
|
|
9
|
+
- [Bot API 9.3](https://core.telegram.org/bots/api-changelog#december-31-2025) [#328](https://github.com/atipugin/telegram-bot-ruby/pull/328)
|
|
10
|
+
- `CallbackQuery#to_s` for improved logging [#327](https://github.com/atipugin/telegram-bot-ruby/pull/327) (thx [@projecteurlumiere](https://github.com/projecteurlumiere))
|
|
11
|
+
|
|
12
|
+
## 2.5.0
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Docs parsers for types and methods
|
|
17
|
+
- [Bot API 9.2](https://core.telegram.org/bots/api-changelog#august-15-2025) [#325](https://github.com/atipugin/telegram-bot-ruby/pull/325)
|
|
18
|
+
|
|
3
19
|
## 2.4.0
|
|
4
20
|
|
|
5
21
|
### Added
|
data/README.md
CHANGED
|
@@ -7,29 +7,12 @@ Ruby wrapper for [Telegram's Bot API](https://core.telegram.org/bots/api).
|
|
|
7
7
|
[](https://codeclimate.com/github/atipugin/telegram-bot-ruby/maintainability)
|
|
8
8
|
[](https://saythanks.io/to/atipugin)
|
|
9
9
|
|
|
10
|
-
## 🚧 Upgrading to 1.0
|
|
11
|
-
|
|
12
|
-
Since v1.0 `telegram-bot-ruby` uses [`dry-struct`](https://github.com/dry-rb/dry-struct)
|
|
13
|
-
instead of [`virtus`](https://github.com/solnic/virtus).
|
|
14
|
-
This means that type objects are now immutable and you can't change them after initialization:
|
|
15
|
-
|
|
16
|
-
```ruby
|
|
17
|
-
# This won't work
|
|
18
|
-
kb = Telegram::Bot::Types::ReplyKeyboardRemove.new
|
|
19
|
-
kb.remove_keyboard = true
|
|
20
|
-
|
|
21
|
-
# You have to set attributes in constructor instead
|
|
22
|
-
kb = Telegram::Bot::Types::ReplyKeyboardRemove.new(remove_keyboard: true)
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Please make sure it doesn't break your existing code before upgrading to 1.0.
|
|
26
|
-
|
|
27
10
|
## Installation
|
|
28
11
|
|
|
29
12
|
Add following line to your Gemfile:
|
|
30
13
|
|
|
31
14
|
```ruby
|
|
32
|
-
gem 'telegram-bot-ruby', '~> 2.
|
|
15
|
+
gem 'telegram-bot-ruby', '~> 2.5'
|
|
33
16
|
```
|
|
34
17
|
|
|
35
18
|
And then execute:
|
|
@@ -115,6 +98,16 @@ Telegram::Bot::Client.run(token, url: 'https://proxy.example.com') do |bot|
|
|
|
115
98
|
end
|
|
116
99
|
```
|
|
117
100
|
|
|
101
|
+
If you want to use a SOCKS5 proxy with the [Excon](https://github.com/excon/excon) adapter,
|
|
102
|
+
you can configure it like this:
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
Telegram::Bot.configure do |config|
|
|
106
|
+
config.adapter = :excon
|
|
107
|
+
config.adapter_options = { socks5_proxy: 'socks5://socks.proxy:1080' }
|
|
108
|
+
end
|
|
109
|
+
```
|
|
110
|
+
|
|
118
111
|
## Custom keyboards
|
|
119
112
|
|
|
120
113
|
You can use your own [custom keyboards](https://core.telegram.org/bots#keyboards).
|
|
@@ -239,7 +232,7 @@ end
|
|
|
239
232
|
|
|
240
233
|
## Logging
|
|
241
234
|
|
|
242
|
-
By default, bot doesn't log anything (uses `
|
|
235
|
+
By default, bot doesn't log anything (uses `NullLogger`).
|
|
243
236
|
You can change this behavior and provide your own logger class.
|
|
244
237
|
See example below:
|
|
245
238
|
|
|
@@ -265,12 +258,36 @@ Telegram::Bot.configure do |config|
|
|
|
265
258
|
end
|
|
266
259
|
```
|
|
267
260
|
|
|
268
|
-
|
|
261
|
+
If your adapter supports additional configuration, you can pass options as a hash:
|
|
262
|
+
|
|
263
|
+
```ruby
|
|
264
|
+
Telegram::Bot.configure do |config|
|
|
265
|
+
config.adapter = :httpx
|
|
266
|
+
config.adapter_options = { persistent: false }
|
|
267
|
+
end
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Maintenance
|
|
271
|
+
|
|
272
|
+
This gem provides rake tasks to parse the official [Telegram Bot API documentation](https://core.telegram.org/bots/api) and regenerate types and API methods.
|
|
273
|
+
|
|
274
|
+
### Parsing
|
|
275
|
+
|
|
276
|
+
Parse types and methods from the official documentation:
|
|
277
|
+
|
|
278
|
+
```shell
|
|
279
|
+
rake parse:types # Parses types to data/types.json
|
|
280
|
+
rake parse:methods # Parses methods to data/methods.json
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Rebuilding
|
|
269
284
|
|
|
270
|
-
|
|
271
|
-
here are some boilerplates which can help you to start faster:
|
|
285
|
+
Regenerate Ruby code from the parsed JSON data:
|
|
272
286
|
|
|
273
|
-
|
|
287
|
+
```shell
|
|
288
|
+
rake rebuild:types # Rebuilds lib/telegram/bot/types/*.rb
|
|
289
|
+
rake rebuild:methods # Rebuilds lib/telegram/bot/api/endpoints.rb
|
|
290
|
+
```
|
|
274
291
|
|
|
275
292
|
## Contributing
|
|
276
293
|
|
|
@@ -9,119 +9,167 @@ module Telegram
|
|
|
9
9
|
'deleteWebhook' => Types::Bool,
|
|
10
10
|
'getWebhookInfo' => Types::WebhookInfo,
|
|
11
11
|
'getMe' => Types::User,
|
|
12
|
+
'logOut' => Types::Bool,
|
|
13
|
+
'close' => Types::Bool,
|
|
12
14
|
'sendMessage' => Types::Message,
|
|
13
15
|
'forwardMessage' => Types::Message,
|
|
14
16
|
'forwardMessages' => Types::Array.of(Types::MessageId),
|
|
17
|
+
'copyMessage' => Types::MessageId,
|
|
18
|
+
'copyMessages' => Types::Array.of(Types::MessageId),
|
|
15
19
|
'sendPhoto' => Types::Message,
|
|
16
20
|
'sendAudio' => Types::Message,
|
|
17
21
|
'sendDocument' => Types::Message,
|
|
18
22
|
'sendVideo' => Types::Message,
|
|
23
|
+
'sendAnimation' => Types::Message,
|
|
19
24
|
'sendVoice' => Types::Message,
|
|
20
25
|
'sendVideoNote' => Types::Message,
|
|
26
|
+
'sendPaidMedia' => Types::Message,
|
|
21
27
|
'sendMediaGroup' => Types::Array.of(Types::Message),
|
|
22
28
|
'sendLocation' => Types::Message,
|
|
23
|
-
'editMessageLiveLocation' => Types::Message | Types::Bool,
|
|
24
|
-
'stopMessageLiveLocation' => Types::Message | Types::Bool,
|
|
25
29
|
'sendVenue' => Types::Message,
|
|
26
30
|
'sendContact' => Types::Message,
|
|
31
|
+
'sendPoll' => Types::Message,
|
|
32
|
+
'sendChecklist' => Types::Message,
|
|
33
|
+
'sendDice' => Types::Message,
|
|
34
|
+
'sendMessageDraft' => Types::Bool,
|
|
27
35
|
'sendChatAction' => Types::Bool,
|
|
28
36
|
'setMessageReaction' => Types::Bool,
|
|
29
37
|
'getUserProfilePhotos' => Types::UserProfilePhotos,
|
|
38
|
+
'getUserProfileAudios' => Types::UserProfileAudios,
|
|
39
|
+
'setUserEmojiStatus' => Types::Bool,
|
|
30
40
|
'getFile' => Types::File,
|
|
31
41
|
'banChatMember' => Types::Bool,
|
|
32
42
|
'unbanChatMember' => Types::Bool,
|
|
33
43
|
'restrictChatMember' => Types::Bool,
|
|
34
44
|
'promoteChatMember' => Types::Bool,
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
45
|
+
'setChatAdministratorCustomTitle' => Types::Bool,
|
|
46
|
+
'setChatMemberTag' => Types::Bool,
|
|
47
|
+
'banChatSenderChat' => Types::Bool,
|
|
48
|
+
'unbanChatSenderChat' => Types::Bool,
|
|
49
|
+
'setChatPermissions' => Types::Bool,
|
|
38
50
|
'exportChatInviteLink' => Types::String,
|
|
51
|
+
'createChatInviteLink' => Types::ChatInviteLink,
|
|
52
|
+
'editChatInviteLink' => Types::ChatInviteLink,
|
|
53
|
+
'createChatSubscriptionInviteLink' => Types::ChatInviteLink,
|
|
54
|
+
'editChatSubscriptionInviteLink' => Types::ChatInviteLink,
|
|
55
|
+
'revokeChatInviteLink' => Types::ChatInviteLink,
|
|
56
|
+
'approveChatJoinRequest' => Types::Bool,
|
|
57
|
+
'declineChatJoinRequest' => Types::Bool,
|
|
39
58
|
'setChatPhoto' => Types::Bool,
|
|
40
59
|
'deleteChatPhoto' => Types::Bool,
|
|
41
60
|
'setChatTitle' => Types::Bool,
|
|
42
61
|
'setChatDescription' => Types::Bool,
|
|
43
62
|
'pinChatMessage' => Types::Bool,
|
|
44
63
|
'unpinChatMessage' => Types::Bool,
|
|
45
|
-
'
|
|
64
|
+
'unpinAllChatMessages' => Types::Bool,
|
|
65
|
+
'leaveChat' => Types::Bool,
|
|
66
|
+
'getChat' => Types::ChatFullInfo,
|
|
67
|
+
'getChatAdministrators' => Types::Array.of(Types::ChatMember),
|
|
68
|
+
'getChatMemberCount' => Types::Integer,
|
|
46
69
|
'getChatMember' => Types::ChatMember,
|
|
47
70
|
'setChatStickerSet' => Types::Bool,
|
|
48
71
|
'deleteChatStickerSet' => Types::Bool,
|
|
72
|
+
'getForumTopicIconStickers' => Types::Array.of(Types::Sticker),
|
|
73
|
+
'createForumTopic' => Types::ForumTopic,
|
|
74
|
+
'editForumTopic' => Types::Bool,
|
|
75
|
+
'closeForumTopic' => Types::Bool,
|
|
76
|
+
'reopenForumTopic' => Types::Bool,
|
|
77
|
+
'deleteForumTopic' => Types::Bool,
|
|
78
|
+
'unpinAllForumTopicMessages' => Types::Bool,
|
|
79
|
+
'editGeneralForumTopic' => Types::Bool,
|
|
80
|
+
'closeGeneralForumTopic' => Types::Bool,
|
|
81
|
+
'reopenGeneralForumTopic' => Types::Bool,
|
|
82
|
+
'hideGeneralForumTopic' => Types::Bool,
|
|
83
|
+
'unhideGeneralForumTopic' => Types::Bool,
|
|
84
|
+
'unpinAllGeneralForumTopicMessages' => Types::Bool,
|
|
49
85
|
'answerCallbackQuery' => Types::Bool,
|
|
50
86
|
'getUserChatBoosts' => Types::UserChatBoosts,
|
|
87
|
+
'getBusinessConnection' => Types::BusinessConnection,
|
|
88
|
+
'setMyCommands' => Types::Bool,
|
|
89
|
+
'deleteMyCommands' => Types::Bool,
|
|
90
|
+
'getMyCommands' => Types::Array.of(Types::BotCommand),
|
|
91
|
+
'setMyName' => Types::Bool,
|
|
92
|
+
'getMyName' => Types::BotName,
|
|
93
|
+
'setMyDescription' => Types::Bool,
|
|
94
|
+
'getMyDescription' => Types::BotDescription,
|
|
95
|
+
'setMyShortDescription' => Types::Bool,
|
|
96
|
+
'getMyShortDescription' => Types::BotShortDescription,
|
|
97
|
+
'setMyProfilePhoto' => Types::Bool,
|
|
98
|
+
'removeMyProfilePhoto' => Types::Bool,
|
|
99
|
+
'setChatMenuButton' => Types::Bool,
|
|
100
|
+
'getChatMenuButton' => Types::MenuButton,
|
|
101
|
+
'setMyDefaultAdministratorRights' => Types::Bool,
|
|
102
|
+
'getMyDefaultAdministratorRights' => Types::ChatAdministratorRights,
|
|
103
|
+
'getAvailableGifts' => Types::Gifts,
|
|
104
|
+
'sendGift' => Types::Bool,
|
|
105
|
+
'giftPremiumSubscription' => Types::Bool,
|
|
106
|
+
'verifyUser' => Types::Bool,
|
|
107
|
+
'verifyChat' => Types::Bool,
|
|
108
|
+
'removeUserVerification' => Types::Bool,
|
|
109
|
+
'removeChatVerification' => Types::Bool,
|
|
110
|
+
'readBusinessMessage' => Types::Bool,
|
|
111
|
+
'deleteBusinessMessages' => Types::Bool,
|
|
112
|
+
'setBusinessAccountName' => Types::Bool,
|
|
113
|
+
'setBusinessAccountUsername' => Types::Bool,
|
|
114
|
+
'setBusinessAccountBio' => Types::Bool,
|
|
115
|
+
'setBusinessAccountProfilePhoto' => Types::Bool,
|
|
116
|
+
'removeBusinessAccountProfilePhoto' => Types::Bool,
|
|
117
|
+
'setBusinessAccountGiftSettings' => Types::Bool,
|
|
118
|
+
'getBusinessAccountStarBalance' => Types::StarAmount,
|
|
119
|
+
'transferBusinessAccountStars' => Types::Bool,
|
|
120
|
+
'getBusinessAccountGifts' => Types::OwnedGifts,
|
|
121
|
+
'getUserGifts' => Types::OwnedGifts,
|
|
122
|
+
'getChatGifts' => Types::OwnedGifts,
|
|
123
|
+
'convertGiftToStars' => Types::Bool,
|
|
124
|
+
'upgradeGift' => Types::Bool,
|
|
125
|
+
'transferGift' => Types::Bool,
|
|
126
|
+
'postStory' => Types::Story,
|
|
127
|
+
'repostStory' => Types::Story,
|
|
128
|
+
'editStory' => Types::Story,
|
|
129
|
+
'deleteStory' => Types::Bool,
|
|
51
130
|
'editMessageText' => Types::Message | Types::Bool,
|
|
52
131
|
'editMessageCaption' => Types::Message | Types::Bool,
|
|
132
|
+
'editMessageMedia' => Types::Message | Types::Bool,
|
|
133
|
+
'editMessageLiveLocation' => Types::Message | Types::Bool,
|
|
134
|
+
'stopMessageLiveLocation' => Types::Message | Types::Bool,
|
|
135
|
+
'editMessageChecklist' => Types::Message,
|
|
53
136
|
'editMessageReplyMarkup' => Types::Message | Types::Bool,
|
|
137
|
+
'stopPoll' => Types::Poll,
|
|
138
|
+
'approveSuggestedPost' => Types::Bool,
|
|
139
|
+
'declineSuggestedPost' => Types::Bool,
|
|
54
140
|
'deleteMessage' => Types::Bool,
|
|
55
141
|
'deleteMessages' => Types::Bool,
|
|
56
142
|
'sendSticker' => Types::Message,
|
|
57
143
|
'getStickerSet' => Types::StickerSet,
|
|
144
|
+
'getCustomEmojiStickers' => Types::Array.of(Types::Sticker),
|
|
58
145
|
'uploadStickerFile' => Types::File,
|
|
59
146
|
'createNewStickerSet' => Types::Bool,
|
|
60
147
|
'addStickerToSet' => Types::Bool,
|
|
61
148
|
'setStickerPositionInSet' => Types::Bool,
|
|
62
149
|
'deleteStickerFromSet' => Types::Bool,
|
|
150
|
+
'replaceStickerInSet' => Types::Bool,
|
|
151
|
+
'setStickerEmojiList' => Types::Bool,
|
|
152
|
+
'setStickerKeywords' => Types::Bool,
|
|
153
|
+
'setStickerMaskPosition' => Types::Bool,
|
|
154
|
+
'setStickerSetTitle' => Types::Bool,
|
|
155
|
+
'setStickerSetThumbnail' => Types::Bool,
|
|
156
|
+
'setCustomEmojiStickerSetThumbnail' => Types::Bool,
|
|
157
|
+
'deleteStickerSet' => Types::Bool,
|
|
63
158
|
'answerInlineQuery' => Types::Bool,
|
|
159
|
+
'answerWebAppQuery' => Types::SentWebAppMessage,
|
|
160
|
+
'savePreparedInlineMessage' => Types::PreparedInlineMessage,
|
|
64
161
|
'sendInvoice' => Types::Message,
|
|
162
|
+
'createInvoiceLink' => Types::String,
|
|
65
163
|
'answerShippingQuery' => Types::Bool,
|
|
66
164
|
'answerPreCheckoutQuery' => Types::Bool,
|
|
67
|
-
'
|
|
68
|
-
'setGameScore' => Types::Message | Types::Bool,
|
|
69
|
-
'getGameHighScores' => Types::Array.of(Types::GameHighScore),
|
|
70
|
-
'setPassportDataErrors' => Types::Bool,
|
|
71
|
-
'editMessageMedia' => Types::Message | Types::Bool,
|
|
72
|
-
'sendAnimation' => Types::Message,
|
|
73
|
-
'sendPoll' => Types::Message,
|
|
74
|
-
'stopPoll' => Types::Poll,
|
|
75
|
-
'setChatPermissions' => Types::Bool,
|
|
76
|
-
'setChatAdministratorCustomTitle' => Types::Bool,
|
|
77
|
-
'sendDice' => Types::Message,
|
|
78
|
-
'getMyCommands' => Types::Array.of(Types::BotCommand),
|
|
79
|
-
'setMyCommands' => Types::Bool,
|
|
80
|
-
'deleteMyCommands' => Types::Bool,
|
|
81
|
-
'setStickerSetThumbnail' => Types::Bool,
|
|
82
|
-
'logOut' => Types::Bool,
|
|
83
|
-
'close' => Types::Bool,
|
|
84
|
-
'copyMessage' => Types::MessageId,
|
|
85
|
-
'copyMessages' => Types::Array.of(Types::MessageId),
|
|
86
|
-
'createChatInviteLink' => Types::ChatInviteLink,
|
|
87
|
-
'editChatInviteLink' => Types::ChatInviteLink,
|
|
88
|
-
'revokeChatInviteLink' => Types::ChatInviteLink,
|
|
89
|
-
'approveChatJoinRequest' => Types::Bool,
|
|
90
|
-
'declineChatJoinRequest' => Types::Bool,
|
|
91
|
-
'banChatSenderChat' => Types::Bool,
|
|
92
|
-
'unbanChatSenderChat' => Types::Bool,
|
|
93
|
-
'answerWebAppQuery' => Types::SentWebAppMessage,
|
|
94
|
-
'setChatMenuButton' => Types::Bool,
|
|
95
|
-
'getChatMenuButton' => Types::MenuButtonDefault | Types::MenuButtonCommands | Types::MenuButtonWebApp,
|
|
96
|
-
'setMyDefaultAdministratorRights' => Types::Bool,
|
|
97
|
-
'getMyDefaultAdministratorRights' => Types::ChatAdministratorRights,
|
|
98
|
-
'createInvoiceLink' => Types::String,
|
|
99
|
-
'editGeneralForumTopic' => Types::Bool,
|
|
100
|
-
'closeGeneralForumTopic' => Types::Bool,
|
|
101
|
-
'reopenGeneralForumTopic' => Types::Bool,
|
|
102
|
-
'hideGeneralForumTopic' => Types::Bool,
|
|
103
|
-
'unhideGeneralForumTopic' => Types::Bool,
|
|
104
|
-
'unpinAllGeneralForumTopicMessages' => Types::Bool,
|
|
105
|
-
'setMyName' => Types::Bool,
|
|
106
|
-
'getMyName' => Types::BotName,
|
|
107
|
-
'setMyDescription' => Types::Bool,
|
|
108
|
-
'getMyDescription' => Types::BotDescription,
|
|
109
|
-
'setMyShortDescription' => Types::Bool,
|
|
110
|
-
'getMyShortDescription' => Types::BotShortDescription,
|
|
111
|
-
'refundStarPayment' => Types::Bool,
|
|
165
|
+
'getMyStarBalance' => Types::StarAmount,
|
|
112
166
|
'getStarTransactions' => Types::StarTransactions,
|
|
113
|
-
'
|
|
114
|
-
'createChatSubscriptionInviteLink' => Types::ChatInviteLink,
|
|
115
|
-
'editChatSubscriptionInviteLink' => Types::ChatInviteLink,
|
|
116
|
-
'getAvailableGifts' => Types::Gifts,
|
|
117
|
-
'sendGift' => Types::Bool,
|
|
118
|
-
'savePreparedInlineMessage' => Types::PreparedInlineMessage,
|
|
167
|
+
'refundStarPayment' => Types::Bool,
|
|
119
168
|
'editUserStarSubscription' => Types::Bool,
|
|
120
|
-
'
|
|
121
|
-
'
|
|
122
|
-
'
|
|
123
|
-
'
|
|
124
|
-
'removeChatVerification' => Types::Bool
|
|
169
|
+
'setPassportDataErrors' => Types::Bool,
|
|
170
|
+
'sendGame' => Types::Message,
|
|
171
|
+
'setGameScore' => Types::Message | Types::Bool,
|
|
172
|
+
'getGameHighScores' => Types::Array.of(Types::GameHighScore)
|
|
125
173
|
}.freeze
|
|
126
174
|
end
|
|
127
175
|
end
|
data/lib/telegram/bot/api.rb
CHANGED
|
@@ -15,7 +15,7 @@ module Telegram
|
|
|
15
15
|
@connection ||= Faraday.new(url: url) do |faraday|
|
|
16
16
|
faraday.request :multipart
|
|
17
17
|
faraday.request :url_encoded
|
|
18
|
-
faraday
|
|
18
|
+
configure_adapter(faraday)
|
|
19
19
|
faraday.options.timeout = Telegram::Bot.configuration.connection_timeout
|
|
20
20
|
faraday.options.open_timeout = Telegram::Bot.configuration.connection_open_timeout
|
|
21
21
|
end
|
|
@@ -52,6 +52,18 @@ module Telegram
|
|
|
52
52
|
|
|
53
53
|
private
|
|
54
54
|
|
|
55
|
+
def configure_adapter(faraday)
|
|
56
|
+
if adapter_options.empty?
|
|
57
|
+
faraday.adapter Telegram::Bot.configuration.adapter
|
|
58
|
+
else
|
|
59
|
+
faraday.adapter Telegram::Bot.configuration.adapter, **adapter_options
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def adapter_options
|
|
64
|
+
Telegram::Bot.configuration.adapter_options || {}
|
|
65
|
+
end
|
|
66
|
+
|
|
55
67
|
def build_params(params)
|
|
56
68
|
params.transform_values do |value|
|
|
57
69
|
sanitize_value(value)
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
module Telegram
|
|
4
4
|
module Bot
|
|
5
5
|
class Configuration
|
|
6
|
-
attr_accessor :adapter, :connection_open_timeout, :connection_timeout
|
|
6
|
+
attr_accessor :adapter, :adapter_options, :connection_open_timeout, :connection_timeout
|
|
7
7
|
|
|
8
8
|
def initialize
|
|
9
9
|
@adapter = Faraday.default_adapter
|
|
10
|
+
@adapter_options = nil
|
|
10
11
|
@connection_open_timeout = 20
|
|
11
12
|
@connection_timeout = 20
|
|
12
13
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telegram
|
|
4
|
+
module Bot
|
|
5
|
+
module Types
|
|
6
|
+
class AcceptedGiftTypes < Base
|
|
7
|
+
attribute :unlimited_gifts, Types::Bool
|
|
8
|
+
attribute :limited_gifts, Types::Bool
|
|
9
|
+
attribute :unique_gifts, Types::Bool
|
|
10
|
+
attribute :premium_subscription, Types::Bool
|
|
11
|
+
attribute :gifts_from_channels, Types::Bool
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telegram
|
|
4
|
+
module Bot
|
|
5
|
+
module Types
|
|
6
|
+
class BusinessBotRights < Base
|
|
7
|
+
attribute? :can_reply, Types::True
|
|
8
|
+
attribute? :can_read_messages, Types::True
|
|
9
|
+
attribute? :can_delete_sent_messages, Types::True
|
|
10
|
+
attribute? :can_delete_all_messages, Types::True
|
|
11
|
+
attribute? :can_edit_name, Types::True
|
|
12
|
+
attribute? :can_edit_bio, Types::True
|
|
13
|
+
attribute? :can_edit_profile_photo, Types::True
|
|
14
|
+
attribute? :can_edit_username, Types::True
|
|
15
|
+
attribute? :can_change_gift_settings, Types::True
|
|
16
|
+
attribute? :can_view_gifts_and_stars, Types::True
|
|
17
|
+
attribute? :can_convert_gifts_to_stars, Types::True
|
|
18
|
+
attribute? :can_transfer_and_upgrade_gifts, Types::True
|
|
19
|
+
attribute? :can_transfer_stars, Types::True
|
|
20
|
+
attribute? :can_manage_stories, Types::True
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -19,6 +19,8 @@ module Telegram
|
|
|
19
19
|
attribute? :can_edit_messages, Types::Bool
|
|
20
20
|
attribute? :can_pin_messages, Types::Bool
|
|
21
21
|
attribute? :can_manage_topics, Types::Bool
|
|
22
|
+
attribute? :can_manage_direct_messages, Types::Bool
|
|
23
|
+
attribute? :can_manage_tags, Types::Bool
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -11,6 +11,7 @@ module Telegram
|
|
|
11
11
|
attribute? :first_name, Types::String
|
|
12
12
|
attribute? :last_name, Types::String
|
|
13
13
|
attribute? :is_forum, Types::True
|
|
14
|
+
attribute? :is_direct_messages, Types::True
|
|
14
15
|
attribute :accent_color_id, Types::Integer
|
|
15
16
|
attribute :max_reaction_count, Types::Integer
|
|
16
17
|
attribute? :photo, ChatPhoto
|
|
@@ -20,6 +21,7 @@ module Telegram
|
|
|
20
21
|
attribute? :business_location, BusinessLocation
|
|
21
22
|
attribute? :business_opening_hours, BusinessOpeningHours
|
|
22
23
|
attribute? :personal_chat, Chat
|
|
24
|
+
attribute? :parent_chat, Chat
|
|
23
25
|
attribute? :available_reactions, Types::Array.of(ReactionType)
|
|
24
26
|
attribute? :background_custom_emoji_id, Types::String
|
|
25
27
|
attribute? :profile_accent_color_id, Types::Integer
|
|
@@ -35,7 +37,7 @@ module Telegram
|
|
|
35
37
|
attribute? :invite_link, Types::String
|
|
36
38
|
attribute? :pinned_message, Message
|
|
37
39
|
attribute? :permissions, ChatPermissions
|
|
38
|
-
attribute
|
|
40
|
+
attribute :accepted_gift_types, AcceptedGiftTypes
|
|
39
41
|
attribute? :can_send_paid_media, Types::True
|
|
40
42
|
attribute? :slow_mode_delay, Types::Integer
|
|
41
43
|
attribute? :unrestrict_boost_count, Types::Integer
|
|
@@ -49,6 +51,10 @@ module Telegram
|
|
|
49
51
|
attribute? :custom_emoji_sticker_set_name, Types::String
|
|
50
52
|
attribute? :linked_chat_id, Types::Integer
|
|
51
53
|
attribute? :location, ChatLocation
|
|
54
|
+
attribute? :rating, UserRating
|
|
55
|
+
attribute? :first_profile_audio, Audio
|
|
56
|
+
attribute? :unique_gift_colors, UniqueGiftColors
|
|
57
|
+
attribute? :paid_message_star_count, Types::Integer
|
|
52
58
|
end
|
|
53
59
|
end
|
|
54
60
|
end
|
|
@@ -22,6 +22,8 @@ module Telegram
|
|
|
22
22
|
attribute? :can_edit_messages, Types::Bool
|
|
23
23
|
attribute? :can_pin_messages, Types::Bool
|
|
24
24
|
attribute? :can_manage_topics, Types::Bool
|
|
25
|
+
attribute? :can_manage_direct_messages, Types::Bool
|
|
26
|
+
attribute? :can_manage_tags, Types::Bool
|
|
25
27
|
attribute? :custom_title, Types::String
|
|
26
28
|
end
|
|
27
29
|
end
|