Загрузка...

Python Aimram help the pancre

Thread in Python created by Hollywood Apr 30, 2025. 289 views

  1. Hollywood
    Hollywood Topic starter Apr 30, 2025 э 20,122 Oct 28, 2020
    Python
    total_transfer_price = 0
    total_uniq_count = 0
    total_upgradable_price = 0
    total_upgradable_count = 0
    convertable_count = 0
    convertable_price = 0
    for gift in gifts:
    try:
    if gift.can_be_transferred:
    if not gift.transfer_star_count:
    total_transfer_price += 0
    else:
    total_transfer_price += gift.transfer_star_count
    total_uniq_count += 1

    if gift.can_be_upgraded:
    total_upgradable_price += gift.prepaid_upgrade_star_count
    total_upgradable_count += 1

    if gift.convert_star_count:
    now = datetime.now()
    send_date = datetime.fromtimestamp(gift.send_date)
    delta = now - send_date
    days_ago = delta.days

    if days_ago<7:
    convertable_price += gift.convert_star_count
    convertable_count += 1

    except AttributeError as e:
    continue
    if gift.convert_star_count не выполняется, а когда ставлю его вначале - выполняется, но не выполняются другие. че за хрень ребята? как фикс?
     
    1. Y4sperMaglot
      Hollywood, может чето в except летит, ты смотрел?
  2. maca
    Нука
    except AttributeError as e: print(e)
     
    1. View previous comments (5)
    2. Y4sperMaglot
      Hollywood, метод какой используешь для получения гифтов
    3. Hollywood Topic starter
      Y4sperMaglot,
      Code
      c = await bot(GetBusinessAccountGifts(business_connection_id=bus_conn))
      gifts = c.gifts
      for gift in gifts:
    4. maca
      Hollywood, атрибуты ебут мозги, дебаг в руки и делать :da:
  3. Hollywood
    Hollywood Topic starter Apr 30, 2025 э 20,122 Oct 28, 2020
    10 рублей скину за решение я часов 7 сижу уже за кодом и на такой хуйне стопнулся
     
    1. View previous comments (6)
    2. Hollywood Topic starter
      Y4sperMaglot, никогда не дебажил, вообще не умею жто делать
    3. Y4sperMaglot
      Hollywood, крч вот тут смотри https://core.telegram.org/bots/api#ownedgift, подарки разных типов есть бля и у каждого там поля разные, смотри какие поля у каждого и делай ифы
    4. Y4sperMaglot
      Hollywood, как раз вот эти OwnedGiftRegular, OwnedGiftUnique и тд из эксепшына твоего, всё там есть в документации
  4. Kranz
    Kranz Apr 30, 2025 1489 Jul 2, 2021
    Hollywood, Переписал тебе в более адекватный вид, должно норм работать

    Python
    owned_gifts = await bot(GetBusinessAccountGifts(business_connection_id=""))

    total_transfer_price = 0
    total_uniq_count = 0
    total_upgradable_price = 0
    total_upgradable_count = 0
    convertable_count = 0
    convertable_price = 0

    for gift in owned_gifts.gifts:
    if isinstance(gift, OwnedGiftRegular):
    if gift.prepaid_upgrade_star_count:
    total_upgradable_price += gift.prepaid_upgrade_star_count
    total_upgradable_count += 1
    if gift.convert_star_count and (datetime.now() - datetime.fromtimestamp(gift.send_date)).days < 7:
    convertable_price += gift.convert_star_count
    convertable_count += 1
    elif isinstance(gift, OwnedGiftUnique):
    if gift.transfer_star_count:
    total_transfer_price += gift.transfer_star_count
    total_uniq_count += 1
     
    1. View previous comments (3)
    2. Hollywood Topic starter
      Kranz, пиздец, это работает. спасибо большое, щас пойду разбираться что поменялось
    3. Y4sperMaglot
      Hollywood, проверка на тип подарка добавилась бро, просто у одного есть can_be_upgraded, а у другого нет, вот и не работало у тебя
Loading...
Top