Enter key sends messages; admins can chat with Violet

- Add keydown listener: Enter submits, Shift+Enter inserts newline
- Allow admin users (even guests) to PM Violet
This commit is contained in:
3nd3r 2026-04-12 13:03:34 -05:00
parent 01c6c4a1b0
commit 8214f9c244
2 changed files with 9 additions and 1 deletions

2
app.py
View File

@ -601,7 +601,7 @@ def on_pm_message(data):
# Route to AI if recipient is Violet
if room.endswith(f":{AI_BOT_NAME.lower()}"):
if not user.get("user_id"):
if not user.get("user_id") and not user.get("is_admin"):
emit("error", {"msg": "You must be registered to chat with Violet."}); return
if not user.get("has_ai_access") and user.get("ai_messages_used", 0) >= AI_FREE_LIMIT:
emit("pm_message", {"from": AI_BOT_NAME, "text": "ai_limit_reached", "room": room, "system": True}, to=sid)

View File

@ -428,6 +428,14 @@ messageForm.addEventListener("submit", async (e) => {
messageInput.style.height = "auto";
});
// Enter to send, Shift+Enter for newline
messageInput.addEventListener("keydown", (e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
messageForm.requestSubmit();
}
});
// Auto-expand textarea
messageInput.addEventListener("input", () => {
messageInput.style.height = "auto";