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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 189f024f3c6411b1c2c7d918a7ccfca6afd2cffe096c53f76522932c74be1b17
4
- data.tar.gz: 9f9b3928b68ea6b1fc1e6ae204d5e0a34223c3e909b2986bae0c477b848d73ca
3
+ metadata.gz: 9584eaa28f3af232e1678f2560636b1881959f6c44a1d23784f3f8c8d6279747
4
+ data.tar.gz: 4477b10b8f8fe6560f21a4193b89511dfaa4211970b08ab8f75e255508dcdd1e
5
5
  SHA512:
6
- metadata.gz: 234bf15cd1c11549de4b8d3513a7abc50f76ffaae56aeb2248a112007b540fccf0e6a42f195c67b7a2a5032d13930e20f2384fb117ab86194d564c30ebb1d423
7
- data.tar.gz: f3c6e1743cea030340a677d6b7674932ded040e2ac4febfcc24eacfb76e7f36d39bbec85a908c52fe7e06bf782364a11abebc4f941b1d314b60e48fed7ed7766
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
 
@@ -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
- @provider.send_message(channel || current_channel, content)
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
- @provider.send_image(channel || current_channel, content)
37
+ provider.send_image(channel || current_channel, content)
29
38
  end
30
39
 
31
40
  def send_audio(content, channel = nil)
32
- @provider.send_audio(channel || current_channel, content)
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 = @provider.read_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
- @provider.mention(name)
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
- @provider.send_message(current_channel,
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kybus
4
4
  module Bot
5
- VERSION = '0.4.1'
5
+ VERSION = '0.4.2'
6
6
  end
7
7
  end
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.1
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-06-15 00:00:00.000000000 Z
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.1.4
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