From 706c5ee89691e26c3d2d707410aeeddd66cb78d7 Mon Sep 17 00:00:00 2001 From: Wong Yiek Heng Date: Sun, 5 Oct 2025 20:09:03 +0800 Subject: [PATCH] + Fix wrong sleep using --- cm_telegram.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cm_telegram.py b/cm_telegram.py index 345733d..13df0cf 100644 --- a/cm_telegram.py +++ b/cm_telegram.py @@ -1,4 +1,4 @@ -import threading, logging, time +import threading, logging, time, asyncio from telegram import ForceReply, Update from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters @@ -24,9 +24,10 @@ async def menu_cmd_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) - await update.message.reply_text('\n'.join(menu)) async def get_acc_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + global creating_acc_now while creating_acc_now == True: await update.message.reply_text('CM account creation is running, queuing ...') - time.sleep(1) + await asyncio.sleep(1) creating_acc_now = True await update.message.reply_text('Start Getting CM Account ...') try: @@ -82,14 +83,13 @@ def monitor_amount_of_available_acc(): available_size = len(bot.get_all_available_acc()) if available_size <= max_available: + global creating_acc_now creating_acc_now = True for i in range(available_size, max_available): bot.create_new_acc() creating_acc_now = False time.sleep(10 * 60) del bot - - def main() -> None: """Start the bot."""