def encode(self, text: str) -> str:
def callback(match: Match) -> str:<EOL><INDENT>name = match.group("<STR_LIT:name>").lower()<EOL>if name in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>return f"<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>for user in self.users.values():<EOL><INDENT>if user.name == name:<EOL><INDENT>return f"<STR_LIT>"<EOL><DEDENT><DEDENT><DEDENT>return match.group(<NUM_LIT:0>)<EOL><DEDENT>return self.encode_re.sub(callback, text)<EOL>
Encode @username into <@id> or <!alias>.