botbase 0.1.6 → 0.2.2
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/botbase.rb +85 -45
- data.tar.gz.sig +0 -0
- metadata +52 -29
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 801284ecc457532920f6f6ae54adaa0dc9ff49d2f2b021341cd4d4bf5f4e4ef9
|
4
|
+
data.tar.gz: 1638c34bc647c6d550e662f621b715e0d473877094c04d5a6351cfbaf19dc83b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3309cf2096cfadf1f638177c94360fbbeb8c213ec11c6ea61bb994f40e2b9db4c3b3c0b6ea6fc913f43abcddf832bcda8eebb138acaaf2915d4210719654060
|
7
|
+
data.tar.gz: f410511eb2994605d428532a5e1ad90b59d46f7d022f4b0637f65fcc594526f81741c4989bb216ab87122175d809fa128f75e682bb68541dc6b972a56733afcd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/botbase.rb
CHANGED
@@ -3,55 +3,89 @@
|
|
3
3
|
# file: botbase.rb
|
4
4
|
|
5
5
|
|
6
|
+
require 'mtlite'
|
6
7
|
require 'simple-config'
|
7
8
|
|
8
9
|
|
9
|
-
|
10
10
|
class BotBase
|
11
|
-
|
12
|
-
def initialize(config=nil, botname: 'Nicole', notifier: nil, debug: false)
|
13
11
|
|
14
|
-
|
12
|
+
attr_reader :log
|
13
|
+
attr_accessor :channel_lock, :message_prefix
|
14
|
+
|
15
|
+
def initialize(config=nil, botname: 'Nicole', notifier: nil, log: nil,
|
16
|
+
debug: false)
|
17
|
+
|
18
|
+
@botname, @notifier, @log, @h, @debug = botname, notifier, log, nil, debug
|
15
19
|
|
16
|
-
@botname, @notifier, @debug = botname, notifier, debug
|
17
|
-
|
18
20
|
if config then
|
19
|
-
|
20
|
-
@h = SimpleConfig.new(config).to_h
|
21
|
-
puts '
|
22
|
-
# load the service modules
|
21
|
+
|
22
|
+
@h = SimpleConfig.new(config).to_h
|
23
|
+
puts '@h: ' + @h.inspect if @debug
|
23
24
|
@modules = initialize_modules(@h[:modules])
|
24
|
-
|
25
|
+
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
28
|
-
|
29
|
-
#
|
30
|
-
#
|
31
|
-
def debug(msg)
|
32
|
-
notice 'botbase/debug: ' + msg if @debug
|
33
|
-
end
|
34
|
-
|
35
|
-
# used for display debug messages from modules
|
29
|
+
|
30
|
+
# displays debug messages from modules
|
36
31
|
#
|
37
32
|
def notice(msg)
|
38
33
|
@notifier.notice msg if @notifier
|
39
|
-
|
40
|
-
|
34
|
+
puts msg
|
35
|
+
end
|
36
|
+
|
41
37
|
def received(sender='user01', msg, mode: :voicechat, echo_node: 'node1')
|
42
38
|
|
43
39
|
msg.rstrip!
|
40
|
+
|
41
|
+
if msg.downcase == 'exit' then
|
42
|
+
@channel_lock, @message_prefix = nil, nil
|
43
|
+
end
|
44
|
+
|
45
|
+
log.info 'BotBase/received: ' + msg if log
|
44
46
|
self.restart if msg == @botname + ' restart'
|
45
|
-
|
47
|
+
|
46
48
|
r = nil
|
47
|
-
|
48
|
-
detected = @
|
49
|
-
|
50
|
-
|
49
|
+
|
50
|
+
detected = if @channel_lock then
|
51
|
+
|
52
|
+
if @debug then
|
53
|
+
notice 'botbase: inside channel locked'
|
54
|
+
notice 'botbase: fullmsg:' + (@message_prefix.to_s + msg).inspect
|
55
|
+
end
|
56
|
+
|
57
|
+
r = @modules[@channel_lock].query(@message_prefix.to_s + msg,
|
58
|
+
mode: mode, echo_node: echo_node)
|
59
|
+
puts 'r: ' + r.inspect if @debug
|
60
|
+
r and r.length > 0
|
61
|
+
|
62
|
+
else
|
63
|
+
|
64
|
+
if @debug then
|
65
|
+
puts 'before modules.detect'
|
66
|
+
puts '@modules.values: ' + @modules.values\
|
67
|
+
.map {|x| x.inspect[0..100] }.join("\n")
|
68
|
+
end
|
69
|
+
|
70
|
+
@modules.detect do |name, obj|
|
71
|
+
puts 'name: ' + name.inspect if @debug
|
72
|
+
r = obj.query(msg, mode: mode, echo_node: echo_node)
|
73
|
+
r and r.length > 0
|
74
|
+
end
|
75
|
+
|
51
76
|
end
|
52
|
-
|
77
|
+
|
78
|
+
|
53
79
|
if detected then
|
54
|
-
|
80
|
+
|
81
|
+
puts 'detected: ' + detected.inspect[0..200] + ' ...' if @debug
|
82
|
+
|
83
|
+
if mode == :voicechat then
|
84
|
+
MTLite.new(r).to_s.gsub(/ +https:\/\/[\S]+/,'')
|
85
|
+
else
|
86
|
+
MTLite.new(r).to_html
|
87
|
+
end
|
88
|
+
|
55
89
|
else
|
56
90
|
''
|
57
91
|
end
|
@@ -60,30 +94,36 @@ class BotBase
|
|
60
94
|
|
61
95
|
def restart
|
62
96
|
|
63
|
-
|
97
|
+
log.info 'BotBase/restart: restarting ...' if log
|
64
98
|
@modules = initialize_modules(@h[:modules]) if @h
|
65
99
|
notice "echo: #{@botname} is now ready"
|
66
|
-
|
100
|
+
|
67
101
|
end
|
68
|
-
|
102
|
+
|
69
103
|
private
|
70
|
-
|
104
|
+
|
71
105
|
def initialize_modules(modules)
|
72
|
-
|
73
|
-
modules.
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
106
|
+
|
107
|
+
a = modules.map do |name, settings|
|
108
|
+
|
109
|
+
settings = {} if settings.is_a? String
|
110
|
+
|
111
|
+
if log then
|
112
|
+
log.info 'BotBase/initialize_modules: ' +
|
113
|
+
'initialising botbase-module-' + name.to_s
|
114
|
+
end
|
115
|
+
|
79
116
|
klass_name = 'BotBaseModule' + name.to_s
|
80
117
|
|
81
|
-
|
82
|
-
|
118
|
+
[name, Kernel.const_get(klass_name).new(**settings.merge({callback: self,
|
119
|
+
debug: @debug}))]
|
83
120
|
|
84
121
|
end
|
85
|
-
|
86
|
-
end
|
87
122
|
|
88
|
-
|
89
|
-
|
123
|
+
puts 'a: ' + a[0..100].inspect if @debug
|
124
|
+
a.to_h
|
125
|
+
|
126
|
+
|
127
|
+
end
|
128
|
+
|
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.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,51 +10,75 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjE4MjEyMTQzWhcN
|
15
|
+
MjMwMjE4MjEyMTQzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC0u6QX
|
17
|
+
g3p989j/R2G82uzFRMQkiGgwP2Mu0IVGHDPPGIPOdllju1iq7SVHSMBU75MwVEYI
|
18
|
+
Ybhi/xf4noF2DWND/taAcYjyM+m9cXXutEYgktSeYVSQ9n30AEDLCVOljwAGVdY+
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Q7oNyVdm2/gYq9k4U5s0fZ3MFc8NVUS
|
34
|
+
9pKO1E6ZwgJWCS8i3OXR+KGLD6vM9EXKxhHt3xTTmmDSkh+NSFX7cUCFrT2JMf9h
|
35
|
+
IAiTYWcp2K6HhPr/C46tBo6SMl9cc8ZhSEe6o+v8LhynIxIGj7fUgkDRI7mFC8BE
|
36
|
+
apXkbMI804Bcbz4RKd7yRvY/
|
33
37
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
38
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
35
39
|
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: mtlite
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.4'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.4.1
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.4'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.4.1
|
36
60
|
- !ruby/object:Gem::Dependency
|
37
61
|
name: simple-config
|
38
62
|
requirement: !ruby/object:Gem::Requirement
|
39
63
|
requirements:
|
40
64
|
- - "~>"
|
41
65
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
66
|
+
version: '0.7'
|
43
67
|
- - ">="
|
44
68
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
69
|
+
version: 0.7.2
|
46
70
|
type: :runtime
|
47
71
|
prerelease: false
|
48
72
|
version_requirements: !ruby/object:Gem::Requirement
|
49
73
|
requirements:
|
50
74
|
- - "~>"
|
51
75
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
76
|
+
version: '0.7'
|
53
77
|
- - ">="
|
54
78
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
79
|
+
version: 0.7.2
|
56
80
|
description:
|
57
|
-
email:
|
81
|
+
email: digital.robertson@gmail.com
|
58
82
|
executables: []
|
59
83
|
extensions: []
|
60
84
|
extra_rdoc_files: []
|
@@ -79,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
103
|
- !ruby/object:Gem::Version
|
80
104
|
version: '0'
|
81
105
|
requirements: []
|
82
|
-
|
83
|
-
rubygems_version: 2.6.13
|
106
|
+
rubygems_version: 3.2.22
|
84
107
|
signing_key:
|
85
108
|
specification_version: 4
|
86
109
|
summary: Provides bot functionality primarily for use by the sps_bot gem.
|
metadata.gz.sig
CHANGED
Binary file
|