コード例 #1
0
def get_bot_response():
    userText = request.args.get('msg')
    return str(bot(userText))
コード例 #2
0
import hashlib
import web
import reply
import receive
from chatbot import bot
import time

agent = bot()


class Handle(object):
    def POST(self):
        try:
            webData = web.data()
            print("Handle Post webdata is :", webData)
            #后台打日志
            recMsg = receive.parse_xml(webData)
            if isinstance(recMsg, receive.Msg):
                toUser = recMsg.FromUserName
                fromUser = recMsg.ToUserName
                recv_content = recMsg.Content.decode()
                if recMsg.MsgType == 'text':
                    print('recv:', recv_content)
                    ans = agent.search(recv_content)
                    #print('ans:',ans)
                    #content = "公众号test"
                    replyMsg = reply.TextMsg(toUser, fromUser, ans)
                    return replyMsg.send()
                if recMsg.MsgType == 'image':
                    mediaId = recMsg.MediaId
                    replyMsg = reply.ImageMsg(toUser, fromUser, mediaId)
コード例 #3
0
ファイル: app.py プロジェクト: aimihat/IChack-2018
from flask import Flask, request, session, g, redirect, url_for, abort, \
	render_template, flash, Markup, jsonify, make_response, send_from_directory

from werkzeug.contrib.profiler import ProfilerMiddleware
from xlsxwriter.utility import xl_rowcol_to_cell

# Intitialize and configure Flask app.
app = Flask(__name__)
app.config.from_object(__name__)
app.config.update(dict(
	SECRET_KEY="#$dsfasdas943JHSs9dueidoijdf",  # secret key for signing sessions
))
app.config.from_envvar('APP_SETTINGS', silent=True)

chatbot = bot()
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

def tts(response, session):
    path= "sessions/"+str(session)+"/tts.mp3"
    tts = gTTS(text=response, lang='en')
    if os.path.exists(path):
        os.remove(path)
        print('deleted existing tts')
    tts.save(path)
    return path

@app.before_request
def before_request():
コード例 #4
0
ファイル: tcp.py プロジェクト: ArthonKorea/artchatbot
    port = 8000
    mySocket = socket.socket()
    mySocket.bind((host, port))

    mySocket.listen(1)
    conn, addr = mySocket.accept()
    print("Connection from: " + str(addr))
    while True:
        data = conn.recv(1024).decode()
        if not data:
            break
        if "init" in str(data):
            conn.send("init/안녕하세요 저는 **라는 작품이에요".encode())
            continue

        print("from connected  user: "******"안녕"
        data = "response/" + str(Output)
        print("respon: " + str(Output))
        conn.send(data.encode())

    conn.close()


if __name__ == '__main__':
    bot = chatbot.bot()
    Main()
コード例 #5
0
ファイル: main.py プロジェクト: ahmedBassell/bot
from chatbot import bot


# Main
sara = bot('Sara')
sara.start()
コード例 #6
0
ファイル: train.py プロジェクト: joanmon/chat-bot
from chatbot import bot
from chatterbot.trainers import ListTrainer

vilaNetBot = bot()

conversation = [
    "Hello", "Hi there!", "How are you doing?", "I'm doing great.",
    "That is good to hear", "Thank you.", "You're welcome."
]

vilaNetBot.set_trainer(ListTrainer)
vilaNetBot.train(conversation)
コード例 #7
0
ファイル: apiGateway.py プロジェクト: deepti96/FarmApp
def get():
    args = request.args
    question = args['question']
    answer = bot(question)
    #print (answer) # For debugging
    return jsonify(answer)
コード例 #8
0
def chatbot(request):
    return chatbot_request(request, bot())