Add ability to add "x" to commands

This is to allow web client users to use the BBS since the web client doesn't allow you to send single characters
This commit is contained in:
TC² 2024-07-23 16:07:13 -04:00
parent ddc3fbf1f1
commit e9709fd781
3 changed files with 34 additions and 10 deletions

View File

@ -111,8 +111,12 @@ def handle_fortune_command(sender_id, interface):
def handle_stats_steps(sender_id, message, step, interface):
message = message.lower().strip()
if len(message) == 2 and message[1] == 'x':
message = message[0]
if step == 1:
choice = message.lower()
choice = message
if choice == 'x':
handle_help_command(sender_id, interface)
return
@ -155,7 +159,6 @@ def handle_stats_steps(sender_id, message, step, interface):
handle_stats_command(sender_id, interface)
def handle_bb_steps(sender_id, message, step, state, interface, bbs_nodes):
boards = {0: "General", 1: "Info", 2: "News", 3: "Urgent"}
if step == 1:
@ -225,8 +228,12 @@ def handle_bb_steps(sender_id, message, step, state, interface, bbs_nodes):
def handle_mail_steps(sender_id, message, step, state, interface, bbs_nodes):
message = message.lower().strip()
if len(message) == 2 and message[1] == 'x':
message = message[0]
if step == 1:
choice = message.lower()
choice = message
if choice == 'r':
sender_node_id = get_node_id_from_num(sender_id, interface)
mail = get_mail(sender_node_id)
@ -353,8 +360,12 @@ def handle_channel_directory_command(sender_id, interface):
def handle_channel_directory_steps(sender_id, message, step, state, interface):
message = message.lower().strip()
if len(message) == 2 and message[1] == 'x':
message = message[0]
if step == 1:
choice = message.lower()
choice = message
if choice == 'x':
handle_help_command(sender_id, interface)
return
@ -473,7 +484,10 @@ def handle_read_mail_command(sender_id, message, state, interface):
def handle_delete_mail_confirmation(sender_id, message, state, interface, bbs_nodes):
try:
choice = message.lower()
choice = message.lower().strip()
if len(choice) == 2 and choice[1] == 'x':
choice = choice[0]
if choice == 'd':
unique_id = state['unique_id']
sender_node_id = get_node_id_from_num(sender_id, interface)
@ -493,6 +507,7 @@ def handle_delete_mail_confirmation(sender_id, message, state, interface, bbs_no
send_message("Error processing delete mail confirmation.", sender_id, interface)
def handle_post_bulletin_command(sender_id, message, interface, bbs_nodes):
try:
parts = message.split(",,", 3)

View File

@ -214,15 +214,19 @@ class JS8CallClient:
self.connected = False
def handle_js8call_command(sender_id, interface):
response = "JS8Call Menu:\n[G]roup Messages\n[S]tation Messages\n[U]rgent Messages\nE[X]IT"
send_message(response, sender_id, interface)
update_user_state(sender_id, {'command': 'JS8CALL_MENU', 'step': 1})
def handle_js8call_steps(sender_id, message, step, interface, state):
message = message.lower().strip()
if len(message) == 2 and message[1] == 'x':
message = message[0]
if step == 1:
choice = message.lower()
choice = message
if choice == 'x':
handle_help_command(sender_id, interface, 'bbs')
return
@ -236,6 +240,8 @@ def handle_js8call_steps(sender_id, message, step, interface, state):
send_message("Invalid option. Please choose again.", sender_id, interface)
handle_js8call_command(sender_id, interface)
def handle_group_messages_command(sender_id, interface):
conn = sqlite3.connect('js8call.db')
c = conn.cursor()

View File

@ -55,9 +55,13 @@ board_action_handlers = {
def process_message(sender_id, message, interface, is_sync_message=False):
state = get_user_state(sender_id)
message_lower = message.lower()
message_lower = message.lower().strip()
bbs_nodes = interface.bbs_nodes
# Handle repeated characters for single character commands using a prefix
if len(message_lower) == 2 and message_lower[1] == 'x':
message_lower = message_lower[0]
if is_sync_message:
if message.startswith("BULLETIN|"):
parts = message.split("|")
@ -164,11 +168,10 @@ def process_message(sender_id, message, interface, is_sync_message=False):
handle_js8call_steps(sender_id, message, step, interface, state)
elif command == 'GROUP_MESSAGES':
handle_group_message_selection(sender_id, message, step, state, interface)
else:
handle_help_command(sender_id, interface)
else:
handle_help_command(sender_id, interface)
def on_receive(packet, interface):
try:
if 'decoded' in packet and packet['decoded']['portnum'] == 'TEXT_MESSAGE_APP':