"""Generated reviewed adapter for single-player-games.""" from jwebot_sdk import Event, ExtensionResult, ReplyPlan, SingleGroupContext PROFILE = 'single-player-games' AUTHOR = 'jwebot' DESCRIPTION = '金币游戏' HELP_ENTRIES = ('/金币 /wallet;/游戏记录 /gamehistory', '/抽奖 [金额];/draw', '/彩票 开始|报名|状态|开奖|取消;/lottery', '/21点 单人开始|要牌|停牌|状态;多人启动|加入|开始|放200', '/游戏帮助;/games') COMMANDS = ('/金币', '/wallet', '/抽奖', '/draw', '/彩票', '/买彩票', '/lottery', '/21点', '/二十一点', '/blackjack', '/游戏记录', '/个人记录', '/gamehistory', '/游戏帮助', '/games') def _handler(context: SingleGroupContext, command: str): def handle(event: Event, arguments: str) -> ExtensionResult: response = context.services.call( PROFILE, operation="execute", payload={ "command": command, "arguments": arguments, "event": event.to_mapping(), }, ) texts = response.get("texts") if isinstance(texts, list) and texts and all( isinstance(item, str) and item.strip() for item in texts ): return ExtensionResult( reply=ReplyPlan.multi_text(texts), metadata={"local_extension": PROFILE, "author": AUTHOR}, ) text = response.get("text") if not isinstance(text, str) or not text.strip(): raise ValueError("local service returned invalid text") return ExtensionResult( reply=ReplyPlan.text(text), metadata={"local_extension": PROFILE, "author": AUTHOR}, ) return handle def plugin(context: SingleGroupContext) -> None: for command in COMMANDS: context.commands.register(command, _handler(context, command))