sps_bot 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce530ef25261caba1cf7366d6e444388dc7655c4
4
- data.tar.gz: 6300de20701965b373e1926b8dedeafb01da6725
3
+ metadata.gz: 3cdcdf2ad7477331d1a755e6394e8669808c39fe
4
+ data.tar.gz: 3ade3a1ab3191d376cc0716f1bee29ad1aa4de77
5
5
  SHA512:
6
- metadata.gz: f03b4dfb5839660f60eb81048e1ba98961a5d8cefe85d3a0aeca441679851b9a4a29d93d49190632acef00de12e2a1e33550fa9151bfe85dcaa8691fa3196075
7
- data.tar.gz: 0bd661ef61ec15ff0515ffa6761cfd864563dc01b13415c242d77e8ec9acabae388a5d64556d29e72a2d2e8ae1ccdc055a9d4b249cd97cfde9249abfa41cc8e4
6
+ metadata.gz: 0759f72b90e270c4c6373cd8e44168ebc4c2ffac3d5ceb574de95d1a21453353b51941457c75efe24fff9d15b5c1cf4e4576b658ccee745278e793da26ab1e3a
7
+ data.tar.gz: c4910cc60cd0292ddb877f86afd1186ca6c279515d00136343ca747aecac1265896fab5d4a526186e8900ee1c22f30d2c71680c4f1ffd7514ff9874300d7ac80
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/sps_bot.rb CHANGED
@@ -7,23 +7,47 @@ require 'sps_chat'
7
7
 
8
8
  class SpsBot < SPSChat
9
9
 
10
- def initialize(host: 'localhost', port: '8080', userid: 'bot')
10
+ def initialize(host: 'localhost', port: '8080', userid: 'bot',
11
+ service_modules: nil, room: '')
11
12
 
12
- super(host: host, port: port, userid: userid)
13
+ super(host: host, port: port, userid: userid, room: room)
14
+
15
+ @phrases = {}
13
16
 
14
- end
15
-
16
- def onincoming(sender, msg)
17
+ a = if service_modules then
18
+
19
+ service_modules
17
20
 
18
- case msg
19
- when /what's the time\?/i
20
- self.send 'The time is ' + Time.now.strftime("%-I:%M%p")
21
- when /hello?/i
22
- self.send "hello #{sender}, how can I help you?" % sender
23
21
  else
24
- self.send "I'm sorry, I don't understand what you said."
22
+
23
+ h = {
24
+ "^What's the time?" => "'The time is ' + Time.now.strftime(\"%-I:%M%p\")",
25
+ "hello?" => %q("hello #{sender}, how can I help you?" % sender),
26
+ 'unknown' => "\"I'm sorry, I don't understand what you said.\""
27
+ }
28
+ [h]
29
+
30
+ end
31
+
32
+ a.each {|x| @phrases.merge! x }
33
+
34
+ end
35
+
36
+ def onincoming(sender, msg)
37
+
38
+ r = @phrases.detect {|k,v| msg =~ /#{k}/i }
39
+
40
+ raw_msg = if r then
41
+ r.last
42
+ else
43
+ unknown = h['unknown']
44
+ unknown.last if unknown
25
45
  end
26
46
 
47
+ response = eval raw_msg
48
+
49
+ self.send response
50
+
27
51
  end
28
52
 
29
- end
53
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  C9953c/cW9RSvURZAGzbWWYlJrpUPx8rLJTUfpphqF+p4HssT5ddVIfb9sGiiRrL
32
32
  FproyCdNk6P65Q==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-11-16 00:00:00.000000000 Z
34
+ date: 2016-04-16 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sps_chat
metadata.gz.sig CHANGED
Binary file