Загрузка...

Проблема с сервисом Subgram

Тема в разделе Python создана пользователем beta 30 мар 2025. 209 просмотров

  1. beta
    beta Автор темы 30 мар 2025 475 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. Посмотреть предыдущие комментарии (13)
    2. beta Автор темы
      n1s_01, бывает 3 статуса всего ok warning и gender, ok - всё хорошо и можно выдавать контент пользователю, warning - пользователь не подписан на какие то из каналов, gender - требуется узнать пол пользователя
      из за того что каналов нет надо выдать контент пользователю так что если code 404 и спонсоров нету status будет = ok
    3. n1s_01
      beta, ты мне ответь зачем ты проверяешь код) ведь можно просто статус проверять, какая разница есть каналы или нет каналов
    4. beta Автор темы
      n1s_01, аааа блят ну да че то я долбаёб, щас проверю
    5. Посмотреть следующие комментарии (2)
Top
Загрузка...