teleruby 1.5.1 → 1.5.4
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/LICENSE.md +9 -0
- data/README.md +398 -0
- data/lib/api/all.rb +12 -0
- data/lib/api/delete_apis.rb +55 -0
- data/lib/api/get_apis.rb +162 -0
- data/lib/api/nstandard.rb +26 -0
- data/lib/api/other_apis.rb +225 -0
- data/lib/api/send_apis.rb +191 -0
- data/lib/api/set_apis.rb +130 -0
- data/lib/core_api.rb +41 -0
- data/lib/objects/all.rb +42 -0
- data/lib/objects/animation.rb +38 -0
- data/lib/objects/audio.rb +37 -0
- data/lib/objects/bot_command.rb +24 -0
- data/lib/objects/callback_query.rb +64 -0
- data/lib/objects/chat.rb +158 -0
- data/lib/objects/chat_member.rb +142 -0
- data/lib/objects/chat_permissions.rb +59 -0
- data/lib/objects/chat_photo.rb +37 -0
- data/lib/objects/chosen_inline_result.rb +43 -0
- data/lib/objects/contact.rb +37 -0
- data/lib/objects/dice.rb +21 -0
- data/lib/objects/document.rb +27 -0
- data/lib/objects/file.rb +32 -0
- data/lib/objects/game.rb +65 -0
- data/lib/objects/inline_query.rb +42 -0
- data/lib/objects/inlinekeyboardbutton.rb +59 -0
- data/lib/objects/inlinekeyboardmarkup.rb +30 -0
- data/lib/objects/location.rb +21 -0
- data/lib/objects/mask_position.rb +35 -0
- data/lib/objects/message.rb +378 -0
- data/lib/objects/message_entity.rb +93 -0
- data/lib/objects/order_info.rb +34 -0
- data/lib/objects/photo_size.rb +14 -0
- data/lib/objects/poll.rb +97 -0
- data/lib/objects/poll_answer.rb +29 -0
- data/lib/objects/poll_option.rb +22 -0
- data/lib/objects/pre_checkout_query.rb +48 -0
- data/lib/objects/same/common.rb +37 -0
- data/lib/objects/same/common_2.rb +38 -0
- data/lib/objects/shipping_address.rb +39 -0
- data/lib/objects/shipping_query.rb +32 -0
- data/lib/objects/sticker.rb +55 -0
- data/lib/objects/update.rb +174 -0
- data/lib/objects/user.rb +66 -0
- data/lib/objects/user_profile_photos.rb +35 -0
- data/lib/objects/venue.rb +40 -0
- data/lib/objects/video.rb +37 -0
- data/lib/objects/video_note.rb +48 -0
- data/lib/objects/voice.rb +20 -0
- data/lib/teleruby.rb +4 -40
- data/lib/teleruby/all_apis.rb +22 -0
- data/lib/teleruby/api/delete_apis.rb +58 -0
- data/lib/teleruby/api/get_apis.rb +172 -0
- data/lib/teleruby/api/nstandard.rb +27 -0
- data/lib/teleruby/api/other_apis.rb +241 -0
- data/lib/teleruby/api/send_apis.rb +206 -0
- data/lib/teleruby/api/set_apis.rb +137 -0
- data/lib/teleruby/core_api.rb +52 -0
- data/lib/teleruby/objects/all.rb +42 -0
- data/lib/teleruby/objects/animation.rb +40 -0
- data/lib/teleruby/objects/audio.rb +39 -0
- data/lib/teleruby/objects/bot_command.rb +24 -0
- data/lib/teleruby/objects/callback_query.rb +66 -0
- data/lib/teleruby/objects/chat.rb +164 -0
- data/lib/teleruby/objects/chat_member.rb +142 -0
- data/lib/teleruby/objects/chat_permissions.rb +59 -0
- data/lib/teleruby/objects/chat_photo.rb +37 -0
- data/lib/teleruby/objects/chosen_inline_result.rb +45 -0
- data/lib/teleruby/objects/contact.rb +37 -0
- data/lib/teleruby/objects/dice.rb +21 -0
- data/lib/teleruby/objects/document.rb +29 -0
- data/lib/teleruby/objects/file.rb +32 -0
- data/lib/teleruby/objects/game.rb +65 -0
- data/lib/teleruby/objects/inline_query.rb +44 -0
- data/lib/teleruby/objects/inlinekeyboardbutton.rb +59 -0
- data/lib/teleruby/objects/inlinekeyboardmarkup.rb +31 -0
- data/lib/teleruby/objects/location.rb +21 -0
- data/lib/teleruby/objects/mask_position.rb +35 -0
- data/lib/teleruby/objects/message.rb +400 -0
- data/lib/teleruby/objects/message_entity.rb +95 -0
- data/lib/teleruby/objects/order_info.rb +36 -0
- data/lib/teleruby/objects/photo_size.rb +14 -0
- data/lib/teleruby/objects/poll.rb +97 -0
- data/lib/teleruby/objects/poll_answer.rb +29 -0
- data/lib/teleruby/objects/poll_option.rb +22 -0
- data/lib/teleruby/objects/pre_checkout_query.rb +50 -0
- data/lib/teleruby/objects/same/common.rb +31 -0
- data/lib/teleruby/objects/same/common_2.rb +32 -0
- data/lib/teleruby/objects/shipping_address.rb +39 -0
- data/lib/teleruby/objects/shipping_query.rb +32 -0
- data/lib/teleruby/objects/sticker.rb +59 -0
- data/lib/teleruby/objects/update.rb +207 -0
- data/lib/teleruby/objects/user.rb +66 -0
- data/lib/teleruby/objects/user_profile_photos.rb +36 -0
- data/lib/teleruby/objects/venue.rb +40 -0
- data/lib/teleruby/objects/video.rb +39 -0
- data/lib/teleruby/objects/video_note.rb +50 -0
- data/lib/teleruby/objects/voice.rb +20 -0
- data/lib/teleruby/version.rb +3 -0
- data/msg.png +0 -0
- data/rdoc.png +0 -0
- data/teleruby.gemspec +9 -7
- metadata +109 -6
@@ -0,0 +1,206 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../core_api'
|
5
|
+
|
6
|
+
# Solomon Boloshe(Lee Crey)
|
7
|
+
# Friday, August 21 2020 05:35:05 PM +0300
|
8
|
+
|
9
|
+
module Telegram
|
10
|
+
module SendApis # rubocop:disable Metrics/ModuleLength
|
11
|
+
##
|
12
|
+
# Use this method to send text messages.
|
13
|
+
def send_message(chat_id, text, params = {})
|
14
|
+
hash = { chat_id: chat_id, text: text }.merge!(params)
|
15
|
+
response = post('sendMessage', hash)
|
16
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
17
|
+
fail FatalError, response.description
|
18
|
+
end
|
19
|
+
Message.new(response.result)
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# Use this method to send photos.
|
24
|
+
def send_photo(chat_id, photo, params = {})
|
25
|
+
hash = { chat_id: chat_id, photo: photo }.merge!(params)
|
26
|
+
response = post('sendPhoto', hash)
|
27
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
28
|
+
fail FatalError, response.description
|
29
|
+
end
|
30
|
+
Message.new(response.result)
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Use this method to send audio files.
|
35
|
+
def send_audio(chat_id, audio, params = {})
|
36
|
+
hash = { chat_id: chat_id, audio: audio }.merge!(params)
|
37
|
+
response = post('sendAudio', hash)
|
38
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
39
|
+
fail FatalError, response.description
|
40
|
+
end
|
41
|
+
Message.new(response.result)
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Use this method to send general files.
|
46
|
+
def send_document(chat_id, document, params = {})
|
47
|
+
hash = { chat_id: chat_id, document: document }.merge!(params)
|
48
|
+
response = post('sendDocument', hash)
|
49
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
50
|
+
fail FatalError, response.description
|
51
|
+
end
|
52
|
+
Message.new(response.result)
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Use this method to send video files, Telegram clients support
|
57
|
+
# mp4 videos (other formats may be sent as Document).
|
58
|
+
def send_video(chat_id, video, params = {})
|
59
|
+
hash = { chat_id: chat_id, video: video }.merge!(params)
|
60
|
+
response = post('sendVideo', hash)
|
61
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
62
|
+
fail FatalError, response.description
|
63
|
+
end
|
64
|
+
Message.new(response.result)
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Use this method to send animation files (GIF or H.264/MPEG-4
|
69
|
+
# AVC video without sound).
|
70
|
+
def send_animation(chat_id, animation, params = {})
|
71
|
+
hash = { chat_id: chat_id, animation: animation }.merge!(params)
|
72
|
+
response = post('sendAnimation', hash)
|
73
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
74
|
+
fail FatalError, response.description
|
75
|
+
end
|
76
|
+
Message.new(response.result)
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Use this method to send voice file
|
81
|
+
def send_voice(chat_id, voice, params = {})
|
82
|
+
hash = { chat_id: chat_id, voice: voice }.merge!(params)
|
83
|
+
response = post('sendVoice', hash)
|
84
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
85
|
+
fail FatalError, response.description
|
86
|
+
end
|
87
|
+
Message.new(response.result)
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Use this methods to send video note file
|
92
|
+
def send_video_note(chat_id, video_note, params = {})
|
93
|
+
hash = { chat_id: chat_id, video_note: video_note }.merge!(params)
|
94
|
+
response = post('sendVideoNote', hash)
|
95
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
96
|
+
fail FatalError, response.description
|
97
|
+
end
|
98
|
+
Message.new(response.result)
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Use this method to send a group of photos or videos as an album.
|
103
|
+
def send_media_group(chat_id, media, params = {})
|
104
|
+
hash = { chat_id: chat_id, media: media }.merge!(params)
|
105
|
+
response = post('sendMediaGroup', hash)
|
106
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
107
|
+
fail FatalError, response.description
|
108
|
+
end
|
109
|
+
Message.new(response.result)
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Use this method to send point on the map.
|
114
|
+
def send_location(chat_id, latitude, longitude, params = {})
|
115
|
+
hash = { chat_id: chat_id, latitude: latitude, longitude: longitude}
|
116
|
+
hash.merge!(params)
|
117
|
+
response = post('sendLocation', hash)
|
118
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
119
|
+
fail FatalError, response.description
|
120
|
+
end
|
121
|
+
Message.new(response.result)
|
122
|
+
end
|
123
|
+
|
124
|
+
##
|
125
|
+
# Use this method to send information about a venue.
|
126
|
+
def send_venue(chat_id, latitude, longitude, title, address, params = {})
|
127
|
+
hash = { chat_id: chat_id, latitude: latitude, longitude: longitude }
|
128
|
+
hash2 = { title: title, address: address}.merge!(params)
|
129
|
+
hash.merge!(hash2)
|
130
|
+
response = post('sendVenue', hash)
|
131
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
132
|
+
throw FatalError, response.description
|
133
|
+
end
|
134
|
+
Message.new(response.result)
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Use this method to send phone contacts.
|
139
|
+
def send_contact(chat_id, phone_number, first_name, params = {})
|
140
|
+
hash = { chat_id: chat_id, phone_number: phone_number }
|
141
|
+
hash2 = { first_name: first_name }.merge!(params)
|
142
|
+
hash.merge!(hash2)
|
143
|
+
response = post('sendContact', hash)
|
144
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
145
|
+
fail FatalError, response.description
|
146
|
+
end
|
147
|
+
Message.new(response.result)
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# Use this method to send a native poll.
|
152
|
+
def send_poll(chat_id, question, options, params = {})
|
153
|
+
hash = { chat_id: chat_id, question: question }
|
154
|
+
hash2 = { options: options }.merge!(params)
|
155
|
+
hash.merge!(hash2)
|
156
|
+
response = post('sendPoll', hash)
|
157
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
158
|
+
fail FatalError, response.description
|
159
|
+
end
|
160
|
+
Message.new(response.result)
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Use this method to send an animated emoji that will display a
|
165
|
+
# random value.
|
166
|
+
def send_dice(chat_id, params = {})
|
167
|
+
hash = { chat_id: chat_id}.merge!(params)
|
168
|
+
response = post('sendDice', hash)
|
169
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
170
|
+
fail FatalError, response.description
|
171
|
+
end
|
172
|
+
Message.new(response.description)
|
173
|
+
end
|
174
|
+
|
175
|
+
##
|
176
|
+
# Use this methods to send chat actions
|
177
|
+
# actions may be typing upload_photo record_video upload_video
|
178
|
+
# upload_audio upload_document find_location record_video_note
|
179
|
+
# upload_video_note
|
180
|
+
def send_chat_action(chat_id, action) # rubocop:disable: Metrics/MethodLength
|
181
|
+
actions = %w{ typing upload_photo record_video upload_video
|
182
|
+
upload_audio upload_document find_location record_video_note
|
183
|
+
upload_video_note }
|
184
|
+
unless actions.include? action # rubocop:disable Style/IfUnlessModifier
|
185
|
+
throw Error, 'invalid chat action'
|
186
|
+
end
|
187
|
+
hash = { chat_id: chat_id, action: action }
|
188
|
+
response = post('sendChatAction', hash)
|
189
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
190
|
+
fail IdError, 'incorrect chat id'
|
191
|
+
end
|
192
|
+
response.result
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Use this method to send sticker file
|
197
|
+
def send_sticker(chat_id, file, params = {})
|
198
|
+
hash = { chat_id: chat_id, sticker: file }.merge!(params)
|
199
|
+
response = post('sendSticker', hash)
|
200
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
201
|
+
fail FatalError, response.description
|
202
|
+
end
|
203
|
+
Message.new(response.result)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../core_api'
|
5
|
+
|
6
|
+
##
|
7
|
+
# Solomon Boloshe(Lee Crey)
|
8
|
+
# Friday, August 21 2020 06:35:33 PM +0300
|
9
|
+
|
10
|
+
module Telegram
|
11
|
+
module SetApis # rubocop:disable Metrics/ModuleLength
|
12
|
+
##
|
13
|
+
# Use this method to set a custom title for an administrator
|
14
|
+
# in a supergroup promoted by the bot.
|
15
|
+
def set_cutom_title(chat_id, user_id, title)
|
16
|
+
if chat_id.to_i.negative?
|
17
|
+
fail BadRequestError, 'can\' set custom title for private chat'
|
18
|
+
end
|
19
|
+
hash = { chat_id: chat_id, user_id: user_id, custom_title: title }
|
20
|
+
response = post('setChatAdministratorCustomTitle', hash)
|
21
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
22
|
+
fail PermissionError, response.description
|
23
|
+
end
|
24
|
+
response.result
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_chat_permissions(chat_id, permissions)
|
28
|
+
unless chat_id.to_i.negative?
|
29
|
+
fail BadRequestError, 'can\' set permissions for private chat'
|
30
|
+
end
|
31
|
+
hash = { chat_id: chat_id, permissions: permissions }
|
32
|
+
response = post('setChatPermissions', hash)
|
33
|
+
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
34
|
+
fail PermissionError, response.description
|
35
|
+
end
|
36
|
+
response.result
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Use this method to set a new profile photo for the chat.
|
41
|
+
# Photos can't be changed for private chats.
|
42
|
+
def set_chat_photo(chat_id, file)
|
43
|
+
unless chat_id.to_i.negative?
|
44
|
+
fail BadRequestError, 'can\'t set photo for private chat'
|
45
|
+
end
|
46
|
+
hash = { chat_id: chat_id, photo: file }
|
47
|
+
data = post('setChatPhoto', hash)
|
48
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
49
|
+
fail PermissionError, data.description
|
50
|
+
end
|
51
|
+
data.result
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Use this method to change the title of a chat.
|
56
|
+
# Titles can't be changed for private chats.
|
57
|
+
def set_chat_title(chat_id, title)
|
58
|
+
unless chat_id.to_i.negative?
|
59
|
+
fail BadRequestError, 'can\'t set chat title for private'
|
60
|
+
end
|
61
|
+
|
62
|
+
hash = { chat_id: chat_id, title: title.to_s }
|
63
|
+
data = post('setChatTitle', hash)
|
64
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
65
|
+
throw PermissionError, data.description
|
66
|
+
end
|
67
|
+
|
68
|
+
data.result
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Use this method to change the description of a group,
|
73
|
+
# a supergroup or a channel.
|
74
|
+
def set_chat_description(chat_id, description)
|
75
|
+
unless chat_id.to_i.negative?
|
76
|
+
fail BadRequestError, 'can\'t set description for private chat'
|
77
|
+
end
|
78
|
+
|
79
|
+
hash = { chat_id: chat_id, description: description }
|
80
|
+
data = post('setChatDescription', hash)
|
81
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
82
|
+
fail PermissionError, data.description
|
83
|
+
end
|
84
|
+
|
85
|
+
data.result
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Use this method to set a new group sticker set for a supergroup.
|
90
|
+
def set_chat_sticker_set(chat_id, set_name)
|
91
|
+
hash = { chat_id: chat_id, set_name: set_name }
|
92
|
+
data = post('setChatStickerSet', hash)
|
93
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
94
|
+
fail StandardError, data.description
|
95
|
+
end
|
96
|
+
data.result
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Use this method to change the list of the bot's commands.
|
101
|
+
def set_my_command(command)
|
102
|
+
hash = { command: command }
|
103
|
+
data = post('setMyCommand', hash)
|
104
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
105
|
+
fail TokenError, data.description
|
106
|
+
end
|
107
|
+
data.result
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Use this method to move a sticker in a set created by the bot
|
112
|
+
# to a specific position. position must be int value
|
113
|
+
def set_sticker_position_in_the_set(sticker, position)
|
114
|
+
hash = { sticker: sticker, position: position }
|
115
|
+
data = post('setStickerPositionInTheSet', hash)
|
116
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
117
|
+
fail Error, data.description
|
118
|
+
end
|
119
|
+
data.result
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Use this method to set the thumbnail of a sticker set.
|
124
|
+
def set_sticker_set_thumb(name, user_id, params = {})
|
125
|
+
hash = { name: name, user_id: user_id }.merge!(params)
|
126
|
+
data = post('setStickerSetThumb', hash)
|
127
|
+
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
128
|
+
fail Error, data.description
|
129
|
+
end
|
130
|
+
data.result
|
131
|
+
end
|
132
|
+
|
133
|
+
def set_webhook(url, params = {})
|
134
|
+
fail NotImplementedError, 'not implemented'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'faraday'
|
6
|
+
f = true
|
7
|
+
require 'json'
|
8
|
+
j = true
|
9
|
+
rescue LoadError
|
10
|
+
puts 'some gems are not installed'
|
11
|
+
print 'should i install them?(y/n):'
|
12
|
+
ans = gets.chomp!
|
13
|
+
unless (ans.eql? 'y') or (ans.eql? 'Y')
|
14
|
+
puts 'okay bye'
|
15
|
+
exit 0
|
16
|
+
end
|
17
|
+
if !f
|
18
|
+
Gem.install 'faday'
|
19
|
+
elsif !j
|
20
|
+
Gem.install 'json'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require_relative 'objects/all'
|
25
|
+
|
26
|
+
class Hash
|
27
|
+
def method_missing(method_name)
|
28
|
+
self[method_name.to_s]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Telegram
|
33
|
+
class TGClient
|
34
|
+
@@base_uri = %q{https://api.telegram.org/bot}
|
35
|
+
@@file_uri = %q{https://api.telegram.org/file/bot}
|
36
|
+
# == Post
|
37
|
+
# method to submit data to telegram server
|
38
|
+
def post(method, params = {})
|
39
|
+
body = Faraday.post(@@base_uri + @token + '/' + method, params).body
|
40
|
+
JSON.parse(body)
|
41
|
+
end
|
42
|
+
|
43
|
+
# == Get
|
44
|
+
# method to get data from telegram server
|
45
|
+
def get(method, params = {})
|
46
|
+
body = Faraday.get(@@base_uri + @token + '/' + method, params).body
|
47
|
+
JSON.parse(body)
|
48
|
+
end
|
49
|
+
|
50
|
+
protected :post, :get
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: false
|
3
|
+
|
4
|
+
# :nodoc:
|
5
|
+
|
6
|
+
require_relative 'poll'
|
7
|
+
require_relative 'location'
|
8
|
+
require_relative 'venue'
|
9
|
+
require_relative 'chat'
|
10
|
+
require_relative 'bot_command'
|
11
|
+
require_relative 'chat_permissions'
|
12
|
+
require_relative 'chat_photo'
|
13
|
+
require_relative 'callback_query'
|
14
|
+
require_relative 'file'
|
15
|
+
require_relative 'user_profile_photos'
|
16
|
+
require_relative 'poll_answer'
|
17
|
+
require_relative 'poll_option'
|
18
|
+
require_relative 'dice'
|
19
|
+
require_relative 'contact'
|
20
|
+
require_relative 'voice'
|
21
|
+
require_relative 'video'
|
22
|
+
require_relative 'audio'
|
23
|
+
require_relative 'photo_size'
|
24
|
+
require_relative 'document'
|
25
|
+
require_relative 'video_note'
|
26
|
+
require_relative 'user'
|
27
|
+
require_relative 'message_entity'
|
28
|
+
require_relative 'chat_member'
|
29
|
+
require_relative 'update'
|
30
|
+
require_relative 'chosen_inline_result'
|
31
|
+
require_relative 'sticker'
|
32
|
+
require_relative 'game'
|
33
|
+
require_relative 'inline_query'
|
34
|
+
require_relative 'shipping_query'
|
35
|
+
require_relative 'mask_position'
|
36
|
+
require_relative 'shipping_address'
|
37
|
+
require_relative 'pre_checkout_query'
|
38
|
+
require_relative 'order_info'
|
39
|
+
require_relative 'message'
|
40
|
+
require_relative 'animation'
|
41
|
+
require_relative 'inlinekeyboardbutton'
|
42
|
+
require_relative 'inlinekeyboardmarkup'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'photo_size'
|
5
|
+
require_relative 'same/common'
|
6
|
+
|
7
|
+
##
|
8
|
+
# +Sunday+, +August+ +23+ +2020+
|
9
|
+
# ===This object represents an animation file.
|
10
|
+
# (GIF or H.264/MPEG-4 AVC video without sound).
|
11
|
+
class Animation < Common
|
12
|
+
def initialize(obj) # :nodoc:
|
13
|
+
super(obj)
|
14
|
+
freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
# Duration of the video in seconds as defined by sender.
|
18
|
+
def duration
|
19
|
+
@obj.duration
|
20
|
+
end
|
21
|
+
|
22
|
+
# +Optional+. Original animation filename as defined by sender.
|
23
|
+
def file_name
|
24
|
+
@obj.file_name
|
25
|
+
end
|
26
|
+
|
27
|
+
# +Optional.+ MIME type of the file as defined by sender.
|
28
|
+
def mime_type
|
29
|
+
@obj.mime_type
|
30
|
+
end
|
31
|
+
|
32
|
+
def thumb
|
33
|
+
data = @obj.thumb
|
34
|
+
unless data.nil?
|
35
|
+
return PhotoSize.new(data)
|
36
|
+
end
|
37
|
+
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|