From 4f309f40e6b662ea28e03316b45e8306c06b16d9 Mon Sep 17 00:00:00 2001 From: Wong Yiek Heng Date: Sat, 4 Oct 2025 11:06:28 +0800 Subject: [PATCH] + Add error handler for set security pin --- cm_bot.py | 3 +++ cm_bot_hal.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cm_bot.py b/cm_bot.py index b0094b6..70130e5 100644 --- a/cm_bot.py +++ b/cm_bot.py @@ -410,6 +410,9 @@ class CM_BOT: data=security_data, headers=self.set_security_pin_headers ) + if 'java.lang.NullPointerException' in response.text: + return False + return True def transfer_credit(self, t_username: str, t_password: str, amount: float): token = self.get_transfer_token() diff --git a/cm_bot_hal.py b/cm_bot_hal.py index 26af044..b0493ac 100644 --- a/cm_bot_hal.py +++ b/cm_bot_hal.py @@ -137,7 +137,9 @@ class CM_BOT_HAL: username = f_username, password = password ) - cm_bot.set_security_pin(self.security_pin) + if cm_bot.set_security_pin(self.security_pin) == False: + cm_bot.logout() + raise Exception(f'Agent acc: {f_username} already has security pin!') cm_bot.logout() result = self.update_user_status_to_done(f_username)