diff --git a/.env b/.env index 8752c29..1c2193e 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ TG_BOT_TOKEN=7727936968:AAELs0gg5VNGzg6wMnG66CkpYaEv0K1Tp5w -API_URL=http://127.0.0.1:8000 \ No newline at end of file +API_URL=http://127.0.0.1:8000 +COMPANY_KEY=re-premium-key \ No newline at end of file diff --git a/main.py b/main.py index 8285364..244a4c2 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ load_dotenv() API_TOKEN = os.getenv('TG_BOT_TOKEN') API_URL = os.getenv('API_URL') - +COMPANY_KEY = os.getenv('COMPANY_KEY') bot = Bot(token=API_TOKEN) dp = Dispatcher() @@ -118,6 +118,7 @@ async def send_welcome(message: types.Message): token = None error = None hash_value = sha256(f"{tg_id}sold".encode()).hexdigest() + company_key = COMPANY_KEY async with aiohttp.ClientSession() as session: try: # 1. Пробуем авторизоваться по hash @@ -126,7 +127,7 @@ async def send_welcome(message: types.Message): token = hash_value else: # 2. Если не найден — регистрируем - async with session.post(f'{API_URL}/register', json={'tg_id': tg_id, 'chat_id': chat_id, 'name': name, 'login': login}) as reg_resp: + async with session.post(f'{API_URL}/register', json={'tg_id': tg_id, 'chat_id': chat_id, 'name': name, 'login': login, 'company_key': company_key}) as reg_resp: if reg_resp.status == 200: # После регистрации снова пробуем авторизоваться async with session.post(f'{API_URL}/tg_auth', json={'hash': hash_value}) as auth_resp2: