uploader-bot/app/core/models/messages.py

33 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from base58 import b58decode
from sqlalchemy import Column, Integer, String, DateTime, JSON, BigInteger, Boolean, ForeignKey
from sqlalchemy.orm import relationship
from .base import AlchemyBase
# Only for clean old messages now
class KnownTelegramMessage(AlchemyBase):
__tablename__ = 'known_telegram_messages'
id = Column(Integer, autoincrement=True, primary_key=True)
type = Column(String(64), nullable=True)
# common: все сообщения (удаляются постоянно)
# start_command: /start (остается одно)
# notification (не удаляется): licenseWasBought, contentWasIndexed
# content/audio, content/video (удаляются только если пришел еще раз этот же контент в лс)
# hint
bot_id = Column(Integer, nullable=False, default=1) # 0 uploader, 1 client
chat_id = Column(BigInteger, nullable=False)
message_id = Column(BigInteger, nullable=False)
from_user = Column(Boolean, nullable=False)
from_telegram_id = Column(BigInteger, nullable=True)
created = Column(DateTime, nullable=False, default=0)
deleted = Column(Boolean, nullable=True, default=False)
meta = Column(JSON, nullable=False, default={})
# можно записывать все что угодно о сообщениях
content_id = Column(Integer, ForeignKey('node_storage.id'), nullable=True)