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:
parent
01c6c4a1b0
commit
8214f9c244
2
app.py
2
app.py
|
|
@ -601,7 +601,7 @@ def on_pm_message(data):
|
||||||
|
|
||||||
# Route to AI if recipient is Violet
|
# Route to AI if recipient is Violet
|
||||||
if room.endswith(f":{AI_BOT_NAME.lower()}"):
|
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
|
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:
|
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)
|
emit("pm_message", {"from": AI_BOT_NAME, "text": "ai_limit_reached", "room": room, "system": True}, to=sid)
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,14 @@ messageForm.addEventListener("submit", async (e) => {
|
||||||
messageInput.style.height = "auto";
|
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
|
// Auto-expand textarea
|
||||||
messageInput.addEventListener("input", () => {
|
messageInput.addEventListener("input", () => {
|
||||||
messageInput.style.height = "auto";
|
messageInput.style.height = "auto";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue