What a mess

This commit is contained in:
Joan
2025-11-07 15:27:13 +01:00
parent 0b79b3ae59
commit 33cc9586c2
130 changed files with 29819 additions and 1175 deletions

View File

@@ -9,7 +9,8 @@ import json
from io import BytesIO
from telegram import Update
from telegram.ext import ContextTypes
from . import database, keyboards
from . import keyboards
from .api_client import api_client
from .utils import admin_only
from .action_handlers import get_player_status_text
from data.world_loader import game_world
@@ -19,23 +20,25 @@ logger = logging.getLogger(__name__)
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Handle /start command - initialize or show player status."""
from .api_client import api_client
user = update.effective_user
player = await database.get_player(user.id)
player = await api_client.get_player(user.id)
if not player:
await database.create_player(user.id, user.first_name)
player = await api_client.create_player(user.id, user.first_name)
await update.message.reply_html(
f"Welcome, {user.mention_html()}! Your story is just beginning."
)
# Get player status and location image
player = await database.get_player(user.id)
player = await api_client.get_player(user.id)
status_text = await get_player_status_text(user.id)
location = game_world.get_location(player['location_id'])
# Send with image if available
if location and location.image_path:
cached_file_id = await database.get_cached_image(location.image_path)
cached_file_id = await api_client.get_cached_image(location.image_path)
if cached_file_id:
await update.message.reply_photo(
photo=cached_file_id,
@@ -52,7 +55,7 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
parse_mode='HTML'
)
if msg.photo:
await database.cache_image(location.image_path, msg.photo[-1].file_id)
await api_client.cache_image(location.image_path, msg.photo[-1].file_id)
else:
await update.message.reply_html(
status_text,