telegram-bot-ruby 0.18.0 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -3
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/Rakefile +3 -1
- data/examples/bot.rb +2 -0
- data/lib/telegram/bot/api.rb +10 -4
- data/lib/telegram/bot/client.rb +4 -3
- data/lib/telegram/bot/configuration.rb +5 -1
- data/lib/telegram/bot/exceptions/base.rb +2 -0
- data/lib/telegram/bot/exceptions/response_error.rb +3 -0
- data/lib/telegram/bot/exceptions.rb +2 -0
- data/lib/telegram/bot/null_logger.rb +3 -1
- data/lib/telegram/bot/types/animation.rb +2 -0
- data/lib/telegram/bot/types/audio.rb +2 -0
- data/lib/telegram/bot/types/base.rb +2 -0
- data/lib/telegram/bot/types/bot_command.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_chat.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_chat_member.rb +2 -0
- data/lib/telegram/bot/types/bot_command_scope_default.rb +2 -0
- data/lib/telegram/bot/types/callback_game.rb +2 -0
- data/lib/telegram/bot/types/callback_query.rb +2 -0
- data/lib/telegram/bot/types/chat.rb +2 -0
- data/lib/telegram/bot/types/chat_administrator_rights.rb +21 -0
- data/lib/telegram/bot/types/chat_invite_link.rb +2 -0
- data/lib/telegram/bot/types/chat_join_request.rb +2 -0
- data/lib/telegram/bot/types/chat_location.rb +2 -0
- data/lib/telegram/bot/types/chat_member.rb +3 -1
- data/lib/telegram/bot/types/chat_member_updated.rb +2 -0
- data/lib/telegram/bot/types/chat_permissions.rb +2 -0
- data/lib/telegram/bot/types/chat_photo.rb +2 -0
- data/lib/telegram/bot/types/chosen_inline_result.rb +2 -0
- data/lib/telegram/bot/types/compactable.rb +4 -2
- data/lib/telegram/bot/types/contact.rb +2 -0
- data/lib/telegram/bot/types/dice.rb +2 -0
- data/lib/telegram/bot/types/document.rb +2 -0
- data/lib/telegram/bot/types/encrypted_credentials.rb +2 -0
- data/lib/telegram/bot/types/encrypted_passport_element.rb +2 -0
- data/lib/telegram/bot/types/file.rb +2 -0
- data/lib/telegram/bot/types/force_reply.rb +2 -0
- data/lib/telegram/bot/types/game.rb +2 -0
- data/lib/telegram/bot/types/game_high_score.rb +2 -0
- data/lib/telegram/bot/types/inline_keyboard_button.rb +4 -1
- data/lib/telegram/bot/types/inline_keyboard_markup.rb +2 -0
- data/lib/telegram/bot/types/inline_query.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_article.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_audio.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_audio.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_document.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_gif.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_photo.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_sticker.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_video.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_cached_voice.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_contact.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_document.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_game.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_gif.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_location.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_photo.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_venue.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_video.rb +2 -0
- data/lib/telegram/bot/types/inline_query_result_voice.rb +2 -0
- data/lib/telegram/bot/types/input_contact_message_content.rb +2 -0
- data/lib/telegram/bot/types/input_invoice_message_content.rb +2 -0
- data/lib/telegram/bot/types/input_location_message_content.rb +2 -0
- data/lib/telegram/bot/types/input_media_animation.rb +2 -0
- data/lib/telegram/bot/types/input_media_audio.rb +2 -0
- data/lib/telegram/bot/types/input_media_document.rb +2 -0
- data/lib/telegram/bot/types/input_media_photo.rb +2 -0
- data/lib/telegram/bot/types/input_media_video.rb +2 -0
- data/lib/telegram/bot/types/input_message_content.rb +2 -0
- data/lib/telegram/bot/types/input_text_message_content.rb +2 -0
- data/lib/telegram/bot/types/input_venue_message_content.rb +2 -0
- data/lib/telegram/bot/types/invoice.rb +2 -0
- data/lib/telegram/bot/types/keyboard_button.rb +3 -0
- data/lib/telegram/bot/types/keyboard_button_poll_type.rb +2 -0
- data/lib/telegram/bot/types/labeled_price.rb +2 -0
- data/lib/telegram/bot/types/location.rb +2 -0
- data/lib/telegram/bot/types/login_url.rb +2 -0
- data/lib/telegram/bot/types/mask_position.rb +2 -0
- data/lib/telegram/bot/types/menu_button_commands.rb +11 -0
- data/lib/telegram/bot/types/menu_button_default.rb +11 -0
- data/lib/telegram/bot/types/menu_button_web_app.rb +13 -0
- data/lib/telegram/bot/types/message.rb +7 -4
- data/lib/telegram/bot/types/message_auto_delete_timer_changed.rb +2 -0
- data/lib/telegram/bot/types/message_entity.rb +2 -0
- data/lib/telegram/bot/types/order_info.rb +2 -0
- data/lib/telegram/bot/types/passport_data.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_data_field.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_file.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_files.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_front_side.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_reverse_side.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_selfie.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_translation_file.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_translation_files.rb +2 -0
- data/lib/telegram/bot/types/passport_element_error_unspecified.rb +2 -0
- data/lib/telegram/bot/types/passport_file.rb +2 -0
- data/lib/telegram/bot/types/pattern_matching.rb +2 -0
- data/lib/telegram/bot/types/photo_size.rb +2 -0
- data/lib/telegram/bot/types/poll.rb +2 -0
- data/lib/telegram/bot/types/poll_answer.rb +2 -0
- data/lib/telegram/bot/types/poll_option.rb +2 -0
- data/lib/telegram/bot/types/pre_checkout_query.rb +2 -0
- data/lib/telegram/bot/types/proximity_alert_triggered.rb +2 -0
- data/lib/telegram/bot/types/reply_keyboard_markup.rb +2 -0
- data/lib/telegram/bot/types/reply_keyboard_remove.rb +2 -0
- data/lib/telegram/bot/types/sent_web_app_message.rb +11 -0
- data/lib/telegram/bot/types/shipping_address.rb +2 -0
- data/lib/telegram/bot/types/shipping_option.rb +2 -0
- data/lib/telegram/bot/types/shipping_query.rb +2 -0
- data/lib/telegram/bot/types/sticker.rb +2 -0
- data/lib/telegram/bot/types/sticker_set.rb +2 -0
- data/lib/telegram/bot/types/successful_payment.rb +2 -0
- data/lib/telegram/bot/types/update.rb +2 -0
- data/lib/telegram/bot/types/user.rb +2 -0
- data/lib/telegram/bot/types/user_profile_photos.rb +2 -0
- data/lib/telegram/bot/types/venue.rb +2 -0
- data/lib/telegram/bot/types/video.rb +2 -0
- data/lib/telegram/bot/types/{voice_chat_ended.rb → video_chat_ended.rb} +3 -1
- data/lib/telegram/bot/types/{voice_chat_participants_invited.rb → video_chat_participants_invited.rb} +3 -1
- data/lib/telegram/bot/types/{voice_chat_scheduled.rb → video_chat_scheduled.rb} +3 -1
- data/lib/telegram/bot/types/{voice_chat_started.rb → video_chat_started.rb} +3 -1
- data/lib/telegram/bot/types/video_note.rb +2 -0
- data/lib/telegram/bot/types/voice.rb +2 -0
- data/lib/telegram/bot/types/web_app_data.rb +12 -0
- data/lib/telegram/bot/types/web_app_info.rb +11 -0
- data/lib/telegram/bot/types/webhook_info.rb +3 -1
- data/lib/telegram/bot/types.rb +13 -4
- data/lib/telegram/bot/version.rb +3 -1
- data/lib/telegram/bot.rb +2 -0
- data/telegram-bot-ruby.gemspec +8 -5
- metadata +43 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9970580930d293b15526952759b73e37053fe951d6156dd59db5ea656e12b6e
|
4
|
+
data.tar.gz: a3ef5ee45d4a99bfcd15c467dc578e102d0c7ed6889e7bd1e7babe5149c3fac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fad84ade7546e3556266307630c4091d6f45f7aa6f9587db45e8cff9d924dc420d481832bee6b508499487e2f33693f72ddbb47b5610401aea85cf0bc8474c46
|
7
|
+
data.tar.gz: 1d47cdfdaa414c72bb3d678ba780f59531d7a2c2248219fc6a94d36a5e99b25a91db23ec273222cb7affece8df73669edad71dead347b910f9b25367e6222500
|
data/.rubocop.yml
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
---
|
2
|
-
require:
|
2
|
+
require:
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
NewCops: enable
|
3
8
|
|
4
9
|
Style/Documentation:
|
5
10
|
Enabled: false
|
6
11
|
|
7
12
|
Metrics/BlockLength:
|
8
|
-
|
13
|
+
IgnoredMethods:
|
9
14
|
- context
|
10
15
|
- describe
|
11
16
|
|
12
|
-
|
17
|
+
Layout/LineLength:
|
13
18
|
Max: 120
|
14
19
|
Exclude:
|
15
20
|
- telegram-bot-ruby.gemspec
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'bundler/setup'
|
3
5
|
require 'rubocop/rake_task'
|
@@ -6,7 +8,7 @@ require 'rspec/core/rake_task'
|
|
6
8
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
7
9
|
task.fail_on_error = false
|
8
10
|
task.options = %w[--force-exclusion]
|
9
|
-
task.patterns = %w[lib/**/*.rb]
|
11
|
+
task.patterns = %w[{lib,spec}/**/*.rb Rakefile]
|
10
12
|
task.requires << 'rubocop-rspec'
|
11
13
|
end
|
12
14
|
|
data/examples/bot.rb
CHANGED
data/lib/telegram/bot/api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
class Api
|
@@ -22,7 +24,9 @@ module Telegram
|
|
22
24
|
deleteMyCommands setStickerSetThumb logOut close copyMessage
|
23
25
|
createChatInviteLink editChatInviteLink revokeChatInviteLink
|
24
26
|
approveChatJoinRequest declineChatJoinRequest banChatSenderChat
|
25
|
-
unbanChatSenderChat
|
27
|
+
unbanChatSenderChat answerWebAppQuery setChatMenuButton
|
28
|
+
getChatMenuButton setMyDefaultAdministratorRights
|
29
|
+
getMyDefaultAdministratorRights
|
26
30
|
].freeze
|
27
31
|
|
28
32
|
attr_reader :token, :url
|
@@ -59,9 +63,9 @@ module Telegram
|
|
59
63
|
|
60
64
|
private
|
61
65
|
|
62
|
-
def build_params(
|
63
|
-
|
64
|
-
|
66
|
+
def build_params(params)
|
67
|
+
params.transform_values do |value|
|
68
|
+
sanitize_value(value)
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
@@ -88,6 +92,8 @@ module Telegram
|
|
88
92
|
faraday.request :multipart
|
89
93
|
faraday.request :url_encoded
|
90
94
|
faraday.adapter Telegram::Bot.configuration.adapter
|
95
|
+
faraday.options.timeout = Telegram::Bot.configuration.timeout
|
96
|
+
faraday.options.open_timeout = Telegram::Bot.configuration.open_timeout
|
91
97
|
end
|
92
98
|
end
|
93
99
|
end
|
data/lib/telegram/bot/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
class Client
|
@@ -33,7 +35,7 @@ module Telegram
|
|
33
35
|
response['result'].each do |data|
|
34
36
|
yield handle_update(Types::Update.new(data))
|
35
37
|
end
|
36
|
-
rescue Faraday::TimeoutError
|
38
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed
|
37
39
|
retry
|
38
40
|
end
|
39
41
|
|
@@ -50,7 +52,6 @@ module Telegram
|
|
50
52
|
def default_options
|
51
53
|
{
|
52
54
|
offset: 0,
|
53
|
-
timeout: 20,
|
54
55
|
logger: NullLogger.new,
|
55
56
|
url: 'https://api.telegram.org'
|
56
57
|
}
|
@@ -59,7 +60,7 @@ module Telegram
|
|
59
60
|
def log_incoming_message(message)
|
60
61
|
uid = message.respond_to?(:from) && message.from ? message.from.id : nil
|
61
62
|
logger.info(
|
62
|
-
format('Incoming message: text="
|
63
|
+
format('Incoming message: text="%<message>s" uid=%<uid>s', message: message, uid: uid)
|
63
64
|
)
|
64
65
|
end
|
65
66
|
end
|
@@ -1,10 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
class Configuration
|
4
|
-
attr_accessor :adapter
|
6
|
+
attr_accessor :adapter, :open_timeout, :timeout
|
5
7
|
|
6
8
|
def initialize
|
7
9
|
@adapter = Faraday.default_adapter
|
10
|
+
@open_timeout = 20
|
11
|
+
@timeout = 20
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Telegram
|
4
|
+
module Bot
|
5
|
+
module Types
|
6
|
+
class ChatAdministratorRight < Base
|
7
|
+
attribute :is_anonymous, Boolean
|
8
|
+
attribute :can_manage_chat, Boolean
|
9
|
+
attribute :can_delete_messages, Boolean
|
10
|
+
attribute :can_manage_video_chats, Boolean
|
11
|
+
attribute :can_restrict_members, Boolean
|
12
|
+
attribute :can_promote_members, Boolean
|
13
|
+
attribute :can_change_info, Boolean
|
14
|
+
attribute :can_invite_users, Boolean
|
15
|
+
attribute :can_post_messages, Boolean
|
16
|
+
attribute :can_edit_messages, Boolean
|
17
|
+
attribute :can_pin_messages, Boolean
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
module Types
|
@@ -11,7 +13,7 @@ module Telegram
|
|
11
13
|
attribute :can_post_messages, Boolean
|
12
14
|
attribute :can_edit_messages, Boolean
|
13
15
|
attribute :can_delete_messages, Boolean
|
14
|
-
attribute :
|
16
|
+
attribute :can_manage_video_chats, Boolean
|
15
17
|
attribute :can_restrict_members, Boolean
|
16
18
|
attribute :can_promote_members, Boolean
|
17
19
|
attribute :can_change_info, Boolean
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
module Types
|
4
6
|
module Compactable
|
5
7
|
def to_compact_hash
|
6
|
-
|
8
|
+
attributes.dup.delete_if { |_, v| v.nil? }.map do |key, value|
|
7
9
|
value =
|
8
10
|
if value.respond_to?(:to_compact_hash)
|
9
11
|
value.to_compact_hash
|
@@ -12,7 +14,7 @@ module Telegram
|
|
12
14
|
end
|
13
15
|
|
14
16
|
[key, value]
|
15
|
-
end
|
17
|
+
end.to_h
|
16
18
|
end
|
17
19
|
|
18
20
|
def to_json(*args)
|
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
module Types
|
4
6
|
class InlineKeyboardButton < Base
|
5
7
|
attribute :text, String
|
6
8
|
attribute :url, String
|
7
|
-
attribute :login_url, LoginUrl
|
8
9
|
attribute :callback_data, String
|
10
|
+
attribute :web_app, WebAppInfo
|
11
|
+
attribute :login_url, LoginUrl
|
9
12
|
attribute :switch_inline_query, String
|
10
13
|
attribute :switch_inline_query_current_chat, String
|
11
14
|
attribute :callback_game, CallbackGame
|