def _get_status(self) -> None: """ Get the current status of the account """ self.account.receive_msg( Message.status(self.account, self.client.status))
async def get_status(acc: Optional["Account"], _cmd: Callback, _params: Tuple) -> str: """ Get the status of the account """ assert acc acc.receive_msg(Message.status(acc, acc.status)) return ""
async def set_status(acc: Optional["Account"], _cmd: Callback, params: Tuple) -> str: """ Set the status of the account """ assert acc status = params[0] acc.status = status acc.receive_msg(Message.status(acc, status)) return ""
async def _handle_account_status(self, acc_id: int, params: List[str]) -> str: """ Get or set current status of account Expected format: account <ID> status get account <ID> status set <STATUS> params does not include "account <ID> status" Returned messages for "status get" should look like: status: account <ID> status: <STATUS> """ if not params: return "" # get account accounts = self.account_list.get() acc = accounts[acc_id] # get current status if params[0] == "get": status = await self.callbacks.call(Callback.GET_STATUS, acc, ()) if status: return Message.status(acc, status) # set current status if params[0] == "set": if len(params) < 2: return "" status = params[1] return await self.callbacks.call(Callback.SET_STATUS, acc, (status, )) return ""