botbase 0.2.0 → 0.2.1

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 +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/botbase.rb +47 -10
  5. metadata +29 -26
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5a3376d131dd2f7fd14437f20bfcd5715b56a646
4
- data.tar.gz: ce7bb6b2f91974c946c97388190ad08a74a9d914
2
+ SHA256:
3
+ metadata.gz: 3bbd23516c8209afe0fdb853910f6b0c92c21b8dd62065ce7b7454a2273469b7
4
+ data.tar.gz: a905535704581fdbbf8fb4857565bff1e238328c911db44cc94c49209a2bc64a
5
5
  SHA512:
6
- metadata.gz: 2a28663cb9cf43a6c5f98202db7c445b538198f3f34049d0555f0cdfc530564cb037815ec333ba497d086943613ce968f1440ec6b6f995ba7afc0c2792c19cb4
7
- data.tar.gz: 292949c8c503273ab8468e7a947774ea3ce7d84eaef5fd2f5133fd220c32622a3302908f571ee46fcf24c266a9aa53596448199993e6e0f98e15314d93ec72b3
6
+ metadata.gz: aadebb98b3ce7d1f64272e32d67e8bdfe9673043305c0d0135f2757feb44386aa64c6e3e3a216a6ccf04b5da4a16b9e397ca6ff104fee496208f629cda1402df
7
+ data.tar.gz: 9674b8b047ffbbaa524920c8e1920143854032b32efd50fbe81d77e70ae0aebf83506ffdf30467c68ddd10f4e4fcf3981f98290291286a497b6ac4d81be7ada0
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -10,43 +10,76 @@ require 'simple-config'
10
10
  class BotBase
11
11
 
12
12
  attr_reader :log
13
+ attr_accessor :channel_lock, :message_prefix
13
14
 
14
-
15
- def initialize(config=nil, botname: 'Nicole', notifier: nil, log: nil)
15
+ def initialize(config=nil, botname: 'Nicole', notifier: nil, log: nil,
16
+ debug: false)
16
17
 
17
- @botname, @notifier, @log, @h = botname, notifier, log, nil
18
+ @botname, @notifier, @log, @h, @debug = botname, notifier, log, nil, debug
18
19
 
19
20
  if config then
20
21
 
21
22
  @h = SimpleConfig.new(config).to_h
23
+ puts '@h: ' + @h.inspect if @debug
22
24
  @modules = initialize_modules(@h[:modules])
23
25
 
24
26
  end
25
27
 
26
28
  end
27
29
 
28
- # used for display debug messages from modules
30
+ # displays debug messages from modules
29
31
  #
30
32
  def notice(msg)
31
33
  @notifier.notice msg if @notifier
34
+ puts msg
32
35
  end
33
36
 
34
37
  def received(sender='user01', msg, mode: :voicechat, echo_node: 'node1')
35
38
 
36
39
  msg.rstrip!
37
40
 
41
+ if msg.downcase == 'exit' then
42
+ @channel_lock, @message_prefix = nil, nil
43
+ end
44
+
38
45
  log.info 'BotBase/received: ' + msg if log
39
46
  self.restart if msg == @botname + ' restart'
40
47
 
41
48
  r = nil
42
49
 
43
- detected = @modules.detect do |m|
44
- r = m.query(msg, mode: mode, echo_node: echo_node)
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
45
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
+
46
76
  end
47
77
 
78
+
48
79
  if detected then
49
80
 
81
+ puts 'detected: ' + detected.inspect[0..200] + ' ...' if @debug
82
+
50
83
  if mode == :voicechat then
51
84
  MTLite.new(r).to_s.gsub(/ +https:\/\/[\S]+/,'')
52
85
  else
@@ -71,9 +104,8 @@ class BotBase
71
104
 
72
105
  def initialize_modules(modules)
73
106
 
74
- modules.inject([]) do |r, m|
107
+ a = modules.map do |name, settings|
75
108
 
76
- name, settings = m
77
109
  settings = {} if settings.is_a? String
78
110
 
79
111
  if log then
@@ -83,10 +115,15 @@ class BotBase
83
115
 
84
116
  klass_name = 'BotBaseModule' + name.to_s
85
117
 
86
- r << Kernel.const_get(klass_name).new(settings.merge({callback: self}))
118
+ [name, Kernel.const_get(klass_name).new(settings.merge({callback: self,
119
+ debug: @debug}))]
87
120
 
88
121
  end
122
+
123
+ puts 'a: ' + a[0..100].inspect if @debug
124
+ a.to_h
125
+
89
126
 
90
127
  end
91
128
 
92
- end
129
+ end
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MTAxNDE2NDUzNVoXDTE4MTAxNDE2NDUzNVowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBANRgsuAOAgt7b/Ss3HNTIZOuJE3zhRVN8Vm0GjNRHpazL61v3mCFMLQCdqX7
19
- AVgM5KGcM2N11UntqBPcrm/ZoH7/QixzdPJ1B3Sm5vgA/XUSLIqFZgo6rmB9gCwj
20
- K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+ 262I7WGjLgCUNff+IyUpqoamAKS1QnPaESTOuveagyLCFS1vPNHAKYK5AZBFcf6y
33
+ 8ebqh6Juc9VkxCopWu04bDjrjCvNZ04YtbUwvP5ypsK6PqMw+leSn6T9aN8H3jcc
34
+ als1Sa+uEEug4C+DfnxUhoC0AvbZHy8DfDB8b0CRwqfo4PHDQUEDMSuoq62MuGqw
35
+ 6lxxv/jQ5LA2SHCIatmdVQQqUXVpPmCojcHy4+FB0Vfcq9e/pEdiGEhaJnQkNjMc
36
+ NH8JIgyRVXldUCa9Ahsubk7V
33
37
  -----END CERTIFICATE-----
34
- date: 2017-11-07 00:00:00.000000000 Z
38
+ date: 2020-07-03 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: mtlite
@@ -62,7 +66,7 @@ dependencies:
62
66
  version: '0.6'
63
67
  - - ">="
64
68
  - !ruby/object:Gem::Version
65
- version: 0.6.3
69
+ version: 0.6.4
66
70
  type: :runtime
67
71
  prerelease: false
68
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,7 +76,7 @@ dependencies:
72
76
  version: '0.6'
73
77
  - - ">="
74
78
  - !ruby/object:Gem::Version
75
- version: 0.6.3
79
+ version: 0.6.4
76
80
  description:
77
81
  email: james@jamesrobertson.eu
78
82
  executables: []
@@ -99,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
103
  - !ruby/object:Gem::Version
100
104
  version: '0'
101
105
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.6.13
106
+ rubygems_version: 3.0.3
104
107
  signing_key:
105
108
  specification_version: 4
106
109
  summary: Provides bot functionality primarily for use by the sps_bot gem.
metadata.gz.sig CHANGED
Binary file