コード例 #1
0
ファイル: app.py プロジェクト: Nandini9634/MapBot
def chat(user_input):
    try:
        response = message_to_bot(user_input, clf, learn_response)
    except:  # noqa: E722
        return jsonify({'message': ('Unable to get response', learn_response)},
                       500)  # noqa: E501

    return jsonify({'message': response}, 200)
コード例 #2
0
ファイル: views.py プロジェクト: laetit/MapBot
 def post(self, request, *args, **kwargs):
     body_payload = json.loads(self.request.body.decode('utf-8'))
     received_message = body_payload.get('message')
     print('Received Message:', received_message)
     global learn_response
     send_message, learn_response = message_to_bot(
         received_message, clf, learn_response
     )  #send received message to bot and retrieve appropriate response
     return HttpResponse(json.dumps({"message": send_message}),
                         content_type="application/json")
コード例 #3
0
ファイル: views.py プロジェクト: laetit/MapBot
def post_facebook_message(fbid, received_message):
    post_message_url = config.url
    global learn_response
    send_message, learn_response = message_to_bot(
        received_message, clf, learn_response
    )  #send received message to bot and retrieve appropriate response
    response_msg = json.dumps({
        "recipient": {
            "id": fbid
        },
        "message": {
            "text": send_message
        }
    })
    status = requests.post(post_message_url,
                           headers={"Content-Type": "application/json"},
                           data=response_msg)
    print(status.json())
コード例 #4
0
from chatbot import setup
from chatbot import message_to_bot
clf, learn_response = setup()    
while(True):
	received_message = input("You: ")
	send_message, learn_response = message_to_bot(received_message,clf,learn_response)
	print("MapBot: "+send_message)