mirror of
				https://github.com/civsocit/olgram.git
				synced 2025-10-30 02:43:24 +00: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 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) | ||||
|  |  | |||
|  | @ -110,6 +110,7 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL", "WARNING")) | |||
| 
 | ||||
| class BotSettings(AbstractSettings): | ||||
|     @classmethod | ||||
|     @lru_cache | ||||
|     def token(cls) -> str: | ||||
|         """ | ||||
|         Токен olgram бота | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user