Encode @username into <@id> or <!alias>.

def encode(self, text: str) -> str:
        """Encode @username into <@id> or <!alias>."""

        def callback(match: Match) -> str:
            name = match.group("name").lower()
            if name in ["here", "everyone", "channel"]:
                return f"<!{name}>"
            else:
                for user in self.users.values():
                    if user.name == name:
                        return f"<@{user.id}>"
            return match.group(0)

        return self.encode_re.sub(callback, text)