Merge pull request #83 from kizeren/main

Bug #75 message.lower() breaks adding channels.  Add a fix for all lo…
This commit is contained in:
TC² 2024-09-26 10:47:02 -04:00 committed by GitHub
commit d8eea1640f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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):
message = message.lower().strip()
message = message.strip()
if len(message) == 2 and message[1] == 'x':
message = message[0]
if step == 1:
choice = message
choice = message.lower()
if choice == 'r':
sender_node_id = get_node_id_from_num(sender_id, interface)
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):
message = message.lower().strip()
message = message.strip()
if len(message) == 2 and message[1] == 'x':
message = message[0]
if step == 1:
choice = message
if choice == 'x':
if choice.lower() == 'x':
handle_help_command(sender_id, interface)
return
elif choice == 'v':
elif choice.lower() == 'v':
channels = get_channels()
if channels:
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:
send_message("No channels available in the directory.", 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)
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):
conn = get_db_connection()
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()
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):
state = get_user_state(sender_id)
message_lower = message.lower().strip()
message_strip = message.strip()
bbs_nodes = interface.bbs_nodes
# 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)
else:
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"):
handle_check_mail_command(sender_id, interface)
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,,"):
handle_check_bulletin_command(sender_id, message_lower, interface)
handle_check_bulletin_command(sender_id, message_strip, interface)
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"):
handle_list_channels_command(sender_id, interface)
else: