This commit is contained in:
bakatrouble 2020-02-12 20:22:42 +03:00
parent db530d98fd
commit 789a3c0a9d

View File

@ -17,15 +17,15 @@ from bots.models import TelegramBotModuleConfig
class PingBotCategory(models.Model):
chat_id = models.BigIntegerField(db_index=True)
cat_name = models.CharField(max_length=64, db_index=True)
user_ids = JSONField(default='[]')
user_ids = JSONField(null=True)
def add_user(self, uid: int):
user_ids = set(self.user_ids)
user_ids = set(self.user_ids or [])
user_ids.add(uid)
self.user_ids = list(user_ids)
def remove_user(self, uid: int):
user_ids = set(self.user_ids)
user_ids = set(self.user_ids or [])
user_ids.add(uid)
self.user_ids = list(user_ids)