2022-09-12 10:19:35 +00:00
|
|
|
import time
|
2022-01-22 21:27:52 +00:00
|
|
|
|
2022-11-15 09:19:08 +00:00
|
|
|
from sqlalchemy import Column, ForeignKey
|
|
|
|
from sqlalchemy.sql.sqltypes import *
|
|
|
|
|
|
|
|
from files.classes import Base
|
|
|
|
|
2023-03-18 13:34:04 +00:00
|
|
|
class Emoji(Base):
|
|
|
|
__tablename__ = "emojis"
|
2022-01-22 21:27:52 +00:00
|
|
|
|
|
|
|
name = Column(String, primary_key=True)
|
2023-03-18 13:34:04 +00:00
|
|
|
kind = Column(String)
|
2022-01-23 23:06:34 +00:00
|
|
|
author_id = Column(Integer, ForeignKey("users.id"))
|
|
|
|
tags = Column(String)
|
|
|
|
count = Column(Integer, default=0)
|
2022-09-09 09:13:50 +00:00
|
|
|
submitter_id = Column(Integer, ForeignKey("users.id"))
|
2022-09-19 20:40:33 +00:00
|
|
|
created_utc = Column(Integer)
|
2023-09-29 07:15:29 +00:00
|
|
|
over_18 = Column(Boolean, default=False)
|
2022-09-19 20:40:33 +00:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
|
|
|
super().__init__(*args, **kwargs)
|
2022-01-22 21:27:52 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
2022-11-29 21:02:38 +00:00
|
|
|
return f"<{self.__class__.__name__}(name={self.name})>"
|
2022-11-27 16:59:36 +00:00
|
|
|
|
|
|
|
def tags_list(self):
|
|
|
|
return self.tags.split(" ") + [self.name[len("marsey"):]] # type: ignore
|
|
|
|
|
|
|
|
def json(self):
|
2022-11-29 03:17:28 +00:00
|
|
|
data = {
|
2022-11-27 16:59:36 +00:00
|
|
|
"name": self.name,
|
|
|
|
"author_id": self.author_id,
|
|
|
|
"submitter_id": self.submitter_id,
|
|
|
|
"tags": self.tags_list(),
|
|
|
|
"count": self.count,
|
|
|
|
"created_utc": self.created_utc,
|
2023-03-18 13:34:04 +00:00
|
|
|
"kind": self.kind,
|
2022-11-27 16:59:36 +00:00
|
|
|
}
|
2023-07-01 00:25:09 +00:00
|
|
|
if "author_username" in self.__dict__ and self.author_username:
|
|
|
|
data["author_username"] = self.author_username
|
|
|
|
if "author_original_username" in self.__dict__ and self.author_original_username:
|
|
|
|
data["author_original_username"] = self.author_original_username
|
|
|
|
if "author_prelock_username" in self.__dict__ and self.author_prelock_username:
|
|
|
|
data["author_prelock_username"] = self.author_prelock_username
|
2022-11-29 03:17:28 +00:00
|
|
|
return data
|