only logout on shutdown if MATRIX_PASSWORD is set
This commit is contained in:
parent
ab7f803e9b
commit
df224a1b03
28
bot.py
28
bot.py
|
@ -341,23 +341,23 @@ class Bot:
|
||||||
self.logger.error('Client was not able to log in, check env variables!')
|
self.logger.error('Client was not able to log in, check env variables!')
|
||||||
|
|
||||||
async def shutdown(self):
|
async def shutdown(self):
|
||||||
|
await self.logout()
|
||||||
|
await self.close()
|
||||||
|
|
||||||
if self.client.logged_in:
|
async def logout(self):
|
||||||
logout = await self.client.logout()
|
if self.matrix_pass is not None and self.client.logged_in:
|
||||||
|
response = await self.client.logout()
|
||||||
if isinstance(logout, LogoutResponse):
|
if isinstance(response, LogoutResponse):
|
||||||
self.logger.info("Logout successful")
|
self.logger.info("Logout successful")
|
||||||
try:
|
|
||||||
await self.client.close()
|
|
||||||
self.logger.info("Connection closed")
|
|
||||||
except Exception as e:
|
|
||||||
self.logger.error("error while closing client: %s", e)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logout: LogoutError
|
self.logger.error(f"Logout unsuccessful. msg: {response.message}")
|
||||||
self.logger.error(f"Logout unsuccessful. msg: {logout.message}")
|
|
||||||
else:
|
async def close(self):
|
||||||
await self.client.client_session.close()
|
try:
|
||||||
|
await self.client.close()
|
||||||
|
self.logger.info("Connection closed")
|
||||||
|
except Exception as ex:
|
||||||
|
self.logger.error("error while closing client: %s", ex)
|
||||||
|
|
||||||
def handle_exit(self, signame, loop):
|
def handle_exit(self, signame, loop):
|
||||||
self.logger.info(f"Received signal {signame}")
|
self.logger.info(f"Received signal {signame}")
|
||||||
|
|
Loading…
Reference in New Issue