Example #1
0
        class Player(peewee.Model):
            user_id = peewee.BigIntegerField()
            chat_id = peewee.BigIntegerField()

            last_payout = peewee.BigIntegerField(default=0)

            lastmsg = peewee.BigIntegerField(default=0)
            lastreq = peewee.BigIntegerField(default=0)

            state = peewee.IntegerField(default=0)
            money = peewee.IntegerField(default=0)

            wins = peewee.IntegerField(default=0)
            losses = peewee.IntegerField(default=0)

            helm = peewee.ForeignKeyField(Equipment,
                                          on_delete='SET NULL',
                                          null=True,
                                          related_name="hemled")
            chest = peewee.ForeignKeyField(Equipment,
                                           on_delete='SET NULL',
                                           null=True,
                                           related_name="chested")
            weapon = peewee.ForeignKeyField(Equipment, on_delete='SET NULL', null=True, related_name="weaponed")\

            class Meta:
                database = self.pwmanager.database
                indexes = ((('user_id', 'chat_id'), True), )
Example #2
0
class Log(peewee.Model):
    id = peewee.BigIntegerField()
    timestamp = peewee.DateTimeField()
    channel = peewee.BigIntegerField()
    author = peewee.BigIntegerField()
    content = peewee.TextField()
    attachments = peewee.TextField()

    class Meta:
        table_name = 'logs'
        database = db

    @classmethod
    def log(cls, message):
        cls.create(id=message.id,
                   timestamp=message.created_at,
                   channel=message.channel.id,
                   author=message.author.id,
                   content=message.content,
                   attachments=json.dumps(
                       list(
                           map(
                               lambda attachment: {
                                   'id': str(attachment.id),
                                   'size': attachment.size,
                                   'width': attachment.width,
                                   'height': attachment.height,
                                   'filename': attachment.filename,
                                   'url': attachment.url,
                                   'proxy_url': attachment.proxy_url
                               }, message.attachments))))
Example #3
0
class Cat(BaseModel):
    id = peewee.BigAutoField(unique=True, index=True, primary_key=True)
    uuid = peewee.CharField(unique=True, index=True, max_length=36)
    name = peewee.CharField(max_length=256)
    age = peewee.SmallIntegerField()
    sex = peewee.BooleanField()
    breed = peewee.BigIntegerField()
    health_status = peewee.BigIntegerField()
    castrated = peewee.BooleanField()
    vaccinated = peewee.BooleanField()
    dewormed = peewee.BooleanField()
    colour = peewee.BigIntegerField()
    description = peewee.TextField()
    health_log = peewee.TextField()
    adoptive = peewee.BooleanField()
    adopted_by = peewee.CharField(index=True, max_length=36, null=True)
    pictures = peewee.TextField()
    created_at = peewee.DateTimeField(default=datetime.datetime.now)
    updated_at = peewee.DateTimeField()

    def save(self, *args, **kwargs):
        self.updated_at = datetime.datetime.now()
        return super(Cat, self).save(*args, **kwargs)

    class Meta:
        table_name = 'cats'
class PessoaContato(peewee.Model, Base):
    def __init__(self, env=None):
        super(PessoaContato, self).__init__()
        if env:
            database = env.db.connect()

    email = peewee.CharField(null=True)
    fax = peewee.CharField(null=True)
    celular = peewee.CharField(null=True)
    telefone = peewee.CharField(null=True)
    nome = peewee.CharField(null=True)
    telefone_empresarial = peewee.CharField(null=True)
    skype = peewee.CharField(null=True)
    observacoes = peewee.CharField(null=True)
    data_cad = peewee.DateField(null=True)
    codigo = peewee.BigIntegerField(null=True)
    pessoa = peewee.BigIntegerField(null=True)
    padrao = peewee.IntegerField(null=True)
    ativo = peewee.IntegerField(null=True)

    def begin(self):
        database.begin()
        database.set_autocommit(False)

    def commit(self):
        database.commit()
        database.set_autocommit(True)

    def rollback(self):
        database.rollback()
        database.set_autocommit(True)

    class Meta:
        database = database
        db_table = 'pessoa_contato'
