from backend.models.user import db

class TelegramBot(db.Model):
    __tablename__ = 'telegram_bots'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)  # 봇 식별 이름 (예: 알림용, 경고용)
    token = db.Column(db.String(200), nullable=False)
    chat_id = db.Column(db.String(100), nullable=False)
    is_active = db.Column(db.Boolean, default=True)
    description = db.Column(db.String(255), nullable=True)
    # 알림 유형: 콤마로 구분 (예: "auth,activity,system")
    notification_types = db.Column(db.String(255), default="auth,activity,system")

    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'token': self.token,
            'chat_id': self.chat_id,
            'is_active': self.is_active,
            'description': self.description,
            'notification_types': self.notification_types
        }
