From 57906ed2c690697cd493fd83212975cb24bb2ffe Mon Sep 17 00:00:00 2001 From: Wong Yiek Heng Date: Sat, 4 Oct 2025 11:29:27 +0800 Subject: [PATCH] + Change raise cannot login for transfer credit --- cm_bot_hal.py | 6 ++++-- cm_transfer_credit.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cm_bot_hal.py b/cm_bot_hal.py index 41a3033..bad1f6a 100644 --- a/cm_bot_hal.py +++ b/cm_bot_hal.py @@ -166,7 +166,8 @@ class CM_BOT_HAL: username = f_username, password = f_password ) == False: - raise Exception(f'[Cannot login] {f_username} cannot login.') + print(f'[Cannot login] {f_username} cannot login.') + return 0 return float(cm_bot.get_user_credit()) def transfer_credit_api(self, f_username: str, f_password: str, t_username: str, t_password: str): @@ -175,7 +176,8 @@ class CM_BOT_HAL: username = f_username, password = f_password ) == False: - raise Exception(f'[Cannot login] {f_username} cannot login.') + print(f'[Cannot login] {f_username} cannot login.') + return False amount = cm_bot.get_user_credit() - 0.01 if amount <= 0.01: print(f'[No enough credit] {f_username} do not have enough credit.') diff --git a/cm_transfer_credit.py b/cm_transfer_credit.py index 03b2fde..553dcd1 100644 --- a/cm_transfer_credit.py +++ b/cm_transfer_credit.py @@ -19,7 +19,8 @@ max_threading = 1 def transfer(data: dict, local_logger): bot = CM_BOT_HAL() local_logger.info(f"[Start] Transfer Credit from {data['f_username']} to {data['t_username']}") - bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password']) + if bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password']) == False: + local_logger.error(f"Cannot transfer for {data['f_username']}") local_logger.info(f"[Done] {data['f_username']} transfer done!") del bot time.sleep(0.5)