From 07f5889f749c5985a51dcbb254f6ca344e175fc1 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Mon, 28 Jul 2025 22:36:29 -0700 Subject: [PATCH] Warn About 2-Second Message Delay --- contact/ui/contact_ui.py | 9 ++++++++- contact/ui/ui_state.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contact/ui/contact_ui.py b/contact/ui/contact_ui.py index 7ce41c0..d21eb5b 100644 --- a/contact/ui/contact_ui.py +++ b/contact/ui/contact_ui.py @@ -1,5 +1,6 @@ import curses import logging +import time import traceback from typing import Union @@ -320,10 +321,15 @@ def handle_enter(input_text: str) -> str: return input_text elif len(input_text) > 0: + + now = time.monotonic() + if now - ui_state.last_sent_time < 2.5: + contact.ui.dialog.dialog("Slow down", "Please wait 2 seconds between messages.") + return input_text # Enter key pressed, send user input as message send_message(input_text, channel=ui_state.selected_channel) draw_messages_window(True) - + ui_state.last_sent_time = now # Clear entry window and reset input text entry_win.erase() return "" @@ -335,6 +341,7 @@ def handle_ctrl_t(stdscr: curses.window) -> None: send_traceroute() curses.curs_set(0) # Hide cursor contact.ui.dialog.dialog( + stdscr, f"Traceroute Sent To: {get_name_from_database(ui_state.node_list[ui_state.selected_node])}", "Results will appear in messages window.\nNote: Traceroute is limited to once every 30 seconds.", ) diff --git a/contact/ui/ui_state.py b/contact/ui/ui_state.py index 7754322..ce5d643 100644 --- a/contact/ui/ui_state.py +++ b/contact/ui/ui_state.py @@ -29,6 +29,7 @@ class ChatUIState: start_index: List[int] = field(default_factory=lambda: [0, 0, 0]) show_save_option: bool = False menu_path: List[str] = field(default_factory=list) + last_sent_time: float = 0.0 @dataclass