kybus-bot 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kybus/bot/adapters/telegram.rb +2 -2
- data/lib/kybus/bot/base.rb +15 -6
- data/lib/kybus/bot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9584eaa28f3af232e1678f2560636b1881959f6c44a1d23784f3f8c8d6279747
|
4
|
+
data.tar.gz: 4477b10b8f8fe6560f21a4193b89511dfaa4211970b08ab8f75e255508dcdd1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6dc9f558d43e3241c9d4c39c9b1a4b88d1e5bd528fe0d63bfaaed6eee462a7fe5f2aef0d563300fe426169ca7907ca01f8ff3fa8fbff44cdce103b8df09de04
|
7
|
+
data.tar.gz: f4e0412e1cae28254147f76aaf8c8eb2f33c9821e79e3cc8e905b2f449fb0e9806ecdd7f2425dd8bba8c44230f55c5f4763b1dd922fe32d62d95f000b868fa3d
|
@@ -64,7 +64,7 @@ module Kybus
|
|
64
64
|
from: message.from.to_h)
|
65
65
|
return TelegramMessage.new(message)
|
66
66
|
end
|
67
|
-
rescue Telegram::Bot::Exceptions::ResponseError => e
|
67
|
+
rescue ::Telegram::Bot::Exceptions::ResponseError => e
|
68
68
|
log_error('An error ocurred while calling to Telegram API', e)
|
69
69
|
end
|
70
70
|
end
|
@@ -78,7 +78,7 @@ module Kybus
|
|
78
78
|
def send_message(channel_name, contents)
|
79
79
|
puts "#{channel_name} => #{contents}" if @config['debug']
|
80
80
|
@client.api.send_message(chat_id: channel_name, text: contents)
|
81
|
-
rescue Telegram::Bot::Exceptions::ResponseError => err
|
81
|
+
rescue ::Telegram::Bot::Exceptions::ResponseError => err
|
82
82
|
return if err[:error_code] == '403'
|
83
83
|
end
|
84
84
|
|
data/lib/kybus/bot/base.rb
CHANGED
@@ -16,8 +16,17 @@ module Kybus
|
|
16
16
|
include Kybus::Logger
|
17
17
|
attr_reader :provider
|
18
18
|
|
19
|
+
class BotError < StandardError; end
|
20
|
+
|
21
|
+
class EmptyMessageError < BotError
|
22
|
+
def initialize
|
23
|
+
super('Message is empty')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
def send_message(content, channel = nil)
|
20
|
-
|
28
|
+
raise(EmptyMessageError) unless content
|
29
|
+
provider.send_message(channel || current_channel, content)
|
21
30
|
end
|
22
31
|
|
23
32
|
def rescue_from(klass, &block)
|
@@ -25,11 +34,11 @@ module Kybus
|
|
25
34
|
end
|
26
35
|
|
27
36
|
def send_image(content, channel = nil)
|
28
|
-
|
37
|
+
provider.send_image(channel || current_channel, content)
|
29
38
|
end
|
30
39
|
|
31
40
|
def send_audio(content, channel = nil)
|
32
|
-
|
41
|
+
provider.send_audio(channel || current_channel, content)
|
33
42
|
end
|
34
43
|
|
35
44
|
# Configurations needed:
|
@@ -61,7 +70,7 @@ module Kybus
|
|
61
70
|
@pool = Array.new(@pool_size) do
|
62
71
|
# TODO: Create a subclass with the context execution
|
63
72
|
Kybus::DRY::Daemon.new(@pool_size, true) do
|
64
|
-
message =
|
73
|
+
message = provider.read_message
|
65
74
|
@last_message = message
|
66
75
|
process_message(message)
|
67
76
|
end
|
@@ -136,7 +145,7 @@ module Kybus
|
|
136
145
|
end
|
137
146
|
|
138
147
|
def mention(name)
|
139
|
-
|
148
|
+
provider.mention(name)
|
140
149
|
end
|
141
150
|
|
142
151
|
# Loads command from state
|
@@ -174,7 +183,7 @@ module Kybus
|
|
174
183
|
# Sends a message to get the next parameter from the user
|
175
184
|
def ask_param(param)
|
176
185
|
log_debug('I\'m going to ask the next param', param: param)
|
177
|
-
|
186
|
+
provider.send_message(current_channel,
|
178
187
|
"I need you to tell me #{param}")
|
179
188
|
@state[:requested_param] = param.to_s
|
180
189
|
end
|
data/lib/kybus/bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kybus-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilberto Vargas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kybus-core
|
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
- !ruby/object:Gem::Version
|
244
244
|
version: '0'
|
245
245
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
246
|
+
rubygems_version: 3.2.32
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
249
|
summary: Provides a framework for building bots with ruby
|