mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
don't accept bot own token (for self-hosted projects)
This commit is contained in:
parent
b229a2c7e2
commit
4063f9f336
@ -9,7 +9,7 @@ import re
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from olgram.models.models import Bot, User
|
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 olgram.commands.menu import send_bots_menu
|
||||||
from server.server import register_token
|
from server.server import register_token
|
||||||
from locales.locale import _
|
from locales.locale import _
|
||||||
@ -104,6 +104,9 @@ async def bot_added(message: types.Message, state: FSMContext):
|
|||||||
except TelegramAPIError:
|
except TelegramAPIError:
|
||||||
return await on_unknown_error()
|
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)
|
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,
|
bot = Bot(token=Bot.encrypted_token(token), owner=user, name=test_bot_info.username,
|
||||||
super_chat_id=message.from_user.id)
|
super_chat_id=message.from_user.id)
|
||||||
|
@ -110,6 +110,7 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL", "WARNING"))
|
|||||||
|
|
||||||
class BotSettings(AbstractSettings):
|
class BotSettings(AbstractSettings):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@lru_cache
|
||||||
def token(cls) -> str:
|
def token(cls) -> str:
|
||||||
"""
|
"""
|
||||||
Токен olgram бота
|
Токен olgram бота
|
||||||
|
Loading…
Reference in New Issue
Block a user