11986cc5aa
ok, ok, it a late initial one include a wolfram search, some simple talking. Add a quickly, poorly written network server.
24 lines
596 B
Python
24 lines
596 B
Python
#!/usr/bin/python2.7
|
|
#-*- coding: utf-8 -*-
|
|
|
|
from rivescript import RiveScript
|
|
from twisted.internet import protocol, reactor, endpoints
|
|
from twisted.protocols.basic import LineReceiver
|
|
|
|
class Echo(LineReceiver):
|
|
def lineReceived(self, line):
|
|
print("I just receive "+line)
|
|
self.sendLine('{0}'.format(rs.reply("localuser",line)))
|
|
|
|
class EchoFactory(protocol.Factory):
|
|
def buildProtocol(self, addr):
|
|
return Echo()
|
|
|
|
|
|
rs = RiveScript()
|
|
rs.load_directory("./brain")
|
|
rs.sort_replies()
|
|
|
|
endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory())
|
|
reactor.run()
|