def check(self, new_status): if self.is_in_hospital and new_status.is_okay: self.add_alert( Alert("You got out of the hospital", AlertTypes.OUT_OF_HOSPITAL)) if self.is_in_jail and new_status.is_okay: self.add_alert( Alert("You got out of jail", AlertTypes.OUT_OF_HOSPITAL))
def check(self, new_cooldowns): if self.drug != 0 and new_cooldowns.drug == 0: self.add_alert( Alert("Your drugs cooldown ended", AlertTypes.DRUG_COOLDOWN_ZERO)) if self.medical != 0 and new_cooldowns.medical == 0: self.add_alert( Alert("Your medical cooldown ended", AlertTypes.MEDICAL_COOLDOWN_ZERO)) if self.booster != 0 and new_cooldowns.booster == 0: self.add_alert( Alert("Your boosters cooldown ended", AlertTypes.BOOSTER_COOLDOWN_ZERO))
async def handle_errors(results): bad_users = [] alerts = {} sleep = False for result in results: if isinstance(result, TornException): if result.users_fault: bad_users.append(result) if result.code == TornErrorCode.IP_BLOCK or result.torns_fault: sleep = True results.remove(result) for exc in bad_users: user = db.get_user(exc.user_id) db.delete_user(user) alerts[user.credentials.discord_id] = Alert( "Your torn key is invalid, so your account has been deleted", AlertTypes.INVALID_KEY) if sleep: logger.error("IP block or torn api problems. Sleeping for 30 minutes") await asyncio.sleep(30 * 60) logger.info("IP block sleep ended.") return alerts
def check(self, new_obj): if not self.is_max and new_obj.is_max: self.add_alert(Alert(f"Your {self.name} is full", self.FULL_TYPE))
def check(self, new_travel): if self.time_left != 0 and new_travel.time_left == 0: self.add_alert( Alert(f"You have arrived to {new_travel.destination}", AlertTypes.TRAVEL_ARRIVED))
def alert_new(self): return Alert(f"New message from {self.name}: {self.title}", AlertTypes.NEW_MESSAGE)
def alert_new(self): return Alert(f"New event: {strip_html(self.event)}", AlertTypes.NEW_EVENT)