telbe 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +3 -0
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/lib/telbe/base.rb +5 -5
- data/lib/telbe/bot.rb +233 -231
- data/lib/telbe/chat.rb +1 -1
- data/lib/telbe/keyboard.rb +1 -1
- data/lib/telbe/version.rb +1 -1
- data/spec/bot_spec.rb +0 -0
- data/spec/spec_helper.rb +100 -0
- data/telbe.gemspec +19 -14
- metadata +62 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7c896576ba70db333e3545589afc64b42fb3ebe437e031d32c6b9cdd4f76c4d
|
4
|
+
data.tar.gz: a3ae4f6a883708888c6be49e7c00f791cca50ebe858f630e02ab0b8662913377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8e1c434683fe70d45f54e9700660ed96794b3b40e473dd75425a23303a7efe6f4b2831c451a806f60e8857b3b79b8a53f94b4f01f549a0031ad437a0f3e4782
|
7
|
+
data.tar.gz: bc851b6a16fd2ea0a0c970a065701653801cac0a197715c63341590ccd4a3e56a0f4009f3f758a697436a423c7187446323aed42d9606422c1b78091db5eecb2
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,9 +4,9 @@ A complete ruby client that implements [Telegram's Bot API](https://core.telegra
|
|
4
4
|
|
5
5
|
Ruby is such a beautiful and productive language.
|
6
6
|
|
7
|
-
|
7
|
+
SimplifyApi is being used to automagicaly objectify JSON and JSONify objects, it also implements a "safe" environment to accomodate future API specifications without too much burden.
|
8
8
|
|
9
|
-
Currently under heavy development.
|
9
|
+
Currently under heavy development (or maybe not!).
|
10
10
|
|
11
11
|
Please [collaborate](https://github.com/rodgco/telbe/issues/new) with your questions, ideas or problems!
|
12
12
|
|
data/lib/telbe/base.rb
CHANGED
@@ -3,7 +3,7 @@ module Telbe
|
|
3
3
|
def self.inherited(base)
|
4
4
|
base.send(:include, SimplifyApi)
|
5
5
|
base.send(:attribute, :chat_id, Object, mandatory: true)
|
6
|
-
base.send(:attribute, :disable_notification, values: [true, false])
|
6
|
+
base.send(:attribute, :disable_notification, values: [true, false], default: false)
|
7
7
|
base.send(:attribute, :reply_to_message_id, Integer)
|
8
8
|
base.send(:attribute, :reply_markup, Object)
|
9
9
|
end
|
@@ -13,7 +13,7 @@ module Telbe
|
|
13
13
|
def self.inherited(base)
|
14
14
|
super(base)
|
15
15
|
base.send(:attribute, :caption, String)
|
16
|
-
base.send(:attribute, :parse_mode, String, values: [
|
16
|
+
base.send(:attribute, :parse_mode, String, values: %w[Markdown HTML], default: 'Markdown')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -23,17 +23,17 @@ module Telbe
|
|
23
23
|
base.send(:attribute, :type, String, mandatory: true)
|
24
24
|
base.send(:attribute, :media, String, mandatory: true)
|
25
25
|
base.send(:attribute, :caption, String)
|
26
|
-
base.send(:attribute, :parse_mode, String, values: [
|
26
|
+
base.send(:attribute, :parse_mode, String, values: %w[Markdown HTML], default: 'Markdown')
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
class InlineQueryResult
|
31
31
|
def self.inherited(base)
|
32
32
|
base.send(:include, SimplifyApi)
|
33
33
|
base.send(:attribute, :type, String, mandatory: true)
|
34
34
|
base.send(:attribute, :id, String, mandatory: true)
|
35
35
|
base.send(:attribute, :caption, String)
|
36
|
-
base.send(:attribute, :parse_mode, String, values: [
|
36
|
+
base.send(:attribute, :parse_mode, String, values: %w[Markdown HTML], default: 'Markdown')
|
37
37
|
base.send(:attribute, :reply_markup, InlineKeyboardMarkup)
|
38
38
|
base.send(:attribute, :input_message_content, Object)
|
39
39
|
end
|
data/lib/telbe/bot.rb
CHANGED
@@ -1,231 +1,233 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
attribute :
|
44
|
-
attribute :
|
45
|
-
attribute :
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
attribute :
|
68
|
-
attribute :
|
69
|
-
attribute :
|
70
|
-
attribute :
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
attribute :
|
124
|
-
attribute :
|
125
|
-
attribute :
|
126
|
-
attribute :
|
127
|
-
attribute :
|
128
|
-
attribute :
|
129
|
-
attribute :
|
130
|
-
attribute :
|
131
|
-
attribute :
|
132
|
-
attribute :
|
133
|
-
attribute :
|
134
|
-
attribute :
|
135
|
-
attribute :
|
136
|
-
attribute :
|
137
|
-
attribute :
|
138
|
-
attribute :
|
139
|
-
attribute :
|
140
|
-
attribute :
|
141
|
-
|
142
|
-
attribute :
|
143
|
-
attribute :
|
144
|
-
attribute :
|
145
|
-
attribute :
|
146
|
-
attribute :
|
147
|
-
attribute :
|
148
|
-
attribute :
|
149
|
-
attribute :
|
150
|
-
attribute :
|
151
|
-
attribute :
|
152
|
-
attribute :
|
153
|
-
attribute :
|
154
|
-
attribute :
|
155
|
-
attribute :
|
156
|
-
attribute :
|
157
|
-
attribute :
|
158
|
-
attribute :
|
159
|
-
attribute :
|
160
|
-
attribute :
|
161
|
-
attribute :
|
162
|
-
attribute :
|
163
|
-
|
164
|
-
|
165
|
-
attribute :
|
166
|
-
# attribute :
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
reply
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
#
|
182
|
-
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
attribute :
|
188
|
-
attribute :
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
200
|
-
#
|
201
|
-
#
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
attribute :
|
207
|
-
attribute :
|
208
|
-
attribute :
|
209
|
-
attribute :
|
210
|
-
attribute :
|
211
|
-
attribute :
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
#
|
217
|
-
#
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
attribute :
|
223
|
-
attribute :
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The main module that agregates all classes
|
4
|
+
module Telbe
|
5
|
+
|
6
|
+
class Bot
|
7
|
+
ENDPOINT = 'https://api.telegram.org/'
|
8
|
+
|
9
|
+
def initialize(token:, proxy: nil)
|
10
|
+
@token = token
|
11
|
+
@proxy = proxy
|
12
|
+
@connection = Excon.new(ENDPOINT, persistent: true, proxy: @proxy)
|
13
|
+
end
|
14
|
+
|
15
|
+
def request(action, query = {})
|
16
|
+
path = "/bot#{@token}/#{action}"
|
17
|
+
response = @connection.post(path: path, query: query.to_h)
|
18
|
+
raise ResponseError, response.body unless response.status == 200
|
19
|
+
|
20
|
+
body = response.body
|
21
|
+
data = JSON.parse(body)
|
22
|
+
data['result']
|
23
|
+
end
|
24
|
+
|
25
|
+
def send_message(message_descriptor)
|
26
|
+
Message.new(request(:sendMessage, message_descriptor))
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_updates(get_updates_descriptor)
|
30
|
+
request(:getUpdates, get_updates_descriptor).collect do |update|
|
31
|
+
Update.new(update)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# type String Type of the entity. Can be mention (@username), hashtag, cashtag, bot_command, url, email, phone_number, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames)
|
37
|
+
# offset Integer Offset in UTF-16 code units to the start of the entity
|
38
|
+
# length Integer Length of the entity in UTF-16 code units
|
39
|
+
# url String Optional. For “text_link” only, url that will be opened after user taps on the text
|
40
|
+
# user User Optional. For “text_mention” only, the mentioned user
|
41
|
+
class MessageEntity
|
42
|
+
include SimplifyApi
|
43
|
+
attribute :type, String, mandatory: true
|
44
|
+
attribute :offset, Integer, mandatory: true
|
45
|
+
attribute :length, Integer, mandatory: true
|
46
|
+
attribute :url, String
|
47
|
+
attribute :user, User
|
48
|
+
end
|
49
|
+
|
50
|
+
# force_reply True Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
|
51
|
+
# selective Boolean Optional. Use this parameter if you want to force reply from 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.
|
52
|
+
class ForceReply
|
53
|
+
include SimplifyApi
|
54
|
+
attribute :force_reply, values: [true], mandatory: true, default: true
|
55
|
+
attribute :selective, values: [true, false], default: true
|
56
|
+
end
|
57
|
+
|
58
|
+
# chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
59
|
+
# text String Yes Text of the message to be sent
|
60
|
+
# parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
|
61
|
+
# disable_web_page_preview Boolean Optional Disables link previews for links in this message
|
62
|
+
# disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
|
63
|
+
# reply_to_message_id Integer Optional If the message is a reply, ID of the original message
|
64
|
+
# 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.
|
65
|
+
class MessageDescriptor
|
66
|
+
include SimplifyApi
|
67
|
+
attribute :chat_id, Integer, mandatory: true
|
68
|
+
attribute :text, String, mandatory: true
|
69
|
+
attribute :parse_mode, String, values: %w[Markdown HTML], default: 'Markdown'
|
70
|
+
attribute :disable_web_page_preview, values: [true, false], default: false
|
71
|
+
attribute :reply_to_message_id, Integer
|
72
|
+
attribute :reply_markup, Object
|
73
|
+
end
|
74
|
+
|
75
|
+
# message_id Integer Unique message identifier inside this chat
|
76
|
+
# from User Optional. Sender, empty for messages sent to channels
|
77
|
+
# date Integer Date the message was sent in Unix time
|
78
|
+
# chat Chat Conversation the message belongs to
|
79
|
+
# forward_from User Optional. For forwarded messages, sender of the original message
|
80
|
+
# forward_from_chat Chat Optional. For messages forwarded from channels, information about the original channel
|
81
|
+
# forward_from_message_id Integer Optional. For messages forwarded from channels, identifier of the original message in the channel
|
82
|
+
# forward_signature String Optional. For messages forwarded from channels, signature of the post author if present
|
83
|
+
# forward_sender_name String Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages
|
84
|
+
# forward_date Integer Optional. For forwarded messages, date the original message was sent in Unix time
|
85
|
+
# 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.
|
86
|
+
# edit_date Integer Optional. Date the message was last edited in Unix time
|
87
|
+
# media_group_id String Optional. The unique identifier of a media message group this message belongs to
|
88
|
+
# author_signature String Optional. Signature of the post author for messages in channels
|
89
|
+
# text String Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters.
|
90
|
+
# entities Array of MessageEntity Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
|
91
|
+
# caption_entities Array of MessageEntity Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
|
92
|
+
# audio Audio Optional. Message is an audio file, information about the file
|
93
|
+
# document Document Optional. Message is a general file, information about the file
|
94
|
+
# 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
|
95
|
+
# game Game Optional. Message is a game, information about the game. More about games »
|
96
|
+
# photo Array of PhotoSize Optional. Message is a photo, available sizes of the photo
|
97
|
+
# sticker Sticker Optional. Message is a sticker, information about the sticker
|
98
|
+
# video Video Optional. Message is a video, information about the video
|
99
|
+
# voice Voice Optional. Message is a voice message, information about the file
|
100
|
+
# video_note VideoNote Optional. Message is a video note, information about the video message
|
101
|
+
# caption String Optional. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters
|
102
|
+
# contact Contact Optional. Message is a shared contact, information about the contact
|
103
|
+
# location Location Optional. Message is a shared location, information about the location
|
104
|
+
# venue Venue Optional. Message is a venue, information about the venue
|
105
|
+
# poll Poll Optional. Message is a native poll, information about the poll
|
106
|
+
# 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)
|
107
|
+
# left_chat_member User Optional. A member was removed from the group, information about them (this member may be the bot itself)
|
108
|
+
# new_chat_title String Optional. A chat title was changed to this value
|
109
|
+
# new_chat_photo Array of PhotoSize Optional. A chat photo was change to this value
|
110
|
+
# delete_chat_photo True Optional. Service message: the chat photo was deleted
|
111
|
+
# group_chat_created True Optional. Service message: the group has been created
|
112
|
+
# 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.
|
113
|
+
# 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.
|
114
|
+
# 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.
|
115
|
+
# 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.
|
116
|
+
# 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.
|
117
|
+
# invoice Invoice Optional. Message is an invoice for a payment, information about the invoice. More about payments »
|
118
|
+
# successful_payment SuccessfulPayment Optional. Message is a service message about a successful payment, information about the payment. More about payments »
|
119
|
+
# connected_website String Optional. The domain name of the website on which the user has logged in. More about Telegram Login »
|
120
|
+
# passport_data PassportData Optional. Telegram Passport data
|
121
|
+
class Message
|
122
|
+
include SimplifyApi
|
123
|
+
attribute :message_id, Integer, mandatory: true
|
124
|
+
attribute :from, User
|
125
|
+
attribute :date, Integer, mandatory: true
|
126
|
+
attribute :chat, Chat, mandatory: true
|
127
|
+
attribute :forward_from, User
|
128
|
+
attribute :forward_from_chat, Chat
|
129
|
+
attribute :forward_from_message_id, Integer
|
130
|
+
attribute :forward_signature, String
|
131
|
+
attribute :forward_sender_name, String
|
132
|
+
attribute :forward_date, Integer
|
133
|
+
attribute :reply_to_message, Message
|
134
|
+
attribute :edit_date, Integer
|
135
|
+
attribute :media_group_id, String
|
136
|
+
attribute :author_signature, String
|
137
|
+
attribute :text, String
|
138
|
+
attribute :entities, [MessageEntity]
|
139
|
+
attribute :caption_entities, [MessageEntity]
|
140
|
+
attribute :audio, Audio
|
141
|
+
attribute :document, Document
|
142
|
+
attribute :animation, Animation
|
143
|
+
# attribute :game, Game
|
144
|
+
attribute :photo, [PhotoSize]
|
145
|
+
attribute :sticker, Sticker
|
146
|
+
attribute :video, Video
|
147
|
+
attribute :voice, Voice
|
148
|
+
attribute :video_note, VideoNote
|
149
|
+
attribute :caption, String
|
150
|
+
attribute :contact, Contact
|
151
|
+
attribute :location, Location
|
152
|
+
attribute :venue, Venue
|
153
|
+
attribute :poll, Poll
|
154
|
+
attribute :new_chat_members, [User]
|
155
|
+
attribute :left_chat_member, User
|
156
|
+
attribute :new_chat_title, String
|
157
|
+
attribute :new_chat_photo, [PhotoSize]
|
158
|
+
# attribute :delete_chat_photo, values: [true], default: true
|
159
|
+
# attribute :group_chat_created, values: [true], default: true
|
160
|
+
# attribute :supergroup_chat_created, values: [true], default: true
|
161
|
+
# attribute :channel_chat_created, values: [true], default: true
|
162
|
+
attribute :migrate_to_chat_id, Integer
|
163
|
+
attribute :migrate_from_chat_id, Integer
|
164
|
+
attribute :pinned_message, Message
|
165
|
+
# attribute :invoice, Invoice
|
166
|
+
# attribute :successful_payment, SuccessfulPayment
|
167
|
+
attribute :connected_website, String
|
168
|
+
# attribute :passport_data, PassportData
|
169
|
+
|
170
|
+
def reply(&block)
|
171
|
+
reply = MessageDescriptor.new(chat_id: chat.id)
|
172
|
+
yield reply if block_given?
|
173
|
+
reply
|
174
|
+
end
|
175
|
+
|
176
|
+
def get_command_for(bot)
|
177
|
+
text && text.sub(Regexp.new("@#{bot.get_me.username}($|\s|\.|,)", Regexp::IGNORECASE), '').strip
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
182
|
+
# 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)
|
183
|
+
# disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
|
184
|
+
# message_id Integer Yes Message identifier in the chat specified in from_chat_id
|
185
|
+
class ForwardMessageDescriptor
|
186
|
+
include SimplifyApi
|
187
|
+
attribute :chat_id, Object, mandatory: true
|
188
|
+
attribute :from_chat_id, Object, mandatory: true
|
189
|
+
attribute :disable_notification, values: [true, false], default: true
|
190
|
+
attribute :message_id, Integer, mandatory: true
|
191
|
+
end
|
192
|
+
|
193
|
+
# 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.
|
194
|
+
# message Message Optional. New incoming message of any kind — text, photo, sticker, etc.
|
195
|
+
# edited_message Message Optional. New version of a message that is known to the bot and was edited
|
196
|
+
# channel_post Message Optional. New incoming channel post of any kind — text, photo, sticker, etc.
|
197
|
+
# edited_channel_post Message Optional. New version of a channel post that is known to the bot and was edited
|
198
|
+
# inline_query InlineQuery Optional. New incoming inline query
|
199
|
+
# 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.
|
200
|
+
# callback_query CallbackQuery Optional. New incoming callback query
|
201
|
+
# shipping_query ShippingQuery Optional. New incoming shipping query. Only for invoices with flexible price
|
202
|
+
# pre_checkout_query PreCheckoutQuery Optional. New incoming pre-checkout query. Contains full information about checkout
|
203
|
+
# poll Poll Optional. New poll state. Bots receive only updates about polls, which are sent or stopped by the bot
|
204
|
+
class Update
|
205
|
+
include SimplifyApi
|
206
|
+
attribute :update_id, Integer, mandatory: true
|
207
|
+
attribute :message, Message
|
208
|
+
attribute :edited_message, Message
|
209
|
+
attribute :channel_post, Message
|
210
|
+
attribute :inline_query, InlineQuery
|
211
|
+
attribute :chosen_inline_result, ChosenInlineResult
|
212
|
+
attribute :callback_query, CallbackQuery
|
213
|
+
attribute :poll, Poll
|
214
|
+
end
|
215
|
+
|
216
|
+
# 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.
|
217
|
+
# limit Integer Optional Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
|
218
|
+
# 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.
|
219
|
+
# 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.
|
220
|
+
class GetUpdatesDescriptor
|
221
|
+
include SimplifyApi
|
222
|
+
attribute :offset, Integer
|
223
|
+
attribute :limit, Integer
|
224
|
+
attribute :timeout, Integer
|
225
|
+
attribute :allowed_updates, [String]
|
226
|
+
end
|
227
|
+
|
228
|
+
class ResponseError < StandardError
|
229
|
+
def initialize(msg = "Bot Response Error")
|
230
|
+
super
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
data/lib/telbe/chat.rb
CHANGED
@@ -106,7 +106,7 @@ module Telbe
|
|
106
106
|
class Chat
|
107
107
|
include SimplifyApi
|
108
108
|
attribute :id, Integer, mandatory: true
|
109
|
-
attribute :type, String, mandatory: true, values: [
|
109
|
+
attribute :type, String, mandatory: true, values: %w[private group supergroup channel]
|
110
110
|
attribute :title, String
|
111
111
|
attribute :username, String
|
112
112
|
attribute :first_name, String
|
data/lib/telbe/keyboard.rb
CHANGED
@@ -52,7 +52,7 @@ module Telbe
|
|
52
52
|
attribute :switch_inline_query, String
|
53
53
|
attribute :switch_inline_query_current_chat, String
|
54
54
|
# attribute :callback_game, CallbackGame
|
55
|
-
attribute :pay, values: [true, false]
|
55
|
+
attribute :pay, values: [true, false]
|
56
56
|
end
|
57
57
|
|
58
58
|
# Created to nest the arrays in InlineKeyboardMarkup
|
data/lib/telbe/version.rb
CHANGED
data/spec/bot_spec.rb
ADDED
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
70
|
+
# be too noisy due to issues in dependencies.
|
71
|
+
config.warnings = true
|
72
|
+
|
73
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
74
|
+
# file, and it's useful to allow more verbose output when running an
|
75
|
+
# individual spec file.
|
76
|
+
if config.files_to_run.one?
|
77
|
+
# Use the documentation formatter for detailed output,
|
78
|
+
# unless a formatter has already been configured
|
79
|
+
# (e.g. via a command-line flag).
|
80
|
+
config.default_formatter = "doc"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the 10 slowest examples and example groups at the
|
84
|
+
# end of the spec run, to help surface which specs are running
|
85
|
+
# particularly slow.
|
86
|
+
config.profile_examples = 10
|
87
|
+
|
88
|
+
# Run specs in random order to surface order dependencies. If you find an
|
89
|
+
# order dependency and want to debug it, you can fix the order by providing
|
90
|
+
# the seed, which is printed after each run.
|
91
|
+
# --seed 1234
|
92
|
+
config.order = :random
|
93
|
+
|
94
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
95
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
96
|
+
# test failures related to randomization by passing the same `--seed` value
|
97
|
+
# as the one that triggered the failure.
|
98
|
+
Kernel.srand config.seed
|
99
|
+
=end
|
100
|
+
end
|
data/telbe.gemspec
CHANGED
@@ -1,22 +1,27 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'telbe/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'telbe'
|
8
9
|
spec.version = Telbe::VERSION
|
9
|
-
spec.date =
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
10
|
+
spec.date = '2019-05-07'
|
11
|
+
spec.authors = ['Rodrigo Garcia Couto']
|
12
|
+
spec.email = ['r@rodg.co']
|
13
|
+
spec.summary = 'A Telegram Bot Engine'
|
14
|
+
spec.description = 'Still in development. A Telegram Bot Engine that eventually will support all of Telegrams features'
|
15
|
+
spec.homepage = 'https://github.com/rodgco/telbe'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
18
19
|
|
19
|
-
spec.add_dependency
|
20
|
-
spec.add_dependency
|
21
|
-
spec.add_development_dependency
|
20
|
+
spec.add_dependency 'excon', '>= 0.64.0'
|
21
|
+
spec.add_dependency 'simplify_api', '~> 0.1'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
24
|
+
spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0'
|
26
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.4'
|
22
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telbe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Garcia Couto
|
@@ -52,8 +52,64 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-collection_matchers
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-performance
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.4'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.4'
|
55
111
|
description: Still in development. A Telegram Bot Engine that eventually will support
|
56
|
-
all of Telegrams features
|
112
|
+
all of Telegrams features
|
57
113
|
email:
|
58
114
|
- r@rodg.co
|
59
115
|
executables: []
|
@@ -61,6 +117,7 @@ extensions: []
|
|
61
117
|
extra_rdoc_files: []
|
62
118
|
files:
|
63
119
|
- ".gitignore"
|
120
|
+
- ".rspec"
|
64
121
|
- Gemfile
|
65
122
|
- README.md
|
66
123
|
- lib/telbe.rb
|
@@ -77,6 +134,8 @@ files:
|
|
77
134
|
- lib/telbe/user.rb
|
78
135
|
- lib/telbe/version.rb
|
79
136
|
- lib/telbe/webhook.rb
|
137
|
+
- spec/bot_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
80
139
|
- telbe.gemspec
|
81
140
|
homepage: https://github.com/rodgco/telbe
|
82
141
|
licenses:
|
@@ -97,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
156
|
- !ruby/object:Gem::Version
|
98
157
|
version: '0'
|
99
158
|
requirements: []
|
100
|
-
|
101
|
-
rubygems_version: 2.7.3
|
159
|
+
rubygems_version: 3.0.3
|
102
160
|
signing_key:
|
103
161
|
specification_version: 4
|
104
162
|
summary: A Telegram Bot Engine
|