Ejemplo n.º 1
0
 def post(self, conversation_id):
     body = request.get_json()
     user_id = get_jwt_identity()
     conversation = Conversation.objects.get(id=conversation_id)
     user = User.objects.get(id=user_id)
     message =  Message(**body)
     message.conversation = conversation
     message.save()
     id = message.id
     return {'id': str(id)}, 200
Ejemplo n.º 2
0
    def post(self, conversation_id):
        conversation = Conversation.objects.get(id=conversation_id)
        query = Message.objects()
        character = Character.objects.get(id=conversation.character.id)

        query = Knowledge.objects()

        knowledges = Knowledge.objects(character=conversation.character.id)

        ramdom_message = []

        for i in range(0,random.randint(1, 10)):
            ramdom_message.append(knowledges[random.randrange(len(knowledges))].content+' ')

        message =  Message()
        message.content = ''.join(ramdom_message).strip()
        message.conversation = conversation
        message.sender_character = True
        message.save()
        return Response(message.to_json(), mimetype="application/json", status=200)