Module kibicara.platforms.telegram.model
Expand source code
# Copyright (C) 2020 by Cathy Hu <cathy.hu@fau.de>
#
# SPDX-License-Identifier: 0BSD
from kibicara.model import Hood, Mapping
from ormantic import Boolean, Integer, ForeignKey, Model, Text
class Telegram(Model):
id: Integer(primary_key=True) = None
hood: ForeignKey(Hood)
api_token: Text(unique=True)
welcome_message: Text()
username: Text(allow_null=True) = None
enabled: Boolean() = True
class Mapping(Mapping):
table_name = 'telegrambots'
class TelegramUser(Model):
id: Integer(primary_key=True) = None
user_id: Integer(unique=True)
# TODO unique
bot: ForeignKey(Telegram)
class Mapping(Mapping):
table_name = 'telegramusers'
Classes
class Telegram (**data)
-
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Expand source code
class Telegram(Model): id: Integer(primary_key=True) = None hood: ForeignKey(Hood) api_token: Text(unique=True) welcome_message: Text() username: Text(allow_null=True) = None enabled: Boolean() = True class Mapping(Mapping): table_name = 'telegrambots'
Ancestors
- ormantic.models.Model
- pydantic.main.BaseModel
- pydantic.utils.Representation
Class variables
var Mapping
var api_token : ormantic.fields.Text
var enabled : ormantic.fields.Boolean
var hood : ormantic.fields.ForeignKey
var id : ormantic.fields.Integer
var username : ormantic.fields.Text
var welcome_message : ormantic.fields.Text
Instance variables
var objects
-
Expand source code
def __get__(self, instance, owner): return self.__class__(model_cls=owner)
class TelegramUser (**data)
-
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Expand source code
class TelegramUser(Model): id: Integer(primary_key=True) = None user_id: Integer(unique=True) # TODO unique bot: ForeignKey(Telegram) class Mapping(Mapping): table_name = 'telegramusers'
Ancestors
- ormantic.models.Model
- pydantic.main.BaseModel
- pydantic.utils.Representation
Class variables
var Mapping
var bot : ormantic.fields.ForeignKey
var id : ormantic.fields.Integer
var user_id : ormantic.fields.Integer
Instance variables
var objects
-
Expand source code
def __get__(self, instance, owner): return self.__class__(model_cls=owner)