botbase 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/botbase.rb +43 -43
  4. data.tar.gz.sig +0 -0
  5. metadata +34 -34
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bbd23516c8209afe0fdb853910f6b0c92c21b8dd62065ce7b7454a2273469b7
4
- data.tar.gz: a905535704581fdbbf8fb4857565bff1e238328c911db44cc94c49209a2bc64a
3
+ metadata.gz: 801284ecc457532920f6f6ae54adaa0dc9ff49d2f2b021341cd4d4bf5f4e4ef9
4
+ data.tar.gz: 1638c34bc647c6d550e662f621b715e0d473877094c04d5a6351cfbaf19dc83b
5
5
  SHA512:
6
- metadata.gz: aadebb98b3ce7d1f64272e32d67e8bdfe9673043305c0d0135f2757feb44386aa64c6e3e3a216a6ccf04b5da4a16b9e397ca6ff104fee496208f629cda1402df
7
- data.tar.gz: 9674b8b047ffbbaa524920c8e1920143854032b32efd50fbe81d77e70ae0aebf83506ffdf30467c68ddd10f4e4fcf3981f98290291286a497b6ac4d81be7ada0
6
+ metadata.gz: a3309cf2096cfadf1f638177c94360fbbeb8c213ec11c6ea61bb994f40e2b9db4c3b3c0b6ea6fc913f43abcddf832bcda8eebb138acaaf2915d4210719654060
7
+ data.tar.gz: f410511eb2994605d428532a5e1ad90b59d46f7d022f4b0637f65fcc594526f81741c4989bb216ab87122175d809fa128f75e682bb68541dc6b972a56733afcd
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/botbase.rb CHANGED
@@ -7,79 +7,79 @@ require 'mtlite'
7
7
  require 'simple-config'
8
8
 
9
9
 
10
- class BotBase
11
-
10
+ class BotBase
11
+
12
12
  attr_reader :log
13
13
  attr_accessor :channel_lock, :message_prefix
