Compare commits
5 Commits
543a65b7fb
...
0363dc2bcd
| Author | SHA1 | Date | |
|---|---|---|---|
| 0363dc2bcd | |||
| ce46bd49fe | |||
| 4653689e5e | |||
| e8e44b7da8 | |||
| 445935f2c9 |
@@ -1 +1 @@
|
|||||||
from .profiles import setup
|
from .profiles import setup, twitch_setup
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
async def setup(bot: 'Bot'):
|
async def setup(bot: 'Bot'):
|
||||||
from .component import ProfileComponent
|
from .component import ProfilesComponent
|
||||||
await bot.add_component(ProfileComponent(bot))
|
await bot.add_component(ProfilesComponent(bot))
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class ProfilesComponent(cmds.Component):
|
|||||||
# ----- API -----
|
# ----- API -----
|
||||||
async def component_load(self):
|
async def component_load(self):
|
||||||
await self.data.init()
|
await self.data.init()
|
||||||
|
await self.bot.version_check(*self.data.VERSION)
|
||||||
|
await self.profiles.init()
|
||||||
|
|
||||||
async def component_teardown(self):
|
async def component_teardown(self):
|
||||||
pass
|
pass
|
||||||
@@ -39,9 +41,7 @@ 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
|
|
||||||
async with conn.transaction():
|
|
||||||
profile = await self.profiles.get_profile_twitch(userid)
|
profile = await self.profiles.get_profile_twitch(userid)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
args = {}
|
args = {}
|
||||||
@@ -51,6 +51,8 @@ class ProfilesComponent(cmds.Component):
|
|||||||
args['avatar'] = user.profile_image.url
|
args['avatar'] = user.profile_image.url
|
||||||
except twitchio.HTTPException:
|
except twitchio.HTTPException:
|
||||||
pass
|
pass
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
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:
|
||||||
@@ -68,9 +70,7 @@ 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
|
|
||||||
async with conn.transaction():
|
|
||||||
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user