tweak: Update nickname by touch
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user