async def set_name(self, ctx, *, name: str): """Set new display name""" if not repo_u.exists(ctx.author.id): return await ctx.author.send(f"Register with `{self.p}register`") if repo_u.get_attribute(ctx.author.id, "restricted") == 1: return await ctx.author.send("You are forbidden to alter your settings.") name = self.sanitise(name, limit=32) u = repo_u.get_by_nickname(name) if u is not None: return await ctx.author.send("This name is already used by someone.") # fmt: off disallowed = ( "(", ")", "*", "/", "@", "\\", "_", "`", "\u200B", "\u200C", "\u200D", "\u2028", "\u2060", "\uFEFF", # guild emojis "<:", "<a:", ) # fmt: on for char in disallowed: if char in name: return await ctx.author.send("The name contains forbidden characters.") before = repo_u.get_attribute(ctx.author.id, "nickname") repo_u.set(ctx.author.id, key="nickname", value=name) await ctx.author.send(f"Your nickname was changed to **{name}**") await self.event.user(ctx, f"Nickname changed from **{before}** to **{name}**.")
async def whois(self, ctx, *, member: str): """Get information about member""" await self.delete(ctx.message) await self.event.user(ctx, f"Whois lookup for **{member}**.") u = repo_u.get_by_nickname(member) if u: return await self.display_user_info(ctx, u) await ctx.author.send("User not found")
def _get_users_from_tags(self, beam_name: str, text: str) -> List[objects.User]: tags = [ repo_u.get_by_nickname(tag) for tag in re.findall(r"\(\(([^\(\)]*)\)\)", text) ] users = [ user for user in tags if user is not None and beam_name in user.home_ids.keys() ] return users