telbe 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c710a1a3419afc4a5068d6b2cdc3291451e7c7e62c309384c8d31021df3c6d74
4
- data.tar.gz: 88e578bfccddbf24fab533e920b690945d0ac8a5c6ba5a3d34d42a846846383d
3
+ metadata.gz: 499475c7a996403dfd24966de5fecf052f9acd62c7b49b334ec67b8204cf0b97
4
+ data.tar.gz: 4d88cc491dfd65af9c93bcff7413aa4e0d9e5f23859a2913aea971ed68ef30f0
5
5
  SHA512:
6
- metadata.gz: bc9b91a5a112548d353bfd80b59e546979f6b98c1d34f429637c2cbec988b1cac72f6742bf04b696985a38da9bb24d271f101cd6bb636b2de99266e3be89b414
7
- data.tar.gz: 6a0e69ac415e379108b3b880fddbd80c027387345704a471a5fcc0fcad74c5d848a0f9afa5c9e2db74c810aafaddcd385f00a81f5e3cfaa3c7b41cae9085ecf2
6
+ metadata.gz: b26ef0f8fd374b51269747433d489593c4a1b579dc1106349d8b8dae78574976c52f4b38c51756d6603a1ffd7ced442b774e2a21ca5dc8c58d98ba7213948577
7
+ data.tar.gz: 8ef7b347fddc1c797c4aa16a637797cf4b093418573da52085d82fd73a76d9aeb5b08603a4414c9699ebf658fb8c267d41b9efc536358ead84bf655ecab234bd
data/lib/telbe/base.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Telbe
2
+ class Descriptor
3
+ def self.inherited(base)
4
+ base.send(:include, SimplifyApi)
5
+ base.send(:attribute, :chat_id, Object, mandatory: true)
6
+ base.send(:attribute, :disable_notification, values: [true, false])
7
+ base.send(:attribute, :reply_to_message_id, Integer)
8
+ base.send(:attribute, :reply_markup, Object)
9
+ end
10
+ end
11
+
12
+ class MediaDescriptor < Descriptor
13
+ def self.inherited(base)
14
+ super(base)
15
+ base.send(:attribute, :caption, String)
16
+ base.send(:attribute, :parse_mode, String, values: ["Markdown", "HTML"])
17
+ end
18
+ end
19
+
20
+ class InputMedia
21
+ def self.inherited(base)
22
+ base.send(:include, SimplifyApi)
23
+ base.send(:attribute, :type, String, mandatory: true)
24
+ base.send(:attribute, :media, String, mandatory: true)
25
+ base.send(:attribute, :caption, String)
26
+ base.send(:attribute, :parse_mode, String, values: ["Markdown", "HTML"])
27
+ end
28
+ end
29
+ end
data/lib/telbe/bot.rb CHANGED
@@ -9,16 +9,13 @@ module Telbe
9
9
  end
10
10
 
11
11
  def request(action, query = {})
12
- puts "### Telbe::Bot.request #{action} - #{query.to_h}"
13
12
  path = "/bot#{@token}/#{action}"
14
13
  response = @connection.post(path: path, query: query.to_h)
15
14
  if response.status == 200
16
- puts "### Telbe::Bot.request --- Success"
17
15
  body = response.body
18
16
  data = JSON.parse(body)
19
17
  data["result"]
20
18
  else
21
- puts "### Telbe::Bot.request --- Error"
22
19
  raise ResponseError, response.body
23
20
  end
24
21
  end
@@ -27,31 +24,27 @@ module Telbe
27
24
  Message.new(request(:sendMessage, message_descriptor))
28
25
  end
29
26
 
30
- def get_updates(update_descriptor)
31
- request(:getUpdates, update_descriptor).collect do |update_hash|
32
- Update.new(update_hash)
27
+ def get_updates(get_updates_descriptor)
28
+ request(:getUpdates, get_updates_descriptor).collect do |update|
29
+ Update.new(update)
33
30
  end
34
31
  end
35
32
 
36
- def get_me
37
- User.new(request(:getMe))
38
- end
39
-
40
33
  def get_chat(chatid_descriptor)
41
34
  Chat.new(request(:getChat, chatid_descriptor))
42
35
  end
43
36
 
44
- def download_file(file)
45
- # https://api.telegram.org/file/bot<token>/<file_path>
37
+ def send_chat_action(send_chat_action_descriptor)
38
+ request(:sendChatAction, send_chat_action_descriptor)
46
39
  end
47
40
  end
48
41
 
49
42
  class MessageEntity
50
- include InitializeFromHash
43
+ include SimplifyApi
51
44
  end
52
45
 
53
46
  class ForceReply
54
- include InitializeFromHash
47
+ include SimplifyApi
55
48
  end
56
49
 
57
50
  # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -62,46 +55,154 @@ module Telbe
62
55
  # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
63
56
  # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
64
57
  class MessageDescriptor
65
- include InitializeFromHash
66
- def self.factory
67
- new(
68
- chat_id: nil,
69
- text: "",
70
- parse_mode: "", # Markdown or HTML
71
- disable_web_page_preview: false,
72
- disable_notification: false,
73
- reply_to_message_id: nil,
74
- reply_markup: nil
75
- )
76
- end
77
-
78
- def initialize(opts)
79
- raise ArgumentError, 'Invalid parse_mode' unless valid_parse_mode? opts[:parse_mode]
80
- super opts
81
- end
82
-
83
- def parse_mode= (value)
84
- value ||= "" # cast nil to the empty string
85
- raise ArgumentError, 'Invalid parse_mode' unless valid_parse_mode? value
86
- @parse_mode = value
87
- end
88
-
89
- private
90
- def valid_parse_mode? (value)
91
- value =~ /(^Markdown$)|(^HTML$)|(^$)/ # 0 = true
92
- end
58
+ include SimplifyApi
59
+ attribute :chat_id, Integer, mandatory: true
60
+ attribute :text, String, mandatory: true
61
+ attribute :parse_mode, String, values: ["Markdown", "HTML"]
62
+ attribute :disable_web_page_preview, values: [true, false]
63
+ attribute :reply_to_message_id, Integer
64
+ attribute :reply_markup , Object
93
65
  end
94
66
 
95
67
  class ChatPhoto
96
- include InitializeFromHash
68
+ include SimplifyApi
97
69
  end
98
70
 
71
+ class Message # Dummy
72
+ end
73
+
74
+ # id Integer Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
75
+ # type String Type of chat, can be either “private”, “group”, “supergroup” or “channel”
76
+ # title String Optional. Title, for supergroups, channels and group chats
77
+ # username String Optional. Username, for private chats, supergroups and channels if available
78
+ # first_name String Optional. First name of the other party in a private chat
79
+ # last_name String Optional. Last name of the other party in a private chat
80
+ # all_members_are_administrators Boolean Optional. True if a group has ‘All Members Are Admins’ enabled.
81
+ # photo ChatPhoto Optional. Chat photo. Returned only in getChat.
82
+ # description String Optional. Description, for supergroups and channel chats. Returned only in getChat.
83
+ # invite_link String Optional. Chat invite link, for supergroups and channel chats. Each administrator in a chat generates their own invite links, so the bot must first generate the link using exportChatInviteLink. Returned only in getChat.
84
+ # pinned_message Message Optional. Pinned message, for groups, supergroups and channels. Returned only in getChat.
85
+ # sticker_set_name String Optional. For supergroups, name of group sticker set. Returned only in getChat.
86
+ # can_set_sticker_set Boolean Optional. True, if the bot can change the group sticker set. Returned only in getChat.
99
87
  class Chat
100
- include InitializeFromHash
88
+ include SimplifyApi
89
+ attribute :id, Integer, mandatory: true
90
+ attribute :type, String, mandatory: true, values: ["private", "group", "supergroup", "channel"]
91
+ attribute :title, String
92
+ attribute :username, String
93
+ attribute :first_name, String
94
+ attribute :last_name, String
95
+ attribute :all_members_are_administrators, values: [true, false]
96
+ attribute :photo, ChatPhoto
97
+ attribute :description, String
98
+ attribute :invite_link, String
99
+ attribute :pinned_message, Message
100
+ attribute :sticker_set_name, String
101
+ attribute :can_set_sticker_set, values: [true, false]
102
+ end
103
+
104
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
105
+ # action String Yes Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data, record_video_note or upload_video_note for video notes.
106
+ class SendChatActionDescriptor
107
+ include SimplifyApi
108
+ attribute :chat_id, Object, mandatory: true
109
+ attribute :action, String, values: ["typing", "upload_photo", "record_video", "upload_video", "record_audio", "upload_audio", "upload_document", "find_location", "record_video_note", "upload_video_note"]
101
110
  end
102
111
 
112
+ # message_id Integer Unique message identifier inside this chat
113
+ # from User Optional. Sender, empty for messages sent to channels
114
+ # date Integer Date the message was sent in Unix time
115
+ # chat Chat Conversation the message belongs to
116
+ # forward_from User Optional. For forwarded messages, sender of the original message
117
+ # forward_from_chat Chat Optional. For messages forwarded from channels, information about the original channel
118
+ # forward_from_message_id Integer Optional. For messages forwarded from channels, identifier of the original message in the channel
119
+ # forward_signature String Optional. For messages forwarded from channels, signature of the post author if present
120
+ # forward_sender_name String Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages
121
+ # forward_date Integer Optional. For forwarded messages, date the original message was sent in Unix time
122
+ # reply_to_message Message Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
123
+ # edit_date Integer Optional. Date the message was last edited in Unix time
124
+ # media_group_id String Optional. The unique identifier of a media message group this message belongs to
125
+ # author_signature String Optional. Signature of the post author for messages in channels
126
+ # text String Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters.
127
+ # entities Array of MessageEntity Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
128
+ # caption_entities Array of MessageEntity Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
129
+ # audio Audio Optional. Message is an audio file, information about the file
130
+ # document Document Optional. Message is a general file, information about the file
131
+ # animation Animation Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
132
+ # game Game Optional. Message is a game, information about the game. More about games »
133
+ # photo Array of PhotoSize Optional. Message is a photo, available sizes of the photo
134
+ # sticker Sticker Optional. Message is a sticker, information about the sticker
135
+ # video Video Optional. Message is a video, information about the video
136
+ # voice Voice Optional. Message is a voice message, information about the file
137
+ # video_note VideoNote Optional. Message is a video note, information about the video message
138
+ # caption String Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters
139
+ # contact Contact Optional. Message is a shared contact, information about the contact
140
+ # location Location Optional. Message is a shared location, information about the location
141
+ # venue Venue Optional. Message is a venue, information about the venue
142
+ # poll Poll Optional. Message is a native poll, information about the poll
143
+ # new_chat_members Array of User Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
144
+ # left_chat_member User Optional. A member was removed from the group, information about them (this member may be the bot itself)
145
+ # new_chat_title String Optional. A chat title was changed to this value
146
+ # new_chat_photo Array of PhotoSize Optional. A chat photo was change to this value
147
+ # delete_chat_photo True Optional. Service message: the chat photo was deleted
148
+ # group_chat_created True Optional. Service message: the group has been created
149
+ # supergroup_chat_created True Optional. Service message: the supergroup has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.
150
+ # channel_chat_created True Optional. Service message: the channel has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.
151
+ # migrate_to_chat_id Integer Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
152
+ # migrate_from_chat_id Integer Optional. The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
153
+ # pinned_message Message Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
154
+ # invoice Invoice Optional. Message is an invoice for a payment, information about the invoice. More about payments »
155
+ # successful_payment SuccessfulPayment Optional. Message is a service message about a successful payment, information about the payment. More about payments »
156
+ # connected_website String Optional. The domain name of the website on which the user has logged in. More about Telegram Login »
157
+ # passport_data PassportData Optional. Telegram Passport data
103
158
  class Message
