telegem 2.0.7 → 2.0.8
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/lib/api/client.rb +14 -16
- data/lib/core/bot.rb +19 -29
- data/lib/telegem.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5e8e2d8f412d455281a8ed45a4384161431715964447abf7d323c8e5a651eaf
|
|
4
|
+
data.tar.gz: e92cf5b7324c3e745a66dfcf935b9ed18bae231fa0051316070cf726dc259d4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95f13660c4b21333d0a4d68a6fb1ba25767a1f3d5aa7f06f07d0f76b82796730f8803c3036c7297d9b8aaea99cd73e22cfe01999d5a52c6456b6b0b9a42921b3
|
|
7
|
+
data.tar.gz: f5cc5f64bb886ea1f38b8c51993db49c8850a0017a0722a70f670f783fbb997fcbdebc816fb28fb92e74bf543473addda1da8300430565df0fce260c84ea8cb4
|
data/lib/api/client.rb
CHANGED
|
@@ -34,25 +34,23 @@ module Telegem
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def call!(method, params = {})
|
|
37
|
-
|
|
38
|
-
response = request.wait
|
|
39
|
-
|
|
40
|
-
if response.status != 200
|
|
41
|
-
@logger.error("HTTP Error #{response.status}") if @logger
|
|
42
|
-
return nil
|
|
43
|
-
end
|
|
37
|
+
url = "#{BASE_URL}/bot#{@token}/#{method}"
|
|
44
38
|
|
|
45
|
-
|
|
39
|
+
@logger.debug("API Call (sync): #{method}") if @logger
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
json
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
begin
|
|
42
|
+
response = @http.post(url, json: params.compact)
|
|
43
|
+
|
|
44
|
+
if response.respond_to?(:status) && response.status == 200
|
|
45
|
+
json = response.json
|
|
46
|
+
return json['result'] if json && json['ok']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
@logger.error("API Error: HTTP #{response.status}") if response.respond_to?(:status) && @logger
|
|
50
|
+
rescue => e
|
|
51
|
+
@logger.error("Exception: #{e.message}") if @logger
|
|
53
52
|
end
|
|
54
|
-
|
|
55
|
-
@logger.error("Error in call!: #{e.class}: #{e.message}") if @logger
|
|
53
|
+
|
|
56
54
|
nil
|
|
57
55
|
end
|
|
58
56
|
|
data/lib/core/bot.rb
CHANGED
|
@@ -171,35 +171,25 @@ module Telegem
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
def fetch_updates
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else
|
|
194
|
-
@logger.error("API didn't return a waitable request: #{request.class}")
|
|
195
|
-
end
|
|
196
|
-
rescue => e
|
|
197
|
-
@logger.error("Error fetching updates: #{e.class}: #{e.message}")
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
nil
|
|
201
|
-
end
|
|
202
|
-
|
|
174
|
+
params = {
|
|
175
|
+
timeout: @polling_options[:timeout],
|
|
176
|
+
limit: @polling_options[:limit]
|
|
177
|
+
}
|
|
178
|
+
params[:offset] = @offset if @offset
|
|
179
|
+
params[:allowed_updates] = @polling_options[:allowed_updates] if @polling_options[:allowed_updates]
|
|
180
|
+
|
|
181
|
+
@logger.debug("Fetching updates with offset: #{@offset}")
|
|
182
|
+
|
|
183
|
+
# Simple direct call - no .wait
|
|
184
|
+
updates = @api.call!('getUpdates', params)
|
|
185
|
+
|
|
186
|
+
if updates && updates.is_a?(Array)
|
|
187
|
+
@logger.debug("Got #{updates.length} updates")
|
|
188
|
+
return { 'ok' => true, 'result' => updates }
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
nil
|
|
192
|
+
end
|
|
203
193
|
def handle_updates_response(api_response)
|
|
204
194
|
updates = api_response['result'] || []
|
|
205
195
|
|
data/lib/telegem.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: telegem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sick_phantom
|
|
@@ -198,7 +198,7 @@ metadata:
|
|
|
198
198
|
bug_tracker_uri: https://gitlab.com/ruby-telegem/telegem/-/issues
|
|
199
199
|
documentation_uri: https://gitlab.com/ruby-telegem/telegem/-/blob/main/README.md
|
|
200
200
|
rubygems_mfa_required: 'false'
|
|
201
|
-
post_install_message: "Thanks for installing Telegem 2.0.
|
|
201
|
+
post_install_message: "Thanks for installing Telegem 2.0.8!\n\nQuick start:\n bot
|
|
202
202
|
= Telegem.new(\"YOUR_TOKEN\")\n bot.on(:message) { |ctx| ctx.reply(\"Hello!\")
|
|
203
203
|
}\n bot.start_polling\n\nDocumentation: https://gitlab.com/ruby-telegem/telegem\nHappy
|
|
204
204
|
bot building! \U0001F916\n"
|