Bug #75 message.lower() breaks adding channels. Add a fix for all lower case board names not showing up.

This commit is contained in:
Shaun Mcbride 2024-08-23 15:50:25 -05:00
parent b778b8b6cd
commit 6a9c90a0f4
3 changed files with 13 additions and 11 deletions

View File

@ -228,12 +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): def handle_mail_steps(sender_id, message, step, state, interface, bbs_nodes):
message = message.lower().strip() message = message.strip()
if len(message) == 2 and message[1] == 'x': if len(message) == 2 and message[1] == 'x':
message = message[0] message = message[0]
if step == 1: if step == 1:
choice = message choice = message.lower()
if choice == 'r': if choice == 'r':
sender_node_id = get_node_id_from_num(sender_id, interface) sender_node_id = get_node_id_from_num(sender_id, interface)
mail = get_mail(sender_node_id) mail = get_mail(sender_node_id)
@ -360,16 +360,16 @@ def handle_channel_directory_command(sender_id, interface):
def handle_channel_directory_steps(sender_id, message, step, state, interface): def handle_channel_directory_steps(sender_id, message, step, state, interface):
message = message.lower().strip() message = message.strip()
if len(message) == 2 and message[1] == 'x': if len(message) == 2 and message[1] == 'x':
message = message[0] message = message[0]
if step == 1: if step == 1:
choice = message choice = message
if choice == 'x': if choice.lower() == 'x':
handle_help_command(sender_id, interface) handle_help_command(sender_id, interface)
return return
elif choice == 'v': elif choice.lower() == 'v':
channels = get_channels() channels = get_channels()
if channels: if channels:
response = "Select a channel number to view:\n" + "\n".join( response = "Select a channel number to view:\n" + "\n".join(
@ -379,7 +379,7 @@ def handle_channel_directory_steps(sender_id, message, step, state, interface):
else: else:
send_message("No channels available in the directory.", sender_id, interface) send_message("No channels available in the directory.", sender_id, interface)
handle_channel_directory_command(sender_id, interface) handle_channel_directory_command(sender_id, interface)
elif choice == 'p': elif choice.lower == 'p':
send_message("Name your channel for the directory:", sender_id, interface) send_message("Name your channel for the directory:", sender_id, interface)
update_user_state(sender_id, {'command': 'CHANNEL_DIRECTORY', 'step': 3}) update_user_state(sender_id, {'command': 'CHANNEL_DIRECTORY', 'step': 3})

View File

@ -93,7 +93,7 @@ def add_bulletin(board, sender_short_name, subject, content, bbs_nodes, interfac
def get_bulletins(board): def get_bulletins(board):
conn = get_db_connection() conn = get_db_connection()
c = conn.cursor() c = conn.cursor()
c.execute("SELECT id, subject, sender_short_name, date, unique_id FROM bulletins WHERE board = ?", (board,)) c.execute("SELECT id, subject, sender_short_name, date, unique_id FROM bulletins WHERE board = ? COLLATE NOCASE", (board,))
return c.fetchall() return c.fetchall()
def get_bulletin_content(bulletin_id): def get_bulletin_content(bulletin_id):

View File

@ -56,6 +56,8 @@ board_action_handlers = {
def process_message(sender_id, message, interface, is_sync_message=False): def process_message(sender_id, message, interface, is_sync_message=False):
state = get_user_state(sender_id) state = get_user_state(sender_id)
message_lower = message.lower().strip() message_lower = message.lower().strip()
message_strip = message.strip()
bbs_nodes = interface.bbs_nodes bbs_nodes = interface.bbs_nodes
# Handle repeated characters for single character commands using a prefix # Handle repeated characters for single character commands using a prefix
@ -89,15 +91,15 @@ def process_message(sender_id, message, interface, is_sync_message=False):
add_channel(channel_name, channel_url) add_channel(channel_name, channel_url)
else: else:
if message_lower.startswith("sm,,"): if message_lower.startswith("sm,,"):
handle_send_mail_command(sender_id, message_lower, interface, bbs_nodes) handle_send_mail_command(sender_id, message_strip, interface, bbs_nodes)
elif message_lower.startswith("cm"): elif message_lower.startswith("cm"):
handle_check_mail_command(sender_id, interface) handle_check_mail_command(sender_id, interface)
elif message_lower.startswith("pb,,"): elif message_lower.startswith("pb,,"):
handle_post_bulletin_command(sender_id, message_lower, interface, bbs_nodes) handle_post_bulletin_command(sender_id, message_strip, interface, bbs_nodes)
elif message_lower.startswith("cb,,"): elif message_lower.startswith("cb,,"):
handle_check_bulletin_command(sender_id, message_lower, interface) handle_check_bulletin_command(sender_id, message_strip, interface)
elif message_lower.startswith("chp,,"): elif message_lower.startswith("chp,,"):
handle_post_channel_command(sender_id, message_lower, interface) handle_post_channel_command(sender_id, message_strip, interface)
elif message_lower.startswith("chl"): elif message_lower.startswith("chl"):
handle_list_channels_command(sender_id, interface) handle_list_channels_command(sender_id, interface)
else: else: