Compare commits

...

1 Commits

Author SHA1 Message Date
conatum fd522c8e8a tweak: Update nickname by touch 2026-08-04 10:50:11 +03:00
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) profile = await UserProfile.create(**args)
await DiscordProfileLink.create(profileid=profile.profileid, userid=user.id) await DiscordProfileLink.create(profileid=profile.profileid, userid=user.id)
elif touch: 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 return profile
+17 -6
View File
@@ -10,7 +10,13 @@ from utils.lib import utc_now
from . import logger from . import logger
from ..data import ProfilesData, UserProfile, TwitchProfileLink, Community, TwitchCommunityLink from ..data import (
ProfilesData,
UserProfile,
TwitchProfileLink,
Community,
TwitchCommunityLink,
)
from ..profiles import ProfilesRegistry from ..profiles import ProfilesRegistry
@@ -47,8 +53,8 @@ class ProfilesComponent(cmds.Component):
args = {} args = {}
try: try:
user = await user.user() user = await user.user()
args['nickname'] = user.display_name args["nickname"] = user.display_name
args['avatar'] = user.profile_image.url args["avatar"] = user.profile_image.url
except twitchio.HTTPException: except twitchio.HTTPException:
pass pass
except IndexError: except IndexError:
@@ -56,7 +62,11 @@ class ProfilesComponent(cmds.Component):
profile = await UserProfile.create(**args) profile = await UserProfile.create(**args)
await TwitchProfileLink.create(profileid=profile.profileid, userid=userid) await TwitchProfileLink.create(profileid=profile.profileid, userid=userid)
elif touch: 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 return profile
@@ -74,8 +84,9 @@ class ProfilesComponent(cmds.Component):
comm = await self.profiles.get_community_twitch(chanid) comm = await self.profiles.get_community_twitch(chanid)
if comm is None: if comm is None:
comm = await Community.create() comm = await Community.create()
await TwitchCommunityLink.create(channelid=chanid, communityid=comm.communityid) await TwitchCommunityLink.create(
channelid=chanid, communityid=comm.communityid
)
elif touch: elif touch:
await comm.update(last_seen=utc_now()) await comm.update(last_seen=utc_now())
return comm return comm