mirror of
https://github.com/civsocit/olgram.git
synced 2025-12-16 20:26:16 +00:00
регистрация токенов
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
from aiogram import types
|
||||
from aiogram.utils.exceptions import TelegramAPIError
|
||||
from olgram.models.models import Bot
|
||||
from server.server import unregister_token
|
||||
|
||||
|
||||
async def delete_bot(bot: Bot, call: types.CallbackQuery):
|
||||
"""
|
||||
Пользователь решил удалить бота
|
||||
"""
|
||||
await unregister_token(bot.token)
|
||||
await bot.delete()
|
||||
await call.answer("Бот удалён")
|
||||
try:
|
||||
|
||||
@@ -11,6 +11,7 @@ from textwrap import dedent
|
||||
from olgram.models.models import Bot, User
|
||||
from olgram.settings import OlgramSettings
|
||||
from olgram.commands.menu import send_bots_menu
|
||||
from server.server import register_token
|
||||
|
||||
from olgram.router import dp
|
||||
|
||||
@@ -94,6 +95,9 @@ async def bot_added(message: types.Message, state: FSMContext):
|
||||
except TelegramAPIError:
|
||||
return await on_unknown_error()
|
||||
|
||||
if not register_token(token):
|
||||
return await on_unknown_error()
|
||||
|
||||
user, _ = await User.get_or_create(telegram_id=message.from_user.id)
|
||||
bot = Bot(token=token, owner=user, name=test_bot_info.username, super_chat_id=message.from_user.id)
|
||||
try:
|
||||
|
||||
@@ -29,6 +29,16 @@ class OlgramSettings(AbstractSettings):
|
||||
return "0.0.0"
|
||||
|
||||
|
||||
class ServerSettings(AbstractSettings):
|
||||
@classmethod
|
||||
def hook_host(cls) -> str:
|
||||
return cls._get_env("WEBHOOK_HOST")
|
||||
|
||||
@classmethod
|
||||
def hook_port(cls) -> int:
|
||||
return int(cls._get_env("WEBHOOK_PORT"))
|
||||
|
||||
|
||||
class BotSettings(AbstractSettings):
|
||||
@classmethod
|
||||
def token(cls) -> str:
|
||||
|
||||
Reference in New Issue
Block a user