Example #5
0
class PollTemplate(BaseModel):
    name = peewee.CharField(null=False, max_length=100)
    guild_id = peewee.BigIntegerField(null=False)

    channel_id = peewee.BigIntegerField(null=True)
    result_channel_id = peewee.BigIntegerField(null=True)
    anonymous = peewee.BooleanField(null=True)
    max_votes_per_user = peewee.IntegerField(null=True)
    type = EnumField(Poll.Type, null=True)
    role_id_needed_to_vote = peewee.BigIntegerField(null=True)
    delta = peewee.CharField(null=True)
    vote_percentage_to_pass = peewee.IntegerField(null=True)
    mention_role = peewee.BooleanField(null=True, default=False)
    pin = peewee.BooleanField(null=True, default=False)
    delete_after_results = peewee.BooleanField(null=True, default=False)

    class Meta:
        indexes = ((('name', 'guild_id'), True), )

    @property
    def shared_columns(self):
        return \
        {
            "guild_id"                  : self.guild_id,
            "channel_id"                : self.channel_id,
            "result_channel_id"         : self.result_channel_id,
            "anonymous"                 : self.anonymous,
            "max_votes_per_user"        : self.max_votes_per_user,
            "type"                      : self.type,
            "role_id_needed_to_vote"    : self.role_id_needed_to_vote,
            "vote_percentage_to_pass"   : self.vote_percentage_to_pass,
            "pin"                       : self.pin,
            "delete_after_results"      : self.delete_after_results,
            "mention_role"              : self.mention_role,
        }
Example #6
0
class TabLog(BaseModel):
    '''
    用户访问行为记录
    '''
    uid = peewee.CharField(
        null=False,
        index=True,
        unique=True,
        primary_key=True,
        max_length=36,
    )
    current_url = peewee.CharField(
        null=False,
        help_text='',
    )
    refer_url = peewee.CharField(
        null=False,
        help_text='',
    )
    user_id = peewee.CharField(
        null=False,
        index=True,
        max_length=36,
        help_text='',
    )
    time_create = peewee.BigIntegerField()
    time_out = peewee.BigIntegerField()
    time = peewee.BigIntegerField()
Example #7
0
class LeaveMessagePluginData(BaseModel):
    """
    留言数据表
    """
    id = pw.BigAutoField()  # 留言id
    ref_id = pw.BigIntegerField(default=-1)  # 关联留言id(一个对话下来的留言id, 取第一个留言的id)
    user_id = pw.BigIntegerField(index=True)  # 留言所属客户id
    user_name = pw.CharField(max_length=50)  # 留言用户名
    status = pw.CharField(max_length=20,
                          choices=[('untreated', '未处理'), ('treating', '处理中'),
                                   ('treated', '已处理'), ('canceled', '已撤销')],
                          default='untreated',
                          index=True)  # 处理状态
    msg = pw.CharField(max_length=2000)  # 客户留言信息
    pic_urls = pw.CharField(max_length=1000,
                            default='')  # 客户上传的图片文件url清单, 逗号分隔
    ref_msg = pw.CharField(max_length=2000, default='')  # 留言引用对话消息内容
    resp_time = pw.DateTimeField(null=True)  # 回复时间
    resp_user_id = pw.BigIntegerField(index=True, default=0)  # 回复用户id
    resp_user_name = pw.CharField(default='')  # 回复用户名
    resp_msg = pw.CharField(max_length=2000, default='')  # 回复信息
    resp_pic_urls = pw.CharField(max_length=1000,
                                 default='')  # 回复的图片文件url清单, 逗号分隔
    create_time = pw.DateTimeField(default=datetime.datetime.now)  # 创建时间

    class Meta:
        # 定义数据库表名
        table_name = 'leave_message_plugin_data'
Example #8
0
class Prankster(BaseModel):
    class PrankType(Enum):
        nickname = 1
        role = 2
        emoji = 3

    user_id = peewee.BigIntegerField(null=False)
    guild_id = peewee.BigIntegerField(null=False)
    last_pranked = peewee.DateTimeField(null=True)
    enabled = peewee.BooleanField(null=False, default=False)
    pranked = peewee.BooleanField(null=False, default=False)
    prank_type = EnumField(PrankType, null=True)

    @property
    def days_ago_last_pranked(self):
        if self.last_pranked is not None:
            return (datetime.datetime.utcnow() - self.last_pranked).days

    @property
    def current_prank(self):
        if not self.pranked:
            return None

        classes = {
            self.PrankType.nickname: NicknamePrank,
            self.PrankType.emoji: EmojiPrank,
            self.PrankType.role: RolePrank,
        }
        cls = classes.get(self.prank_type)

        if cls is not None:
            query = cls.select()
            query = query.where(cls.victim == self)
            query = query.where(cls.finished == False)
            return query.first()
