mirror of
https://github.com/TheCommsChannel/TC2-BBS-mesh.git
synced 2024-10-01 01:15:36 -04:00
Merge pull request #89 from noon92/patch-1
Add new mail notification to main menu and request ack
This commit is contained in:
commit
141eb05156
@ -61,10 +61,10 @@ 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)
|
||||
|
||||
|
||||
def get_node_name(node_id, interface):
|
||||
node_info = interface.nodes.get(node_id)
|
||||
if node_info:
|
||||
@ -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)
|
||||
|
@ -188,7 +188,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
|
||||
|
6
utils.py
6
utils.py
@ -20,10 +20,12 @@ def send_message(message, destination, interface):
|
||||
d = interface.sendText(
|
||||
text=chunk,
|
||||
destinationId=destination,
|
||||
wantAck=False,
|
||||
wantAck=True,
|
||||
wantResponse=False
|
||||
)
|
||||
logging.info(f"REPLY SEND ID={d.id}")
|
||||
destid = get_node_id_from_num(destination, interface)
|
||||
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}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user