telbe 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +40 -0
- data/lib/telbe/bot.rb +187 -0
- data/lib/telbe/contact.rb +28 -0
- data/lib/telbe/keyboard.rb +38 -0
- data/lib/telbe/location.rb +16 -0
- data/lib/telbe/media.rb +108 -0
- data/lib/telbe/poll.rb +18 -0
- data/lib/telbe/sticker.rb +32 -0
- data/lib/telbe/user.rb +45 -0
- data/lib/telbe/version.rb +3 -0
- data/lib/telbe/webhook.rb +37 -0
- data/lib/telbe.rb +19 -0
- data/telbe.gemspec +23 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e42bc9b3ba26ce5475bd53652e612411b8503a935dd7d93069ee21aa89259cb7
|
4
|
+
data.tar.gz: 6ef864e72b29856c78e63bb08f796504e81d3b0688422edb2314c72ea9f93508
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: caeac2384355c9564da6237140dea46d4a29f30ed2d3530761e3c680f0e77a4ea178585ceba2c0e855a5a2bc8089210cecb3e030c23e50c6ec84b76c87e4ae13
|
7
|
+
data.tar.gz: 11257f6e714730882ce6843cc4acb49b4a2280a11764a8a565df83f2716351138de405b57b8cfbea1c8a3f95e4db765e1d8225126473b999f9636d37c242b478
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Telbe
|
2
|
+
|
3
|
+
A complete ruby client that implements [Telegram's Bot API](https://core.telegram.org/bots).
|
4
|
+
|
5
|
+
Ruby is such a beautiful and productive language.
|
6
|
+
|
7
|
+
[Virtus](https://github.com/solnic/virtus) is heavilly used, mainly because it's easy to instantiate objects from hashes, even complex objects. Virtus is deprecated, at a future release we'll evaulate differente approaches to address the problem.
|
8
|
+
|
9
|
+
Currently under heavy development.
|
10
|
+
|
11
|
+
Please [collaborate](https://github.com/rodgco/telbe/issues/new) with your questions, ideas or problems!
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile (currently under development):
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'telbe'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
## How do I get a Bot Token
|
28
|
+
|
29
|
+
Talk to the [@BotFather](https://telegram.me/botfather).
|
30
|
+
You can find more info [here](https://core.telegram.org/bots).
|
31
|
+
|
32
|
+
![How to get Token](http://i.imgur.com/90ya4Oe.png)
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rodgco/telbe. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/telbe/bot.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Bot
|
3
|
+
ENDPOINT = 'https://api.telegram.org/'
|
4
|
+
|
5
|
+
def initialize(token:, proxy: nil)
|
6
|
+
@token = token
|
7
|
+
@proxy = proxy
|
8
|
+
@connection = Excon.new(ENDPOINT, persistent: true, proxy: @proxy)
|
9
|
+
end
|
10
|
+
|
11
|
+
def request(action, query = {})
|
12
|
+
path = "/bot#{@token}/#{action}"
|
13
|
+
response = @connection.post(path: path, query: query.to_h)
|
14
|
+
if response.status == 200
|
15
|
+
body = response.body
|
16
|
+
data = JSON.parse(body)
|
17
|
+
data["result"]
|
18
|
+
else
|
19
|
+
raise ResponseError, response.body
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def send_message(message_descriptor)
|
24
|
+
Message.new(request(:sendMessage, message_descriptor))
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_updates(update_descriptor)
|
28
|
+
request(:getUpdates, update_descriptor).collect do |update_hash|
|
29
|
+
Update.new(update_hash)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_me
|
34
|
+
User.new(request(:getMe))
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_chat(chatid_descriptor)
|
38
|
+
Chat.new(request(:getChat, chatid_descriptor))
|
39
|
+
end
|
40
|
+
|
41
|
+
def download_file(file)
|
42
|
+
# https://api.telegram.org/file/bot<token>/<file_path>
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class MessageEntity
|
47
|
+
include Virtus.model
|
48
|
+
end
|
49
|
+
|
50
|
+
class ForceReply
|
51
|
+
include Virtus.model
|
52
|
+
attribute :force_reply, Boolean
|
53
|
+
attribute :selective, Boolean
|
54
|
+
end
|
55
|
+
|
56
|
+
class MessageDescriptor
|
57
|
+
include Virtus.model
|
58
|
+
attribute :chat_id, Object # Integer or String - Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
59
|
+
attribute :text, String # Text of the message to be sent
|
60
|
+
attribute :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
|
+
attribute :disable_web_page_preview, Boolean # Optional Disables link previews for links in this message
|
62
|
+
attribute :disable_notification, Boolean # Optional Sends the message silently. Users will receive a notification with no sound.
|
63
|
+
attribute :reply_to_message_id, Integer # Optional If the message is a reply, ID of the original message
|
64
|
+
attribute :reply_markup, Object # 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
|
+
end
|
66
|
+
|
67
|
+
class ChatPhoto
|
68
|
+
include Virtus.model
|
69
|
+
attribute :small_file_id, String
|
70
|
+
attribute :big_file_id, String
|
71
|
+
end
|
72
|
+
|
73
|
+
class Chat
|
74
|
+
include Virtus.model
|
75
|
+
attribute :id, Integer
|
76
|
+
attribute :type, String
|
77
|
+
attribute :title, String
|
78
|
+
attribute :username, String
|
79
|
+
attribute :first_name, String
|
80
|
+
attribute :last_name, String
|
81
|
+
attribute :all_members_are_administrators, Boolean
|
82
|
+
attribute :photo, ChatPhoto
|
83
|
+
attribute :description, String
|
84
|
+
attribute :invite_link, String
|
85
|
+
attribute :sticker_set_name, String
|
86
|
+
attribute :can_set_sticker_set, Boolean
|
87
|
+
end
|
88
|
+
|
89
|
+
class Message
|
90
|
+
include Virtus.model
|
91
|
+
attribute :message_id, Integer
|
92
|
+
alias_method :id, :message_id
|
93
|
+
alias_method :to_i, :id
|
94
|
+
attribute :from, User
|
95
|
+
alias_method :user, :from
|
96
|
+
attribute :text, String
|
97
|
+
attribute :date, DateTime
|
98
|
+
attribute :chat, Chat
|
99
|
+
attribute :forward_from, User
|
100
|
+
attribute :forward_from_chat, Chat
|
101
|
+
attribute :forward_from_message_id, Integer
|
102
|
+
attribute :forward_signature, String
|
103
|
+
attribute :forward_sender_name, String
|
104
|
+
attribute :forward_date, Integer
|
105
|
+
attribute :reply_to_message, Message
|
106
|
+
attribute :edit_date, Integer
|
107
|
+
attribute :media_group_id, String
|
108
|
+
attribute :author_signature, String
|
109
|
+
attribute :text, String
|
110
|
+
attribute :entities, Array # of MessageEntity
|
111
|
+
attribute :caption_entities, Array # of MessageEntity
|
112
|
+
attribute :audio, Audio
|
113
|
+
attribute :document, Document
|
114
|
+
attribute :animation, Animation
|
115
|
+
# attribute :game, Game
|
116
|
+
attribute :photo, Array # of PhotoSize
|
117
|
+
attribute :sticker, Sticker
|
118
|
+
attribute :video, Video
|
119
|
+
attribute :voice, Voice
|
120
|
+
attribute :video_note, VideoNote
|
121
|
+
attribute :caption, String
|
122
|
+
attribute :contact, Contact
|
123
|
+
attribute :location, Location
|
124
|
+
attribute :venue, Venue
|
125
|
+
attribute :poll, Poll
|
126
|
+
attribute :new_chat_members, Array # of User
|
127
|
+
attribute :left_chat_member , User
|
128
|
+
attribute :new_chat_title, String
|
129
|
+
attribute :new_chat_photo, Array # of PhotoSize
|
130
|
+
attribute :delete_chat_photo, Boolean
|
131
|
+
attribute :group_chat_created, Boolean
|
132
|
+
attribute :supergroup_chat_created, Boolean
|
133
|
+
attribute :channel_chat_created, Boolean
|
134
|
+
attribute :migrate_to_chat_id, Integer
|
135
|
+
attribute :migrate_from_chat_id, Integer
|
136
|
+
attribute :pinned_message, Message
|
137
|
+
# attribute :invoice, Invoice
|
138
|
+
# attribute :successful_payment, SuccessfulPayment
|
139
|
+
attribute :connected_website, String
|
140
|
+
# attribute :passport_data, PassportData
|
141
|
+
|
142
|
+
def reply(&block)
|
143
|
+
reply = MessageDescriptor.new(chat_id: chat.id)
|
144
|
+
yield reply if block_given?
|
145
|
+
reply
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_command_for(bot)
|
149
|
+
text && text.sub(Regexp.new("@#{bot.identity.username}($|\s|\.|,)", Regexp::IGNORECASE), '').strip
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
class Chat
|
154
|
+
attribute :pinned_message, Message
|
155
|
+
end
|
156
|
+
|
157
|
+
class Update
|
158
|
+
include Virtus.model
|
159
|
+
attribute :update_id, Integer
|
160
|
+
alias_method :id, :update_id
|
161
|
+
alias_method :to_i, :id
|
162
|
+
attribute :message, Message
|
163
|
+
alias_method :edited_message, :message
|
164
|
+
alias_method :channel_post, :message
|
165
|
+
alias_method :edited_channel_post, :message
|
166
|
+
# attribute :inline_query, InlineQuery
|
167
|
+
# attribute :chosen_inline_result, ChosenInlineResult
|
168
|
+
# attribute :callback_query, CallbackQuery
|
169
|
+
# attribute :shipping_query, ShippingQuery
|
170
|
+
# attribute :pre_checkout_query, PreCheckoutQuery
|
171
|
+
attribute :poll, Poll
|
172
|
+
end
|
173
|
+
|
174
|
+
class UpdateDescriptor
|
175
|
+
include Virtus.model
|
176
|
+
attribute :offset, Integer
|
177
|
+
attribute :limit, Integer
|
178
|
+
attribute :timeout, Integer
|
179
|
+
attribute :allowed_updates, Array # of String
|
180
|
+
end
|
181
|
+
|
182
|
+
class ResponseError < StandardError
|
183
|
+
def initialize(msg = "Bot Response Error")
|
184
|
+
super
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Bot
|
3
|
+
def send_contact(contact_descriptor)
|
4
|
+
Message.new(request(:sendContact, contact_descriptor))
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Contact
|
9
|
+
include Virtus.model
|
10
|
+
attribute :phone_number, String
|
11
|
+
attribute :first_name, String
|
12
|
+
attribute :last_name, String
|
13
|
+
attribute :user_id, Integer
|
14
|
+
attribute :vcard, String
|
15
|
+
end
|
16
|
+
|
17
|
+
class ContactDescriptor
|
18
|
+
include Virtus.model
|
19
|
+
attribute :chat_id, Integer or String
|
20
|
+
attribute :phone_number, String
|
21
|
+
attribute :first_name, String
|
22
|
+
attribute :last_name, String
|
23
|
+
attribute :vcard, String
|
24
|
+
attribute :disable_notification, Boolean
|
25
|
+
attribute :reply_to_message_id, Integer
|
26
|
+
attribute :reply_markup, Object #InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Telbe
|
2
|
+
class KeyboardButton
|
3
|
+
include Virtus.model
|
4
|
+
attribute :text, String
|
5
|
+
attribute :request_contact, Boolean
|
6
|
+
attribute :request_location, Boolean
|
7
|
+
end
|
8
|
+
|
9
|
+
class ReplyKeyboardRemove
|
10
|
+
include Virtus.model
|
11
|
+
attribute :remove_keyboard, Boolean
|
12
|
+
attribute :selective, Boolean
|
13
|
+
end
|
14
|
+
|
15
|
+
class ReplyKeyboardMarkup
|
16
|
+
include Virtus.model
|
17
|
+
attribute :keyboard, Array # of Array of KeyboardButton
|
18
|
+
attribute :resize_keyboard, Boolean
|
19
|
+
attribute :one_time_keyboard, Boolean
|
20
|
+
attribute :selective, Boolean
|
21
|
+
end
|
22
|
+
|
23
|
+
class InlineKeyboardMarkup
|
24
|
+
include Virtus.model
|
25
|
+
attribute :inline_keyboard, Array # of Array of InlineKeyboardButton
|
26
|
+
end
|
27
|
+
|
28
|
+
class InlineKeyboardButton
|
29
|
+
include Virtus.model
|
30
|
+
attribute :text, String
|
31
|
+
attribute :url, String
|
32
|
+
attribute :callback_data, String
|
33
|
+
attribute :switch_inline_query, String
|
34
|
+
attribute :switch_inline_query_current_chat, String
|
35
|
+
# attribute :callback_game, CallbackGame
|
36
|
+
# attribute :pay, Boolean
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Location
|
3
|
+
include Virtus.model
|
4
|
+
attribute :longitude, Float
|
5
|
+
attribute :latitude, Float
|
6
|
+
end
|
7
|
+
|
8
|
+
class Venue
|
9
|
+
include Virtus.model
|
10
|
+
attribute :location, Location
|
11
|
+
attribute :address, String
|
12
|
+
attribute :title, String
|
13
|
+
attribute :foursquare_id, String
|
14
|
+
attribute :foursquare_type, String
|
15
|
+
end
|
16
|
+
end
|
data/lib/telbe/media.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
module Telbe
|
2
|
+
class PhotoSize
|
3
|
+
include Virtus.model
|
4
|
+
attribute :file_id, String
|
5
|
+
attribute :width, Integer
|
6
|
+
attribute :height, Integer
|
7
|
+
attribute :file_size, Integer
|
8
|
+
end
|
9
|
+
|
10
|
+
class Animation
|
11
|
+
include Virtus.model
|
12
|
+
attribute :file_id, String
|
13
|
+
attribute :width, Integer
|
14
|
+
attribute :height, Integer
|
15
|
+
attribute :duration, Integer
|
16
|
+
attribute :thumb, PhotoSize
|
17
|
+
attribute :file_name, String
|
18
|
+
attribute :mime_type, String
|
19
|
+
attribute :file_size, Integer
|
20
|
+
end
|
21
|
+
|
22
|
+
class Document
|
23
|
+
include Virtus.model
|
24
|
+
attribute :file_id, String
|
25
|
+
attribute :thumb, PhotoSize
|
26
|
+
attribute :file_name, String
|
27
|
+
attribute :mime_type, String
|
28
|
+
attribute :file_size, Integer
|
29
|
+
end
|
30
|
+
|
31
|
+
class Audio
|
32
|
+
include Virtus.model
|
33
|
+
attribute :file_id, String
|
34
|
+
attribute :duration, Integer
|
35
|
+
attribute :performer, String
|
36
|
+
attribute :title, String
|
37
|
+
attribute :mime_type, String
|
38
|
+
attribute :file_size, Integer
|
39
|
+
attribute :thumb, PhotoSize
|
40
|
+
end
|
41
|
+
|
42
|
+
class Video
|
43
|
+
include Virtus.model
|
44
|
+
attribute :file_id, String
|
45
|
+
attribute :width, Integer
|
46
|
+
attribute :height, Integer
|
47
|
+
attribute :duration, Integer
|
48
|
+
attribute :thumb, PhotoSize
|
49
|
+
attribute :mime_type, String
|
50
|
+
attribute :file_size, Integer
|
51
|
+
end
|
52
|
+
|
53
|
+
class Voice
|
54
|
+
include Virtus.model
|
55
|
+
attribute :file_id, String
|
56
|
+
attribute :duration, Integer
|
57
|
+
attribute :mime_type, String
|
58
|
+
attribute :file_size, Integer
|
59
|
+
end
|
60
|
+
|
61
|
+
class VideoNote
|
62
|
+
include Virtus.model
|
63
|
+
attribute :file_id, String
|
64
|
+
attribute :length, Integer
|
65
|
+
attribute :duration, Integer
|
66
|
+
attribute :thumb, PhotoSize
|
67
|
+
attribute :file_size, Integer
|
68
|
+
end
|
69
|
+
|
70
|
+
class InputMedia
|
71
|
+
include Virtus.model
|
72
|
+
attribute :type, String
|
73
|
+
attribute :media, String
|
74
|
+
attribute :caption, String
|
75
|
+
attribute :parse_mode, String
|
76
|
+
end
|
77
|
+
|
78
|
+
class InputMediaAnimation < InputMedia
|
79
|
+
attribute :thumb, Object
|
80
|
+
attribute :width, Integer
|
81
|
+
attribute :height, Integer
|
82
|
+
attribute :duration, Integer
|
83
|
+
end
|
84
|
+
|
85
|
+
class InputMediaDocument < InputMedia
|
86
|
+
include Virtus.model
|
87
|
+
attribute :thumb, Object
|
88
|
+
end
|
89
|
+
|
90
|
+
class InputMediaAudio < InputMedia
|
91
|
+
include Virtus.model
|
92
|
+
attribute :thumb, Object
|
93
|
+
attribute :duration, Integer
|
94
|
+
attribute :performer, String
|
95
|
+
attribute :title, String
|
96
|
+
end
|
97
|
+
|
98
|
+
class InputMediaPhoto < InputMedia
|
99
|
+
end
|
100
|
+
|
101
|
+
class InputMediaVideo < InputMedia
|
102
|
+
attribute :thumb, Object
|
103
|
+
attribute :width, Integer
|
104
|
+
attribute :height, Integer
|
105
|
+
attribute :duration, Integer
|
106
|
+
attribute :supports_streaming, Boolean
|
107
|
+
end
|
108
|
+
end
|
data/lib/telbe/poll.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Bot
|
3
|
+
end
|
4
|
+
|
5
|
+
class PollOption
|
6
|
+
include Virtus.model
|
7
|
+
attribute :text, String
|
8
|
+
attribute :voter_count, Integer
|
9
|
+
end
|
10
|
+
|
11
|
+
class Poll
|
12
|
+
include Virtus.model
|
13
|
+
attribute :id, String
|
14
|
+
attribute :question, String
|
15
|
+
attribute :options, Array # of PollOption
|
16
|
+
attribute :is_closed, Boolean
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Bot
|
3
|
+
end
|
4
|
+
|
5
|
+
class MaskPosition
|
6
|
+
include Virtus.model
|
7
|
+
attribute :point, String
|
8
|
+
attribute :x_shift, Float
|
9
|
+
attribute :y_shift, Float
|
10
|
+
attribute :scale, Float
|
11
|
+
end
|
12
|
+
|
13
|
+
class Sticker
|
14
|
+
include Virtus.model
|
15
|
+
attribute :file_id, String
|
16
|
+
attribute :width, Integer
|
17
|
+
attribute :height, Integer
|
18
|
+
attribute :thumb, PhotoSize
|
19
|
+
attribute :emoji, String
|
20
|
+
attribute :set_name, String
|
21
|
+
attribute :mask_position, MaskPosition
|
22
|
+
attribute :file_size, Integer
|
23
|
+
end
|
24
|
+
|
25
|
+
class StickerSet
|
26
|
+
include Virtus.model
|
27
|
+
attribute :name, String
|
28
|
+
attribute :title, String
|
29
|
+
attribute :contains_masks, Boolean
|
30
|
+
attribute :stickers, Array # of Sticker
|
31
|
+
end
|
32
|
+
end
|
data/lib/telbe/user.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Bot
|
3
|
+
def get_chat_administrators(chatid_descriptor)
|
4
|
+
request(:getChatAdministrators, chatid_descriptor).collect do |member_hash|
|
5
|
+
ChatMember.new(member_hash)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_chat_members_count(chatid_descriptor)
|
10
|
+
request(:getChatMembersCount, chatid_descriptor)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class User
|
15
|
+
include Virtus.model
|
16
|
+
attribute :id, Integer #Unique identifier for this user or bot
|
17
|
+
alias_method :to_i, :id
|
18
|
+
attribute :is_bot, Boolean
|
19
|
+
attribute :first_name, String #User‘s or bot’s first name
|
20
|
+
attribute :last_name, String
|
21
|
+
attribute :username, String
|
22
|
+
attribute :language_code, String
|
23
|
+
end
|
24
|
+
|
25
|
+
class ChatMember
|
26
|
+
include Virtus.model
|
27
|
+
attribute :user, User
|
28
|
+
attribute :status, String
|
29
|
+
attribute :until_date, Integer
|
30
|
+
attribute :can_be_edited, Boolean
|
31
|
+
attribute :can_change_info, Boolean
|
32
|
+
attribute :can_post_messages, Boolean
|
33
|
+
attribute :can_edit_messages, Boolean
|
34
|
+
attribute :can_delete_messages, Boolean
|
35
|
+
attribute :can_invite_users, Boolean
|
36
|
+
attribute :can_restrict_members, Boolean
|
37
|
+
attribute :can_pin_messages, Boolean
|
38
|
+
attribute :can_promote_members, Boolean
|
39
|
+
attribute :is_member, Boolean
|
40
|
+
attribute :can_send_messages, Boolean
|
41
|
+
attribute :can_send_media_messages, Boolean
|
42
|
+
attribute :can_send_other_messages, Boolean
|
43
|
+
attribute :can_add_web_page_previews, Boolean
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Telbe
|
2
|
+
class Bot
|
3
|
+
def set_webhook(webhook_descriptor)
|
4
|
+
request(:setWebhook, webhook_descriptor)
|
5
|
+
end
|
6
|
+
|
7
|
+
def delete_webhook
|
8
|
+
request(:deleteWebhook)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_webhookinfo
|
12
|
+
WebHookInfo.new(request(:getWebhookInfo))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class WebHookInfo
|
17
|
+
include Virtus.model
|
18
|
+
attribute :url, String
|
19
|
+
attribute :has_custom_certificate, Boolean
|
20
|
+
attribute :pending_update_count, Integer
|
21
|
+
attribute :last_error_date, Integer
|
22
|
+
attribute :last_error_message, String
|
23
|
+
attribute :max_connections, Integer
|
24
|
+
attribute :allowed_updates, Array # of String
|
25
|
+
end
|
26
|
+
|
27
|
+
class InputFile
|
28
|
+
end
|
29
|
+
|
30
|
+
class WebHookDescriptor
|
31
|
+
include Virtus.model
|
32
|
+
attribute :url, String
|
33
|
+
attribute :certificate, InputFile
|
34
|
+
attribute :max_connections, Integer
|
35
|
+
attribute :allowed_updates, Array # of String
|
36
|
+
end
|
37
|
+
end
|
data/lib/telbe.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'excon'
|
2
|
+
require 'virtus'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require 'telbe/webhook'
|
6
|
+
require 'telbe/user'
|
7
|
+
require 'telbe/contact'
|
8
|
+
require 'telbe/keyboard'
|
9
|
+
require 'telbe/poll'
|
10
|
+
require 'telbe/media'
|
11
|
+
require 'telbe/sticker'
|
12
|
+
require 'telbe/location'
|
13
|
+
require 'telbe/bot'
|
14
|
+
|
15
|
+
module BotEngine
|
16
|
+
def self.new(opts)
|
17
|
+
Bot.new(opts)
|
18
|
+
end
|
19
|
+
end
|
data/telbe.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'telbe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "telbe"
|
8
|
+
spec.version = Telbe::VERSION
|
9
|
+
spec.date = "2019-05-07"
|
10
|
+
spec.authors = ["Rodrigo Garcia Couto"]
|
11
|
+
spec.email = ["r@rodg.co"]
|
12
|
+
spec.summary = %q{A Telegram Bot Engine}
|
13
|
+
spec.description = %q{Still in development. A Telegram Bot Engine that eventually will support all of Telegrams features.}
|
14
|
+
spec.homepage = "https://github.com/rodgco/telbe"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "excon", ">= 0.64.0"
|
20
|
+
spec.add_dependency "virtus", ">= 0.64.0"
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: telbe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo Garcia Couto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: excon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.64.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.64.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: virtus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.64.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.64.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
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: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Still in development. A Telegram Bot Engine that eventually will support
|
70
|
+
all of Telegrams features.
|
71
|
+
email:
|
72
|
+
- r@rodg.co
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- README.md
|
80
|
+
- lib/telbe.rb
|
81
|
+
- lib/telbe/bot.rb
|
82
|
+
- lib/telbe/contact.rb
|
83
|
+
- lib/telbe/keyboard.rb
|
84
|
+
- lib/telbe/location.rb
|
85
|
+
- lib/telbe/media.rb
|
86
|
+
- lib/telbe/poll.rb
|
87
|
+
- lib/telbe/sticker.rb
|
88
|
+
- lib/telbe/user.rb
|
89
|
+
- lib/telbe/version.rb
|
90
|
+
- lib/telbe/webhook.rb
|
91
|
+
- telbe.gemspec
|
92
|
+
homepage: https://github.com/rodgco/telbe
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.7.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A Telegram Bot Engine
|
116
|
+
test_files: []
|