botbase 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/botbase.rb +43 -43
- data.tar.gz.sig +0 -0
- metadata +34 -34
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
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
@@ -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.
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjE4MjEyMTQzWhcN
|
15
|
+
MjMwMjE4MjEyMTQzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC0u6QX
|
17
|
+
g3p989j/R2G82uzFRMQkiGgwP2Mu0IVGHDPPGIPOdllju1iq7SVHSMBU75MwVEYI
|
18
|
+
Ybhi/xf4noF2DWND/taAcYjyM+m9cXXutEYgktSeYVSQ9n30AEDLCVOljwAGVdY+
|
19
|
+
97x9ChUtIPGjkarqt4TZyE+rIdFcngXSyL8U1DgFxfnDoDpeuKGPOCFVsDlZSMXf
|
20
|
+
lrirFugsjfXrBONVbkR/fr/gSDqekwc4x5/anMRJhP9FW9dI4zaFVt39McrbbL1w
|
21
|
+
cX6IDdn6RDUMa5AR2FBiAZeDLhwOCqwA6eK/wl46LhcULoi4ZQyCKLwjt4MY0Seu
|
22
|
+
eabM/QzuF5TvAP2FqcT0NV3FR8yOxlJrNPe6kiNBfV1/1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apXkbMI804Bcbz4RKd7yRvY/
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
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.
|
46
|
+
version: '0.4'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
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.
|
56
|
+
version: '0.4'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
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.
|
66
|
+
version: '0.7'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
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.
|
76
|
+
version: '0.7'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
79
|
+
version: 0.7.2
|
80
80
|
description:
|
81
|
-
email:
|
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.
|
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
|