yupix / MiPAC

Misskey Python API Core
https://mipac.akarinext.org/
MIT License
17 stars 4 forks source link

get_profile_linkをモデルにつけるか検討する #112

Open yupix opened 10 months ago

yupix commented 10 months ago

Summary

あんまりMisskeyに無い属性をモデルに追加したくないけど利便性を考えるとあってもいい気がする

    def get_profile_link(
        self,
        external: bool = True,
        protocol: Literal["http", "https"] = "https",
    ): 
        if not self._user:
            return None
        host = (
            f"{protocol}://{self._user.host}"
            if external and self._user.host
            else self._session._url
        )
        path = (
            f"/@{self._user.username}" if external else f"/{self._user.api.action.get_mention()}"
        )
        return host + path