From baf9cd08808f9450c9458a6d3358ec0eb269c2ea Mon Sep 17 00:00:00 2001 From: Redsandyg Date: Tue, 3 Jun 2025 14:03:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B5=20=D0=BE=D0=BA?= =?UTF-8?q?=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=20COMPANY?= =?UTF-8?q?=5FKEY=20=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B2=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20send=5Fwelcome=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B8=20company=5Fkey=20=D0=B2?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 ++- main.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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: