4.1 KiB
4.1 KiB
Bot Refactor Progress
Status: ✅ Bot successfully connecting to API!
The bot is now running and making API calls. Initial testing shows successful communication.
Completed
API Endpoints (Internal)
- ✅ GET
/api/internal/player/{telegram_id}- Get player by Telegram ID - ✅ POST
/api/internal/player- Create player - ✅ POST
/api/internal/player/{player_id}/move- Move player - ✅ GET
/api/internal/player/{player_id}/inspect- Inspect area - ✅ POST
/api/internal/player/{player_id}/interact- Interact with object - ✅ GET
/api/internal/player/{player_id}/inventory- Get inventory - ✅ POST
/api/internal/player/{player_id}/use_item- Use item - ✅ POST
/api/internal/player/{player_id}/pickup- Pick up item - ✅ POST
/api/internal/player/{player_id}/drop_item- Drop item - ✅ POST
/api/internal/player/{player_id}/equip- Equip item - ✅ POST
/api/internal/player/{player_id}/unequip- Unequip item
API Client (bot/api_client.py)
- ✅
get_player()- Get player by Telegram ID - ✅
create_player()- Create new player - ✅
move_player()- Move in direction - ✅
inspect_area()- Inspect current area - ✅
interact()- Interact with object - ✅
get_inventory()- Get inventory - ✅
use_item()- Use item - ✅
pickup_item()- Pick up item - ✅
drop_item()- Drop item - ✅
equip_item()- Equip item - ✅
unequip_item()- Unequip item
Bot Handlers Updated
- ✅
bot/handlers.py- Main button handler now uses API to get player - ✅
bot/commands.py- /start command uses API - ✅
bot/action_handlers.py- Movement handler updated - ✅
bot/inventory_handlers.py- Inventory menu uses API
Database Functions Added
- ✅
api/database.py::remove_item_from_inventory() - ✅
api/database.py::update_item_equipped_status()
In Progress
Testing
- 🔄 Movement system
- 🔄 Inventory system
- 🔄 Interaction system
Known Issues
- ⚠️
GET /api/internal/player/None/inventory- Some handler is passing None instead of player_id- Likely in inventory_handlers.py when player dict doesn't have 'id' field
- Need to trace which handler is causing this
Not Yet Updated (Still using bot/database.py directly)
Handlers that need refactoring:
-
⏳
action_handlers.py:handle_inspect_area()- Usesget_dropped_items_in_location,get_wandering_enemies_in_locationhandle_attack_wandering()- Combat-relatedhandle_inspect_interactable()- Usesget_cooldownhandle_action()- Usesget_cooldown,set_cooldown, item rewards
-
⏳
inventory_handlers.py:handle_inventory_item()- Usesget_inventory_itemhandle_inventory_use()- Uses multiple database callshandle_inventory_drop()- Usesadd_dropped_item_to_locationhandle_inventory_equip()- Direct database operationshandle_inventory_unequip()- Direct database operations
-
⏳
combat_handlers.py- ALL handlers (combat system not in API yet) -
⏳
pickup_handlers.py- Usesget_dropped_items_in_location -
⏳
profile_handlers.py- Stats management -
⏳
corpse_handlers.py- Looting system
API endpoints still needed:
- ⏳ Combat system endpoints
- ⏳ Dropped items endpoints
- ⏳ Wandering enemies endpoints
- ⏳ Status effects endpoints
- ⏳ Cooldown management endpoints
- ⏳ Corpse/looting endpoints
- ⏳ Stats/profile endpoints
Testing Plan
- ✅ Bot startup
- ✅ API connectivity
- 🔄 Test /start command (player creation)
- 🔄 Test movement
- ⏳ Test inventory viewing
- ⏳ Test item usage
- ⏳ Test interactions
- ⏳ Test combat
- ⏳ Test pickup/drop
- ⏳ Test equipment
Next Steps
- Debug the None player_id issue - Find where we're not properly passing player['id']
- Test basic movement - Try moving between locations
- Add missing API endpoints - Combat, cooldowns, dropped items, etc.
- Continue refactoring handlers - One module at a time
- Remove bot/database.py - Once all handlers use API
Current Status: Bot is operational and communicating with API. Basic functionality working, deeper features need more endpoints and refactoring.