mirror of
https://github.com/TheCommsChannel/TC2-BBS-mesh.git
synced 2025-08-19 03:38:01 -04:00
fixed an issue with exiting midgame
This commit is contained in:
parent
463c333e48
commit
dc5efa2b47
3 changed files with 13 additions and 7 deletions
|
@ -949,4 +949,4 @@ def process_game_choice(sender_id, message, interface, state):
|
||||||
present_story_segment(sender_id, interface, state)
|
present_story_segment(sender_id, interface, state)
|
||||||
|
|
||||||
except ValueError:
|
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)
|
|
@ -104,14 +104,19 @@ def process_message(sender_id, message, interface, is_sync_message=False):
|
||||||
channel_name, channel_url = parts[1], parts[2]
|
channel_name, channel_url = parts[1], parts[2]
|
||||||
add_channel(channel_name, channel_url)
|
add_channel(channel_name, channel_url)
|
||||||
else:
|
else:
|
||||||
# ✅ **Corrected IN_GAME Handling**
|
# ✅ **Fix: Ensure Games Menu Loads After Exiting a Game**
|
||||||
if state and state['command'] == 'IN_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":
|
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)
|
send_message(f"Exiting '{state['game']}'... Returning to Games Menu.", sender_id, interface)
|
||||||
update_user_state(sender_id, {'command': 'GAMES', 'step': 1})
|
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
|
return
|
||||||
|
|
||||||
# Otherwise, process the game choice
|
# 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):
|
def on_receive(packet, interface):
|
||||||
try:
|
try:
|
||||||
if 'decoded' in packet and packet['decoded']['portnum'] == 'TEXT_MESSAGE_APP':
|
if 'decoded' in packet and packet['decoded']['portnum'] == 'TEXT_MESSAGE_APP':
|
||||||
|
|
|
@ -16,9 +16,11 @@ import logging
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
|
import locale
|
||||||
|
|
||||||
# Reconfigure stdout to use UTF-8 encoding
|
# Apply UTF-8 fix only if needed
|
||||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
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 config_init import initialize_config, get_interface, init_cli_parser, merge_config
|
||||||
from db_operations import initialize_database
|
from db_operations import initialize_database
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue