Загрузка...

SUBGRAM Service problem

Thread in Python created by beta Mar 30, 2025. 221 view

  1. beta
    beta Topic starter Mar 30, 2025 475 Jan 6, 2019
    [IMG]

    code == 404 значит спонсоров не нашлось и блок подписок не выводится
    Мне надо что бы когда было status == 'ok' and code == 404: (всё хорошо но каналов для подписок нету) выводилось меню, оно так же выводится когда status == 'ok' and code == 200: (то есть всё хорошо и человек подписан)
    Python
        if status == 'ok' and code == 200:
    await register_user(user_id, username, full_name, referrer_id)
    if user_id in pending_referrals:
    del pending_referrals[user_id]
    await send_main_menu(chat_id, message.message_id if message.reply_to_message else None)


    Python
        if status == 'ok' and code == 200:
    await register_user(user_id, username, full_name, referrer_id)
    if user_id in pending_referrals:
    del pending_referrals[user_id]
    await send_main_menu(chat_id, message.message_id if message.reply_to_message else None)
    elif status == 'ok' and code == 404:
    await register_user(user_id, username, full_name, referrer_id)
    if user_id in pending_referrals:
    del pending_referrals[user_id]
    await send_main_menu(chat_id, message.message_id if message.reply_to_message else None)

    Python
        if status == 'ok' and code == 200 or status == 'ok' and code == 404:
    await register_user(user_id, username, full_name, referrer_id)
    if user_id in pending_referrals:
    del pending_referrals[user_id]
    await send_main_menu(chat_id, message.message_id if message.reply_to_message else None)
    [IMG]
     
  2. n1s_01
    бро все элементарно, в Python функция or "ленивая" и в твоем одном из неправильных кодов она видит только
    Python
    if status == 'ok' and code == 200 or status == 'ok'
    поэтому тебе надо написать вот так вот

    Python
    if (status == 'ok' and code == 200) or (status == 'ok' and code == 404):
    await register_user(user_id, username, full_name, referrer_id)
    if user_id in pending_referrals:
    del pending_referrals[user_id]
    await send_main_menu(chat_id, message.message_id if message.reply_to_message else None)
     
    1. View previous comments (4)
    2. beta Topic starter
      n1s_01, чучуть не шарю как breakpoint юзать в общем, понимаю что это но как именно к этому хз, и в консоль ты говорил если status ok and code 200 то в консоли вообще пусто, но как только что то меняется например code 404 в консоль вылетает это [IMG]
    3. n1s_01
      beta, а почему error то пишет :frog_why:
      что это вообще такое, не пайму. попробуй логирование добавить простая хуйня, именно библиотеку logging посмотри до куда доходит код прежде чем выдать ошибку
    4. beta Topic starter
      n1s_01, так в коде у меня можно сказать нет ошибки, это ответ от сервиса получаем мы при запросе ссылок для подписки
    5. View the next comments (11)
Top
Loading...