bstkchat 2.4.2__tar.gz → 2.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bstkchat-2.4.2 → bstkchat-2.4.3}/PKG-INFO +1 -1
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/cli.py +30 -8
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat.egg-info/PKG-INFO +1 -1
- {bstkchat-2.4.2 → bstkchat-2.4.3}/pyproject.toml +1 -1
- {bstkchat-2.4.2 → bstkchat-2.4.3}/setup.py +1 -1
- {bstkchat-2.4.2 → bstkchat-2.4.3}/tests/test_chain.py +15 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/README.md +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/__init__.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/chain.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/config.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/crypto.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/web.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat/web_ui.html +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat.egg-info/SOURCES.txt +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat.egg-info/dependency_links.txt +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat.egg-info/entry_points.txt +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat.egg-info/requires.txt +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/bstkchat.egg-info/top_level.txt +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/setup.cfg +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/tests/test_cli.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/tests/test_crypto.py +0 -0
- {bstkchat-2.4.2 → bstkchat-2.4.3}/tests/test_web.py +0 -0
|
@@ -57,7 +57,7 @@ from bstkchat.crypto import (
|
|
|
57
57
|
sanitize_room_id,
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
-
APP_VERSION = "2.4.
|
|
60
|
+
APP_VERSION = "2.4.3"
|
|
61
61
|
AUTO_AWAY_SECONDS = 300
|
|
62
62
|
TYPING_TTL_SECONDS = 5.0
|
|
63
63
|
TYPING_THROTTLE_SECONDS = 3.0
|
|
@@ -488,7 +488,9 @@ class ChatClient:
|
|
|
488
488
|
self.client.subscribe(presence_topic)
|
|
489
489
|
self.client.subscribe(sync_topic)
|
|
490
490
|
self.send_presence("join")
|
|
491
|
-
self.request_sync
|
|
491
|
+
t = threading.Timer(0.6, self.request_sync)
|
|
492
|
+
t.daemon = True
|
|
493
|
+
t.start()
|
|
492
494
|
self._emit_event("state_update", self.get_web_state())
|
|
493
495
|
|
|
494
496
|
def on_disconnect(self, client, userdata, rc, *args, **kwargs) -> None:
|
|
@@ -547,6 +549,9 @@ class ChatClient:
|
|
|
547
549
|
)
|
|
548
550
|
self.send_presence("heartbeat")
|
|
549
551
|
self._emit_event("system", {"text": f"{sender} joined the room.", "time": datetime.now().strftime("%H:%M:%S")}, record_history=True)
|
|
552
|
+
t = threading.Timer(0.4, self.request_sync)
|
|
553
|
+
t.daemon = True
|
|
554
|
+
t.start()
|
|
550
555
|
self._emit_event("state_update", self.get_web_state())
|
|
551
556
|
|
|
552
557
|
elif msg_type == "leave":
|
|
@@ -794,7 +799,7 @@ class ChatClient:
|
|
|
794
799
|
)
|
|
795
800
|
self._emit_event("state_update", self.get_web_state())
|
|
796
801
|
|
|
797
|
-
def replay_recent_chain(self, limit: int =
|
|
802
|
+
def replay_recent_chain(self, limit: int = 25) -> None:
|
|
798
803
|
"""Displays recent decrypted blocks from the local room chain on join."""
|
|
799
804
|
if not self.chain.enabled:
|
|
800
805
|
return
|
|
@@ -810,11 +815,25 @@ class ChatClient:
|
|
|
810
815
|
if ok:
|
|
811
816
|
if rendered == 0:
|
|
812
817
|
self.print_system(f"⛓️ Loaded {len(recent)} recent block(s) from local room chain:")
|
|
818
|
+
b_sender = str(block.get("sender", "Peer"))
|
|
819
|
+
b_time = str(block.get("time", "--:--:--"))
|
|
813
820
|
self._render_incoming_text(
|
|
814
|
-
escape_markup(
|
|
815
|
-
|
|
821
|
+
escape_markup(b_time),
|
|
822
|
+
b_sender,
|
|
816
823
|
text,
|
|
817
824
|
)
|
|
825
|
+
self._emit_event(
|
|
826
|
+
"message",
|
|
827
|
+
{
|
|
828
|
+
"sender": b_sender,
|
|
829
|
+
"color": get_user_color(b_sender),
|
|
830
|
+
"text": text,
|
|
831
|
+
"time": b_time,
|
|
832
|
+
"synced": True,
|
|
833
|
+
"own": b_sender == self.nickname,
|
|
834
|
+
},
|
|
835
|
+
record_history=True,
|
|
836
|
+
)
|
|
818
837
|
rendered += 1
|
|
819
838
|
|
|
820
839
|
def _handle_incoming_file(self, sender: str, decrypted_json: str) -> None:
|
|
@@ -1125,8 +1144,10 @@ class ChatClient:
|
|
|
1125
1144
|
|
|
1126
1145
|
self.clear_screen()
|
|
1127
1146
|
self.print_room_banner()
|
|
1128
|
-
self.replay_recent_chain(
|
|
1129
|
-
self.request_sync
|
|
1147
|
+
self.replay_recent_chain(25)
|
|
1148
|
+
t = threading.Timer(0.6, self.request_sync)
|
|
1149
|
+
t.daemon = True
|
|
1150
|
+
t.start()
|
|
1130
1151
|
self._emit_event("state_update", self.get_web_state())
|
|
1131
1152
|
|
|
1132
1153
|
def print_room_banner(self) -> None:
|
|
@@ -1455,6 +1476,7 @@ def main(argv: Optional[List[str]] = None) -> None:
|
|
|
1455
1476
|
if args.web:
|
|
1456
1477
|
from bstkchat.web import WebServer
|
|
1457
1478
|
|
|
1479
|
+
chat.replay_recent_chain(25)
|
|
1458
1480
|
web_server = WebServer(chat, port=args.web_port)
|
|
1459
1481
|
url = web_server.start()
|
|
1460
1482
|
chat.safe_print(
|
|
@@ -1483,7 +1505,7 @@ def main(argv: Optional[List[str]] = None) -> None:
|
|
|
1483
1505
|
|
|
1484
1506
|
chat.clear_screen()
|
|
1485
1507
|
chat.print_room_banner()
|
|
1486
|
-
chat.replay_recent_chain(
|
|
1508
|
+
chat.replay_recent_chain(25)
|
|
1487
1509
|
|
|
1488
1510
|
dynamic_style = DynamicStyle(
|
|
1489
1511
|
lambda: PromptStyle.from_dict(THEME_STYLES.get(chat.theme, THEME_STYLES["dark"]))
|
|
@@ -67,3 +67,18 @@ def test_peer_sync_request_and_response_between_clients(tmp_path):
|
|
|
67
67
|
bob.handle_sync("Alice", "sync_response", sync_resp, bob.sync_topic)
|
|
68
68
|
assert bob.chain.get_known_ids() == ["id1", "id2"]
|
|
69
69
|
assert bob.chain.verify_integrity() == (True, 2)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_replay_recent_chain_populates_web_recent_events(tmp_path):
|
|
73
|
+
client = ChatClient("Alice", "replay-room", "pw", store_chain=False)
|
|
74
|
+
client.chain = RoomChain("replay-room", store_dir=str(tmp_path))
|
|
75
|
+
client.safe_print = MagicMock()
|
|
76
|
+
client.write_to_log = MagicMock()
|
|
77
|
+
|
|
78
|
+
c1 = encrypt_payload("past message", client.secret_key, aad=client.msg_topic.encode("utf-8"))
|
|
79
|
+
client.chain.append_message("m1", 10.0, "01:00:00", "Bob", "message", c1)
|
|
80
|
+
|
|
81
|
+
client.replay_recent_chain(25)
|
|
82
|
+
state = client.get_web_state()
|
|
83
|
+
assert len(state["recent_events"]) == 1
|
|
84
|
+
assert state["recent_events"][0]["data"]["text"] == "past message"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|