Explorar el Código

Readme feature sync

lainlives hace 3 días
padre
commit
9654da3cbd
Se han modificado 2 ficheros con 10 adiciones y 9 borrados
  1. 2 2
      README.md
  2. 8 7
      main.py

+ 2 - 2
README.md

@@ -14,7 +14,7 @@ A modernized web-based clone inspired by the classic DS PictoChat. This updated
 * **Expandable Canvas (`↕`)**: Need more vertical space to draw? Click the extend button to instantly double or triple your canvas height (capped at 3x) without losing any existing strokes!
 * **Auto-Cropping**: When you hit send, the app intelligently scans your canvas and crops out unused whitespace from the top and bottom to maximize space in the chat log. 
 * **Custom Color Swatches**: Includes 8 standard colors, a custom hex picker, and a **Randomize (`🎲`)** button that instantly generates a unique theme color for your strokes and chat name.
-* **Anti-Spam Cooldown**: Integrated 60-second cooldown timer displayed directly on the send button to prevent room spamming.
+* **Anti-Spam Cooldown**: 60-second cooldown timer.
 
 ### Streaming & Archives
 * **OBS Stream Mode**: Add `?stream=1` to the URL to instantly convert the page into a pure, UI-free, transparent scrolling chat feed—perfect for overlaying on Twitch/OBS streams!
@@ -48,7 +48,7 @@ python main.py --admin Owner:supersecret
 ### Accessing the Room
 1. Open your browser and navigate to `http://localhost:2004` (or whatever port you configured).
 2. Enter your desired handle.
-3. Draw, type, and chat! All history is permanently stored in a local SQLite database (`chat.db`) and safely pruned down to the 500 most recent messages automatically.
+3. Draw, type, and chat! All history is permanently stored in a local SQLite database (`chat.db`) and pruned down to the 500 most recent messages automatically.
 
 
 ## Screenshots

+ 8 - 7
main.py

@@ -27,6 +27,7 @@ PORT = 2004
 custom_address = None
 verbose = False
 CHATNAME = "lainchat"
+PRUNE_COUNT = 500
 
 app = Flask(__name__, static_folder="public", static_url_path="")
 
@@ -207,11 +208,11 @@ def post_message():
         c = conn.cursor()
         c.execute("INSERT INTO messages (payload) VALUES (?)", (payload,))
 
-        # Prune if over 500
+        # Prune if over prune count
         c.execute("SELECT COUNT(*) FROM messages")
         count = c.fetchone()[0]
-        if count > 500:
-            excess = count - 500
+        if count > PRUNE_COUNT:
+            excess = count - PRUNE_COUNT
             c.execute(
                 "DELETE FROM messages WHERE id IN (SELECT id FROM messages ORDER BY id ASC LIMIT ?)",
                 (excess,),
@@ -235,11 +236,11 @@ def post_message():
 @app.route("/api/messages", methods=["GET"])
 def get_messages():
     is_stream = request.args.get("stream") == "1"
-    
+
     if not is_stream:
         session_id = request.cookies.get("session_id")
         with db_lock:
-            conn = sqlite3.connect('chat.db', check_same_thread=False)
+            conn = sqlite3.connect("chat.db", check_same_thread=False)
             c = conn.cursor()
             c.execute("SELECT 1 FROM users WHERE session_id = ?", (session_id,))
             if not c.fetchone():
@@ -301,11 +302,11 @@ def download_images():
 @app.route("/api/backlog", methods=["GET"])
 def get_backlog():
     is_stream = request.args.get("stream") == "1"
-    
+
     if not is_stream:
         session_id = request.cookies.get("session_id")
         with db_lock:
-            conn = sqlite3.connect('chat.db', check_same_thread=False)
+            conn = sqlite3.connect("chat.db", check_same_thread=False)
             c = conn.cursor()
             c.execute("SELECT 1 FROM users WHERE session_id = ?", (session_id,))
             if not c.fetchone():