Updated handle_channel_directory_command and handle_channel_directory_steps in command_handlers.py

-Cosmetic menu formating updated. Added new lines.
-Added functionality to remove channels.
This commit is contained in:
tbrinkhuis 2024-09-09 20:17:21 +00:00
parent 8331906820
commit 23ff660c8c

View File

@ -352,7 +352,7 @@ def handle_wall_of_shame_command(sender_id, interface):
def handle_channel_directory_command(sender_id, interface):
response = "📚CHANNEL DIRECTORY📚\nWhat would you like to do?\n[V]iew [P]ost E[X]IT"
response = "📚CHANNEL DIRECTORY📚\nWhat would you like to do?\n[V]iew \n[P]ost \n[R]emove \nE[X]IT"
send_message(response, sender_id, interface)
update_user_state(sender_id, {'command': 'CHANNEL_DIRECTORY', 'step': 1})
@ -380,6 +380,16 @@ def handle_channel_directory_steps(sender_id, message, step, state, interface):
elif choice == 'p':
send_message("Name your channel for the directory:", sender_id, interface)
update_user_state(sender_id, {'command': 'CHANNEL_DIRECTORY', 'step': 3})
elif choice == 'r':
channels = get_channels()
if channels:
response = "Select a channel number to remove:\n" + "\n".join(
[f"[{i}] {channel[0]}" for i, channel in enumerate(channels)])
send_message(response, sender_id, interface)
update_user_state(sender_id, {'command': 'CHANNEL_DIRECTORY', 'step': 5})
else:
send_message("No channels available in the directory.", sender_id, interface)
handle_channel_directory_command(sender_id, interface
elif step == 2:
channel_index = int(message)
@ -401,6 +411,15 @@ def handle_channel_directory_steps(sender_id, message, step, state, interface):
send_message(f"Your channel '{channel_name}' has been added to the directory.", sender_id, interface)
handle_channel_directory_command(sender_id, interface)
elif step == 5:
channel_index = int(message)
channels = get_channels()
if 0 <= channel_index < len(channels):
channel_name, _ = channels[channel_index]
remove_channel(channel_index)
send_message(f"Channel '{channel_name}' has been removed from the directory.", sender_id, interface)
handle_channel_directory_command(sender_id, interface)
def handle_send_mail_command(sender_id, message, interface, bbs_nodes):
try: