mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 21:10:23 +00:00
NapCatQQ
This commit is contained in:
16
src/onebot11/event/OB11BaseEvent.ts
Normal file
16
src/onebot11/event/OB11BaseEvent.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { selfInfo } from '@/common/data';
|
||||
|
||||
export enum EventType {
|
||||
META = 'meta_event',
|
||||
REQUEST = 'request',
|
||||
NOTICE = 'notice',
|
||||
MESSAGE = 'message',
|
||||
MESSAGE_SENT = 'message_sent',
|
||||
}
|
||||
|
||||
|
||||
export abstract class OB11BaseEvent {
|
||||
time = Math.floor(Date.now() / 1000);
|
||||
self_id = parseInt(selfInfo.uin);
|
||||
post_type: EventType = EventType.META;
|
||||
}
|
||||
5
src/onebot11/event/message/OB11BaseMessageEvent.ts
Normal file
5
src/onebot11/event/message/OB11BaseMessageEvent.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { EventType, OB11BaseEvent } from '../OB11BaseEvent';
|
||||
|
||||
export abstract class OB11BaseMessageEvent extends OB11BaseEvent {
|
||||
post_type = EventType.MESSAGE;
|
||||
}
|
||||
6
src/onebot11/event/meta/OB11BaseMetaEvent.ts
Normal file
6
src/onebot11/event/meta/OB11BaseMetaEvent.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { EventType, OB11BaseEvent } from '../OB11BaseEvent';
|
||||
|
||||
export abstract class OB11BaseMetaEvent extends OB11BaseEvent {
|
||||
post_type = EventType.META;
|
||||
meta_event_type: string;
|
||||
}
|
||||
21
src/onebot11/event/meta/OB11HeartbeatEvent.ts
Normal file
21
src/onebot11/event/meta/OB11HeartbeatEvent.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { OB11BaseMetaEvent } from './OB11BaseMetaEvent';
|
||||
|
||||
interface HeartbeatStatus {
|
||||
online: boolean | null,
|
||||
good: boolean
|
||||
}
|
||||
|
||||
export class OB11HeartbeatEvent extends OB11BaseMetaEvent {
|
||||
meta_event_type = 'heartbeat';
|
||||
status: HeartbeatStatus;
|
||||
interval: number;
|
||||
|
||||
public constructor(isOnline: boolean, isGood: boolean, interval: number) {
|
||||
super();
|
||||
this.interval = interval;
|
||||
this.status = {
|
||||
online: isOnline,
|
||||
good: isGood
|
||||
};
|
||||
}
|
||||
}
|
||||
17
src/onebot11/event/meta/OB11LifeCycleEvent.ts
Normal file
17
src/onebot11/event/meta/OB11LifeCycleEvent.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { OB11BaseMetaEvent } from './OB11BaseMetaEvent';
|
||||
|
||||
export enum LifeCycleSubType {
|
||||
ENABLE = 'enable',
|
||||
DISABLE = 'disable',
|
||||
CONNECT = 'connect'
|
||||
}
|
||||
|
||||
export class OB11LifeCycleEvent extends OB11BaseMetaEvent {
|
||||
meta_event_type = 'lifecycle';
|
||||
sub_type: LifeCycleSubType;
|
||||
|
||||
public constructor(subType: LifeCycleSubType) {
|
||||
super();
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
5
src/onebot11/event/notice/OB11BaseNoticeEvent.ts
Normal file
5
src/onebot11/event/notice/OB11BaseNoticeEvent.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { EventType, OB11BaseEvent } from '../OB11BaseEvent';
|
||||
|
||||
export abstract class OB11BaseNoticeEvent extends OB11BaseEvent {
|
||||
post_type = EventType.NOTICE;
|
||||
}
|
||||
13
src/onebot11/event/notice/OB11FriendRecallNoticeEvent.ts
Normal file
13
src/onebot11/event/notice/OB11FriendRecallNoticeEvent.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
|
||||
export class OB11FriendRecallNoticeEvent extends OB11BaseNoticeEvent {
|
||||
notice_type = 'friend_recall';
|
||||
user_id: number;
|
||||
message_id: number;
|
||||
|
||||
public constructor(userId: number, messageId: number) {
|
||||
super();
|
||||
this.user_id = userId;
|
||||
this.message_id = messageId;
|
||||
}
|
||||
}
|
||||
6
src/onebot11/event/notice/OB11GroupAdminNoticeEvent.ts
Normal file
6
src/onebot11/event/notice/OB11GroupAdminNoticeEvent.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export class OB11GroupAdminNoticeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_admin';
|
||||
sub_type: 'set' | 'unset'; // "set" | "unset"
|
||||
}
|
||||
17
src/onebot11/event/notice/OB11GroupBanEvent.ts
Normal file
17
src/onebot11/event/notice/OB11GroupBanEvent.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export class OB11GroupBanEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_ban';
|
||||
operator_id: number;
|
||||
duration: number;
|
||||
sub_type: 'ban' | 'lift_ban';
|
||||
|
||||
constructor(groupId: number, userId: number, operatorId: number, duration: number, sub_type: 'ban' | 'lift_ban') {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operatorId;
|
||||
this.user_id = userId;
|
||||
this.duration = duration;
|
||||
this.sub_type = sub_type;
|
||||
}
|
||||
}
|
||||
16
src/onebot11/event/notice/OB11GroupCardEvent.ts
Normal file
16
src/onebot11/event/notice/OB11GroupCardEvent.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export class OB11GroupCardEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_card';
|
||||
card_new: string;
|
||||
card_old: string;
|
||||
|
||||
|
||||
constructor(groupId: number, userId: number, cardNew: string, cardOld: string) {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.card_new = cardNew;
|
||||
this.card_old = cardOld;
|
||||
}
|
||||
}
|
||||
17
src/onebot11/event/notice/OB11GroupDecreaseEvent.ts
Normal file
17
src/onebot11/event/notice/OB11GroupDecreaseEvent.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export type GroupDecreaseSubType = 'leave' | 'kick' | 'kick_me';
|
||||
|
||||
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_decrease';
|
||||
sub_type: GroupDecreaseSubType = 'leave'; // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
|
||||
operator_id: number;
|
||||
|
||||
constructor(groupId: number, userId: number, operatorId: number, subType: GroupDecreaseSubType = 'leave') {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operatorId; // 实际上不应该这么实现,但是现在还没有办法识别用户是被踢出的,还是自己主动退出的
|
||||
this.user_id = userId;
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
15
src/onebot11/event/notice/OB11GroupIncreaseEvent.ts
Normal file
15
src/onebot11/event/notice/OB11GroupIncreaseEvent.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
type GroupIncreaseSubType = 'approve' | 'invite';
|
||||
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_increase';
|
||||
operator_id: number;
|
||||
sub_type: GroupIncreaseSubType;
|
||||
constructor(groupId: number, userId: number, operatorId: number, subType: GroupIncreaseSubType = 'approve') {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.operator_id = operatorId;
|
||||
this.user_id = userId;
|
||||
this.sub_type = subType;
|
||||
}
|
||||
}
|
||||
6
src/onebot11/event/notice/OB11GroupNoticeEvent.ts
Normal file
6
src/onebot11/event/notice/OB11GroupNoticeEvent.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
|
||||
export abstract class OB11GroupNoticeEvent extends OB11BaseNoticeEvent {
|
||||
group_id: number;
|
||||
user_id: number;
|
||||
}
|
||||
15
src/onebot11/event/notice/OB11GroupRecallNoticeEvent.ts
Normal file
15
src/onebot11/event/notice/OB11GroupRecallNoticeEvent.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export class OB11GroupRecallNoticeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_recall';
|
||||
operator_id: number;
|
||||
message_id: number;
|
||||
|
||||
constructor(groupId: number, userId: number, operatorId: number, messageId: number) {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.operator_id = operatorId;
|
||||
this.message_id = messageId;
|
||||
}
|
||||
}
|
||||
15
src/onebot11/event/notice/OB11GroupTitleEvent.ts
Normal file
15
src/onebot11/event/notice/OB11GroupTitleEvent.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export class OB11GroupTitleEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'notify';
|
||||
sub_type = 'title';
|
||||
title: string;
|
||||
|
||||
|
||||
constructor(groupId: number, userId: number, title: string) {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
20
src/onebot11/event/notice/OB11GroupUploadNoticeEvent.ts
Normal file
20
src/onebot11/event/notice/OB11GroupUploadNoticeEvent.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
|
||||
|
||||
export interface GroupUploadFile{
|
||||
id: string,
|
||||
name: string,
|
||||
size: number,
|
||||
busid: number,
|
||||
}
|
||||
|
||||
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {
|
||||
notice_type = 'group_upload';
|
||||
file: GroupUploadFile;
|
||||
|
||||
constructor(groupId: number, userId: number, file: GroupUploadFile) {
|
||||
super();
|
||||
this.group_id = groupId;
|
||||
this.user_id = userId;
|
||||
this.file = file;
|
||||
}
|
||||
}
|
||||
30
src/onebot11/event/notice/OB11PokeEvent.ts
Normal file
30
src/onebot11/event/notice/OB11PokeEvent.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { selfInfo } from '../../../common/data';
|
||||
import { OB11BaseEvent } from '../OB11BaseEvent';
|
||||
|
||||
class OB11PokeEvent extends OB11BaseNoticeEvent{
|
||||
notice_type = 'notify';
|
||||
sub_type = 'poke';
|
||||
target_id = parseInt(selfInfo.uin);
|
||||
user_id: number;
|
||||
}
|
||||
|
||||
export class OB11FriendPokeEvent extends OB11PokeEvent{
|
||||
sender_id: number;
|
||||
constructor(user_id: number) {
|
||||
super();
|
||||
this.user_id = user_id;
|
||||
this.sender_id = user_id;
|
||||
}
|
||||
}
|
||||
|
||||
export class OB11GroupPokeEvent extends OB11PokeEvent{
|
||||
group_id: number;
|
||||
|
||||
constructor(group_id: number, user_id: number=0) {
|
||||
super();
|
||||
this.group_id = group_id;
|
||||
this.target_id = user_id;
|
||||
this.user_id = user_id;
|
||||
}
|
||||
}
|
||||
11
src/onebot11/event/request/OB11FriendRequest.ts
Normal file
11
src/onebot11/event/request/OB11FriendRequest.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { OB11BaseNoticeEvent } from '../notice/OB11BaseNoticeEvent';
|
||||
import { EventType } from '../OB11BaseEvent';
|
||||
|
||||
|
||||
export class OB11FriendRequestEvent extends OB11BaseNoticeEvent {
|
||||
post_type = EventType.REQUEST;
|
||||
user_id: number = 0;
|
||||
request_type = 'friend' as const;
|
||||
comment: string = '';
|
||||
flag: string = '';
|
||||
}
|
||||
11
src/onebot11/event/request/OB11GroupRequest.ts
Normal file
11
src/onebot11/event/request/OB11GroupRequest.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { OB11GroupNoticeEvent } from '../notice/OB11GroupNoticeEvent';
|
||||
import { EventType } from '../OB11BaseEvent';
|
||||
|
||||
|
||||
export class OB11GroupRequestEvent extends OB11GroupNoticeEvent {
|
||||
post_type = EventType.REQUEST;
|
||||
request_type = 'group' as const;
|
||||
sub_type: 'add' | 'invite' = 'add';
|
||||
comment: string = '';
|
||||
flag: string = '';
|
||||
}
|
||||
Reference in New Issue
Block a user