Example #1
0
class ElizaBot(BotPlugin):
    eliza_daemon = Eliza()

    @botcmd
    def eliza(self, _, args):
        """ El'cheapo shrink for you """
        args = args.strip()
        return self.eliza_daemon.respond(args)

    @botcmd
    def askus(self, _, __):
        """ Give us a fun topic to talk about
            thx to http://chatoms.com/
        """
        content = urlopen('http://chatoms.com/chatom.json?Normal=1&Fun=2&Philosophy=3&Out+There=4&Love=5&Personal=7').read()
        return json.loads(content.decode())['text']

    @botcmd
    def complete(self, _, args):
        """ Complete the given sentence
            thx to the awesome google completion
        """
        args = args.strip()
        if not args:
            return 'Complete what ?'

        content = urlopen('http://google.com/complete/search?q=%s&output=toolbar' % quote(args)).read()
        xml = objectify.fromstring(content)
        possibilities = xml.xpath("//toplevel/CompleteSuggestion/suggestion/@data")
        if possibilities:
            return choice(possibilities)
        return 'Hmmm... no answer for that'
Example #2
0
def main():

    load_dotenv()
    token = os.getenv('DISCORD_TOKEN')
    channel = os.getenv('DISCORD_CHANNEL')

    bot = Eliza(token, channel)
    bot.run()
Example #3
0
 def __init__(self, name, avatar, sprite, scriptfile):
     self.name = name
     self.coordinates = (0,0)
     self.avatar = avatar
     self.sprite = sprite
     self.eliza = Eliza()
     #self.outputbox = OutputBox()
     #self.inputbox = InputBox()
     self.leadinfulfilled = False
     with open(scriptfile) as character_script:
         content = character_script.read()
         self.eliza.combined_script += content
Example #4
0
    def startup(self):
        #alternative icon embedding
        #path=os.path.dirname(os.path.abspath(__file__))
        #brutus_icon=os.path.join(path,"icons","brutus.icns")
        #Eliza module
        self.partner=Eliza()

        self.chat=toga.DetailedList(
            data=[
                {
                    'icon':toga.Icon('icons/ubs-logo.png'),

                    'title': 'Bot',
                    'subtitle': 'Hello. How are you feeling today?'
                }
            ]
            ,style=Pack(flex=1))

        self.text_input=toga.TextInput(style=Pack(flex=1))
        
        send_button=toga.Button('Send',style=Pack(padding_left=5),on_press=self.handle_input)

        input_box=toga.Box(
            children=[self.text_input, send_button],
            style=Pack(direction=ROW, alignment=CENTER, padding=5)
        )
#alignment='CENTER',
        # Create a main window with a name matching the app
        self.main_window = toga.MainWindow(title=self.name)

        # Create a main content box
        #main_box = toga.Box()

        # Add the content on the main window
        self.main_window.content = toga.Box(
            children=[self.chat,input_box],
            style=Pack(direction=COLUMN)
        )

        # Show the main window
        self.main_window.show()
Example #5
0
import random
from eliza import Eliza
from tools import connection, randomString
from flask import Flask
from flask import request
from flask import render_template
from flask import send_from_directory
from flask import session
from flask import make_response
from MySQLdb import escape_string as thwart
from datetime import datetime

# global vars
app = Flask(__name__, static_url_path="")
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
therapist = Eliza();
success = json.dumps({"status": "OK"})
error = json.dumps({"status": "ERROR"})
cookies = dict()
histories = dict()  # holds the histories for each userid

# helper methods
def eliza_response(user_input):
    return '{"eliza": "' +  str(therapist.respond(user_input)) + ' "}'


# flask methods
@app.route('/eliza/static/<path:path>')
def send_static(path):
    return send_from_directory('static', path)
Example #6
0
from eliza import Eliza

eliza = Eliza(lang='id')
print(eliza.respond('aku bosan'))
Example #7
0
 def __init__(self, config_file):
     self.HISTORY_FILENAME = os.path.expanduser('~/.eliza_history')
     self.init_history(self.HISTORY_FILENAME)
     self.eliza = Eliza(config_file)
Example #8
0
#!/usr/bin/env python3
from eliza import Eliza

eliza = Eliza()
eliza.load('doctor-fr.txt')

print(eliza.initial())
while True:
    said = input('> ')
    response = eliza.respond(said)
    if response is None:
        break
    print(response)
print(eliza.final())