don't accept bot own token (for self-hosted projects)

This commit is contained in:
mihalin 2022-06-24 23:33:01 +03:00
parent b229a2c7e2
commit 4063f9f336
2 changed files with 5 additions and 1 deletions
olgram

View File

@ -9,7 +9,7 @@ import re
from textwrap import dedent
from olgram.models.models import Bot, User
from olgram.settings import OlgramSettings
from olgram.settings import OlgramSettings, BotSettings
from olgram.commands.menu import send_bots_menu
from server.server import register_token
from locales.locale import _
@ -104,6 +104,9 @@ async def bot_added(message: types.Message, state: FSMContext):
except TelegramAPIError:
return await on_unknown_error()
if token == BotSettings.token():
return await on_duplication_bot()
user, created = await User.get_or_create(telegram_id=message.from_user.id)
bot = Bot(token=Bot.encrypted_token(token), owner=user, name=test_bot_info.username,
super_chat_id=message.from_user.id)

View File

@ -110,6 +110,7 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL", "WARNING"))
class BotSettings(AbstractSettings):
@classmethod
@lru_cache
def token(cls) -> str:
"""
Токен olgram бота