Загрузка...

SUBGRAM Service problem

Thread in Python created by beta Mar 30, 2025. 223 views

  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 (2)
    2. n1s_01
      beta, попробуй через breakpoint глянуть как идет функция, если она заходит внутрь но не отображает меню то дело в функции
    3. n1s_01
      beta, или добавь логирование в консоль что бы если if проходилось в консоль там условно что нибудь писалось бы
    4. beta Topic starter
      n1s_01, чучуть не шарю как breakpoint юзать в общем, понимаю что это но как именно к этому хз, и в консоль ты говорил если status ok and code 200 то в консоли вообще пусто, но как только что то меняется например code 404 в консоль вылетает это [IMG]
    5. View the next comments (13)
Top
Loading...