+ Fix wrong sleep using

This commit is contained in:
Wong Yiek Heng 2025-10-05 20:09:03 +08:00
parent f2a69e58d5
commit 706c5ee896

View File

@ -1,4 +1,4 @@
import threading, logging, time import threading, logging, time, asyncio
from telegram import ForceReply, Update from telegram import ForceReply, Update
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters 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)) await update.message.reply_text('\n'.join(menu))
async def get_acc_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: async def get_acc_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
global creating_acc_now
while creating_acc_now == True: while creating_acc_now == True:
await update.message.reply_text('CM account creation is running, queuing ...') await update.message.reply_text('CM account creation is running, queuing ...')
time.sleep(1) await asyncio.sleep(1)
creating_acc_now = True creating_acc_now = True
await update.message.reply_text('Start Getting CM Account ...') await update.message.reply_text('Start Getting CM Account ...')
try: try:
@ -82,14 +83,13 @@ def monitor_amount_of_available_acc():
available_size = len(bot.get_all_available_acc()) available_size = len(bot.get_all_available_acc())
if available_size <= max_available: if available_size <= max_available:
global creating_acc_now
creating_acc_now = True creating_acc_now = True
for i in range(available_size, max_available): for i in range(available_size, max_available):
bot.create_new_acc() bot.create_new_acc()
creating_acc_now = False creating_acc_now = False
time.sleep(10 * 60) time.sleep(10 * 60)
del bot del bot
def main() -> None: def main() -> None:
"""Start the bot.""" """Start the bot."""