104
- include InitializeFromHash
159
+ include SimplifyApi
160
+ attribute :message_id, Integer, mandatory: true
161
+ attribute :from, User
162
+ attribute :date, Integer, mandatory: true
163
+ attribute :chat, Chat, mandatory: true
164
+ attribute :forward_from, User
165
+ attribute :forward_from_chat, Chat
166
+ attribute :forward_from_message_id, Integer
167
+ attribute :forward_signature, String
168
+ attribute :forward_sender_name, String
169
+ attribute :forward_date, Integer
170
+ attribute :reply_to_message, Message
171
+ attribute :edit_date, Integer
172
+ attribute :media_group_id, String
173
+ attribute :author_signature, String
174
+ attribute :text, String
175
+ attribute :entities, [MessageEntity]
176
+ attribute :caption_entities, [MessageEntity]
177
+ attribute :audio, Audio
178
+ attribute :document, Document
179
+ attribute :animation, Animation
180
+ # attribute :game, Game
181
+ attribute :photo, [PhotoSize]
182
+ attribute :sticker, Sticker
183
+ attribute :video, Video
184
+ attribute :voice, Voice
185
+ attribute :video_note, VideoNote
186
+ attribute :caption, String
187
+ attribute :contact, Contact
188
+ attribute :location, Location
189
+ attribute :venue, Venue
190
+ attribute :poll, Poll
191
+ attribute :new_chat_members, [User]
192
+ attribute :left_chat_member, User
193
+ attribute :new_chat_title, String
194
+ attribute :new_chat_photo, [PhotoSize]
195
+ attribute :delete_chat_photo, values: [true]
196
+ attribute :group_chat_created, values: [true]
197
+ attribute :supergroup_chat_created, values: [true]
198
+ attribute :channel_chat_created, values: [true]
199
+ attribute :migrate_to_chat_id, Integer
200
+ attribute :migrate_from_chat_id, Integer
201
+ attribute :pinned_message, Message
202
+ # attribute :invoice, Invoice
203
+ # attribute :successful_payment, SuccessfulPayment
204
+ attribute :connected_website, String
205
+ # attribute :passport_data, PassportData
105
206
 
106
207
  def reply(&block)
107
208
  reply = MessageDescriptor.new(chat_id: chat.id)
@@ -114,12 +215,51 @@ module Telbe
114
215
  end
115
216
  end
116
217
 
218
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
219
+ # from_chat_id Integer or String Yes Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
220
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
221
+ # message_id Integer Yes Message identifier in the chat specified in from_chat_id
222
+ class ForwardMessageDescriptor
223
+ include SimplifyApi
224
+ attribute :chat_id, Object, mandatory: true
225
+ attribute :from_chat_id, Object, mandatory: true
226
+ attribute :disable_notification, values: [true, false]
227
+ attribute :message_id, Integer, mandatory: true
228
+ end
229
+
230
+ # update_id Integer The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
231
+ # message Message Optional. New incoming message of any kind — text, photo, sticker, etc.
232
+ # edited_message Message Optional. New version of a message that is known to the bot and was edited
233
+ # channel_post Message Optional. New incoming channel post of any kind — text, photo, sticker, etc.
234
+ # edited_channel_post Message Optional. New version of a channel post that is known to the bot and was edited
235
+ # inline_query InlineQuery Optional. New incoming inline query
236
+ # chosen_inline_result ChosenInlineResult Optional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.
237
+ # callback_query CallbackQuery Optional. New incoming callback query
238
+ # shipping_query ShippingQuery Optional. New incoming shipping query. Only for invoices with flexible price
239
+ # pre_checkout_query PreCheckoutQuery Optional. New incoming pre-checkout query. Contains full information about checkout
240
+ # poll Poll Optional. New poll state. Bots receive only updates about polls, which are sent or stopped by the bot
117
241
  class Update
118
- include InitializeFromHash
242
+ include SimplifyApi
243
+ attribute :update_id, Integer, mandatory: true
244
+ attribute :message, Message
245
+ attribute :edited_message, Message
246
+ attribute :channel_post, Message
247
+ attribute :inline_query, InlineQuery
248
+ attribute :chosen_inline_result, ChosenInlineResult
249
+ attribute :callback_query, CallbackQuery
250
+ attribute :poll, Poll
119
251
  end
120
252
 
