Загрузка...

Cant find payment

Thread in Python created by 5HIVA Jan 10, 2025. 228 views

  1. 5HIVA
    5HIVA Topic starter Jan 10, 2025 Banned 2 Dec 16, 2024
    Python
    import time
    import random
    import secrets
    import aiohttp
    from tgbot.data import config
    import math


    class Lolz:
    def __init__(self, access_token: str):
    self.api_url = 'https://api.zelenka.guru/'
    self.session_headers = {
    'Authorization': f'Bearer {access_token}'
    }
    self.timeout = aiohttp.ClientTimeout(total=360)

    async def get_user(self):
    async with aiohttp.ClientSession(headers=self.session_headers, timeout=self.timeout) as session:
    response = await session.get('https://api.lzt.market/me', timeout=self.timeout)
    if response.status == 200:
    response = await response.json()
    await session.close()
    if 'user' not in response.keys():
    raise ValueError('Invalid Token [Lolzteam Market]')
    return response['user']
    else:
    error = await response.text()
    await session.close()
    error = error.split('<h1>')[1].split('</h1>')[0]
    raise BaseException(error)

    def get_link(self, amount, comment: str):
    amount = math.ceil(amount)
    return f'https://lzt.market/balance/transfer?username={config.lolz_nick}&hold=0&amount={amount}&comment={comment}'

    def get_random_string(self):
    return f'{time.time()}_{secrets.token_hex(random.randint(5, 10))}'

    async def check_payment(self, amount, comment: str):
    user_id = config.lolz_id
    async with aiohttp.ClientSession(headers=self.session_headers, timeout=self.timeout) as session:
    response = await session.get(f'{self.api_url}market/user/{user_id}/payments', timeout=self.timeout)
    amount = int(amount)

    if response.status == 200:
    resp_json = await response.json()
    payments = resp_json['payments']
    for payment in payments.values():
    if 'Перевод денег от' in payment['label']['title'] and amount == payment['incoming_sum'] and comment == payment['data']['comment']:
    await session.close()
    return True
    await session.close()
    return False
    else:
    resp_text = await response.text()
    await session.close()
    error = resp_text
    error = error.split('<h1>')[1].split('</h1>')[0]
    return f"Платеж не найден, {error}"
     
    1. View previous comments (2)
    2. БРЕДИШЬ
      5HIVA, ответ выше
    3. 5HIVA Topic starter
    4. TimeoutException
      5HIVA,
      Python
      if 'Перевод денег от' in payment['label']['title'] and int(amount) == int(float(payment['incoming_sum'])) and comment == payment['data']['comment']
      Хз, как-то так
Top
Loading...