tweak: Update nickname by touch

This commit is contained in:
2026-08-04 10:49:48 +03:00
parent 8818263d88
commit fd522c8e8a
2 changed files with 23 additions and 7 deletions
+6 -1
View File
@@ -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
+17 -6
View File
@@ -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