diff --git a/profiles/discord/cog.py b/profiles/discord/cog.py index 6536100..ce4ef8a 100644 --- a/profiles/discord/cog.py +++ b/profiles/discord/cog.py @@ -62,7 +62,12 @@ class ProfilesCog(LionCog): profile = await UserProfile.create(**args) await DiscordProfileLink.create(profileid=profile.profileid, userid=user.id) elif touch: - await profile.update(last_seen=utc_now()) + # TODO: Should be factored into nickname_hint or similar + # TODO: display_name may be server-local + args = {} + if user.display_name is not None and user.display_name != profile.nickname: + args["nickname"] = user.display_name + await profile.update(last_seen=utc_now(), **args) return profile diff --git a/profiles/twitch/component.py b/profiles/twitch/component.py index d539d6b..eb17aae 100644 --- a/profiles/twitch/component.py +++ b/profiles/twitch/component.py @@ -10,7 +10,13 @@ from utils.lib import utc_now from . import logger -from ..data import ProfilesData, UserProfile, TwitchProfileLink, Community, TwitchCommunityLink +from ..data import ( + ProfilesData, + UserProfile, + TwitchProfileLink, + Community, + TwitchCommunityLink, +) from ..profiles import ProfilesRegistry @@ -47,8 +53,8 @@ class ProfilesComponent(cmds.Component): args = {} try: user = await user.user() - args['nickname'] = user.display_name - args['avatar'] = user.profile_image.url + args["nickname"] = user.display_name + args["avatar"] = user.profile_image.url except twitchio.HTTPException: pass except IndexError: @@ -56,7 +62,11 @@ class ProfilesComponent(cmds.Component): profile = await UserProfile.create(**args) await TwitchProfileLink.create(profileid=profile.profileid, userid=userid) elif touch: - await profile.update(last_seen=utc_now()) + args = {} + # TODO: Should be factored into nickname_hint or similar + if user.display_name is not None and user.display_name != profile.nickname: + args["nickname"] = user.display_name + await profile.update(last_seen=utc_now(), **args) return profile @@ -74,8 +84,9 @@ class ProfilesComponent(cmds.Component): comm = await self.profiles.get_community_twitch(chanid) if comm is None: comm = await Community.create() - await TwitchCommunityLink.create(channelid=chanid, communityid=comm.communityid) + await TwitchCommunityLink.create( + channelid=chanid, communityid=comm.communityid + ) elif touch: await comm.update(last_seen=utc_now()) return comm -