Handle unknown exceptions in matrix bot
This commit is contained in:
parent
3dcc56c3a2
commit
032e996aa3
1 changed files with 11 additions and 1 deletions
12
main.py
12
main.py
|
@ -229,7 +229,9 @@ class DiscordClient(discord.ext.commands.Bot):
|
||||||
config["homeserver"], config["username"]
|
config["homeserver"], config["username"]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.bg_task = self.loop.create_task(self.matrix_client.start(self))
|
self.bg_task = self.loop.create_task(
|
||||||
|
self.log_exceptions(self.matrix_client)
|
||||||
|
)
|
||||||
|
|
||||||
self.add_cogs()
|
self.add_cogs()
|
||||||
|
|
||||||
|
@ -244,6 +246,14 @@ class DiscordClient(discord.ext.commands.Bot):
|
||||||
or str(channel_id) not in config["bridge"].keys():
|
or str(channel_id) not in config["bridge"].keys():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
async def log_exceptions(self, matrix_client):
|
||||||
|
try:
|
||||||
|
return await matrix_client.start(self)
|
||||||
|
except Exception as e:
|
||||||
|
matrix_client.logger.warning(f"Unknown exception occurred: {e}")
|
||||||
|
|
||||||
|
await matrix_client.close()
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
for channel in config["bridge"].keys():
|
for channel in config["bridge"].keys():
|
||||||
channel_store[channel] = self.get_channel(int(channel))
|
channel_store[channel] = self.get_channel(int(channel))
|
||||||
|
|
Loading…
Reference in a new issue