Example #9
0
    class Transaction(pw.Model):
        id = pw.CharField(max_length=64, primary_key=True)
        version = pw.SmallIntegerField()
        block_id = pw.ForeignKeyField(
            backref="transaction_set",
            column_name="block_id",
            field="id",
            model=migrator.orm["blocks"],
        )
        sequence = pw.SmallIntegerField()
        timestamp = pw.IntegerField(index=True)
        sender_public_key = pw.CharField(index=True, max_length=66)
        recipient_id = pw.CharField(index=True, max_length=66, null=True)
        type = pw.SmallIntegerField()
        vendor_field = pw.CharField(max_length=255, null=True)
        amount = pw.BigIntegerField()
        fee = pw.BigIntegerField()
        serialized = pw.BlobField()
        asset = pw_pext.JSONField(null=True)

        class Meta:
            table_name = "transactions"
            indexes = [(
                ("sender_public_key", "recipient_id", "vendor_field",
                 "timestamp"),
                False,
            )]
Example #10
0
class Seasons(peewee.Model):
    series = peewee.ForeignKeyField(Series)
    season_number = peewee.BigIntegerField()
    chapters = peewee.BigIntegerField()

    class Meta:
        database = database
Example #11
0
class StdModel(BaseModel):
    id = peewee.BlobField(primary_key=True)
    time = peewee.BigIntegerField(index=True, default=get_time)
    deleted_at = peewee.BigIntegerField(null=True, index=True)

    is_for_tests = peewee.BooleanField(default=False,
                                       help_text='单元测试专属账号,单元测试结束后删除')
Example #12
0
class User(BaseModel):
    uid = peewee.BigIntegerField(primary_key=True, unique=True)
    message_date = peewee.BigIntegerField(default=0)
    in_group = peewee.BooleanField(default=False)

    do_not_disturb = peewee.BooleanField(default=False)
    memory = peewee.TextField(default="")
Example #13
0
class Prefix(BaseModel):
    prefix_type = peewee.CharField(max_length=10)
    discord_id = peewee.BigIntegerField()
    guild_id = peewee.BigIntegerField(null=True)
    prefix = peewee.CharField(max_length=5)

    class Meta:
        db_table = "prefixes"
Example #14
0
class Guild(BaseModel):
    guild_id = peewee.BigIntegerField(unique=True)
    bonus = peewee.CharField(default="0")
    mute_role = peewee.BigIntegerField(default=0)
    log_channel = peewee.BigIntegerField(default=0)

    class Meta:
        db_table = "guilds"
Example #15
0
class Mutes(BaseModel):
    user_id = peewee.BigIntegerField()
    time_to = peewee.BigIntegerField()

    reason = peewee.TextField(default=None)

    class Meta:
        database = manager.database
Example #16
0
class tweets(MySQLModel):
    ''' Class of tweets '''
    tweet_id = peewee.BigIntegerField(primary_key=True)
    user_id = peewee.BigIntegerField()
    status = peewee.TextField()
    countFavorites = peewee.IntegerField()
    countRTs = peewee.IntegerField()
    time = peewee.DateTimeField()
Example #17
0
class Action(peewee.Model):
    time = peewee.DateTimeField()
    chat_id = peewee.BigIntegerField(index=True)
    user_id = peewee.BigIntegerField(index=True)
    current_username = peewee.CharField(null=True)

    class Meta:
        primary_key = peewee.CompositeKey('chat_id', 'user_id')
Example #18
0
class Media(BaseModel):

    id = peewee.BigIntegerField(unique=True, primary_key=True)
    type = peewee.CharField(null=True)
    url = peewee.CharField(null=True)
    display_url = peewee.CharField(null=True)
    expanded_url = peewee.CharField(null=True)
    source_status_id = peewee.BigIntegerField(null=True)
Example #19
0
class Message(
        BaseModel
):  # содержит в себе id сообщения, id чата, текст сооб, id отправителя
    message_id = peewee.BigIntegerField()
    chat_id = peewee.BigIntegerField()
    text = peewee.TextField()
    tg_id = peewee.BigIntegerField()
    user = peewee.ForeignKeyField(User, backref='messages')
Example #20
0
        class Duel(peewee.Model):
            userid1 = peewee.BigIntegerField()
            userid2 = peewee.BigIntegerField()
            chat_id = peewee.BigIntegerField()

            class Meta:
                database = self.pwmanager.database
                indexes = ((('chat_id', 'userid1', 'userid2'), True), )
Example #21
0
class Example(BaseModel):
    input_hash = orm.BigIntegerField()
    task_hash = orm.BigIntegerField()
    content = orm.BlobField()

    def load(self):
        content = convert_blob(self.content)
        return ujson.loads(content)
Example #22
0
    class Round(pw.Model):
        id = pw.AutoField()
        public_key = pw.CharField(max_length=66)
        balance = pw.BigIntegerField()
        round = pw.BigIntegerField()

        class Meta:
            table_name = "rounds"
            indexes = [(('round', 'public_key'), True)]
Example #23
0
class TemporaryVoiceChannel(BaseModel):
    guild_id = peewee.BigIntegerField(null=False)
    channel_id = peewee.BigIntegerField(null=False)

    def delete_instance(self, *args, **kwargs):
        if self.channel is not None:
            asyncio.gather(
                self.channel.delete(reason="Temporary VC channel removed."))
        super().delete_instance(*args, **kwargs)
Example #24
0
class SavedEmoji(BaseModel):
    name = peewee.CharField(null=False, unique=True)
    guild_id = peewee.BigIntegerField(null=False)
    emoji_id = peewee.BigIntegerField(null=False)

    def delete_instance(self, *args, **kwargs):
        emoji = self.bot.get_emoji(self.emoji_id)
        if emoji is not None:
            asyncio.gather(emoji.delete())
        super().delete_instance(*args, **kwargs)
Example #25
0
        class Roulette(peewee.Model):
            chat_id = peewee.BigIntegerField(primary_key=True, unique=True)
            members = peewee.TextField(default="")
            status = peewee.IntegerField(default=-1)
            turn = peewee.IntegerField(default=0)

            start = peewee.BigIntegerField(default=0)

            class Meta:
                database = self.pwmanager.database
Example #26
0
class Tweet(peewee.Model):
    """ Model for MySQL Table """
    created_at = peewee.TimestampField()
    user_id = peewee.BigIntegerField()
    tweet_id = peewee.BigIntegerField()
    lat = peewee.FloatField()
    lon = peewee.FloatField()

    class Meta:
        database = database
Example #27
0
class business(BaseModel):
    level = peewee.IntegerField()
    level1_name = peewee.TextField()
    level2_name = peewee.TextField()
    level3_name = peewee.TextField()
    up_price = peewee.BigIntegerField()
    price = peewee.BigIntegerField()
    smile = peewee.TextField()
    max_works = peewee.IntegerField()
    pay = peewee.IntegerField()
Example #28
0
class Message(peewee.Model):
    message_id = peewee.BigIntegerField(null=True, unique=True)
    content = peewee.TextField()
    author_name = peewee.CharField()
    author_id = peewee.BigIntegerField()
    channel_id = peewee.BigIntegerField(null=True)
    timestamp = peewee.DateTimeField(null=True)

    class Meta:
        database = db
Example #29
0
class SmallProfile(peewee.Model):
    user_id = peewee.BigIntegerField()
    bankmoney = peewee.BigIntegerField(default=0)
    money = peewee.DecimalField(max_digits=64,
                                decimal_places=2,
                                default=Decimal("5000"))

    class Meta:
        database = manager.database
        db_table = 'profile'
Example #30
0
class Reminder(BaseModel):
    channel_id = peewee.BigIntegerField(null=True)
    user_id = peewee.BigIntegerField(null=False)
    due_date = peewee.DateTimeField(null=False)
    text = peewee.TextField(null=False)
    finished = peewee.BooleanField(null=False, default=False)
    dm = peewee.BooleanField(null=False, default=False)

    @property
    def sendable(self):
        return self.channel if not self.dm else self.user