Разработан чат-бот
This commit is contained in:
6
models/__init__.py
Normal file
6
models/__init__.py
Normal file
@ -0,0 +1,6 @@
|
||||
from aiogram.types import Message
|
||||
from aiogram.types.reply_keyboard import KeyboardButton
|
||||
from aiogram.dispatcher import FSMContext
|
||||
from aiogram.types.input_file import InputFile
|
||||
|
||||
from .models import date, email_address, phone_number, iso_datetime, max_comment_length, ReplyKeyboardMarkup, Category, Subcategory, Executor, TimeRange, FreeToOrder, Order, Issue
|
79
models/models.py
Normal file
79
models/models.py
Normal file
@ -0,0 +1,79 @@
|
||||
from aiogram.types.reply_keyboard import ReplyKeyboardMarkup as _ReplyKeyboardMarkup
|
||||
from datetime import date, time, datetime, timedelta
|
||||
from pydantic import BaseModel
|
||||
import re
|
||||
from typing import Literal
|
||||
|
||||
|
||||
email_address = re.compile(r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)')
|
||||
phone_number = re.compile(r'\D*')
|
||||
iso_datetime = re.compile(r'(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{0,6})([+-]?\d{0,2}:?\d{0,2})')
|
||||
max_comment_length = 1024
|
||||
|
||||
|
||||
class ReplyKeyboardMarkup(_ReplyKeyboardMarkup):
|
||||
def __init__(self, keyboard=None):
|
||||
super().__init__(
|
||||
keyboard=keyboard,
|
||||
resize_keyboard=True,
|
||||
)
|
||||
|
||||
|
||||
class Category(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
|
||||
|
||||
class Subcategory(BaseModel):
|
||||
category: Category
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
|
||||
|
||||
class Executor(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
|
||||
class TimeRange(BaseModel):
|
||||
id: int
|
||||
start_time: time
|
||||
end_time: time
|
||||
|
||||
def __hash__(self):
|
||||
return self.id
|
||||
|
||||
|
||||
class FreeToOrder(BaseModel):
|
||||
date: date
|
||||
time_range: TimeRange
|
||||
executor: Executor
|
||||
busy_interval: timedelta
|
||||
|
||||
|
||||
class Order(BaseModel):
|
||||
id: int
|
||||
subcategory: Subcategory
|
||||
date: date
|
||||
time_range: TimeRange
|
||||
executor: Executor
|
||||
telegram_id: int
|
||||
email_address: str
|
||||
phone_number: str
|
||||
comment: str
|
||||
start_time: datetime = None
|
||||
end_time: datetime = None
|
||||
|
||||
|
||||
class Issue(BaseModel):
|
||||
id: int
|
||||
key: str
|
||||
status: Literal[
|
||||
'undefined',
|
||||
'new',
|
||||
'indeterminate',
|
||||
'done',
|
||||
]
|
||||
telegram_id: int
|
Reference in New Issue
Block a user