Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (51 sloc) 1.836 kB
54a434b Initial import.
Pistos authored
1 # lmathetes-bridge.rb
2
3 # Acts as a bridge between the Learning Mathetes AI engine and your
4 # eggdrop (through Reby)
5 # By Pistos - irc.freenode.net#geobot
6
7 # This is not a standalone Ruby script; it is meant to be run from Reby
8 # (http://purepistos.net/eggdrop).
9
10 # Usage:
11 # Directly address the bot.
12 # e.g. GeoBot: How are you?
13
14 class String
15 def escapeQuotes
16 temp = ""
17 each_byte do |b|
18 if b == 39
19 temp << 39
20 temp << 92
21 temp << 39
22 end
23 temp << b
24 end
25
26 return temp
27 end
28 end
29
30 class Array
31 def escapeQuotes
32 return to_s.escapeQuotes
33 end
34 end
35
36
37 class LMathetesBridge
38 def initialize
39 $reby.bind( "pubm", "-", "#geoshell *", "listen", "$lmathetes_bridge" )
40 $reby.bind( "pubm", "-", "#mathetes *", "listen", "$lmathetes_bridge" )
41 end
42
43 def listen( nick, userhost, handle, channel, args )
44 if args.join( " " ) =~ /^[Gg][Ee][Oo][Bb][Oo][Tt] ?[^A-Za-z!.\s]+\s+(.+)$/
45 speech = $1.escapeQuotes
46
47 pwd = Dir.pwd
48 #Dir.chdir( "/home/geobot/mathetes-unloved" )
49 Dir.chdir( "/home/geobot/public-mathetes" )
50 #response = `./lmathetes.rb -s '#{nick.escapeQuotes}' --database 'lmathetes_unloved' '#{speech}'`.chomp
51 $reby.log "./lmathetes.rb -s '#{nick.escapeQuotes}' '#{speech}'"
52 response = `./lmathetes.rb -s '#{nick.escapeQuotes}' '#{speech}'`.chomp
53 Dir.chdir( pwd )
54 if response == nil or response == ""
55 response = "I experienced technical difficulties handling your input. Please try again."
56 end
57 $reby.putserv "PRIVMSG #{channel} :#{nick}: #{response}"
58 end
59 end
60 end
61
62 $lmathetes_bridge = LMathetesBridge.new
Something went wrong with that request. Please try again.