refactor: 整体重构 (#1381)
* feat: pnpm new * Refactor build and release workflows, update dependencies Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
This commit is contained in:
1 parent
c3d1892545
commit
ed19c52f25
778 files changed
+2356
-26391
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export enum EventType {
|
||||
META = 'meta_event',
|
||||
REQUEST = 'request',
|
||||
NOTICE = 'notice',
|
||||
MESSAGE = 'message',
|
||||
MESSAGE_SENT = 'message_sent',
|
||||
}
|
||||
|
||||
export abstract class OneBotEvent {
|
||||
time = Math.floor(Date.now() / 1000);
|
||||
self_id: number;
|
||||
abstract post_type: EventType;
|
||||
|
||||
constructor (core: NapCatCore) {
|
||||
this.self_id = parseInt(core.selfInfo.uin);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { EventType, OneBotEvent } from '@/napcat-onebot/event/OneBotEvent';
|
||||
|
||||
export abstract class OB11BaseMessageEvent extends OneBotEvent {
|
||||
post_type = EventType.MESSAGE;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { EventType, OneBotEvent } from '@/napcat-onebot/event/OneBotEvent';
|
||||
|
||||
export abstract class OB11BaseMetaEvent extends OneBotEvent {
|
||||
post_type = EventType.META;
|
||||
abstract meta_event_type: string;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { OB11BaseMetaEvent } from './OB11BaseMetaEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
interface HeartbeatStatus {
|
||||
online: boolean | undefined,
|
||||
good: boolean
|
||||
}
|
||||
|
||||
export class OB11HeartbeatEvent extends OB11BaseMetaEvent {
|
||||
meta_event_type = 'heartbeat';
|
||||
status: HeartbeatStatus;
|
||||
interval: number;
|
||||
|
||||
public constructor (core: NapCatCore, interval: number, isOnline: boolean, isGood: boolean) {
|
||||
super(core);
|
||||
this.interval = interval;
|
||||
this.status = {
|
||||
online: isOnline,
|
||||
good: isGood,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { OB11BaseMetaEvent } from './OB11BaseMetaEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export enum LifeCycleSubType {
|
||||
ENABLE = 'enable',
|
||||
DISABLE = 'disable',
|
||||
CONNECT = 'connect',
|
||||
}
|
||||
|
||||
export class OB11LifeCycleEvent extends OB11BaseMetaEvent {
|
||||
meta_event_type = 'lifecycle';
|
||||
sub_type: LifeCycleSubType;
|
||||
|
||||
public constructor (core: NapCatCore, subType: LifeCycleSubType) {
|
||||
super(core);
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class BotOfflineEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'bot_offline';
|
||||
user_id: number;
|
||||
tag: string = 'BotOfflineEvent';
|
||||
message: string = 'BotOfflineEvent';
|
||||
|
||||
public constructor (core: NapCatCore, tag: string, message: string) {
|
||||
super(core);
|
||||
this.user_id = +core.selfInfo.uin;
|
||||
this.tag = tag;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { EventType, OneBotEvent } from '@/napcat-onebot/event/OneBotEvent';
|
||||
|
||||
export abstract class OB11BaseNoticeEvent extends OneBotEvent {
|
||||
post_type = EventType.NOTICE;
|
||||
abstract notice_type: string;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11FriendAddNoticeEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'friend_add';
|
||||
user_id: number;
|
||||
|
||||
public constructor (core: NapCatCore, userId: number) {
|
||||
super(core);
|
||||
this.user_id = userId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11FriendRecallNoticeEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'friend_recall';
|
||||
user_id: number;
|
||||
message_id: number;
|
||||
|
||||
public constructor (core: NapCatCore, userId: number, messageId: number) {
|
||||
super(core);
|
||||
this.user_id = userId;
|
||||
this.message_id = messageId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupAdminNoticeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_admin';
|
||||
sub_type: 'set' | 'unset';
|
||||
|
||||
constructor (core: NapCatCore, group_id: number, user_id: number, sub_type: 'set' | 'unset') {
|
||||
super(core, group_id, user_id);
|
||||
this.sub_type = sub_type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupBanEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_ban';
|
||||
operator_id: number;
|
||||
duration: number;
|
||||
sub_type: 'ban' | 'lift_ban';
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, operatorId: number, duration: number, sub_type: 'ban' | 'lift_ban') {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operatorId;
|
||||
this.user_id = userId;
|
||||
this.duration = duration;
|
||||
this.sub_type = sub_type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupCardEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_card';
|
||||
card_new: string;
|
||||
card_old: string;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, cardNew: string, cardOld: string) {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.card_new = cardNew;
|
||||
this.card_old = cardOld;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export type GroupDecreaseSubType = 'leave' | 'kick' | 'kick_me' | 'disband';
|
||||
|
||||
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_decrease';
|
||||
sub_type: GroupDecreaseSubType = 'leave';
|
||||
operator_id: number;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, operatorId: number, subType: GroupDecreaseSubType = 'leave') {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operatorId;
|
||||
this.user_id = userId;
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupEssenceEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'essence';
|
||||
message_id: number;
|
||||
sender_id: number;
|
||||
operator_id: number;
|
||||
sub_type: 'add' | 'delete' = 'add';
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, message_id: number, sender_id: number, operator_id: number) {
|
||||
super(core, groupId, sender_id);
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operator_id;
|
||||
this.message_id = message_id;
|
||||
this.sender_id = sender_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
type GroupIncreaseSubType = 'approve' | 'invite';
|
||||
|
||||
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_increase';
|
||||
operator_id: number;
|
||||
sub_type: GroupIncreaseSubType;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, operatorId: number, subType: GroupIncreaseSubType = 'approve') {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operatorId;
|
||||
this.user_id = userId;
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupNameEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'notify';
|
||||
sub_type = 'group_name';
|
||||
name_new: string;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, nameNew: string) {
|
||||
super(core, groupId, userId);
|
||||
this.name_new = nameNew;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export abstract class OB11GroupNoticeEvent extends OB11BaseNoticeEvent {
|
||||
group_id: number;
|
||||
user_id: number;
|
||||
|
||||
constructor (core: NapCatCore, group_id: number, user_id: number) {
|
||||
super(core);
|
||||
this.group_id = group_id;
|
||||
this.user_id = user_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupRecallNoticeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_recall';
|
||||
operator_id: number;
|
||||
message_id: number;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, operatorId: number, messageId: number) {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.operator_id = operatorId;
|
||||
this.message_id = messageId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11GroupTitleEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'notify';
|
||||
sub_type = 'title';
|
||||
title: string;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, title: string) {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export interface GroupUploadFile {
|
||||
id: string,
|
||||
name: string,
|
||||
size: number,
|
||||
busid: number,
|
||||
}
|
||||
|
||||
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_upload';
|
||||
file: GroupUploadFile;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, file: GroupUploadFile) {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.file = file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
// TODO: 输入状态事件 初步完成 Mlikiowa 需要做一些过滤
|
||||
export class OB11InputStatusEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'notify';
|
||||
sub_type = 'input_status';
|
||||
status_text = '对方正在输入...';
|
||||
event_type = 1;
|
||||
user_id = 0;
|
||||
group_id = 0;
|
||||
|
||||
constructor (core: NapCatCore, user_id: number, eventType: number, status_text: string) {
|
||||
super(core);
|
||||
this.user_id = user_id;
|
||||
this.event_type = eventType;
|
||||
this.status_text = status_text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export interface MsgEmojiLike {
|
||||
emoji_id: string,
|
||||
count: number;
|
||||
}
|
||||
|
||||
export class OB11GroupMsgEmojiLikeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_msg_emoji_like';
|
||||
message_id: number;
|
||||
likes: MsgEmojiLike[];
|
||||
is_add: boolean;
|
||||
message_seq?: string;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[], isAdd: boolean, _messageSeq?: string) {
|
||||
super(core, groupId, userId);
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId; // 可为空,表示是对别人的消息操作,如果是对bot自己的消息则不为空
|
||||
this.message_id = messageId;
|
||||
this.likes = likes;
|
||||
this.is_add = isAdd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
class OB11PokeEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'notify';
|
||||
sub_type = 'poke';
|
||||
target_id = 0;
|
||||
user_id = 0;
|
||||
}
|
||||
|
||||
export class OB11FriendPokeEvent extends OB11PokeEvent {
|
||||
raw_info: unknown;
|
||||
sender_id: number;
|
||||
|
||||
// raw_message nb等框架标准为string
|
||||
constructor (core: NapCatCore, user_id: number, sender_id: number, target_id: number, raw_message: unknown) {
|
||||
super(core);
|
||||
this.target_id = target_id;
|
||||
this.user_id = user_id;
|
||||
this.sender_id = sender_id;
|
||||
this.raw_info = raw_message;
|
||||
}
|
||||
}
|
||||
|
||||
export class OB11GroupPokeEvent extends OB11PokeEvent {
|
||||
group_id: number;
|
||||
raw_info: unknown;
|
||||
|
||||
// raw_message nb等框架标准为string
|
||||
constructor (core: NapCatCore, group_id: number, user_id: number, target_id: number, raw_message: unknown) {
|
||||
super(core);
|
||||
this.group_id = group_id;
|
||||
this.target_id = target_id;
|
||||
this.user_id = user_id;
|
||||
this.raw_info = raw_message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
|
||||
export class OB11ProfileLikeEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'notify';
|
||||
sub_type = 'profile_like';
|
||||
operator_id: number;
|
||||
operator_nick: string;
|
||||
times: number;
|
||||
override time: number;
|
||||
|
||||
constructor (core: NapCatCore, operatorId: number, operatorNick: string, times: number, time: number) {
|
||||
super(core);
|
||||
this.operator_id = operatorId;
|
||||
this.operator_nick = operatorNick;
|
||||
this.times = times;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { EventType, OneBotEvent } from '@/napcat-onebot/event/OneBotEvent';
|
||||
|
||||
export abstract class OB11BaseRequestEvent extends OneBotEvent {
|
||||
readonly post_type = EventType.REQUEST;
|
||||
abstract request_type: string;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
import { OB11BaseRequestEvent } from './OB11BaseRequestEvent';
|
||||
|
||||
export class OB11FriendRequestEvent extends OB11BaseRequestEvent {
|
||||
override request_type = 'friend';
|
||||
|
||||
user_id: number;
|
||||
comment: string;
|
||||
flag: string;
|
||||
|
||||
constructor (core: NapCatCore, user_id: number, comment: string, flag: string) {
|
||||
super(core);
|
||||
this.user_id = user_id;
|
||||
this.comment = comment;
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { NapCatCore } from 'napcat-core';
|
||||
import { OB11BaseRequestEvent } from './OB11BaseRequestEvent';
|
||||
|
||||
export class OB11GroupRequestEvent extends OB11BaseRequestEvent {
|
||||
override readonly request_type = 'group' as const;
|
||||
|
||||
group_id: number;
|
||||
user_id: number;
|
||||
comment: string;
|
||||
flag: string;
|
||||
sub_type: string;
|
||||
|
||||
constructor (core: NapCatCore, groupId: number, userId: number, sub_type: string, comment: string, flag: string) {
|
||||
super(core);
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.sub_type = sub_type;
|
||||
this.comment = comment;
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user