telegramAPI 1.0.11 → 1.0.12
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/README.md +2 -2
- data/lib/telegramAPI.rb +19 -6
- data/lib/telegramObjects.rb +0 -12
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84b02e4ec0791515fde7440bd0d17ffe2c7af1ad
|
4
|
+
data.tar.gz: 9c160edd39a5818bc5530de9eaf5b10900b19e3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d15ef602f46f4a0f8f34010b3241d5a5d46f6be3f22af085e7bb3f4fd0d3ff73526f2fbac8d2fd7fc04addc2cd04a5bcd673f2f2fc2980b355cd1fadd4372838
|
7
|
+
data.tar.gz: c75acdef5092862dac5016f2ea7dbd4b92a14891d6fd611bb4336482bf26cf7dd2df15058de36c8cc9115353382123e288889d8a23a599cad810efdb7b6daa2d
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# TelegramAPI
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/telegramAPI)
|
4
|
+
[](https://gemnasium.com/bennesp/telegramAPI)
|
5
|
+
[](https://codeclimate.com/github/bennesp/telegramAPI)
|
4
6
|
|
5
7
|
This is a simple and lightweight Ruby API for Telegram Bots.
|
6
8
|
|
7
9
|
With this tiny library you can create awesome Telegram Bot!
|
8
10
|
|
9
|
-
Version: 1.0.10
|
10
|
-
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
```
|
data/lib/telegramAPI.rb
CHANGED
@@ -39,6 +39,10 @@ class TelegramAPI
|
|
39
39
|
JSON.parse(open(@@core+@token+"/"+api+params_s).read)
|
40
40
|
end
|
41
41
|
|
42
|
+
def post api, name, path, to, options={}
|
43
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+api, {name=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
44
|
+
end
|
45
|
+
|
42
46
|
# Provide information about the bot itself
|
43
47
|
# @return [User] Information about the bot
|
44
48
|
def getMe
|
@@ -83,28 +87,37 @@ class TelegramAPI
|
|
83
87
|
# @param options (see #sendMessage)
|
84
88
|
# @return (see #sendMessage)
|
85
89
|
def sendPhoto to, path, options={}
|
86
|
-
|
90
|
+
self.post "/sendPhoto", :photo, path, to, options
|
91
|
+
end
|
92
|
+
|
93
|
+
# Send a photo through an ID
|
94
|
+
# @param to (see #sendMessage)
|
95
|
+
# @param id [String] The id of the photo to send
|
96
|
+
# @param options (see #sendMessage)
|
97
|
+
# @return (see #sendMessage)
|
98
|
+
def sendPhotoFromId to, id, options={}
|
99
|
+
Message.new self.query "sendPhoto", {"chat_id"=>to, "photo"=>id}.merge(parse_hash(options))["result"]
|
87
100
|
end
|
88
101
|
|
89
102
|
# Send an audio file in Ogg OPUS format of max 50MB
|
90
103
|
# @param (see #sendPhoto)
|
91
104
|
# @return (see #sendPhoto)
|
92
105
|
def sendAudio to, path, options={}
|
93
|
-
|
106
|
+
self.post "/sendAudio", :audio, path, to, options
|
94
107
|
end
|
95
108
|
|
96
109
|
# Send a general document (file, image, audio)
|
97
110
|
# @param (see #sendPhoto)
|
98
111
|
# @return (see #sendPhoto)
|
99
112
|
def sendDocument to, path, options={}
|
100
|
-
|
113
|
+
self.post "/sendDocument", :document, path, to, options
|
101
114
|
end
|
102
115
|
|
103
116
|
# Send a Sticker from File
|
104
117
|
# @param (see #sendPhoto)
|
105
118
|
# @return (see #sendSticker)
|
106
119
|
def sendStickerFromFile to, path, options={}
|
107
|
-
|
120
|
+
self.post "/sendSticker", :sticker, path, to, options
|
108
121
|
end
|
109
122
|
|
110
123
|
# Send a Sticker through its ID
|
@@ -120,7 +133,7 @@ class TelegramAPI
|
|
120
133
|
# @param (see #sendPhoto)
|
121
134
|
# @return (see #sendPhoto)
|
122
135
|
def sendVideo to, path, options={}
|
123
|
-
|
136
|
+
self.post "/sendVideo", :video, path, to, options
|
124
137
|
end
|
125
138
|
|
126
139
|
# Send a location
|
@@ -148,5 +161,5 @@ class TelegramAPI
|
|
148
161
|
UserProfilePhotos.new self.query("getUserProfilePhotos", {"user_id"=>id}.merge(parse_hash(options)))["result"]
|
149
162
|
end
|
150
163
|
|
151
|
-
protected :query, :parse_hash
|
164
|
+
protected :query, :parse_hash, :post
|
152
165
|
end
|
data/lib/telegramObjects.rb
CHANGED
@@ -182,10 +182,6 @@ class ReplyKeyboardMarkup
|
|
182
182
|
@one_time_keyboard = json["one_time_keyboard"]
|
183
183
|
@selective = json["selective"]
|
184
184
|
end
|
185
|
-
|
186
|
-
def to_json
|
187
|
-
"{\"keyboard\":" + @keyboard.to_json + ", \"resize_keyboard\":" + (!@resize_keyboard ? "false" : "true") + ", \"one_time_keyboard\":" + (!@one_time_keyboard ? "false" : "true") + ", \"selective\":" + (!@selective ? "false" : "true") + "}"
|
188
|
-
end
|
189
185
|
end
|
190
186
|
|
191
187
|
class ReplyKeyboardHide
|
@@ -195,10 +191,6 @@ class ReplyKeyboardHide
|
|
195
191
|
@hide_keyboard = json["hide_keyboard"]
|
196
192
|
@selective = json["selective"]
|
197
193
|
end
|
198
|
-
|
199
|
-
def to_json
|
200
|
-
"{\"hide_keyboard\":true, \"selective\":"+(!@selective ? "false" : "true")+"}"
|
201
|
-
end
|
202
194
|
end
|
203
195
|
|
204
196
|
class ForceReply
|
@@ -208,8 +200,4 @@ class ForceReply
|
|
208
200
|
@force_reply = json["force_reply"]
|
209
201
|
@selective = json["selective"]
|
210
202
|
end
|
211
|
-
|
212
|
-
def to_json
|
213
|
-
"{\"force_reply\":true, \"selective\":"+(!@selective ? "false" : "true")+"}"
|
214
|
-
end
|
215
203
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegramAPI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benedetto Nespoli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -59,9 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.
|
62
|
+
rubygems_version: 2.4.5
|
63
63
|
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: Telegram API for Bots
|
66
66
|
test_files: []
|
67
|
-
has_rdoc:
|