You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

23 lines
596 B

#!/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()