121
- class UpdateDescriptor
122
- include InitializeFromHash
253
+ # offset Integer Optional Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
254
+ # limit Integer Optional Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
255
+ # timeout Integer Optional Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
256
+ # allowed_updates Array of String Optional List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.
257
+ class GetUpdatesDescriptor
258
+ include SimplifyApi
259
+ attribute :offset, Integer
260
+ attribute :limit, Integer
261
+ attribute :timeout, Integer
262
+ attribute :allowed_updates, [String]
123
263
  end
124
264
 
125
265
  class ResponseError < StandardError
data/lib/telbe/contact.rb CHANGED
@@ -5,11 +5,33 @@ module Telbe
5
5
  end
6
6
  end
7
7
 
8
+ # phone_number String Contact's phone number
9
+ # first_name String Contact's first name
10
+ # last_name String Optional. Contact's last name
11
+ # user_id Integer Optional. Contact's user identifier in Telegram
12
+ # vcard String Optional. Additional data about the contact in the form of a vCard
8
13
  class Contact
9
- include InitializeFromHash
14
+ include SimplifyApi
15
+ attribute :phone_number, String, mandatory: true
16
+ attribute :first_name, String, mandatory: true
17
+ attribute :last_name, String
18
+ attribute :user_id, Integer
19
+ attribute :vcard, String
10
20
  end
11
21
 
12
- class ContactDescriptor
13
- include InitializeFromHash
22
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
23
+ # phone_number String Yes Contact's phone number
24
+ # first_name String Yes Contact's first name
25
+ # last_name String Optional Contact's last name
26
+ # vcard String Optional Additional data about the contact in the form of a vCard, 0-2048 bytes
27
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
28
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
29
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user.
30
+ class ContactDescriptor < Descriptor
31
+ include SimplifyApi
32
+ attribute :phone_number, String, mandatory: true
33
+ attribute :first_name, String, mandatory: true
34
+ attribute :last_name, String
35
+ attribute :vcard, String
14
36
  end
15
37
  end
@@ -0,0 +1,9 @@
1
+ module Telbe
2
+ class InlineQuery
3
+ include SimplifyApi
4
+ end
5
+
6
+ class ChosenInlineResult
7
+ include SimplifyApi
8
+ end
9
+ end
@@ -3,18 +3,20 @@ module Telbe
3
3
  # request_contact Boolean Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only
4
4
  # request_location Boolean Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only
5
5
  class KeyboardButton
6
- include InitializeFromHash
7
- def self.factory
8
- self.new(
9
- text: "",
10
- request_contact: false,
11
- request_location: false
12
- )
13
- end
6
+ include SimplifyApi
7
+ attribute :text, String, mandatory: true
8
+ attribute :request_contact, values: [true, false]
9
+ attribute :request_location, values: [true, false]
10
+ end
11
+
12
+ # Created to nest the arrays in ReplyKeyboardMarkup
13
+ class KeyboardButtons
14
+ include SimplifyApi
15
+ attribute :keyboard_button, [KeyboardButton]
14
16
  end
15
17
 
16
18
  class ReplyKeyboardRemove
17
- include InitializeFromHash
19
+ include SimplifyApi
18
20
  end
19
21
 
20
22
  # keyboard Array of Array of KeyboardButton Array of button rows, each represented by an Array of KeyboardButton objects
@@ -22,22 +24,22 @@ module Telbe
22
24
  # one_time_keyboard Boolean Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false.
23
25
  # selective Boolean Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
24
26
  class ReplyKeyboardMarkup
25
- include InitializeFromHash
26
- def self.factory
27
- self.new(
28
- keyboard: [[]],
29
- resize_keyboard: true,
30
- one_time_keyboard: true,
31
- selective: false
32
- )
33
- end
27
+ include SimplifyApi
28
+ attribute :keyboard, [KeyboardButtons], mandatory: true
29
+ attribute :resize_keyboard, values: [true, false]
30
+ attribute :one_time_keyboard, values: [true, false]
31
+ attribute :selective, values: [true, false]
34
32
  end
35
33
 
36
34
  class InlineKeyboardMarkup
37
- include InitializeFromHash
35
+ include SimplifyApi
38
36
  end
39
37
 
40
38
  class InlineKeyboardButton
41
- include InitializeFromHash
39
+ include SimplifyApi
40
+ end
41
+
42
+ class CallbackQuery
43
+ include SimplifyApi
42
44
  end
