Compare commits
1 Commits
4653689e5e
...
ce46bd49fe
| Author | SHA1 | Date | |
|---|---|---|---|
| ce46bd49fe |
@@ -41,22 +41,20 @@ class ProfilesComponent(cmds.Component):
|
|||||||
Fetch or create the profile for the given user.
|
Fetch or create the profile for the given user.
|
||||||
"""
|
"""
|
||||||
userid = str(user.id)
|
userid = str(user.id)
|
||||||
async with self.bot.dbconn.connection() as conn:
|
# TODO: Transaction
|
||||||
self.bot.dbconn.conn = conn
|
profile = await self.profiles.get_profile_twitch(userid)
|
||||||
async with conn.transaction():
|
if profile is None:
|
||||||
profile = await self.profiles.get_profile_twitch(userid)
|
args = {}
|
||||||
if profile is None:
|
try:
|
||||||
args = {}
|
user = await user.user()
|
||||||
try:
|
args['nickname'] = user.display_name
|
||||||
user = await user.user()
|
args['avatar'] = user.profile_image.url
|
||||||
args['nickname'] = user.display_name
|
except twitchio.HTTPException:
|
||||||
args['avatar'] = user.profile_image.url
|
pass
|
||||||
except twitchio.HTTPException:
|
profile = await UserProfile.create(**args)
|
||||||
pass
|
await TwitchProfileLink.create(profileid=profile.profileid, userid=userid)
|
||||||
profile = await UserProfile.create(**args)
|
elif touch:
|
||||||
await TwitchProfileLink.create(profileid=profile.profileid, userid=userid)
|
await profile.update(last_seen=utc_now())
|
||||||
elif touch:
|
|
||||||
await profile.update(last_seen=utc_now())
|
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
|
|
||||||
@@ -70,14 +68,12 @@ class ProfilesComponent(cmds.Component):
|
|||||||
Fetch or create the community for this channel.
|
Fetch or create the community for this channel.
|
||||||
"""
|
"""
|
||||||
chanid = channel.id
|
chanid = channel.id
|
||||||
async with self.bot.dbconn.connection() as conn:
|
# TODO: Transaction
|
||||||
self.bot.dbconn.conn = conn
|
comm = await self.profiles.get_community_twitch(chanid)
|
||||||
async with conn.transaction():
|
if comm is None:
|
||||||
comm = await self.profiles.get_community_twitch(chanid)
|
comm = await Community.create()
|
||||||
if comm is None:
|
await TwitchCommunityLink.create(channelid=chanid, communityid=comm.communityid)
|
||||||
comm = await Community.create()
|
elif touch:
|
||||||
await TwitchCommunityLink.create(channelid=chanid, communityid=comm.communityid)
|
await comm.update(last_seen=utc_now())
|
||||||
elif touch:
|
|
||||||
await comm.update(last_seen=utc_now())
|
|
||||||
return comm
|
return comm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user