Browse Source

Merge remote-tracking branch 'origin/renovate/matrix-nio-0.x'

subDesTagesMitExtraKaese 1 month ago
parent
commit
bc5dd0b605
3 changed files with 22 additions and 10 deletions
  1. 1 1
      Dockerfile
  2. 19 7
      main.py
  3. 2 2
      requirements.txt

+ 1 - 1
Dockerfile

@@ -11,7 +11,7 @@ ADD whisper.cpp/ /app/
 RUN cmake -B build && cmake --build build --config Release
 
 # main image
-FROM python:3.12-slim-bullseye
+FROM python:3.13-slim-bullseye
 WORKDIR /app/
 
 # Install dependencies

+ 19 - 7
main.py

@@ -2,6 +2,7 @@
 from urllib.parse import urlparse
 import os
 import time
+import traceback
 import asyncio
 
 import simplematrixbotlib as botlib
@@ -85,11 +86,22 @@ async def on_message(room, event):
         }
       })
 
+async def main():
+    asr.load_model()
+    while True:
+        try:
+            await bot.run()
+        except (asyncio.exceptions.TimeoutError, aiohttp.ClientError) as e:
+            print(f"Network issue: {e}")
+            traceback.print_exc()
+            print("Network issue, restarting...")
+            await asyncio.sleep(5)
+        except Exception as e:
+            print(f"Unexpected error: {e}")
+            traceback.print_exc()
+            print("Unexpected error, restarting...")
+            await asyncio.sleep(5)
+
 if __name__ == "__main__":
-  asr.load_model()
-  try:
-    bot.run()
-  except asyncio.exceptions.TimeoutError as e:
-    print(e)
-    print("Timeout, restarting...")
-    time.sleep(5)
+    asyncio.run(main())
+

+ 2 - 2
requirements.txt

@@ -1,3 +1,3 @@
-simplematrixbotlib==2.12.0
-matrix-nio[e2e]==0.24.0
+simplematrixbotlib==2.12.3
+matrix-nio[e2e]==0.25.2
 ffmpeg-python