fixed an issue with exiting midgame

This commit is contained in:
Jonathan Hite 2025-02-07 23:08:04 -05:00
parent 463c333e48
commit dc5efa2b47
3 changed files with 13 additions and 7 deletions

View File

@ -949,4 +949,4 @@ def process_game_choice(sender_id, message, interface, state):
present_story_segment(sender_id, interface, state)
except ValueError:
send_message("Invalid input. Please enter a valid number.", sender_id, interface)
send_message("Invalid input. Please enter a valid number.", sender_id, interface)

View File

@ -104,14 +104,19 @@ def process_message(sender_id, message, interface, is_sync_message=False):
channel_name, channel_url = parts[1], parts[2]
add_channel(channel_name, channel_url)
else:
# ✅ **Corrected IN_GAME Handling**
# ✅ **Fix: Ensure Games Menu Loads After Exiting a Game**
if state and state['command'] == 'IN_GAME':
message_lower = message.lower().strip()
logging.debug(f"🎮 User {sender_id} is in-game, processing game command...")
# Always check if the user wants to exit
if message_lower == "x":
logging.debug(f"❌ User {sender_id} exited the game. Sending exit message...")
send_message(f"Exiting '{state['game']}'... Returning to Games Menu.", sender_id, interface)
update_user_state(sender_id, {'command': 'GAMES', 'step': 1})
logging.debug(f"🚀 Calling handle_games_command() for user {sender_id} after exit.")
handle_games_command(sender_id, interface)
logging.debug(f"✅ handle_games_command() execution completed for user {sender_id}!")
return
# Otherwise, process the game choice
@ -211,7 +216,6 @@ def process_message(sender_id, message, interface, is_sync_message=False):
def on_receive(packet, interface):
try:
if 'decoded' in packet and packet['decoded']['portnum'] == 'TEXT_MESSAGE_APP':

View File

@ -16,9 +16,11 @@ import logging
import time
import sys
import io
import locale
# Reconfigure stdout to use UTF-8 encoding
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
# Apply UTF-8 fix only if needed
if "utf" not in locale.getpreferredencoding().lower():
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
from config_init import initialize_config, get_interface, init_cli_parser, merge_config
from db_operations import initialize_database