From 5adb682ff7a6434ebe0f47f780f2243ef0b1428e Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Sun, 22 Sep 2024 23:03:58 +0300 Subject: [PATCH 1/8] Update command_handlers.py --- command_handlers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/command_handlers.py b/command_handlers.py index 798c110..0cd708d 100644 --- a/command_handlers.py +++ b/command_handlers.py @@ -63,7 +63,9 @@ def handle_help_command(sender_id, interface, menu_name=None): update_user_state(sender_id, {'command': 'MAIN_MENU', 'step': 1}) # Reset to main menu state response = build_menu(main_menu_items, "💾TC² BBS💾") send_message(response, sender_id, interface) - + mail = get_mail(get_node_id_from_num(sender_id, interface)) + if mail: + send_message(f"You have {len(mail)} mail messages.", sender_id, interface) def get_node_name(node_id, interface): node_info = interface.nodes.get(node_id) From 5e06ab1e3f90b16a9fb712d2bffdd68470a2c88b Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Sun, 22 Sep 2024 23:19:47 +0300 Subject: [PATCH 2/8] Update command_handlers.py --- command_handlers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/command_handlers.py b/command_handlers.py index 0cd708d..3ecc5b3 100644 --- a/command_handlers.py +++ b/command_handlers.py @@ -61,11 +61,9 @@ def handle_help_command(sender_id, interface, menu_name=None): response = build_menu(utilities_menu_items, "🛠️Utilities Menu🛠️") else: update_user_state(sender_id, {'command': 'MAIN_MENU', 'step': 1}) # Reset to main menu state - response = build_menu(main_menu_items, "💾TC² BBS💾") + mail = get_mail(get_node_id_from_num(sender_id, interface)) + response = build_menu(main_menu_items, f"💾TC² BBS💾 (✉️:{len(mail)})") send_message(response, sender_id, interface) - mail = get_mail(get_node_id_from_num(sender_id, interface)) - if mail: - send_message(f"You have {len(mail)} mail messages.", sender_id, interface) def get_node_name(node_id, interface): node_info = interface.nodes.get(node_id) From f7b1d49515ec3029d184f6ed5cc236e941a6f9fe Mon Sep 17 00:00:00 2001 From: nagumii Date: Tue, 24 Sep 2024 13:45:33 +0300 Subject: [PATCH 3/8] Add outgoing message contents and destination to logging --- utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index a6f9bc4..8d3784a 100644 --- a/utils.py +++ b/utils.py @@ -23,7 +23,8 @@ def send_message(message, destination, interface): wantAck=False, wantResponse=False ) - logging.info(f"REPLY SEND ID={d.id}") + destid = get_node_id_from_num(destination, interface) + logging.info(f"Sending message \"{chunk.replace("\n", "\\n")}\" to {destid} ({get_node_short_name(destid, interface)}). REPLY SEND ID={d.id}.") except Exception as e: logging.info(f"REPLY SEND ERROR {e.message}") From c6784290b59abfcb1d4bc3ddfeeafb78e0fdb965 Mon Sep 17 00:00:00 2001 From: nagumii Date: Tue, 24 Sep 2024 13:57:22 +0300 Subject: [PATCH 4/8] make send message and receive message use same lingo --- message_processing.py | 2 +- utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/message_processing.py b/message_processing.py index 0d504ca..caea313 100644 --- a/message_processing.py +++ b/message_processing.py @@ -186,7 +186,7 @@ def on_receive(packet, interface): sender_short_name = get_node_short_name(sender_node_id, interface) receiver_short_name = get_node_short_name(get_node_id_from_num(to_id, interface), interface) if to_id else "Group Chat" - logging.info(f"Received message from user '{sender_short_name}' to {receiver_short_name}: {message_string}") + logging.info(f"Received message from user '{sender_short_name}' ({sender_node_id}) to {receiver_short_name}: {message_string}") bbs_nodes = interface.bbs_nodes is_sync_message = any(message_string.startswith(prefix) for prefix in diff --git a/utils.py b/utils.py index 8d3784a..f3488d0 100644 --- a/utils.py +++ b/utils.py @@ -20,11 +20,11 @@ def send_message(message, destination, interface): d = interface.sendText( text=chunk, destinationId=destination, - wantAck=False, + wantAck=False, #should this be true? wantResponse=False ) destid = get_node_id_from_num(destination, interface) - logging.info(f"Sending message \"{chunk.replace("\n", "\\n")}\" to {destid} ({get_node_short_name(destid, interface)}). REPLY SEND ID={d.id}.") + logging.info(f"Sending message to user '{get_node_short_name(destid, interface)}' ({destid}) with sendID {d.id}: \'{chunk.replace("\n", "\\n")}\'") except Exception as e: logging.info(f"REPLY SEND ERROR {e.message}") From 880f93d3ad8505f2c84902d114695d2d7816cf22 Mon Sep 17 00:00:00 2001 From: nagumii Date: Tue, 24 Sep 2024 15:12:32 +0300 Subject: [PATCH 5/8] messages are now wantAck=True to improve reliability --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index f3488d0..23ec97a 100644 --- a/utils.py +++ b/utils.py @@ -20,7 +20,7 @@ def send_message(message, destination, interface): d = interface.sendText( text=chunk, destinationId=destination, - wantAck=False, #should this be true? + wantAck=True, wantResponse=False ) destid = get_node_id_from_num(destination, interface) From 592f8bd07398d0a72594b283319e2246ea976763 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 25 Sep 2024 00:15:38 +0300 Subject: [PATCH 6/8] fixed bug where cb,,board_name would always return no messages --- command_handlers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/command_handlers.py b/command_handlers.py index 3ecc5b3..65184d0 100644 --- a/command_handlers.py +++ b/command_handlers.py @@ -80,7 +80,7 @@ def handle_mail_command(sender_id, interface): def handle_bulletin_command(sender_id, interface): - response = "📰Bulletin Menu📰\nWhich board would you like to enter?\n[G]eneral [I]nfo [N]ews [U]rgent" + response = f"📰Bulletin Menu📰\nWhich board would you like to enter?\n[G]eneral [I]nfo [N]ews [U]rgent" send_message(response, sender_id, interface) update_user_state(sender_id, {'command': 'BULLETIN_MENU', 'step': 1}) @@ -166,7 +166,8 @@ def handle_bb_steps(sender_id, message, step, state, interface, bbs_nodes): handle_help_command(sender_id, interface, 'bbs') return board_name = boards[int(message)] - response = f"What would you like to do in the {board_name} board?\n[R]ead [P]ost" + bulletins = get_bulletins(board_name) + response = f"{board_name} has {len(bulletins)} messages.\n[R]ead [P]ost" send_message(response, sender_id, interface) update_user_state(sender_id, {'command': 'BULLETIN_ACTION', 'step': 2, 'board': board_name}) @@ -186,7 +187,7 @@ def handle_bb_steps(sender_id, message, step, state, interface, bbs_nodes): if board_name.lower() == 'urgent': node_id = get_node_id_from_num(sender_id, interface) allowed_nodes = interface.allowed_nodes - print(f"Checking permissions for node_id: {node_id} with allowed_nodes: {allowed_nodes}") # Debug statement + logging.info(f"Checking permissions for node_id: {node_id} with allowed_nodes: {allowed_nodes}") # Debug statement if allowed_nodes and node_id not in allowed_nodes: send_message("You don't have permission to post to this board.", sender_id, interface) handle_bb_steps(sender_id, 'e', 1, state, interface, bbs_nodes) @@ -535,10 +536,13 @@ def handle_check_bulletin_command(sender_id, message, interface): # Split the message only once parts = message.split(",,", 1) if len(parts) != 2 or not parts[1].strip(): - send_message("Check Bulletins Quick Command format:\nCB,,{board_name}", sender_id, interface) + send_message("Check Bulletins Quick Command format:\nCB,,board_name", sender_id, interface) return - board_name = parts[1].strip() + boards = {0: "General", 1: "Info", 2: "News", 3: "Urgent"} #list of boards + board_name = parts[1].strip().capitalize() #get board name from quick command and capitalize it + board_name = boards[next(key for key, value in boards.items() if value == board_name)] #search for board name in list + bulletins = get_bulletins(board_name) if not bulletins: send_message(f"No bulletins available on {board_name} board.", sender_id, interface) From 251825a12318607b6ca59906eb0d9ed2da966111 Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 26 Sep 2024 19:02:17 +0300 Subject: [PATCH 7/8] fix line break error --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 23ec97a..6dde672 100644 --- a/utils.py +++ b/utils.py @@ -24,7 +24,7 @@ def send_message(message, destination, interface): wantResponse=False ) destid = get_node_id_from_num(destination, interface) - logging.info(f"Sending message to user '{get_node_short_name(destid, interface)}' ({destid}) with sendID {d.id}: \'{chunk.replace("\n", "\\n")}\'") + logging.info(f"Sending message to user '{get_node_short_name(destid, interface)}' ({destid}) with sendID {d.id}: \"{chunk.replace('\n', '\\n')}\"") except Exception as e: logging.info(f"REPLY SEND ERROR {e.message}") From 8a00e435cca029a7b8eec64c93e131e20f6e1e52 Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 27 Sep 2024 16:32:58 +0300 Subject: [PATCH 8/8] retry fix --- utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 6dde672..f1809e8 100644 --- a/utils.py +++ b/utils.py @@ -24,7 +24,8 @@ def send_message(message, destination, interface): wantResponse=False ) destid = get_node_id_from_num(destination, interface) - logging.info(f"Sending message to user '{get_node_short_name(destid, interface)}' ({destid}) with sendID {d.id}: \"{chunk.replace('\n', '\\n')}\"") + chunk = chunk.replace('\n', '\\n') + logging.info(f"Sending message to user '{get_node_short_name(destid, interface)}' ({destid}) with sendID {d.id}: \"{chunk}\"") except Exception as e: logging.info(f"REPLY SEND ERROR {e.message}")