Esempio n. 1
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)
Esempio n. 2
0
 def get(self, conversation_id):
     conversation = Conversation.objects.get(id=conversation_id)
     query = Message.objects()
     print("Id: "+conversation_id)
     messages = Message.objects(conversation=conversation.id).to_json()
     return Response(messages, mimetype="application/json", status=200)