mirror of
https://github.com/pdxlocations/contact.git
synced 2026-03-28 17:12:35 +01:00
Compare commits
3 Commits
queue
...
message-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
415d2bbda5 | ||
|
|
12d98ca999 | ||
|
|
07f5889f74 |
@@ -1,5 +1,6 @@
|
|||||||
import curses
|
import curses
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
@@ -320,10 +321,15 @@ def handle_enter(input_text: str) -> str:
|
|||||||
return input_text
|
return input_text
|
||||||
|
|
||||||
elif len(input_text) > 0:
|
elif len(input_text) > 0:
|
||||||
|
# TODO: This is a hack to prevent sending messages too quickly. Let's get errors from the node.
|
||||||
|
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
|
# Enter key pressed, send user input as message
|
||||||
send_message(input_text, channel=ui_state.selected_channel)
|
send_message(input_text, channel=ui_state.selected_channel)
|
||||||
draw_messages_window(True)
|
draw_messages_window(True)
|
||||||
|
ui_state.last_sent_time = now
|
||||||
# Clear entry window and reset input text
|
# Clear entry window and reset input text
|
||||||
entry_win.erase()
|
entry_win.erase()
|
||||||
return ""
|
return ""
|
||||||
@@ -335,6 +341,7 @@ def handle_ctrl_t(stdscr: curses.window) -> None:
|
|||||||
send_traceroute()
|
send_traceroute()
|
||||||
curses.curs_set(0) # Hide cursor
|
curses.curs_set(0) # Hide cursor
|
||||||
contact.ui.dialog.dialog(
|
contact.ui.dialog.dialog(
|
||||||
|
stdscr,
|
||||||
f"Traceroute Sent To: {get_name_from_database(ui_state.node_list[ui_state.selected_node])}",
|
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.",
|
"Results will appear in messages window.\nNote: Traceroute is limited to once every 30 seconds.",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ from contact.ui.colors import get_color
|
|||||||
|
|
||||||
|
|
||||||
def dialog(title: str, message: str) -> None:
|
def dialog(title: str, message: str) -> None:
|
||||||
|
"""Display a dialog with a title and message."""
|
||||||
|
|
||||||
|
curses.update_lines_cols()
|
||||||
height, width = curses.LINES, curses.COLS
|
height, width = curses.LINES, curses.COLS
|
||||||
|
|
||||||
# Calculate dialog dimensions
|
# Calculate dialog dimensions
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ChatUIState:
|
|||||||
selected_message: int = 0
|
selected_message: int = 0
|
||||||
selected_node: int = 0
|
selected_node: int = 0
|
||||||
current_window: int = 0
|
current_window: int = 0
|
||||||
|
last_sent_time: float = 0.0
|
||||||
|
|
||||||
selected_index: int = 0
|
selected_index: int = 0
|
||||||
start_index: List[int] = field(default_factory=lambda: [0, 0, 0])
|
start_index: List[int] = field(default_factory=lambda: [0, 0, 0])
|
||||||
|
|||||||
Reference in New Issue
Block a user