43
45
  end
@@ -3,6 +3,14 @@ module Telbe
3
3
  def send_location(send_location_descriptor)
4
4
  Message.new(request(:sendLocation, send_location_descriptor))
5
5
  end
6
+
7
+ def edit_message_live_location(edit_message_live_location_descriptor)
8
+ Message.new(request(:editMessageLiveLocation, edit_message_live_location_descriptor))
9
+ end
10
+
11
+ def stop_message_live_location(stop_message_live_location_descriptor)
12
+ Message.new(request(:stopMessageLiveLocation, stop_message_live_location_descriptor))
13
+ end
6
14
  end
7
15
  # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
8
16
  # latitude Float number Yes Latitude of the location
@@ -12,19 +20,14 @@ module Telbe
12
20
  # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
13
21
  # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply
14
22
  class SendLocationDescriptor
15
- include InitializeFromHash
16
-
17
- def self.factory
18
- new(
19
- chat_id: nil,
20
- latitude: nil,
21
- longitude: nil,
22
- liveperiod: 60,
23
- disable_notification: true,
24
- reply_to_message_id: nil,
25
- reply_markup: nil
26
- )
27
- end
23
+ include SimplifyApi
24
+ attribute :chat_id, Object, mandatory: true # Integer or String
25
+ attribute :latitude, Float, mandatory: true
26
+ attribute :longitude, Float, mandatory: true
27
+ attribute :live_period, Integer
28
+ attribute :disable_notification, values: [true, false]
29
+ attribute :reply_to_message_id, Integer
30
+ attribute :reply_markup, Object
28
31
  end
29
32
 
30
33
  # chat_id Integer or String Optional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
@@ -34,25 +37,46 @@ module Telbe
34
37
  # longitude Float number Yes Longitude of new location
35
38
  # reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for a new inline keyboard.
36
39
  class EditMessageLiveLocationDescriptor
37
- include InitializeFromHash
40
+ include SimplifyApi
41
+ attribute :chat_id, Object, mandatory: true # Integer or String
42
+ attribute :message_id, Integer
43
+ attribute :inline_message_id, String
44
+ attribute :latitude, Float, mandatory: true
45
+ attribute :longitude, Float, mandatory: true
46
+ attribute :reply_markup, Object
47
+ end
38
48
 
39
- def self.factory
40
- new(
41
- chat_id: nil,
42
- message_id: nil,
43
- inline_message_id: nil,
44
- latitude: nil,
45
- longitude: nil,
46
- reply_markup:nil
47
- )
48
- end
49
+ # chat_id Integer or String Optional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
50
+ # message_id Integer Optional Required if inline_message_id is not specified. Identifier of the message with live location to stop
51
+ # inline_message_id String Optional Required if chat_id and message_id are not specified. Identifier of the inline message
52
+ # reply_markup InlineKeyboardMarkup Optional A JSON-serialized object for a new inline keyboard.
53
+ class StopMessageLivaLocationDescriptor
54
+ include SimplifyApi
55
+ attribute :chat_id, Object, mandatory: true # Integer or String
56
+ attribute :message_id, Integer
57
+ attribute :inline_message_id, String
58
+ attribute :reply_markup, Object
49
59
  end
50
60
 
61
+ # longitude Float Longitude as defined by sender
62
+ # latitude Float Latitude as defined by sender
51
63
  class Location
52
- include InitializeFromHash
64
+ include SimplifyApi
65
+ attribute :longitude, Float, mandatory: true
66
+ attribute :latitude, Float, mandatory: true
53
67
  end
54
68
 
69
+ # location Location Venue location
70
+ # title String Name of the venue
71
+ # address String Address of the venue
72
+ # foursquare_id String Optional. Foursquare identifier of the venue
73
+ # foursquare_type String Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
55
74
  class Venue
56
- include InitializeFromHash
75
+ include SimplifyApi
76
+ attribute :location, Location, mandatory: true
77
+ attribute :title, String, mandatory: true
78
+ attribute :address, String, mandatory: true
79
+ attribute :foursquare_id, String
80
+ attribute :foursquare_type, String
57
81
  end
58
82
  end