Compare commits

..

No commits in common. "141eb051567479d227bf446cc06578e7ce2bcced" and "d8eea1640f3a16b34b667efb76015124067d196d" have entirely different histories.

3 changed files with 10 additions and 16 deletions

View file

@ -61,10 +61,10 @@ def handle_help_command(sender_id, interface, menu_name=None):
response = build_menu(utilities_menu_items, "🛠Utilities Menu🛠") response = build_menu(utilities_menu_items, "🛠Utilities Menu🛠")
else: else:
update_user_state(sender_id, {'command': 'MAIN_MENU', 'step': 1}) # Reset to main menu state update_user_state(sender_id, {'command': 'MAIN_MENU', 'step': 1}) # Reset to main menu state
mail = get_mail(get_node_id_from_num(sender_id, interface)) response = build_menu(main_menu_items, "💾TC² BBS💾")
response = build_menu(main_menu_items, f"💾TC² BBS💾 (✉️:{len(mail)})")
send_message(response, sender_id, interface) send_message(response, sender_id, interface)
def get_node_name(node_id, interface): def get_node_name(node_id, interface):
node_info = interface.nodes.get(node_id) node_info = interface.nodes.get(node_id)
if node_info: if node_info:
@ -80,7 +80,7 @@ def handle_mail_command(sender_id, interface):
def handle_bulletin_command(sender_id, interface): def handle_bulletin_command(sender_id, interface):
response = f"📰Bulletin Menu📰\nWhich board would you like to enter?\n[G]eneral [I]nfo [N]ews [U]rgent" response = "📰Bulletin Menu📰\nWhich board would you like to enter?\n[G]eneral [I]nfo [N]ews [U]rgent"
send_message(response, sender_id, interface) send_message(response, sender_id, interface)
update_user_state(sender_id, {'command': 'BULLETIN_MENU', 'step': 1}) update_user_state(sender_id, {'command': 'BULLETIN_MENU', 'step': 1})
@ -166,8 +166,7 @@ def handle_bb_steps(sender_id, message, step, state, interface, bbs_nodes):
handle_help_command(sender_id, interface, 'bbs') handle_help_command(sender_id, interface, 'bbs')
return return
board_name = boards[int(message)] board_name = boards[int(message)]
bulletins = get_bulletins(board_name) response = f"What would you like to do in the {board_name} board?\n[R]ead [P]ost"
response = f"{board_name} has {len(bulletins)} messages.\n[R]ead [P]ost"
send_message(response, sender_id, interface) send_message(response, sender_id, interface)
update_user_state(sender_id, {'command': 'BULLETIN_ACTION', 'step': 2, 'board': board_name}) update_user_state(sender_id, {'command': 'BULLETIN_ACTION', 'step': 2, 'board': board_name})
@ -187,7 +186,7 @@ def handle_bb_steps(sender_id, message, step, state, interface, bbs_nodes):
if board_name.lower() == 'urgent': if board_name.lower() == 'urgent':
node_id = get_node_id_from_num(sender_id, interface) node_id = get_node_id_from_num(sender_id, interface)
allowed_nodes = interface.allowed_nodes allowed_nodes = interface.allowed_nodes
logging.info(f"Checking permissions for node_id: {node_id} with allowed_nodes: {allowed_nodes}") # Debug statement print(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: 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) 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) handle_bb_steps(sender_id, 'e', 1, state, interface, bbs_nodes)
@ -536,13 +535,10 @@ def handle_check_bulletin_command(sender_id, message, interface):
# Split the message only once # Split the message only once
parts = message.split(",,", 1) parts = message.split(",,", 1)
if len(parts) != 2 or not parts[1].strip(): 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 return
boards = {0: "General", 1: "Info", 2: "News", 3: "Urgent"} #list of boards board_name = parts[1].strip()
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) bulletins = get_bulletins(board_name)
if not bulletins: if not bulletins:
send_message(f"No bulletins available on {board_name} board.", sender_id, interface) send_message(f"No bulletins available on {board_name} board.", sender_id, interface)

View file

@ -188,7 +188,7 @@ def on_receive(packet, interface):
sender_short_name = get_node_short_name(sender_node_id, 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), receiver_short_name = get_node_short_name(get_node_id_from_num(to_id, interface),
interface) if to_id else "Group Chat" interface) if to_id else "Group Chat"
logging.info(f"Received message from user '{sender_short_name}' ({sender_node_id}) to {receiver_short_name}: {message_string}") logging.info(f"Received message from user '{sender_short_name}' to {receiver_short_name}: {message_string}")
bbs_nodes = interface.bbs_nodes bbs_nodes = interface.bbs_nodes
is_sync_message = any(message_string.startswith(prefix) for prefix in is_sync_message = any(message_string.startswith(prefix) for prefix in

View file

@ -20,12 +20,10 @@ def send_message(message, destination, interface):
d = interface.sendText( d = interface.sendText(
text=chunk, text=chunk,
destinationId=destination, destinationId=destination,
wantAck=True, wantAck=False,
wantResponse=False wantResponse=False
) )
destid = get_node_id_from_num(destination, interface) logging.info(f"REPLY SEND ID={d.id}")
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: except Exception as e:
logging.info(f"REPLY SEND ERROR {e.message}") logging.info(f"REPLY SEND ERROR {e.message}")