telegramAPI 1.0.4 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/telegramAPI.rb +19 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d0765734886b2d843ea2ec0b0526e205e87f9a7
|
4
|
+
data.tar.gz: 619dc5e64b3f2e18c2e9a180b6fccb2f65ff7b0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8378d99c46773a8e6f5b1916ab323d7f431240b8f4c40f075a73a311aa6ed6ae25eaff858fb025181146e04d0f584404bb419c340073e1668c5c531244139a39
|
7
|
+
data.tar.gz: 4f059a70260155c3e4238ad87e5a3ba4d29d79947a458c241d844990876cca97b2f876ea0523798f48498698963e813879d6597edd142afff853739fe8297577
|
data/README.md
CHANGED
data/lib/telegramAPI.rb
CHANGED
@@ -21,6 +21,14 @@ class TelegramAPI
|
|
21
21
|
@last_update = 0
|
22
22
|
end
|
23
23
|
|
24
|
+
def parse_hash hash
|
25
|
+
ret = {}
|
26
|
+
hash.each do |h|
|
27
|
+
ret[h[0]]=h[1]
|
28
|
+
end
|
29
|
+
return ret
|
30
|
+
end
|
31
|
+
|
24
32
|
def query api, params={}
|
25
33
|
p=[]
|
26
34
|
params_s=""
|
@@ -41,7 +49,7 @@ class TelegramAPI
|
|
41
49
|
# @param options [Hash<String, String>] Optional settings
|
42
50
|
# @return [Array<Update>] List of all updates
|
43
51
|
def getUpdates options={"timeout"=>0, "limit"=>100}
|
44
|
-
r=self.query "getUpdates", {"offset"=>@last_update.to_s}.merge(options)
|
52
|
+
r=self.query "getUpdates", {"offset"=>@last_update.to_s}.merge(parse_hash(options))
|
45
53
|
if r['ok']!=true then return nil end
|
46
54
|
up=ArrayOf.new(r['result'],Update).to_a
|
47
55
|
if up[-1]!=nil then @last_update=up[-1].update_id+1 end
|
@@ -57,7 +65,7 @@ class TelegramAPI
|
|
57
65
|
if options.has_key?"reply_markup" then
|
58
66
|
options["reply_markup"]=options["reply_markup"].to_json
|
59
67
|
end
|
60
|
-
Message.new self.query("sendMessage", {"chat_id"=>to.to_s, "text"=>URI::encode(text)}.merge(options))["result"]
|
68
|
+
Message.new self.query("sendMessage", {"chat_id"=>to.to_s, "text"=>URI::encode(text)}.merge(parse_hash(options)))["result"]
|
61
69
|
end
|
62
70
|
|
63
71
|
# Send a message as forwarded
|
@@ -75,28 +83,28 @@ class TelegramAPI
|
|
75
83
|
# @param options (see #sendMessage)
|
76
84
|
# @return (see #sendMessage)
|
77
85
|
def sendPhoto to, path, options={}
|
78
|
-
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendPhoto", {:photo=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(options)).body)["result"]
|
86
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendPhoto", {:photo=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
79
87
|
end
|
80
88
|
|
81
89
|
# Send an audio file in Ogg OPUS format of max 50MB
|
82
90
|
# @param (see #sendPhoto)
|
83
91
|
# @return (see #sendPhoto)
|
84
92
|
def sendAudio to, path, options={}
|
85
|
-
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendAudio", {:audio=>File.new(path, 'rb'), :chat_id=>to.to_s}.merge(options)).body)["result"]
|
93
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendAudio", {:audio=>File.new(path, 'rb'), :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
86
94
|
end
|
87
95
|
|
88
96
|
# Send a general document (file, image, audio)
|
89
97
|
# @param (see #sendPhoto)
|
90
98
|
# @return (see #sendPhoto)
|
91
99
|
def sendDocument to, path, options={}
|
92
|
-
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendDocument", {:document=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(options)).body)["result"]
|
100
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendDocument", {:document=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
93
101
|
end
|
94
102
|
|
95
103
|
# Send a Sticker from File
|
96
104
|
# @param (see #sendPhoto)
|
97
105
|
# @return (see #sendSticker)
|
98
106
|
def sendStickerFromFile to, path, options={}
|
99
|
-
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendStiker", {:sticker=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(options)).body)["result"]
|
107
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendStiker", {:sticker=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
100
108
|
end
|
101
109
|
|
102
110
|
# Send a Sticker through its ID
|
@@ -105,14 +113,14 @@ class TelegramAPI
|
|
105
113
|
# @param options (see #sendPhoto)
|
106
114
|
# @return (see #sendPhoto)
|
107
115
|
def sendSticker to, id, options={}
|
108
|
-
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendSticker", {:sticker=>id, :chat_id=>to.to_s}.merge(options)).body)["result"]
|
116
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendSticker", {:sticker=>id, :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
109
117
|
end
|
110
118
|
|
111
119
|
# Send a video file in mp4 format of max 50MB
|
112
120
|
# @param (see #sendPhoto)
|
113
121
|
# @return (see #sendPhoto)
|
114
122
|
def sendVideo to, path, options={}
|
115
|
-
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendVideo", {:video=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(options)).body)["result"]
|
123
|
+
Message.new JSON.parse(RestClient.post(@@core+@token+"/sendVideo", {:video=>File.new(path,'rb'), :chat_id=>to.to_s}.merge(parse_hash(options))).body)["result"]
|
116
124
|
end
|
117
125
|
|
118
126
|
# Send a location
|
@@ -122,7 +130,7 @@ class TelegramAPI
|
|
122
130
|
# @param options (see #sendPhoto)
|
123
131
|
# @return (see #sendPhoto)
|
124
132
|
def sendLocation to, lat, long, options={}
|
125
|
-
Message.new self.query("sendLocation", {"chat_id"=>to, "latitude"=>lat, "longitude"=>long}.merge(options))["result"]
|
133
|
+
Message.new self.query("sendLocation", {"chat_id"=>to, "latitude"=>lat, "longitude"=>long}.merge(parse_hash(options)))["result"]
|
126
134
|
end
|
127
135
|
|
128
136
|
# Send a Chat Action
|
@@ -137,8 +145,8 @@ class TelegramAPI
|
|
137
145
|
# @param options (see #sendPhoto)
|
138
146
|
# @return [UserProfilePhotos]
|
139
147
|
def getUserProfilePhotos id, options={}
|
140
|
-
UserProfilePhotos.new self.query("getUserProfilePhotos", {"user_id"=>id}.merge(options))["result"]
|
148
|
+
UserProfilePhotos.new self.query("getUserProfilePhotos", {"user_id"=>id}.merge(parse_hash(options)))["result"]
|
141
149
|
end
|
142
150
|
|
143
|
-
protected :query
|
151
|
+
protected :query, :parse_hash
|
144
152
|
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.6
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|