Browse Source

Cleanup unused imports. Fixes a few variables

Justin 1 year ago
parent
commit
e200393670
1 changed files with 4 additions and 6 deletions
  1. 4 6
      classes/bot.py

+ 4 - 6
classes/bot.py

@@ -1,7 +1,6 @@
 import markdown2
 import duckdb
 import tiktoken
-import magic
 import asyncio
 
 from PIL import Image
@@ -27,12 +26,11 @@ from nio import (
     RoomLeaveError,
     RoomSendError,
     RoomVisibility,
-    RoomCreateResponse,
     RoomCreateError,
 )
 from nio.crypto import Olm
 
-from typing import Optional, List, Dict, Tuple
+from typing import Optional, List
 from configparser import ConfigParser
 from datetime import datetime
 from io import BytesIO
@@ -174,7 +172,7 @@ class GPTBot:
 
     async def _last_n_messages(self, room: str | MatrixRoom, n: Optional[int]):
         messages = []
-        n = n or bot.max_messages
+        n = n or self.max_messages
         room_id = room.room_id if isinstance(room, MatrixRoom) else room
 
         self.logger.log(
@@ -585,7 +583,7 @@ class GPTBot:
             self.logger.log(
                 "No database connection set up, using in-memory database. Data will be lost on bot shutdown.")
             IN_MEMORY = True
-            self.database = DuckDBPyConnection(":memory:")
+            self.database = duckdb.DuckDBPyConnection(":memory:")
 
         self.logger.log("Running migrations...")
         before, after = migrate(self.database)
@@ -803,7 +801,7 @@ class GPTBot:
         else:
             # Send a notice to the room if there was an error
             self.logger.log("Didn't get a response from GPT API", "error")
-            await send_message(
+            await self.send_message(
                 room, "Something went wrong. Please try again.", True)
 
         await self.matrix_client.room_typing(room.room_id, False)