+ Update transfer speed

+ Add error handler for getting credit
This commit is contained in:
yiekheng 2025-10-19 10:18:55 +08:00
parent d191821a6a
commit 3fb2786506
2 changed files with 19 additions and 17 deletions

View File

@ -178,20 +178,22 @@ class CM_BOT_HAL:
return float(cm_bot.get_user_credit())
def transfer_credit_api(self, f_username: str, f_password: str, t_username: str, t_password: str):
cm_bot = CM_BOT()
if cm_bot.login(
username = f_username,
password = f_password
) == False:
return(f'[Fail login] {f_username} cannot login.')
amount = round(cm_bot.get_user_credit() - 0.01, 2)
if amount <= 0.01:
return(f'[No enough credit] {f_username} do not have enough credit.')
if cm_bot.transfer_credit(t_username, t_password, amount) == True:
return(f'Successfully transfer amount: {amount} from {f_username} to {t_username}')
else:
return(f'Fail to transfer credit from {f_username} to {t_username}')
try:
cm_bot = CM_BOT()
if cm_bot.login(
username = f_username,
password = f_password
) == False:
return(f'[Fail login] {f_username} cannot login.')
amount = round(cm_bot.get_user_credit() - 0.01, 2)
if amount <= 0.01:
return(f'[No enough credit] {f_username} do not have enough credit.')
if cm_bot.transfer_credit(t_username, t_password, amount) == True:
return(f'Successfully transfer amount: {amount} from {f_username} to {t_username}')
else:
return(f'Fail to transfer credit from {f_username} to {t_username}')
except:
return(f'Fail transfer credit for {f_username}')
if __name__ == '__main__':
bot = CM_BOT_HAL()
@ -201,4 +203,4 @@ if __name__ == '__main__':
# bot.get_user_api()
# bot.insert_user_to_table_acc({'username': 'test0001', 'password': 'test0001', 'link': 'test0001'})
# print(bot.get_whatsapp_link_username('https://chat.whatsapp.com/DZDWcicr6MTFrR4kBfnJXO'))
# print(bot.get_user_pass_from_acc('13c4151'))
# print(bot.get_user_pass_from_acc('13c4151'))

View File

@ -14,7 +14,7 @@ if not os.path.exists(logs_dir):
# api_url = 'https://api.luckytown888.net'
api_url = 'http://api-server:3000'
max_threading = 10
max_threading = 20
def transfer(data: dict, local_logger):
bot = CM_BOT_HAL()
@ -24,7 +24,7 @@ def transfer(data: dict, local_logger):
local_logger.info(f"[Thread-{thread_name}] {result}")
local_logger.info(f"[Thread-{thread_name}] [Done] {data['f_username']} transfer done!")
del bot
time.sleep(10)
time.sleep(5)
while True:
weekday = int(datetime.now().strftime("%w"))