Tentacle interfaces¶
The base classes every tentacle extends, and the pieces a channel is built from. The tentacle model explains the hierarchy; Contributing shows how to add one.
Reference pages¶
NapCat¶
octomate.tentacles.napcat.schema ¶
NapCat wire shapes: OneBot frames, segments and senders, and their decoding.
NapcatMessageSegment
module-attribute
¶
NapcatMessageSegment = Annotated[
Annotated[TextSegment, Tag("text")]
| Annotated[NapcatAtSegment, Tag("at")]
| Annotated[ImageSegment, Tag("image")]
| Annotated[ReplySegment, Tag("reply")]
| Annotated[FaceSegment, Tag("face")]
| Annotated[RecordSegment, Tag("record")]
| Annotated[VideoSegment, Tag("video")]
| Annotated[GenericSegment, Tag("__generic__")],
Discriminator(segment_discriminator),
]
InboundFrame
module-attribute
¶
InboundFrame = Annotated[
Annotated[NapcatMessageEvent, Tag("message")]
| Annotated[NapcatMetaEvent, Tag("meta_event")]
| Annotated[
ActionResponse[JsonObject], Tag("response")
],
Discriminator(_inbound_discriminator),
]
COMPATIBLE_SEGMENTS
module-attribute
¶
NapcatOutboundMessage
dataclass
¶
ActionResponse
pydantic-model
¶
Bases: BaseModel
A typed OneBot action response from HTTP or the event socket.
Config:
extra:ignorecoerce_numbers_to_str:True
Fields:
-
status(str) -
retcode(int) -
data(DataT | None) -
echo(str | None) -
message(str | None) -
wording(str | None)
Source code in octomate/tentacles/napcat/schema.py
model_config
class-attribute
instance-attribute
¶
ImageInfo
pydantic-model
¶
GroupInfo
pydantic-model
¶
SentMessage
pydantic-model
¶
Bases: BaseModel
Config:
coerce_numbers_to_str:True
Fields:
-
message_id(str | None)
Source code in octomate/tentacles/napcat/schema.py
NapcatUserProfile ¶
Bases: UserProfile
A QQ user as get_stranger_info reports them, normalized onto UserProfile.
Source code in octomate/tentacles/napcat/schema.py
model_config
class-attribute
instance-attribute
¶
model_config = ConfigDict(
alias_generator=AliasGenerator(
validation_alias=to_camel
),
validate_by_alias=True,
validate_by_name=True,
extra="ignore",
coerce_numbers_to_str=True,
frozen=True,
)
gender
class-attribute
instance-attribute
¶
normalize
classmethod
¶
Source code in octomate/tentacles/napcat/schema.py
NapcatSender ¶
Bases: UserProfile
The sender block of a OneBot message event.
Source code in octomate/tentacles/napcat/schema.py
model_config
class-attribute
instance-attribute
¶
normalize
classmethod
¶
Source code in octomate/tentacles/napcat/schema.py
NapcatAtData
pydantic-model
¶
Bases: AtData
AtData read from OneBot's qq key.
Config:
populate_by_name:True
Fields:
Source code in octomate/tentacles/napcat/schema.py
NapcatAtSegment
pydantic-model
¶
Bases: Segment
OneBot's at segment, whose target is qq.
Fields:
-
type(Literal['at']) -
data(NapcatAtData)
Source code in octomate/tentacles/napcat/schema.py
FaceData ¶
RecordData ¶
VideoData ¶
GenericSegment
pydantic-model
¶
Bases: Segment
Any segment type this channel does not model.
Fields:
Source code in octomate/tentacles/napcat/schema.py
FaceSegment
pydantic-model
¶
RecordSegment
pydantic-model
¶
Bases: Segment
OneBot's record (voice) segment.
Fields:
-
type(Literal['record']) -
data(RecordData)
Source code in octomate/tentacles/napcat/schema.py
VideoSegment
pydantic-model
¶
NapcatMessageEvent
pydantic-model
¶
Bases: BaseModel
A OneBot message event, private or group.
Config:
extra:ignorecoerce_numbers_to_str:True
Fields:
-
post_type(Literal['message']) -
message_type(Literal['private', 'group']) -
time(int) -
self_id(str) -
message_id(str) -
user_id(str) -
group_id(str) -
group_name(str | None) -
sender(NapcatSender) -
message(list[NapcatMessageSegment]) -
raw_message(str)
Source code in octomate/tentacles/napcat/schema.py
NapcatMetaEvent
pydantic-model
¶
Bases: BaseModel
A OneBot heartbeat or lifecycle notification.
The message pipeline only needs this envelope to discard connection-status notifications; their event-specific fields are ignored.
Fields:
-
post_type(Literal['meta_event']) -
meta_event_type(Literal['heartbeat', 'lifecycle'])