This commit is contained in:
retoor 2025-05-03 17:13:47 +02:00
parent a98ee86ecd
commit f517add468

View File

@ -34,6 +34,9 @@ class Bot:
self.ws = None
self.joined = set()
async def on_init(self):
logger.debug("Bot initialized.")
async def on_join(self, channel_uid):
self.joined.add(channel_uid)
logger.debug("Joined channel: " + channel_uid)
@ -92,14 +95,21 @@ class Bot:
async def run_once(self):
async with aiohttp.ClientSession() as session:
async with session.ws_connect(self.url) as ws:
if is_initial = not self.ws
self.ws = ws
rpc = RPC(self.ws)
self.rpc = rpc
await (await rpc.login(self.username, self.password))()
for channel in await self.get_channels():
logger.debug("Found channel: " + channel["name"])
self.user = await (await rpc.get_user(None))()
logger.debug("Logged in as: " + self.user["username"])
if is_initial:
await self.on_init()
for channel in await self.get_channels():
logger.debug("Found channel: " + channel["name"])
while True:
await self.on_idle()