hackbot/chat_models/models.py

20 lines
796 B
Python
Raw Permalink Normal View History

2022-03-18 18:13:36 +03:00
from django.db import models
2022-03-20 15:46:53 +03:00
from uuid import uuid1
2022-03-18 18:13:36 +03:00
class Chat(models.Model):
name = models.TextField()
start_message = models.TextField(blank=True)
api_key = models.TextField()
2022-03-20 15:46:53 +03:00
admin = models.ForeignKey("users.User", on_delete=models.CASCADE, null=True, related_name='admin_chats')
tg_id = models.CharField(max_length=100, unique=True, default=uuid1)
viewers = models.ManyToManyField("users.User", null=True, related_name='viewers_chats')
2022-03-18 18:13:36 +03:00
class Message(models.Model):
text = models.TextField()
2022-03-19 20:23:17 +03:00
author = models.ForeignKey("users.User", on_delete=models.CASCADE, null=True)
2022-03-18 18:13:36 +03:00
chat = models.ForeignKey(Chat, on_delete=models.CASCADE)
2022-03-19 20:23:17 +03:00
time_created = models.DateTimeField(auto_now_add=True, null=True)
tg_id = models.CharField(null=True, max_length=100)