def chat():
    request_data = request.args.get('msg')
    request_data = request_data.capitalize()
    if request_data == "Drama" or request_data == "Comedy" or request_data == "Romance" or request_data == "Horror" or request_data == "Thriller" or request_data == "Action" or request_data == "Children" or request_data == "Adventure" or request_data == "Animation":
        movieToPrint = getMovie(request_data)
        response = bot.chat(request_data)
        return movieToPrint + "--->" + str(response)
    else:
        response = bot.chat(request_data)
        return str(response)
示例#2
0
def receive_message():
    if request.method == 'GET':
        """Before allowing people to message your bot, Facebook has implemented a verify token
        that confirms all requests that your bot receives came from Facebook.""" 
        token_sent = request.args.get("hub.verify_token")
        return verify_fb_token(token_sent)
    #if the request was not get, it must be POST and we can just proceed with sending a message back to user
    else:
        # get whatever message a user sent the bot
       output = request.get_json()
       for event in output['entry']:
          messaging = event['messaging']
          for message in messaging:
            if message.get('message'):
                #Facebook Messenger ID for user so we know where to send response back to
                recipient_id = message['sender']['id']
                if message['message'].get('text'):
                    text = message['message'].get('text')
                    response_sent_text = bot.chat(text)
                    send_message_fb(recipient_id, response_sent_text)
                #if user sends us a GIF, photo,video, or any other non-text item
                if message['message'].get('attachments'):
                    response_sent_nontext = "I'm sorry, I can't handle non text messages"
                    send_message_fb(recipient_id, response_sent_nontext)
    return "Message Processed"
示例#3
0
def chat():
    if request.method == "POST":
        request_data = request.get_json()
        message = request_data['message']
        response = bot.chat(message)
        data = {}
        data["reply"] = response
        data["status"] = 'Success'
        return jsonify(data)
示例#4
0
def chat():
    if request.method == "POST":
        request_data = request.get_json()
        message = request_data['message']
        status, response = bot.chat(message)
        data = {}
        data["reply"] = response
        data["status"] = 'success' if status != 0 else 'failed'
        return jsonify(data)
示例#5
0
def process_update():
    if request.method == "POST":
        data = request.get_json()
        if "message" in data:
            chat_id = get_last_mess(data)["chat_id"]
            text = get_last_mess(data)["text"]
            bot_text = bot.chat(text)
            send_mess(chat_id, bot_text)
        return "ok!", 200
    return "..."
示例#6
0
def chat():
    try:
        user_message = request.form["text"]
        response_text = bot.chat(user_message)
        return jsonify({"status": "success", "response": response_text})
    except Exception as e:
        print(e)
        return jsonify({
            "status": "success",
            "response": "Sorry I am not trained to do that yet..."
        })
示例#7
0
def chat():
    if request.method == "POST":
        request_data = request.get_json()
        message = request_data['message']
        status, responce = bot.chat(message)
        data = {}
        if status == 0:
            data["reply"] = responce
            data["status"] = 'Success'
            return jsonify(data)
        else:
            data["reply"] = responce
            data["status"] = 'failed'
            return jsonify(data)
def chat():
    if request.method == "POST":
        rf = request.form
        for key in rf.keys():
            message = key
        status, response = bot.chat(str(message))
        data = {}

        if status == 0:
            data["reply"] = response
            data["status"] = 'Sucess'
            return data
        else:
            data["reply"] = response
            data["status"] = 'Failed'
            return data
def chat():
    if request.method == "POST":
        request_data = request.form.to_dict()
        print(request_data)
        message = request_data['message']
        print(message)
        status, response = bot.chat(str(message))
        data = {}

        if status == 0:
            data["reply"] = response
            data["status"] = 'Sucess'
            return jsonify(data)
        else:
            data["reply"] = response
            data["status"] = 'Failed'
            return jsonify(data)
示例#10
0
 def send_message_insert(self, message):
     user_input = self.entry_field.get()
     pr1 = "Human : " + user_input + "\n"
     self.text_box.configure(state=NORMAL)
     self.text_box.insert(END, pr1)
     self.text_box.configure(state=DISABLED)
     self.text_box.see(END)
     ob=chat(user_input)
     pr="PyBot : " + ob + "\n"
     self.text_box.configure(state=NORMAL)
     self.text_box.insert(END, pr)
     self.text_box.configure(state=DISABLED)
     self.text_box.see(END)
     self.last_sent_label(str(time.strftime( "Last message sent: " + '%B %d, %Y' + ' at ' + '%I:%M %p')))
     self.entry_field.delete(0,END)
     time.sleep(0)
     t2 = threading.Thread(target=self.playResponce, args=(ob,))
     t2.start()
示例#11
0
def hello(client):
        price = ["price", "cost", "rate", "rates", "how much"]
        ask=["can i have","i would like to have","can", "may", "will", "shall", "would", "should", "give", "server", "deliver"]
        ask1=["table","booking","can you book table for ","reservation","can", "may", "will", "shall", "would", "should", "give", "server", "deliver"]
        question = ["suggest me something", "give","best","recomend me ","special", "server", "deliver"]
        if findtagin(price,client)==1:
                output=find_price(client)
        if findtagin(question,client)==1:
                output=recomend(" ")
        if findtagin(ask,client)==1:
                output=count_coffee(client)
        if findtagin(ask1,client)==1:
                output="To book a table you can click on last icon on your left side"
                
        if findtagin(ask,client)==findtagin(ask1,client)==findtagin(price,client)==findtagin(question,client)==0:
                output=chat(client)
        sql = "INSERT INTO chatbot (User,Bot) VALUES (%s, %s)"
        val = (client,output)
        mycursor.execute(sql, val)
        mydb.commit()
示例#12
0
def get_bot_response():
    userText = request.args.get('msg')
    reply = chat(userText)
    return str(reply)
示例#13
0
def handle_command(sock, response) -> None:
    """Execute commands given by users.

    All command handling return strings to be
    printed out to the socket.
    """

    msg = Message(response)
    if msg.username:
        chat_db.add_msg(msg.username, msg.message)
        print(msg)

    # If command is found
    if msg.command:
        static = command_db.get_command(msg.command)
        if static:
            bot.chat(sock, static)

        elif msg.username == 'monipooh' and 'pikachu' in msg.message:
            bot.chat(sock, 'Pikachu OMEGALUL')

        elif msg.command in commands_func_list:
            bot.chat(sock, commands_func_list[msg.command]())

        elif msg.command == 'commands':
            static_list = command_db.get_command_list()
            dynamic_list = ', '.join([
                '!' + x
                for x in sorted(list(static_list.keys()) + command_list)
            ])
            bot.chat(sock, f'The commands for this channel are {dynamic_list}')

        elif msg.command == 'points':
            bot.chat(sock, point_db.points_command(msg))

        elif msg.command == 'gamble':
            bot.chat(sock, point_db.gamble(msg))

        elif msg.command == 'gamblestats':
            bot.chat(sock, point_db.gamblestats(msg))

        elif msg.command == 'challenge':
            bot.chat(sock, point_db.handle_challenge_command(msg))

        elif msg.command == 'cancel':
            bot.chat(sock, point_db.cancel_challenge(msg))

        elif msg.command == 'decline':
            bot.chat(sock, point_db.decline_challenge(msg))

        elif msg.command == 'accept':
            for line in point_db.accept_challenge(msg):
                bot.chat(sock, line)
                sleep(1.5)

        elif msg.command == 'urmom':
            bot.chat(sock, 'YOUR MOM ' + space_command('KappaPride BIG GAY'))

        elif msg.command in [x + 'stats' for x in ['pidgey', 'nido']]:
            bot.chat(sock, counter_db.stats(msg.command))

        elif msg.command == 'eeveestats':
            bot.chat(sock, counter_db.eevee_stats())

        elif msg.command in ['nido', 'pidgey', 'eevee'] and msg.is_admin:
            counter_db.increment_counter(msg.command)
            bot.chat(sock, f'Adding one success to the {msg.command} counter!')

        elif msg.command in ['nidofail', 'pidgeyfail', 'eeveefail'
                             ] and msg.is_admin:
            counter_db.increment_counter(msg.command)
            bot.chat(sock,
                     f'Adding one failed catch to the {msg.command} counter!')

        elif msg.command == 'resetstats' and msg.is_admin:
            bot.chat(sock, counter_db.reset_entries(msg.command_body))

        elif msg.command == 'hydrate':
            bot.chat(sock, counter_db.hydrate())

        elif msg.command in ['hydratestats', 'hydratecount']:
            bot.chat(sock, counter_db.hydrate_stats())

        elif msg.command == 'mock':
            bot.chat(
                sock, ''.join([
                    char.upper() if random.random() > 0.5 else char
                    for char in chat_db.get_recent_msg(msg.command_body)
                ]))

        elif msg.command == 'tts':
            bot.chat(sock, point_db.say(msg))

        # addpoints, subpoints, setpoints
        elif msg.command in point_commands and msg.is_admin:
            bot.chat(sock, point_db.handle_point_command(msg))

        # settitle, setgame
        elif msg.command in admin_commands and msg.is_admin:
            bot.chat(sock, admin_commands[msg.command](msg.command_body))

        # add, edit, remove
        elif msg.command in meta_commands and msg.metacommand:
            bot.chat(sock, handle_meta_command(
                msg))  #msg.command, msg.metacommand[1:], msg.message))

    return
示例#14
0
'''

File: run.py
runs the chat bot from terminal
'''


import bot
bot.chat()
示例#15
0
def runner( ):
    global chatbot
    global out_buff
    global in_buff
    global inflag
    global outflag
    global msghistory
    global stopflag
    inpneed=False
    # program = "python bot.py"
    # print("calling subprocess")
    # # inp=input()
    # # print(inp)
    # chatbot=Popen(program,
    #                     stdin=PIPE,
    #                     stderr=PIPE,
    #                     stdout=PIPE,
    #                     creationflags=CREATE_NEW_CONSOLE)
    # # write(chatbot, "30 m")
    # # print("1")
    # # print(read(chatbot))
    # # print("1")
    # # print(read(chatbot))
    # # print("1")
    # # print(read(chatbot))
    # # print("1")
    # # print(read(chatbot))
    # print("waiting")

    # line=""
    # rc=1
    # while rc != 0:
    #     # print(rc)
    #     while True:
    #         # print(".")
    #         if inpneed:
    #             break
    #         line = read(chatbot)
    #         if not line:
    #             break
    #         print (line)
    #         if "inp!:-" not in line:
    #             msghistory.append(line)
    #             # line=None
    #         if "inp!:-" in line:
    #             inpneed=True
    #     if inpneed:
    #         # inp=input(":-")
    #         # write(chatbot, inp)
    #         # print(".",end="")
    #         if inflag:
    #             write(chatbot, in_buff)
    #             inflag=False
    #             print("Done")
    #             inpneed=False
    #             # time.sleep(1)

    #     rc = chatbot.poll()
    # print("done waiting")

    bot.chat()
    stopflag=True
示例#16
0
文件: main.py 项目: RusseII/deephire
def start(): 
    socketio.emit("message_recieved", chat("start"), room=request.sid)
    return
示例#17
0
def index():
    user_input = request.json['user_input']
    return jsonify({'msg': str(chat(user_input))})
示例#18
0
文件: main.py 项目: RusseII/deephire
def get_message(msg):
    db().query("INSERT INTO Messages VALUES (?)", (msg,))
    print msg
    socketio.emit("message_recieved", chat(msg), room=request.sid )
    return
示例#19
0
def chat_flow(text: str):
    return b.chat(text)
示例#20
0
def talkViaApi():
    user_input = request.args.get("user_input")
    return jsonify({'msg': str(chat(user_input))})
示例#21
0
        output_row = out_empty[:]
        output_row[labels.index(docs_y[x])] = 1

        training.append(bag)
        output.append(output_row)

    training = numpy.array(training)
    output = numpy.array(output)

    with open("data.pickle", "wb") as f:
        pickle.dump((words, labels, training, output), f)

tensorflow.reset_default_graph()

net = tflearn.input_data(shape=[None, len(training[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax")
net = tflearn.regression(net)

model = tflearn.DNN(net)

if os.path.exists("model.tflearn.index"):
    model.load("model.tflearn", weights_only=True)
else:
    model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)
    model.save("model.tflearn")

bot.chat(model, (words, labels))
示例#22
0
from bot import chat

print(
    'REMDEX: I will answer your queries...If you want  to exit,type bye... :)')

W = "REMDEX: "

exit_list = ['exit', 'see you later', 'bye', 'quit', 'break']

while True:
    user_input = input()
    if user_input.lower() in exit_list:
        print('REMDEX: Bye..Take Care..Chat with you later!!')
        break
    else:
        ans = chat(user_input)
        print(W + str(ans))
示例#23
0
#!/usr/bin/env python3

import time
import bot
import cfg
#import argparse
#import numpy as np


def cleanMsg(response):
    chat_MSG = chat_MSG = bot.re.compile(
        r"^:\w+!\w+@\.tmi\.twitch\.tv PRIVMSG #\w+ :")
    return chat_MSG.sub("", response)


bot.chat(s, "I'm here!")


def chat(sock, msg):
    sock.send("PRIVMSG #{} :{}".format(cfg.CHAN, msg))


chat_MSG = bot.re.compile(r"^:\w+!\w+@\.tmi\.twitch\.tv PRIVMSG #\w+ :")
time.sleep(30 / cfg.RATE)

while bot.PING or bot.PONG == True:
    print(str("I'm here"))

#simple hello command
if bot.response == "!hello":
    msg = "HELLO SCRUB"