kybus-bot 0.4.2 → 0.4.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9584eaa28f3af232e1678f2560636b1881959f6c44a1d23784f3f8c8d6279747
4
- data.tar.gz: 4477b10b8f8fe6560f21a4193b89511dfaa4211970b08ab8f75e255508dcdd1e
3
+ metadata.gz: '01392aefbe8bf2a7f5be90e5cc0f77fbbcf66ece5ed77c2bd9f01be3fb9b476b'
4
+ data.tar.gz: 43ec132ea325c8fe9cd6401d6976a80fcd9e57939483b8f79ea48848b0015bc4
5
5
  SHA512:
6
- metadata.gz: e6dc9f558d43e3241c9d4c39c9b1a4b88d1e5bd528fe0d63bfaaed6eee462a7fe5f2aef0d563300fe426169ca7907ca01f8ff3fa8fbff44cdce103b8df09de04
7
- data.tar.gz: f4e0412e1cae28254147f76aaf8c8eb2f33c9821e79e3cc8e905b2f449fb0e9806ecdd7f2425dd8bba8c44230f55c5f4763b1dd922fe32d62d95f000b868fa3d
6
+ metadata.gz: 63f439ab82c6faf1324133146b5b47bff2a0c9fa8d29c8daab00f322edd6c5b47a639f0bd99150cdd420e9a95e2ddd9f32a62245f9ddd85bd6eba35af643481a
7
+ data.tar.gz: a8a5cffea95d2831d911577d5754d45ed97361bda2f99ddf42812aa2b4058b800abb8a17944d7d84c8f14eba4f4d734290b5c0c24355082e3bf54340adce3bee
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'base'
4
+ require_relative '../message'
5
+
3
6
  module Kybus
4
7
  module Bot
5
8
  # :nodoc: #
@@ -8,9 +11,10 @@ module Kybus
8
11
  # Wraps a debugging message inside a class.
9
12
  class DebugMessage < Kybus::Bot::Message
10
13
  # It receives a string with the raw text and the id of the channel
11
- def initialize(text, channel)
14
+ def initialize(text, channel, attachments = {})
12
15
  @text = text
13
16
  @channel = channel
17
+ @attachments = attachments
14
18
  end
15
19
 
16
20
  # Returns the channel id
@@ -22,6 +26,10 @@ module Kybus
22
26
  def raw_message
23
27
  @text
24
28
  end
29
+
30
+ def user
31
+ channel_id
32
+ end
25
33
  end
26
34
 
27
35
  # This class simulates a message chat with a user.
@@ -51,6 +51,7 @@ module Kybus
51
51
  @pool_size = configs['pool_size']
52
52
  @provider = Kybus::Bot::Adapter.from_config(configs['provider'])
53
53
  @commands = Kybus::Bot::CommandDefinition.new
54
+ register_command('default') do; end
54
55
 
55
56
  # TODO: move this to config
56
57
  @repository = Kybus::Storage::Repository.from_config(
@@ -148,6 +149,10 @@ module Kybus
148
149
  provider.mention(name)
149
150
  end
150
151
 
152
+ def registered_commands
153
+ @commands.registered_commands
154
+ end
155
+
151
156
  # Loads command from state
152
157
  def current_command_object
153
158
  command = @state[:cmd]
@@ -36,6 +36,10 @@ module Kybus
36
36
  @commands[name] = Command.new(params, block)
37
37
  end
38
38
 
39
+ def registered_commands
40
+ @commands.keys
41
+ end
42
+
39
43
  # Returns a command with the name
40
44
  def [](name)
41
45
  @commands[name]
@@ -0,0 +1,32 @@
1
+ require_relative 'base'
2
+ require_relative 'adapters/debug'
3
+
4
+ module Kybus
5
+ module Bot
6
+ class Base
7
+ CONFIG = {
8
+ 'name' => 'test',
9
+ 'state_repository' => {
10
+ 'name' => 'json',
11
+ 'storage' => 'storage'
12
+ },
13
+ 'pool_size' => 1,
14
+ 'provider' => {
15
+ 'name' => 'debug',
16
+ 'echo' => true,
17
+ 'channels' => { 'testing' => [] }
18
+ }
19
+ }.freeze
20
+
21
+ def self.make_test_bot
22
+ new(CONFIG)
23
+ end
24
+
25
+ def receives(msg, attachments = {})
26
+ msg = ::Kybus::Bot::Adapter::DebugMessage.new(msg, 'testing', attachments)
27
+ @last_message = msg
28
+ process_message(msg)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kybus
4
4
  module Bot
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.6'
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.2
4
+ version: 0.4.6
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-12-16 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kybus-core
@@ -222,6 +222,7 @@ files:
222
222
  - lib/kybus/bot/command_definition.rb
223
223
  - lib/kybus/bot/message.rb
224
224
  - lib/kybus/bot/migrator.rb
225
+ - lib/kybus/bot/test.rb
225
226
  - lib/kybus/bot/testing.rb
226
227
  - lib/kybus/bot/version.rb
227
228
  homepage: https://github.com/tachomex/kybus