M
M
MMAI2021-11-29 19:24:44
Python
MMAI, 2021-11-29 19:24:44

Why does the cycle in TelegramBot not work?

Question, I have a message board page parser, everything worked yesterday, when I logged in today, the cycle just doesn’t work for me, it should check every 200 seconds if something new has appeared, but now this does not happen. Probably the problem lies somewhere in these lines of code

async def ads_every_minute(user_id):
    while True:
        ads_users_list = get_all_users_ads(user_id)
        if len(ads_users_list) >= 1:
            for ads in ads_users_list:
                ads_url = str(ads).split("'")[1]
                tracked_url_title = get_requested_page_title(ads_url)
                old_ad = get_old_ad_from_db(user_id, tracked_url=ads_url)
                old_ad_url = str(old_ad).split("'")[1]
                new_ad_url = get_ad_data(ads_url)[-1]
                new_ad_data = (user_id, ads_url, new_ad_url,tracked_url_title)
                if new_ad_url != old_ad_url:
                    delete_old_data(user_id, tracked_url=ads_url)
                    write_url_on_db(new_ad_data)

                    await bot.send_message( user_id, f'{build_nice_message(ads_url)}',disable_web_page_preview=True)
                else:
                    print('Обновлений нет ')

        await asyncio.sleep(random.randint(40, 90))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question