teleruby 1.5.4 → 1.5.5
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 +0 -2
- data/lib/api/delete_apis.rb +6 -6
- data/lib/api/get_apis.rb +22 -16
- data/lib/api/nstandard.rb +4 -1
- data/lib/api/other_apis.rb +19 -19
- data/lib/api/send_apis.rb +17 -17
- data/lib/api/set_apis.rb +14 -15
- data/lib/core_api.rb +3 -1
- data/lib/teleruby.rb +7 -2
- data/teleruby.gemspec +1 -1
- metadata +3 -53
- data/lib/api/all.rb +0 -12
- data/lib/objects/all.rb +0 -42
- data/lib/teleruby/all_apis.rb +0 -22
- data/lib/teleruby/api/delete_apis.rb +0 -58
- data/lib/teleruby/api/get_apis.rb +0 -172
- data/lib/teleruby/api/nstandard.rb +0 -27
- data/lib/teleruby/api/other_apis.rb +0 -241
- data/lib/teleruby/api/send_apis.rb +0 -206
- data/lib/teleruby/api/set_apis.rb +0 -137
- data/lib/teleruby/core_api.rb +0 -52
- data/lib/teleruby/objects/all.rb +0 -42
- data/lib/teleruby/objects/animation.rb +0 -40
- data/lib/teleruby/objects/audio.rb +0 -39
- data/lib/teleruby/objects/bot_command.rb +0 -24
- data/lib/teleruby/objects/callback_query.rb +0 -66
- data/lib/teleruby/objects/chat.rb +0 -164
- data/lib/teleruby/objects/chat_member.rb +0 -142
- data/lib/teleruby/objects/chat_permissions.rb +0 -59
- data/lib/teleruby/objects/chat_photo.rb +0 -37
- data/lib/teleruby/objects/chosen_inline_result.rb +0 -45
- data/lib/teleruby/objects/contact.rb +0 -37
- data/lib/teleruby/objects/dice.rb +0 -21
- data/lib/teleruby/objects/document.rb +0 -29
- data/lib/teleruby/objects/file.rb +0 -32
- data/lib/teleruby/objects/game.rb +0 -65
- data/lib/teleruby/objects/inline_query.rb +0 -44
- data/lib/teleruby/objects/inlinekeyboardbutton.rb +0 -59
- data/lib/teleruby/objects/inlinekeyboardmarkup.rb +0 -31
- data/lib/teleruby/objects/location.rb +0 -21
- data/lib/teleruby/objects/mask_position.rb +0 -35
- data/lib/teleruby/objects/message.rb +0 -400
- data/lib/teleruby/objects/message_entity.rb +0 -95
- data/lib/teleruby/objects/order_info.rb +0 -36
- data/lib/teleruby/objects/photo_size.rb +0 -14
- data/lib/teleruby/objects/poll.rb +0 -97
- data/lib/teleruby/objects/poll_answer.rb +0 -29
- data/lib/teleruby/objects/poll_option.rb +0 -22
- data/lib/teleruby/objects/pre_checkout_query.rb +0 -50
- data/lib/teleruby/objects/same/common.rb +0 -31
- data/lib/teleruby/objects/same/common_2.rb +0 -32
- data/lib/teleruby/objects/shipping_address.rb +0 -39
- data/lib/teleruby/objects/shipping_query.rb +0 -32
- data/lib/teleruby/objects/sticker.rb +0 -59
- data/lib/teleruby/objects/update.rb +0 -207
- data/lib/teleruby/objects/user.rb +0 -66
- data/lib/teleruby/objects/user_profile_photos.rb +0 -36
- data/lib/teleruby/objects/venue.rb +0 -40
- data/lib/teleruby/objects/video.rb +0 -39
- data/lib/teleruby/objects/video_note.rb +0 -50
- data/lib/teleruby/objects/voice.rb +0 -20
- data/lib/teleruby/version.rb +0 -3
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'open-uri'
|
5
|
-
|
6
|
-
module Telegram
|
7
|
-
module NonStandard
|
8
|
-
def download_file(file_d, dir = Dir.pwd)
|
9
|
-
d = Dir.new(dir)
|
10
|
-
end
|
11
|
-
|
12
|
-
def download_file_from(uri, dir = Dir.pwd)
|
13
|
-
uri = URI.parse(uri)
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
# use 'markdown'
|
18
|
-
def create_user_link(name, user_id)
|
19
|
-
"[#{name}](tg://user?id=#{id})"
|
20
|
-
end
|
21
|
-
|
22
|
-
# use 'markdow' for parse_mode
|
23
|
-
def create_text_link(message, url)
|
24
|
-
"[#{message}](#{url})"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,241 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative '../core_api'
|
5
|
-
|
6
|
-
module Telegram
|
7
|
-
module OtherApis
|
8
|
-
##
|
9
|
-
# Use this method to forward messages of any kind.
|
10
|
-
def forward_message(from_chat_id, to_chat_id, message_id, params = {})
|
11
|
-
hash = { chat_id: to_chat_id, from_chat_id: from_chat_id }
|
12
|
-
hash2 = { message_id: message_id }.merge!(params)
|
13
|
-
hash.merge!(hash2)
|
14
|
-
data = post('forwardMessage', hash)
|
15
|
-
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
16
|
-
fail TelegramError, data.description
|
17
|
-
end
|
18
|
-
data.result
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# Use this method to kick a user from a group, a supergroup
|
23
|
-
# or a channel.
|
24
|
-
def kick_chat_member(chat_id, user_id, params = {})
|
25
|
-
hash = { chat_id: chat_id, user_id: user_id }.merge!(params)
|
26
|
-
data = post('kickChatMember', hash)
|
27
|
-
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
28
|
-
fail TelegramError, data.description
|
29
|
-
end
|
30
|
-
data.result
|
31
|
-
end
|
32
|
-
|
33
|
-
##
|
34
|
-
# Use this method to unban a previously kicked user in a
|
35
|
-
# supergroup or channel.
|
36
|
-
def unban_chat_member(chat_id, user_id)
|
37
|
-
hash = { chat_id: chat_id, user_id: user_id }
|
38
|
-
data = post('unbanChatMember', hash)
|
39
|
-
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
40
|
-
fail TelegramError, data.description
|
41
|
-
end
|
42
|
-
data.result
|
43
|
-
end
|
44
|
-
|
45
|
-
##
|
46
|
-
# Use this method to restrict a user in a supergroup.
|
47
|
-
def restrict_chat_member(chat_id, user_id, permissions, params = {})
|
48
|
-
hash = { chat_id: chat_id, user_id: user_id }
|
49
|
-
hash2 = { permissions: permissions }
|
50
|
-
hash.merge!(hash2)
|
51
|
-
data = post('restrictChatMember', hash)
|
52
|
-
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
53
|
-
fail TelegramError, data.description
|
54
|
-
end
|
55
|
-
data.result
|
56
|
-
end
|
57
|
-
|
58
|
-
##
|
59
|
-
# Use this method to promote or demote a user in a supergroup or
|
60
|
-
# a channel.
|
61
|
-
def promote_chat_member(chat_id, user_id, params = {})
|
62
|
-
hash = { chat_id: chat_id, user_id: user_id }.merge!(params)
|
63
|
-
data = post('promoteChatMember', hash)
|
64
|
-
unless data.ok # rubocop:disable Style/IfUnlessModifier
|
65
|
-
fail TelegramError, data.description
|
66
|
-
end
|
67
|
-
data.result
|
68
|
-
end
|
69
|
-
|
70
|
-
##
|
71
|
-
# Use this method to generate a new invite link for a chat.
|
72
|
-
def export_chat_link(chat_id)
|
73
|
-
hash = { chat_id: chat_id }
|
74
|
-
response = post('exportChatInviteLink', hash)
|
75
|
-
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
76
|
-
fail TelegramError, response.description
|
77
|
-
end
|
78
|
-
response.result
|
79
|
-
end
|
80
|
-
|
81
|
-
##
|
82
|
-
# Use this method to pin a message in a group, a supergroup,
|
83
|
-
# or a channel.
|
84
|
-
def pin_chat_message(chat_id, message_id, params = {})
|
85
|
-
hash = { chat_id: chat_id, message_id: message_id }.merge!(params)
|
86
|
-
response = post('pinChatMessage', hash)
|
87
|
-
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
88
|
-
fail SecurityError, response.description
|
89
|
-
end
|
90
|
-
response.result
|
91
|
-
end
|
92
|
-
|
93
|
-
##
|
94
|
-
# Use this method to stop a poll which was sent by the bot.
|
95
|
-
def stop_poll(chat_id, message_id, params = {})
|
96
|
-
hash = { chat_id: chat_id, message_id: message_id }.merge!(params)
|
97
|
-
response = post('stopPoll', hash)
|
98
|
-
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
99
|
-
fail Error, response.description
|
100
|
-
end
|
101
|
-
response.result
|
102
|
-
end
|
103
|
-
|
104
|
-
##
|
105
|
-
# Use this method to upload a .PNG file with a sticker for later use
|
106
|
-
# in createNewStickerSet and addStickerToSet methods
|
107
|
-
# (can be used multiple times).
|
108
|
-
def upload_sticker_file(user_id, png_sticker)
|
109
|
-
hash = { user_id: user_id, png_sticker: png_sticker }
|
110
|
-
response = post('uploadStickerFile', hash)
|
111
|
-
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
112
|
-
fail Error, response.description
|
113
|
-
end
|
114
|
-
response.result
|
115
|
-
end
|
116
|
-
|
117
|
-
##
|
118
|
-
# Use this method to create a new sticker set owned by a user.
|
119
|
-
# The bot will be able to edit the sticker set thus created.
|
120
|
-
# You must use exactly one of the fields png_sticker or tgs_sticker.
|
121
|
-
def create_new_stricker_set(user_id, name, title, params = {})
|
122
|
-
hash = { user_id: user_id, name: name, title: title }.merge!(params)
|
123
|
-
response = post('createNewStickerSet', hash)
|
124
|
-
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
125
|
-
fail Error, response.description
|
126
|
-
end
|
127
|
-
response.result
|
128
|
-
end
|
129
|
-
|
130
|
-
##
|
131
|
-
# Use this method to add a new sticker to a set created by the bot.
|
132
|
-
def add_sticker_to_set(user_id, name, emojis, params = {})
|
133
|
-
hash = { user_id: user_id, name: name, emojis: emojis }.merge!(params)
|
134
|
-
response = post('addStickerToSet', hash)
|
135
|
-
unless response.ok # rubocop:disable Style/IfUnlessModifier
|
136
|
-
throw StandardError, response.description
|
137
|
-
end
|
138
|
-
response.result
|
139
|
-
end
|
140
|
-
|
141
|
-
def edit_message_live_location
|
142
|
-
fail NotImplementedError, 'not implemented'
|
143
|
-
end
|
144
|
-
|
145
|
-
##
|
146
|
-
# Use this method to send answers to callback queries sent from inline
|
147
|
-
# keyboards. The answer will be displayed to the user as a notification
|
148
|
-
# at the top of the chat screen or as an alert. On success, True is
|
149
|
-
# returned.
|
150
|
-
def answer_callback_query(callback_query_id, params = {})
|
151
|
-
hash = { callback_query_id: callback_query_id }.merge!(params)
|
152
|
-
response = post('answerCallbackQuery', hash)
|
153
|
-
unless response.ok
|
154
|
-
raise FatalError, response.description
|
155
|
-
end
|
156
|
-
response.result
|
157
|
-
end
|
158
|
-
|
159
|
-
def delete_webhook
|
160
|
-
fail NotImplementedError, 'not support for now'
|
161
|
-
end
|
162
|
-
|
163
|
-
##
|
164
|
-
# Use this method to edit text and game messages. On success,
|
165
|
-
# if edited message is sent by the bot, the edited Message is returned,
|
166
|
-
# otherwise True is returned.
|
167
|
-
def edit_message_text(text, params = {})
|
168
|
-
hash = { text: text }.merge!(params)
|
169
|
-
response = post('editMessageText', hash)
|
170
|
-
unless response.ok
|
171
|
-
fail FatalError, response.description
|
172
|
-
end
|
173
|
-
if response.result == true
|
174
|
-
return true
|
175
|
-
end
|
176
|
-
Message.new(response.result)
|
177
|
-
end
|
178
|
-
|
179
|
-
##
|
180
|
-
# Use this method to edit captions of messages. On success, if edited
|
181
|
-
# message is sent by the bot, the edited Message is returned, otherwise
|
182
|
-
# True is returned.
|
183
|
-
def edit_message_caption(params = {})
|
184
|
-
response = post('editMessageCaption', params)
|
185
|
-
unless response.ok
|
186
|
-
fail FatalError, response.description
|
187
|
-
end
|
188
|
-
if response.result == true
|
189
|
-
return true
|
190
|
-
end
|
191
|
-
Message.new(response.result)
|
192
|
-
end
|
193
|
-
|
194
|
-
##
|
195
|
-
# Use this method to edit animation, audio, document, photo, or video
|
196
|
-
# messages. If a message is a part of a message album, then it can be
|
197
|
-
# edited only to a photo or a video. Otherwise, message type can be
|
198
|
-
# changed arbitrarily. When inline message is edited, new file can't
|
199
|
-
# be uploaded. Use previously uploaded file via its file_id or specify
|
200
|
-
# a URL. On success, if the edited message was sent by the bot, the edited
|
201
|
-
# Message is returned, otherwise True is returned.
|
202
|
-
def edit_message_media(media, params = {})
|
203
|
-
hash = { media: media }.merge!(params)
|
204
|
-
response = post('editMessageMedia', hash)
|
205
|
-
unless response.ok
|
206
|
-
fail FatalError, response.description
|
207
|
-
end
|
208
|
-
if response.result == true
|
209
|
-
return true
|
210
|
-
end
|
211
|
-
Message.new(response.result)
|
212
|
-
end
|
213
|
-
|
214
|
-
##
|
215
|
-
# Use this method to edit only the reply markup of messages.
|
216
|
-
# On success, if edited message is sent by the bot, the edited Message
|
217
|
-
# is returned, otherwise True is returned.
|
218
|
-
def edit_message_reply_markup(params = {})
|
219
|
-
response = post('editMessageReplyMarkup', params)
|
220
|
-
unless response.ok
|
221
|
-
fail FatalError, response.description
|
222
|
-
end
|
223
|
-
if response.result == true
|
224
|
-
return true
|
225
|
-
end
|
226
|
-
Message.new(response.result)
|
227
|
-
end
|
228
|
-
|
229
|
-
##
|
230
|
-
# Use this method to send answers to an inline query. On success, True
|
231
|
-
# is returned. No more than 50 results per query are allowed.
|
232
|
-
def answer_inline_query(inline_query_id, result, params = {})
|
233
|
-
hash = { inline_query_id: inline_query_id, result: result }.merge!(params)
|
234
|
-
response = post('answerInlineQuery', hash)
|
235
|
-
unless response.ok
|
236
|
-
fail FatalError, response.description
|
237
|
-
end
|
238
|
-
response.result
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
@@ -1,206 +0,0 @@
|
|
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
|