Skip to content

Commit

Permalink
fix: 移除非icqq平台的icqq依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Mar 9, 2024
1 parent 9981c8c commit 8f0d0da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 44 deletions.
10 changes: 5 additions & 5 deletions docs/src/guide/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm init
## 2. 安装 `OneBots`
- 在终端进入项目文件夹,并执行以下命令,安装 `OneBots`
```shell
npm install onebots --legacy-peer-deps
npm install onebots --legacy-peer-deps # 带上后边这个是为了防止自动安装对等依赖
```
## 3. 安装适配器
- 根据你的需求,选择对应的适配器进行安装
Expand Down Expand Up @@ -40,16 +40,16 @@ E-Mail: # 你的公开邮箱地址

::: code-group
```shell [ICQQ]
npm install @icqqjs/icqq
npm install @icqqjs/icqq --legacy-peer-deps # 带上后边这个是为了防止自动安装对等依赖
```
```shell [QQ官方机器人]
npm install qq-group-bot
npm install qq-group-bot --legacy-peer-deps # 带上后边这个是为了防止自动安装对等依赖
```
```shell [钉钉机器人]
npm install node-dd-bot
npm install node-dd-bot --legacy-peer-deps # 带上后边这个是为了防止自动安装对等依赖
```
```shell [微信机器人]
npm install lib-wechat
npm install lib-wechat --legacy-peer-deps # 带上后边这个是为了防止自动安装对等依赖
```
:::
## 4. 初始化配置
Expand Down
8 changes: 4 additions & 4 deletions src/service/V11/action/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { OneBotStatus } from "@/onebot";
import { V11 } from "@/service/V11";
import { Message } from "@icqqjs/icqq";
import { MsgEntry } from "@/service/V11/db_entities";

export class CommonAction {
/**
Expand Down Expand Up @@ -34,8 +32,10 @@ export class CommonAction {
*/
async getMsg(this: V11, message_id: number) {
const msg_id = this.getStrByInt("message_id", message_id);
let msg: Message = await this.adapter.call(this.oneBot.uin, "V11", "getMessage", [msg_id]);
msg.message_id = message_id as any; // nonebot v11 要求 message_id 是 number 类型
let msg: V11.MessageRet = await this.adapter.call(this.oneBot.uin, "V11", "getMessage", [
msg_id,
]);
msg.message_id = message_id; // nonebot v11 要求 message_id 是 number 类型
msg["real_id"] = msg.message_id; // nonebot 的reply类型会检测real_id是否存在,虽然它从未使用
return msg;
}
Expand Down
36 changes: 1 addition & 35 deletions src/service/V12/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EventMap } from "@icqqjs/icqq";
import { version } from "@/utils";
import { join } from "path";
import { Config } from "./config";
Expand All @@ -12,7 +11,6 @@ import https from "https";
import { WebSocket, WebSocketServer } from "ws";
import { toBool, toHump, toLine, transformObj, uuid } from "@/utils";
import { JsonDB } from "@/db";
import { genDmMessageId, genGroupMessageId } from "@icqqjs/icqq/lib/message";
import { Service } from "@/service";
import { App } from "@/server/app";
import { Dict } from "@zhinjs/shared";
Expand Down Expand Up @@ -406,27 +404,6 @@ export class V12 extends Service<"V12"> implements OneBot.Base {
data.message_type || data.notice_type || data.request_type || data.system_type;
data.message =
data.type === "message" ? this.adapter.toSegment("V12", data.message) : data.message;
if (data.source)
data.source = {
...data.source,
message_id:
data.detail_type === "private"
? genDmMessageId(
data.source.user_id,
data.source.seq,
data.source.rand,
data.source.time,
)
: genGroupMessageId(
data.group_id,
data.source.user_id,
data.source.seq,
data.source.rand,
data.source.time,
),
user_id: data.source.user_id,
message: data.source.message,
};
return V12.formatPayload(this.oneBot.uin, event, data as any);
}

Expand Down Expand Up @@ -479,7 +456,7 @@ export class V12 extends Service<"V12"> implements OneBot.Base {
}
transformMedia(segment: V12.Segment): V12.Segment {
const file = this.getFile(segment.data.file_id);
if (file)
if (file && file.data)
return {
type: segment.type,
data: {
Expand Down Expand Up @@ -867,18 +844,7 @@ export namespace V12 {
detail_type: "status_update";
status: ReturnType<Action["getStatus"]>;
};
} & TransformEventMap;
export type TransformEventMap = {
[P in keyof EventMap]: TransformEventParams<Parameters<EventMap[P]>>;
};
export type TransformEventParams<T extends any[]> = T extends [infer L, ...infer R]
? L extends object
? L & {
args: R;
}
: { args: [L, ...R] }
: { args: T };

export function success<T extends any>(
data: T,
retcode: Result<T>["retcode"] = 0,
Expand Down

0 comments on commit 8f0d0da

Please sign in to comment.