forked from JosXa/BotListBot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmessage.py
More file actions
22 lines (18 loc) · 708 Bytes
/
Copy pathmessage.py
File metadata and controls
22 lines (18 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
from peewee import *
from models import Bot
from models.basemodel import BaseModel
class Message(BaseModel):
message_id = PrimaryKeyField()
chat_id = IntegerField(unique=True)
command = CharField(choices=['offline', 'spam', 'new'])
entity = ForeignKeyField(Bot)
@staticmethod
def get_or_create(telegram_message, command, entity: Bot):
try:
u = Message.get(Message.message_id == telegram_message.message_id)
except Message.DoesNotExist:
u = Message(message_id=telegram_message.message_id, chat_id=telegram_message.chat.id, entity=entity,
command=command)
u.save()
return u