+ Update logger for transfer credit again
This commit is contained in:
parent
57906ed2c6
commit
676d1e9d49
@ -70,7 +70,7 @@ class CM_BOT_HAL:
|
||||
username = self.agent_id,
|
||||
password = self.agent_password
|
||||
) == False:
|
||||
raise Exception(f'[Cannot login] {self.agent_id} cannot login.')
|
||||
raise Exception(f'[Fail login] {self.agent_id} cannot login.')
|
||||
cm_bot.register_user(
|
||||
user_id = username,
|
||||
user_password = password
|
||||
@ -82,7 +82,7 @@ class CM_BOT_HAL:
|
||||
username = username,
|
||||
password = password
|
||||
) == False:
|
||||
raise Exception(f'[Cannot login] {username} cannot login.')
|
||||
raise Exception(f'[Fail login] {username} cannot login.')
|
||||
link = cm_bot.get_register_link()
|
||||
cm_bot.logout()
|
||||
|
||||
@ -139,7 +139,7 @@ class CM_BOT_HAL:
|
||||
username = f_username,
|
||||
password = password
|
||||
) == False:
|
||||
raise Exception(f'[Cannot login] {f_username} cannot login.')
|
||||
raise Exception(f'[Fail login] {f_username} cannot login.')
|
||||
if cm_bot.set_security_pin(self.security_pin) == False:
|
||||
cm_bot.logout()
|
||||
raise Exception(f'Agent acc: {f_username} already has security pin!')
|
||||
@ -166,7 +166,7 @@ class CM_BOT_HAL:
|
||||
username = f_username,
|
||||
password = f_password
|
||||
) == False:
|
||||
print(f'[Cannot login] {f_username} cannot login.')
|
||||
print(f'[Fail login] {f_username} cannot login.')
|
||||
return 0
|
||||
return float(cm_bot.get_user_credit())
|
||||
|
||||
@ -176,15 +176,14 @@ class CM_BOT_HAL:
|
||||
username = f_username,
|
||||
password = f_password
|
||||
) == False:
|
||||
print(f'[Cannot login] {f_username} cannot login.')
|
||||
return False
|
||||
return(f'[Fail login] {f_username} cannot login.')
|
||||
amount = cm_bot.get_user_credit() - 0.01
|
||||
if amount <= 0.01:
|
||||
print(f'[No enough credit] {f_username} do not have enough credit.')
|
||||
return(f'[No enough credit] {f_username} do not have enough credit.')
|
||||
if cm_bot.transfer_credit(t_username, t_password, amount) == True:
|
||||
print(f'Successfully transfer amount: {amount} from {f_username} to {t_username}')
|
||||
return(f'Successfully transfer amount: {amount} from {f_username} to {t_username}')
|
||||
else:
|
||||
print(f'Failed to transfer credit from {f_username} to {t_username}')
|
||||
return(f'Fail to transfer credit from {f_username} to {t_username}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@ -19,8 +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']}")
|
||||
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']}")
|
||||
result = bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password'])
|
||||
local_logger.info(result)
|
||||
local_logger.info(f"[Done] {data['f_username']} transfer done!")
|
||||
del bot
|
||||
time.sleep(0.5)
|
||||
@ -33,7 +33,7 @@ while True:
|
||||
local_logger = logging.getLogger(f"{__name__}")
|
||||
|
||||
# Configure file handler for logging to logs folder
|
||||
log_filename = f"{logs_dir}/transfer_credit_{datetime.now().strftime('%Y%m%d')}.log"
|
||||
log_filename = f"{logs_dir}/transfer_credit_{datetime.now().strftime('%Y%m%d_%H%M')}.log"
|
||||
file_handler = logging.FileHandler(log_filename)
|
||||
file_handler.setLevel(logging.INFO)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user