feat(shell): satori: add types

This commit is contained in:
Il Harper 2024-03-04 00:37:49 +08:00
parent d05928ddba
commit bf0c5da545
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
4 changed files with 443 additions and 0 deletions

View File

@ -0,0 +1,2 @@
export * from './satoriEntity'
export * from './satoriPayloadRich'

View File

@ -0,0 +1,283 @@
export enum Op {
Event = 0,
Ping = 1,
Pong = 2,
Identify = 3,
Ready = 4,
}
export interface Event {
/**
* ID
*/
id: number
/**
*
*/
type: string
/**
*
*/
platform: string
/**
*
*/
self_id: string
/**
*
*/
timestamp: number
/**
*
*/
channel?: Channel
/**
*
*/
guild?: Guild
/**
*
*/
login?: Login
/**
*
*/
member?: GuildMember
/**
*
*/
message?: Message
/**
*
*/
operator?: User
/**
*
*/
role?: GuildRole
/**
*
*/
user?: User
}
export interface Channel {
/**
* ID
*/
id: string
/**
*
*/
name?: string
/**
*
*/
type: ChannelType
/**
* ID
*/
parent_id?: string
/**
*
*/
avatar: string
}
export enum ChannelType {
/**
*
*/
TEXT = 0,
/**
*
*/
DIRECT = 1,
/**
*
*/
CATEGORY = 2,
/**
*
*/
VOICE = 3,
}
export interface Guild {
/**
* ID
*/
id: string
/**
*
*/
name: string
/**
*
*/
avatar: string
}
export interface Login {
/**
*
*/
user?: User
/**
*
*/
self_id?: string
/**
*
*/
platform?: string
/**
* 线
*/
status: LoginStatus
}
export enum LoginStatus {
/**
* 线
*/
OFFLINE = 0,
/**
* 线
*/
ONLINE = 1,
/**
*
*/
CONNECT = 2,
/**
*
*/
DISCONNECT = 3,
/**
*
*/
RECONNECT = 4,
}
export interface GuildMember {
/**
*
*/
user?: User
/**
*
*/
nick?: string
/**
*
*/
avatar?: string
}
export interface Message {
/**
* ID
*/
id: string
/**
*
*/
content: string
/**
*
*/
channel?: Channel
/**
*
*/
guild?: Guild
/**
*
*/
member?: GuildMember
/**
*
*/
user?: User
/**
*
*/
created_at?: number
/**
*
*/
updated_at?: number
}
export interface User {
/**
* ID
*/
id: string
/**
*
*/
name?: string
/**
*
*/
nick?: string
/**
*
*/
avatar?: string
/**
*
*/
is_bot?: boolean
}
export interface GuildRole {
/**
* ID
*/
id: string
/**
*
*/
name?: string
}

View File

@ -0,0 +1,122 @@
import type { Guild, GuildMember, User } from './satoriEntity'
export interface Next {
/**
* @title
*
* @description
*/
next?: string
}
export interface MessageCreatePayload {
/**
* @title
*
* @description
*
* Chronocat
* private: QQ
*/
channel_id: string
/**
* @title
*
* @description
*
* Satori
*/
content: string
}
export interface ApprovePayload {
/**
* ID
*/
message_id: string
/**
*
*/
approve: boolean
/**
*
*/
comment: string | undefined
}
export interface FriendListResponse extends Next {
data: User[]
}
export interface GuildListResponse extends Next {
data: Guild[]
}
export interface UserPayload {
user_id: string
// 仅限 Chronocat此处无需 guild_id。
}
export interface GuildMemberListPayload extends Next {
guild_id: string
}
export interface GuildMemberListResponse extends Next {
data: GuildMember[]
}
export interface GuildRemovePayload {
guild_id: string
}
export interface MessageDeletePayload {
channel_id: string
message_id: string
}
export interface MessageGetPayload {
channel_id: string
message_id: string
}
export interface ChannelMutePayload {
channel_id: string
enable: boolean
}
export interface ChannelMemberMutePayload {
channel_id: string
user_id: string
duration: number
}
export interface ChannelListPayload extends Next {
guild_id: string
}
export interface ChannelGetPayload {
channel_id: string
}
export interface GuildGetPayload {
guild_id: string
}
export interface UserGetPayload {
user_id: string
}
export interface GuildMemberGetPayload {
guild_id: string
user_id: string
}
export interface GuildMemberKickPayload {
guild_id: string
user_id: string
permanent?: boolean
}

View File

@ -0,0 +1,36 @@
import type h from '@satorijs/element'
import type { Op } from './satoriEntity'
export type {
ApprovePayload,
FriendListResponse,
GuildListResponse,
GuildMemberListPayload,
GuildMemberListResponse,
GuildRemovePayload,
MessageDeletePayload,
MessageGetPayload,
Next,
UserPayload,
} from './satoriPayloadEntity'
export type WebSocketIncomingMessage =
| WebSocketIncomingHeartbeatMessage
| WebSocketIncomingVerifyMessage
export interface WebSocketIncomingHeartbeatMessage {
op: Op.Ping
body: never
}
export interface WebSocketIncomingVerifyMessage {
op: Op.Identify
body?: {
token?: string
}
}
export interface MessageCreatePayload {
channel_id: string
content: h.Fragment
}