14
-
15
- def initialize(config=nil, botname: 'Nicole', notifier: nil, log: nil,
14
+
15
+ def initialize(config=nil, botname: 'Nicole', notifier: nil, log: nil,
16
16
  debug: false)
17
17
 
18
18
  @botname, @notifier, @log, @h, @debug = botname, notifier, log, nil, debug
19
-
19
+
20
20
  if config then
21
-
22
- @h = SimpleConfig.new(config).to_h
21
+
22
+ @h = SimpleConfig.new(config).to_h
23
23
  puts '@h: ' + @h.inspect if @debug
24
24
  @modules = initialize_modules(@h[:modules])
25
-
25
+
26
26
  end
27
27
 
28
28
  end
29
-
29
+
30
30
  # displays debug messages from modules
31
31
  #
32
32
  def notice(msg)
33
33
  @notifier.notice msg if @notifier
34
34
  puts msg
35
- end
36
-
35
+ end
36
+
37
37
  def received(sender='user01', msg, mode: :voicechat, echo_node: 'node1')
38
38
 
39
39
  msg.rstrip!
40
-
40
+
41
41
  if msg.downcase == 'exit' then
42
42
  @channel_lock, @message_prefix = nil, nil
43
43
  end
44
-
44
+
45
45
  log.info 'BotBase/received: ' + msg if log
46
46
  self.restart if msg == @botname + ' restart'
47
-
47
+
48
48
  r = nil
49
-
49
+
50
50
  detected = if @channel_lock then
51
-
51
+
52
52
  if @debug then
53
53
  notice 'botbase: inside channel locked'
54
54
  notice 'botbase: fullmsg:' + (@message_prefix.to_s + msg).inspect
55
55
  end
56
-
57
- r = @modules[@channel_lock].query(@message_prefix.to_s + msg,
56
+
57
+ r = @modules[@channel_lock].query(@message_prefix.to_s + msg,
58
58
  mode: mode, echo_node: echo_node)
59
59
  puts 'r: ' + r.inspect if @debug
60
- r and r.length > 0
61
-
60
+ r and r.length > 0
61
+
62
62
  else
63
-
63
+
64
64
  if @debug then
65
65
  puts 'before modules.detect'
66
66
  puts '@modules.values: ' + @modules.values\
67
67
  .map {|x| x.inspect[0..100] }.join("\n")
68
68
  end
69
-
69
+
70
70
  @modules.detect do |name, obj|
71
71
  puts 'name: ' + name.inspect if @debug
72
72
  r = obj.query(msg, mode: mode, echo_node: echo_node)
73
- r and r.length > 0
73
+ r and r.length > 0
74
74
  end
75
-
75
+
76
76
  end
77
-
78
-
77
+
78
+
79
79
  if detected then
80
-
80
+
81
81
  puts 'detected: ' + detected.inspect[0..200] + ' ...' if @debug
82
-
82
+
83
83
  if mode == :voicechat then
84
84
  MTLite.new(r).to_s.gsub(/ +https:\/\/[\S]+/,'')
85
85
  else
@@ -97,33 +97,33 @@ class BotBase
97
97
  log.info 'BotBase/restart: restarting ...' if log
98
98
  @modules = initialize_modules(@h[:modules]) if @h
99
99
  notice "echo: #{@botname} is now ready"
100
-
100
+
101
101
  end
102
-
102
+
103
103
  private
104
-
104
+
105
105
  def initialize_modules(modules)
106
-
106
+
107
107
  a = modules.map do |name, settings|
108
-
108
+
109
109
  settings = {} if settings.is_a? String
110
-
110
+
111
111
  if log then
112
- log.info 'BotBase/initialize_modules: ' +
112
+ log.info 'BotBase/initialize_modules: ' +
113
113
  'initialising botbase-module-' + name.to_s
114
114
  end
115
-
115
+
116
116
  klass_name = 'BotBaseModule' + name.to_s
117
-
118
- [name, Kernel.const_get(klass_name).new(settings.merge({callback: self,
117
+
118
+ [name, Kernel.const_get(klass_name).new(**settings.merge({callback: self,
119
119
  debug: @debug}))]
120
120
 
121
121
  end
122
-
122
+
123
123
  puts 'a: ' + a[0..100].inspect if @debug
124
124
  a.to_h
125
-
126
-
127
- end
128
-
125
+
126
+
127
+ end
128
+
129
129
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: botbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNzAzMTQ0OTI2WhcN
15
- MjEwNz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5ypsK6PqMw+leSn6T9aN8H3jcc
34
- als1Sa+uEEug4C+DfnxUhoC0AvbZHy8DfDB8b0CRwqfo4PHDQUEDMSuoq62MuGqw
35
- 6lxxv/jQ5LA2SHCIatmdVQQqUXVpPmCojcHy4+FB0Vfcq9e/pEdiGEhaJnQkNjMc
36
- NH8JIgyRVXldUCa9Ahsubk7V
28
+ BgkqhkiG9w0BAQsFAAOCAYEAG0/x3cnRIl8bMU26Jx4yD4H7hx1YdAiOk3ySWjU8
29
+ P+3aWZq+9AtgC0TtgRG4sHIipoDarQfxXt8FXMo7AwRg+NhzL3xFHdtUKsah1hOE
30
+ DKthV6xIdIaGTuBxbFD1hB8eS29CpkgT7mhvL+sDwcCd+AU89A5DpLrIVKXZj09W
31
+ BzCNk4ZgPoCa/ELtGZSdXOw1I+fST8RPFzl7odXDVTPbViLRlQGNjy7nUaCX5Gzf
32
+ Xjy2/XlRfMhNUE/rdconP2gkLZ/UogT3oPXWWHCYT2NfWEme29O7Oo4bhLfDbi/t
33
+ gXKQpLqSFAl3GIiL6MKM6NCpS/f6N4NVdQ7oNyVdm2/gYq9k4U5s0fZ3MFc8NVUS
34
+ 9pKO1E6ZwgJWCS8i3OXR+KGLD6vM9EXKxhHt3xTTmmDSkh+NSFX7cUCFrT2JMf9h
35
+ IAiTYWcp2K6HhPr/C46tBo6SMl9cc8ZhSEe6o+v8LhynIxIGj7fUgkDRI7mFC8BE
36
+ apXkbMI804Bcbz4RKd7yRvY/
37
37
  -----END CERTIFICATE-----
38
- date: 2020-07-03 00:00:00.000000000 Z
38
+ date: 2022-02-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: mtlite
@@ -43,42 +43,42 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.3'
46
+ version: '0.4'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.3.5
49
+ version: 0.4.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.3'
56
+ version: '0.4'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.3.5
59
+ version: 0.4.1
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: simple-config
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0.6'
66
+ version: '0.7'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.6.4
69
+ version: 0.7.2
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.6'
76
+ version: '0.7'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.6.4
79
+ version: 0.7.2
80
80
  description:
81
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
82
82
  executables: []
83
83
  extensions: []
84
84
  extra_rdoc_files: []
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.3
106
+ rubygems_version: 3.2.22
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Provides bot functionality primarily for use by the sps_bot gem.
metadata.gz.sig CHANGED
Binary file