浏览代码

handle matrix timeouts

subDesTagesMitExtraKaese 10 月之前
父节点
当前提交
f9d7f83ac9
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      main.py

+ 8 - 1
main.py

@@ -1,6 +1,8 @@
 #!/usr/bin/env python3
 from urllib.parse import urlparse
 import os
+import time
+import asyncio
 
 import simplematrixbotlib as botlib
 import nio
@@ -82,4 +84,9 @@ async def on_message(room, event):
 
 if __name__ == "__main__":
   asr.load_model()
-  bot.run()
+  try:
+    bot.run()
+  except asyncio.exceptions.TimeoutError as e:
+    print(e)
+    print("Timeout, restarting...")
+    time.sleep(5)