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