Skip to content

Commit

Permalink
refactor: 删除icqq的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
duan602728596 committed Aug 1, 2024
1 parent d90ae53 commit 1f1053f
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 239 deletions.
2 changes: 1 addition & 1 deletion packages/qqtools/src/QQ/QQBotModals/Basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface KeyType {
}

abstract class Basic {
public protocol: QQProtocol; // mirai或者oicq
public protocol: QQProtocol; // 使用的机器人程序
public id: string; // 当前进程的唯一ID
public config: OptionsItemValueV2; // 配置
public groupNumbers: Array<number>; // 多个群号
Expand Down
4 changes: 2 additions & 2 deletions packages/qqtools/src/QQ/QQBotModals/GoCQHttp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IncomingMessage } from 'node:http';
import { setInterval } from 'node:timers';
import { WebSocket as WebSocketClient, WebSocketServer } from 'ws';
import type { GroupMessage, MemberIncreaseEvent as OicqMemberIncreaseEvent } from 'icqq';
import type { GroupMessage, MemberIncreaseEvent as IcqqMemberIncreaseEvent } from 'icqq';
import * as dayjs from 'dayjs';
import { renderString } from 'nunjucks';
import Basic, { type BasicImplement, type BasicArgs } from './Basic';
Expand All @@ -22,7 +22,7 @@ export interface HeartbeatMessage {
meta_event_type: 'heartbeat';
}

export interface MemberIncreaseEvent extends Omit<OicqMemberIncreaseEvent, 'notice_type' | 'sub_type'> {
export interface MemberIncreaseEvent extends Omit<IcqqMemberIncreaseEvent, 'notice_type' | 'sub_type'> {
notice_type: 'group_increase';
sub_type: 'approve' | 'invite';
}
Expand Down
4 changes: 1 addition & 3 deletions packages/qqtools/src/QQ/QQBotModals/ModalTypes.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import type MiraiQQ from './MiraiQQ';
import type OicqQQ from './OicqQQ';
import type GoCQHttp from './GoCQHttp';
import type ConsoleTest from './ConsoleTest';

/* 支持的qq机器人类型 */
export const enum QQProtocol {
Mirai = 'mirai',
Oicq = 'oicq',
GoCQHttp = 'go-cqhttp',
ConsoleTest = 'console-test'
}

export type QQModals = MiraiQQ | OicqQQ | GoCQHttp | ConsoleTest;
export type QQModals = MiraiQQ | GoCQHttp | ConsoleTest;
179 changes: 0 additions & 179 deletions packages/qqtools/src/QQ/QQBotModals/OicqQQ.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let lfid: string; // 账号的lfid
let weiboTimer: number; // 轮询定时器
let weiboAtAll: boolean | undefined; // 是否at全体成员
let weiboId: bigint | null = null; // 记录查询位置
let protocol: QQProtocol; // 协议:mirai或者oicq
let protocol: QQProtocol; // 使用的机器人程序
let port: number; // 端口号

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let lfid: `${ string }_-_sort_time`; // 账号的lfid
let weiboTimer: number; // 轮询定时器
let weiboId: bigint | null = null; // 记录查询位置
let superNick: string; // 超话名称
let protocol: QQProtocol; // 协议:mirai或者oicq
let protocol: QQProtocol; // 协议:使用的机器人程序
let port: number; // 端口号

/**
Expand Down
2 changes: 0 additions & 2 deletions packages/qqtools/src/QQ/function/formatConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export function formatOptionType(config: OptionsItemValueV2): OptionsItemValueV2

if (nextConfig.optionType === 0 || nextConfig.optionType === '0') {
nextConfig.optionType = QQProtocol.Mirai;
} else if (nextConfig.optionType === '1') {
nextConfig.optionType = QQProtocol.Oicq;
} else if (nextConfig.optionType === '2') {
nextConfig.optionType = QQProtocol.GoCQHttp;
} else if (nextConfig.optionType === '100') {
Expand Down
7 changes: 1 addition & 6 deletions packages/qqtools/src/QQ/function/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ function parser(args: ParserArgs): ParserResult {
return text;
}

// oicq解析
const message: Array<MessageElem> = segment.fromCqcode(text);

if (protocol === QQProtocol.Oicq) {
return message;
}

// mirai根据oicq的解析来处理
// mirai根据icqq的解析来处理
const miraiMessageGroup: Array<MiraiMT> = message.map((ele: MessageElem): MiraiMT | undefined => {
switch (ele.type) {
case 'text':
Expand Down
4 changes: 2 additions & 2 deletions packages/qqtools/src/commonTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export interface EditItem {

/* ========== 一些基础的配置 ========== */
/** @deprecated */
type OldOptionType = '0' | '1' | '2' | '100' | 0;
type OldOptionType = '0' | '2' | '100' | 0;

export interface OptionsItemBasic {
optionName: string;
optionType: QQProtocol | OldOptionType; // 0: mirai-api-http,1: oicq,2: go-cqhttp
optionType: QQProtocol | OldOptionType; // 0: mirai-api-http,2: go-cqhttp
qqNumber: number;
groupNumber: string;
socketHost?: string;
Expand Down
10 changes: 1 addition & 9 deletions packages/qqtools/src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { queryOptionsList, OptionsInitialState } from '../Options/reducers/optio
import { setAddLogin, setDeleteLogin, getRoomId, LoginInitialState } from './reducers/reducers';
import dbConfig from '../../utils/IDB/IDBConfig';
import MiraiQQ from '../../QQ/QQBotModals/MiraiQQ';
import OicqQQ from '../../QQ/QQBotModals/OicqQQ';
import GoCQHttp from '../../QQ/QQBotModals/GoCQHttp';
import ConsoleTest from '../../QQ/QQBotModals/ConsoleTest';
import { formatToV2Config, formatOptionType } from '../../QQ/function/formatConfig';
Expand Down Expand Up @@ -76,14 +75,7 @@ function Index(props: {}): ReactElement {
const id: string = randomUUID();
let qq: QQModals | null = null;

if (qqOptions.optionType === QQProtocol.Oicq) {
qq = new OicqQQ({
id,
config: qqOptions,
membersList: roomIdResult?.value,
messageApi
});
} else if (qqOptions.optionType === QQProtocol.GoCQHttp) {
if (qqOptions.optionType === QQProtocol.GoCQHttp) {
qq = new GoCQHttp({
id,
config: qqOptions,
Expand Down
4 changes: 0 additions & 4 deletions packages/qqtools/src/pages/Options/EditV2/editv2.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
"label": "go-cqhttp",
"value": "go-cqhttp"
},
{
"label": "oicq",
"value": "oicq"
},
{
"label": "console-test",
"value": "console-test"
Expand Down
29 changes: 0 additions & 29 deletions packages/qqtools/src/services/oicq/index.ts

This file was deleted.

Empty file.

0 comments on commit 1f1053f

Please sign in to comment.