fix: break circular import in horse racing commands
Extract shared.py from commands/__init__.py to break circular dependency: - shared.py: shared variables/services/helper functions - access.py: get_scope/check_access/get_event_id (canonical source) - __init__.py: re-exports from shared.py for backward compat - register/bet/race/help: import from .shared instead of package
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.adapters.onebot.v11 import Bot, Event
|
||||
from . import (
|
||||
from .shared import (
|
||||
room_store, points_service, config, logger,
|
||||
get_scope, check_access, get_event_id,
|
||||
_resolve_horse_selector, _format_horse_label,
|
||||
_get_horses_in_order, _find_user_horse,
|
||||
calculate_odds,
|
||||
)
|
||||
from ..models import RoomState, Bet
|
||||
|
||||
cancel_cmd = on_command("赛马取消报名", priority=5)
|
||||
|
||||
|
||||
@cancel_cmd.handle()
|
||||
async def handle_cancel(bot: Bot, event: Event):
|
||||
@@ -85,7 +90,6 @@ async def handle_cancel_bet(bot: Bot, event: Event):
|
||||
logger.error(f"退还下注失败 user={bet.user_id} amount={bet.amount}: {e}")
|
||||
refund_errors.append(bet)
|
||||
|
||||
# 只移除已成功退还的下注
|
||||
if refund_errors:
|
||||
failed_amount = sum(b.amount for b in refund_errors)
|
||||
room.bets = [b for b in room.bets if b.user_id != user_id or b in refund_errors]
|
||||
@@ -180,8 +184,3 @@ async def handle_odds(bot: Bot, event: Event):
|
||||
lines.append(f"总下注池: {total_bet}")
|
||||
|
||||
await odds_cmd.finish("\n".join(lines))
|
||||
|
||||
|
||||
race_list_cmd = on_command("赛马列表", priority=5)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user