Esempio n. 1
0
def text():
    backend = get_backend()
    message = unicode(request.args.get('message'))
    displayed_message = format_message(u"You: {}".format(message), False)
    uid = userid()
    time_taken = float(request.args.get('time_taken'))
    received_time = time.time()
    start_time = received_time - time_taken
    chat_info = backend.get_chat_info(uid)
    backend.send(
        uid,
        Event.MessageEvent(chat_info.agent_index, message, str(received_time),
                           str(start_time)))
    return jsonify(message=displayed_message, timestamp=str(received_time))
Esempio n. 2
0
 def message(self, text, metadata=None):
     return Event.MessageEvent(self.agent,
                               text,
                               time=self.timestamp(),
                               metadata=metadata)