async def unrestrict(self, reason: str, fr: "Player") -> None: await self.remove_priv(Privileges.Restricted) self.restricted = False if self.token: self.enqueue( writer.restartServer(0)) # force relog if they're online await glob.db.execute( "INSERT INTO punishments (`type`, `reason`, `target`, `from`, `time`) VALUES " "(%s, %s, %s, %s, %s)", ["unrestrict", reason, self.id, fr.id, time.time()], ) if wh_url := glob.config.webhooks["anticheat"]: wh = Webhook(url=wh_url) embed = Embed(title=f"") embed.set_author( url=f"https://{glob.config.domain}/u/{self.id}", icon_url=f"https://a.{glob.config.domain}/{self.id}", name=self.name, ) embed.add_field( name="New unrestricted user", value= f"{self.name} has been unrestricted by {fr.name} for {reason}.", inline=True, ) wh.add_embed(embed) await wh.post()
async def unrestrict(self, reason: str, fr: 'Player') -> None: await self.remove_priv(Privileges.Restricted) self.restricted = False if self.token: self.enqueue(writer.restartServer(0)) # force relog if they're online await glob.db.execute( 'INSERT INTO punishments (`type`, `reason`, `target`, `from`, `time`) VALUES ' '(%s, %s, %s, %s, %s)', ['unrestrict', reason, self.id, fr.id, time.time()] ) if (wh_url := glob.config.webhooks['anticheat']): wh = Webhook(url=wh_url) embed = Embed(title=f'') embed.set_author( url=f'https://{glob.config.domain}/u/{self.id}', icon_url=f'https://a.{glob.config.domain}/{self.id}', name=self.name ) embed.add_field( name='New unrestricted user', value=f'{self.name} has been unrestricted by {fr.name} for {reason}.', inline=True ) wh.add_embed(embed) await wh.post()
async def restrict(self, reason: str, fr: "Player") -> None: if self.restricted: return # ? await self.add_priv(Privileges.Restricted) self.restricted = True if self.token: self.enqueue( writer.restartServer(0)) # force relog if they're online await glob.db.execute( "INSERT INTO punishments (`type`, `reason`, `target`, `from`, `time`) " "VALUES (%s, %s, %s, %s, %s)", ["restrict", reason, self.id, fr.id, time.time()], ) for mode, stat in self.stats.items(): mode_name = osuModes(mode).name await glob.redis.zrem(f"asahi:leaderboard:{mode_name}", self.id) await glob.redis.zrem( f"asahi:leaderboard:{mode_name}:{self.country_iso}", self.id, ) stat.rank = 0 stat.country_rank = 0 if wh_url := glob.config.webhooks["anticheat"]: wh = Webhook(url=wh_url) embed = Embed(title=f"") embed.set_author( url=f"https://{glob.config.domain}/u/{self.id}", icon_url=f"https://a.{glob.config.domain}/{self.id}", name=self.name, ) embed.add_field( name="New restricted user", value= f"{self.name} has been restricted by {fr.name} for {reason}.", inline=True, ) wh.add_embed(embed) await wh.post()
async def freeze(self, reason: str, fr: "Player") -> None: expire = datetime.now() + timedelta(days=7) if self.frozen: return # ? self.frozen = True self.freeze_timer = expire.timestamp() await self.add_priv(Privileges.Frozen) await glob.db.execute( "UPDATE users SET freeze_timer = %s WHERE id = %s", [self.freeze_timer, self.id], ) await glob.db.execute( "INSERT INTO punishments (`type`, `reason`, `target`, `from`, `time`) " "VALUES (%s, %s, %s, %s, %s)", ["freeze", reason, self.id, fr.id, time.time()], ) if self.token: self.enqueue(writer.restartServer(0)) if wh_url := glob.config.webhooks["anticheat"]: wh = Webhook(url=wh_url) embed = Embed(title="") embed.set_author( url=f"https://{glob.config.domain}/u/{self.id}", icon_url=f"https://a.{glob.config.domain}/{self.id}", name=self.name, ) embed.add_field( name="New frozen user", value=f"{self.name} has been frozen by {fr.name} for {reason}.", inline=True, ) wh.add_embed(embed) await wh.post()
async def freeze(self, reason: str, fr: 'Player') -> None: expire = datetime.now() + timedelta(days=7) if self.frozen: return # ? self.frozen = True self.freeze_timer = expire await self.add_priv(Privileges.Frozen) await glob.db.execute('UPDATE users SET freeze_timer = %s WHERE id = %s', [self.freeze_timer.timestamp(), self.id]) await glob.db.execute( 'INSERT INTO punishments (`type`, `reason`, `target`, `from`, `time`) ' 'VALUES (%s, %s, %s, %s, %s)', ['freeze', reason, self.id, fr.id, time.time()] ) if self.token: self.enqueue(writer.restartServer(0)) if (wh_url := glob.config.webhooks['anticheat']): wh = Webhook(url=wh_url) embed = Embed(title='') embed.set_author( url=f'https://{glob.config.domain}/u/{self.id}', icon_url=f'https://a.{glob.config.domain}/{self.id}', name=self.name ) embed.add_field( name='New frozen user', value=f'{self.name} has been frozen by {fr.name} for {reason}.', inline=True ) wh.add_embed(embed) await wh.post()
tarname=p.name, fromid=glob.bot.id ) elapsed = (time.time() - start) * 1000 data += writer.notification(f'Welcome to Asahi v{glob.version}\n\nTime Elapsed: {elapsed:.2f}ms') # send notification as indicator they've logged in i guess log(f'{p.name} successfully logged in.', Ansi.LBLUE) request.resp_headers['cho-token'] = token return bytes(data) # if we have made it this far then it's a reconnect attempt with token already provided user_token = headers['osu-token'] # client-provided token if not (p := await glob.players.get(token=user_token)): # user is logged in but token is not found? most likely a restart so we force a reconnection return writer.restartServer(0) # handle any packets the client has sent body = request.body if p.restricted: pm = glob.packets_restricted else: pm = glob.packets if body[0] != 4: for pck, cb in pm.items(): if body[0] == pck: await cb(p, bytes(body)) if glob.config.debug: