外观
chat API
模块说明
text
Explicit chat helpers; no listeners, ACKs, retries, or world writes.ChatCommandInfo
python
@dataclass(frozen=True)
class ChatCommandInfo字段(包含继承字段):
ChatCommandInfo.name
python
name: str数据类字段;声明于 chat.ChatCommandInfo。
ChatCommandInfo.aliases
python
aliases: tuple[str, ...] = ()数据类字段;声明于 chat.ChatCommandInfo。
ChatCommandInfo.description
python
description: str = ''数据类字段;声明于 chat.ChatCommandInfo。
ChatCommandInfo.usage
python
usage: str = ''数据类字段;声明于 chat.ChatCommandInfo。
ChatCommandInfo.min_args
python
min_args: int = 0数据类字段;声明于 chat.ChatCommandInfo。
ChatCommandInfo.max_args
python
max_args: int | None = None数据类字段;声明于 chat.ChatCommandInfo。
ChatArgumentError
python
class ChatArgumentError(ValueError)SDK 说明:
text
Recognized command has the wrong argument count; caller owns the reply.ChatArgumentError.__init__
python
def __init__(self, command: ChatCommandInfo, actual_count: int)另继承外部类型 ValueError;其通用方法不在本 SDK 目录中重复展开。
ChatArgumentError.command
python
self.command公开实例属性,在 __init__ 中设置。
ChatArgumentError.actual_count
python
self.actual_count公开实例属性,在 __init__ 中设置。
ChatCommand
python
@dataclass(frozen=True)
class ChatCommand字段(包含继承字段):
ChatCommand.event
python
event: 'Event'数据类字段;声明于 chat.ChatCommand。
ChatCommand.name
python
name: str数据类字段;声明于 chat.ChatCommand。
ChatCommand.args
python
args: tuple[str, ...]数据类字段;声明于 chat.ChatCommand。
ChatCommand.player
python
player: PlayerIdentity数据类字段;声明于 chat.ChatCommand。
ChatCommand.invoked_as
python
invoked_as: str = ''数据类字段;声明于 chat.ChatCommand。
ChatCommand.target
python
@property
def target(self) -> strChatRouter
python
class ChatRouterSDK 说明:
text
Call dispatch(event) from on_event; handlers own business checks and ACK.
Case-sensitive Unicode letters/numbers and ASCII _- names, exact prefix, quoted arguments
(parsing only, never shell execution). Dispatch verifies supplied player/XUID
against one current cached roster read. This proves roster agreement, not
authorization for privileged commands. Ambiguous or missing players fail.ChatRouter.__init__
python
def __init__(self, *, prefix: str='!', max_message_bytes: int=4096)ChatRouter.command
python
def command(
self,
name: str,
*,
aliases: tuple[str, ...] = (),
description: str = '',
usage: str = '',
min_args: int = 0,
max_args: int | None = None,
)SDK 说明:
text
Register an async handler and metadata, atomically claiming every alias.
Names are exact, without normalization or case folding. Metadata does not
create a help command, send replies, or grant permission to the caller.ChatRouter.list_commands
python
def list_commands(self) -> tuple[ChatCommandInfo, ...]SDK 说明:
text
Immutable metadata in registration order, one entry per command.ChatRouter.get_command
python
def get_command(self, name: str) -> ChatCommandInfo | NoneSDK 说明:
text
Look up a canonical name or alias without player reads.ChatRouter.unregister
python
def unregister(self, name: str) -> boolSDK 说明:
text
Remove a name and all its aliases; an already running handler finishes.ChatRouter.dispatch
python
async def dispatch(self, event: 'Event') -> boolSDK 说明:
text
True only after a registered handler finishes. Never acknowledge.
Unrelated/unknown commands return False without player reads. Malformed
recognized arguments raise ValueError. Handler/lookup errors propagate;
caller decides whether to reply/ACK or leave the delivery outstanding.ChatRouter.prefix
python
self.prefix公开实例属性,在 __init__ 中设置。
ChatRouter.max_message_bytes
python
self.max_message_bytes公开实例属性,在 __init__ 中设置。
ChatMessage
python
@dataclass(frozen=True)
class ChatMessage字段(包含继承字段):
ChatMessage.event
python
event: 'Event'数据类字段;声明于 chat.ChatMessage。
ChatMessage.message
python
message: str数据类字段;声明于 chat.ChatMessage。
ChatMessage.player
python
player: PlayerIdentity数据类字段;声明于 chat.ChatMessage。
ChatWaiters
python
class ChatWaitersSDK 说明:
text
One bounded, in-memory reply wait per exact player, fed explicitly.
wait_for registers immediately and returns a Future. Await it in ctx.spawn,
never in the serial on_event callback that must feed the next event. This
helper neither reads event streams nor ACKs deliveries. Restart loses waits.ChatWaiters.__init__
python
def __init__(self, *, max_pending: int=128, max_message_bytes: int=4096)ChatWaiters.wait_for
python
def wait_for(
self,
player: PlayerIdentity,
*,
timeout: float = 30,
) -> asyncio.Future[ChatMessage]SDK 说明:
text
Eagerly register a reply; Future cancellation releases this wait.
Supply a resolved roster record with a nonempty UUID or XUID. All three
identity fields must agree at feed time; there is no name-only fallback.
Timeout raises TimeoutError. Duplicate names fail instead of replacing a
conversation. Must be called on the same running event loop as feed.ChatWaiters.feed
python
async def feed(self, event: 'Event') -> boolSDK 说明:
text
Resolve one matching reply; True means the Future received this event.
This return value is only routing information: the caller/consumer still
explicitly decides whether to ACK or save an event transaction. Unmatched
events return False without a roster read; lookup errors propagate.ChatWaiters.close
python
def close(self) -> NoneSDK 说明:
text
Cancel all pending futures/timers and reject new waits; idempotent.ChatWaiters.max_pending
python
self.max_pending公开实例属性,在 __init__ 中设置。
ChatWaiters.max_message_bytes
python
self.max_message_bytes公开实例属性,在 __init__ 中设置。