1
0
mirror of https://github.com/civsocit/olgram.git synced 2025-12-16 22:06:17 +00:00

add server

This commit is contained in:
mihalin
2021-09-09 23:35:13 +03:00
parent fc9280881c
commit c1d29f4d8c
7 changed files with 117 additions and 13 deletions

View File

@@ -0,0 +1,5 @@
-- upgrade --
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
ALTER TABLE "bot" ADD "code" UUID NOT NULL DEFAULT uuid_generate_v4();
-- downgrade --
ALTER TABLE "bot" DROP COLUMN "code";

View File

@@ -1,6 +1,6 @@
from tortoise.models import Model
from tortoise import fields
from uuid import uuid4
from textwrap import dedent
@@ -9,6 +9,7 @@ class Bot(Model):
token = fields.CharField(max_length=50, unique=True)
owner = fields.ForeignKeyField("models.User", related_name="bots")
name = fields.CharField(max_length=33)
code = fields.UUIDField(default=uuid4, index=True)
start_text = fields.TextField(default=dedent("""
Здравствуйте!
Напишите ваш вопрос и мы ответим вам в ближайшее время.

View File

@@ -38,6 +38,14 @@ class ServerSettings(AbstractSettings):
def hook_port(cls) -> int:
return int(cls._get_env("WEBHOOK_PORT"))
@classmethod
def app_host(cls) -> str:
return "olgram"
@classmethod
def app_port(cls) -> int:
return 80
class BotSettings(AbstractSettings):
@classmethod