chore: OneBotApi

This commit is contained in:
手瓜一十雪
2024-08-09 15:44:45 +08:00
parent 7587e1b8f5
commit 086a6ad2cd
111 changed files with 4493 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import { EventType, OB11BaseEvent } from '../OB11BaseEvent';
export abstract class OB11BaseNoticeEvent extends OB11BaseEvent {
post_type = EventType.NOTICE;
}

View File

@@ -0,0 +1,11 @@
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
export class OB11FriendAddNoticeEvent extends OB11BaseNoticeEvent {
notice_type = 'friend_add';
user_id: number;
public constructor(user_Id: number) {
super();
this.user_id = user_Id;
}
}

View 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;
}
}

View File

@@ -0,0 +1,6 @@
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
export class OB11GroupAdminNoticeEvent extends OB11GroupNoticeEvent {
notice_type = 'group_admin';
sub_type: 'set' | 'unset' = "set"; // "set" | "unset"
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -0,0 +1,14 @@
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
export class OB11GroupEssenceEvent extends OB11GroupNoticeEvent {
notice_type = 'essence';
message_id: number;
sender_id: number;
sub_type: 'add' | 'delete' = 'add';
constructor(groupId: number, message_id: number, sender_id: number) {
super();
this.group_id = groupId;
this.message_id = message_id;
this.sender_id = sender_id;
}
}

View 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;
}
}

View File

@@ -0,0 +1,6 @@
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
export abstract class OB11GroupNoticeEvent extends OB11BaseNoticeEvent {
group_id: number = 0;
user_id: number = 0;
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -0,0 +1,16 @@
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
//输入状态事件 初步完成 Mlikio wa Todo 需要做一些过滤
export class OB11InputStatusEvent extends OB11BaseNoticeEvent {
notice_type = 'notify';
sub_type = 'input_status';
status_text = "对方正在输入..."
eventType = 1;
user_id = 0;
constructor(user_id: number, eventType: number, status_text: string) {
super();
this.user_id = user_id;
this.eventType = eventType;
this.status_text = status_text;
}
}

View File

@@ -0,0 +1,20 @@
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
export interface MsgEmojiLike {
emoji_id: string,
count: number
}
export class OB11GroupMsgEmojiLikeEvent extends OB11GroupNoticeEvent {
notice_type = 'group_msg_emoji_like';
message_id: number;
likes: MsgEmojiLike[];
constructor(groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[]) {
super();
this.group_id = groupId;
this.user_id = userId; // 可为空表示是对别人的消息操作如果是对bot自己的消息则不为空
this.message_id = messageId;
this.likes = likes;
}
}

View File

@@ -0,0 +1,32 @@
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
class OB11PokeEvent extends OB11BaseNoticeEvent {
notice_type = 'notify';
sub_type = 'poke';
target_id = 0;
user_id = 0;
}
export class OB11FriendPokeEvent extends OB11PokeEvent {
raw_info: any;
//raw_message nb等框架标准为string
constructor(user_id: number, target_id: number, raw_message: any) {
super();
this.target_id = target_id;
this.user_id = user_id;
this.raw_info = raw_message;
}
}
export class OB11GroupPokeEvent extends OB11PokeEvent {
group_id: number;
raw_info: any;
//raw_message nb等框架标准为string
constructor(group_id: number, user_id: number = 0, target_id: number = 0, raw_message: any) {
super();
this.group_id = group_id;
this.target_id = target_id;
this.user_id = user_id;
this.raw_info = raw_message;
}
}