Skip to content

Commit

Permalink
fix: icqq => @icqqjs/icqq
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Feb 21, 2024
1 parent eff1c0d commit 0d4e455
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 22 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@icqqjs:registry=https://npm.pkg.github.com
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
## 全局安装(0.4.8以后不推荐)

### 1 安装依赖

- 注意:
```shell
npm install -g onebots
# 0.4.8以上版本需要安装icqq
npm install -g icqq
```

### 2 初始化配置文件
Expand All @@ -45,12 +43,30 @@ npm init -y

```shell
npm install onebots
npm install icqq # 如需使用icqq适配器,请务必安装
npm install @icqqjs/icqq # 如需使用icqq适配器,请务必安装
npm install lib-wechat # 如需使用微信适配器,请务必安装
npm install qq-group-bot # 如需使用qq官方机器人适配器,请务必安装
npm install node-dd-bot # 如需使用钉钉机器人适配器,请务必安装
```
- 关于@icqqjs的安装引导:

**安装:**
1. 在你的项目根目录新建文件 `.npmrc` ,并录入以下内容
```text
@icqqjs:registry=https://npm.pkg.github.com
```
2. 命令行输入 `npm login --scope=@icqqjs --auth-type=legacy --registry=https://npm.pkg.github.com` ,回车,根据提示登录github
```shell
npm login --scope=@icqqjs --auth-type=legacy --registry=https://npm.pkg.github.com

UserName: # 你的github账号
Password: # 前往 https://github.com/settings/tokens/new 获取,scopes勾选 read:packages
E-Mail: # 你的公开邮箱地址
```
3. 安装依赖
```shell
npm install @icqqjs/icqq # or > yarn add @icqqjs/icqq
```
## 3. 执行如下命令生成配置文件

```shell
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"/**/LICENSE"
],
"peerDependencies": {
"icqq": "latest",
"@icqqjs/icqq": "^1.0.2",
"lib-wechat": "latest",
"node-dd-bot": "latest",
"qq-group-bot": "latest"
Expand Down
16 changes: 8 additions & 8 deletions src/adapters/icqq/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Adapter } from "@/adapter";
import { App } from "@/server/app";
import { Client, Config as IcqqConfig, MessageElem, Quotable } from "icqq";
import { Client, Config as IcqqConfig, MessageElem, Quotable } from "@icqqjs/icqq";
import process from "process";
import { rmSync } from "fs";
import { OneBot, OneBotStatus } from "@/onebot";
import * as path from "path";
import { shareMusic } from "@/service/shareMusicCustom";
import { genDmMessageId, genGroupMessageId } from "icqq/lib/message";
import { genDmMessageId, genGroupMessageId } from "@icqqjs/icqq/lib/message";

async function processMessages(
this: IcqqAdapter,
Expand Down Expand Up @@ -368,12 +368,12 @@ export default class IcqqAdapter extends Adapter<"icqq"> {
return result;
}

materialize( content: string ): string {
materialize(content: string): string {
return content
.replace( /&(?!(amp|#91|#93|#44);)/g, "&amp;" )
.replace( /\[/g, "&#91;" )
.replace( /]/g, "&#93;" )
.replace( /,/g, "&#44;" )
.replace(/&(?!(amp|#91|#93|#44);)/g, "&amp;")
.replace(/\[/g, "&#91;")
.replace(/]/g, "&#93;")
.replace(/,/g, "&#44;");
}

toCqcode<V extends OneBot.Version>(version: V, messageArr: OneBot.MessageElement<V>[]): string {
Expand All @@ -384,7 +384,7 @@ export default class IcqqAdapter extends Adapter<"icqq"> {
if (item.type === "text") return item.data?.text || item.text;
let dataStr: string[];
if (typeof item.data === "string") {
dataStr = [`data=${ this.materialize(item.data) }`];
dataStr = [`data=${this.materialize(item.data)}`];
} else {
dataStr = Object.entries(item.data || item).map(([key, value]) => {
// is Buffer
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/icqq/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { remove } from "@/utils";
import { Client, MessageElem, ShareElem } from "icqq";
import { MusicElem } from "icqq/lib/message";
import { Client, MessageElem, ShareElem } from "@icqqjs/icqq";
import { MusicElem } from "@icqqjs/icqq/lib/message";

export async function processMessage(
this: Client,
Expand Down
2 changes: 1 addition & 1 deletion src/service/V11/action/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OneBotStatus } from "@/onebot";
import { V11 } from "@/service/V11";
import { Message } from "icqq";
import { Message } from "@icqqjs/icqq";
import { MsgEntry } from "@/service/V11/db_entities";

export class CommonAction {
Expand Down
4 changes: 2 additions & 2 deletions src/service/V12/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventMap } from "icqq";
import { EventMap } from "@icqqjs/icqq";
import { version } from "@/utils";
import { join } from "path";
import { Config } from "./config";
Expand All @@ -12,7 +12,7 @@ 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 "icqq/lib/message";
import { genDmMessageId, genGroupMessageId } from "@icqqjs/icqq/lib/message";
import { Service } from "@/service";
import { App } from "@/server/app";
import { Dict } from "@zhinjs/shared";
Expand Down
8 changes: 4 additions & 4 deletions src/service/shareMusicCustom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Contactable } from "icqq/lib/internal";
import { MusicElem, musicFactory } from "icqq/lib/message";
import { pb } from "icqq/lib/core";
import { Encodable } from "icqq/lib/core/protobuf";
import { Contactable } from "@icqqjs/icqq/lib/internal";
import { MusicElem, musicFactory } from "@icqqjs/icqq/lib/message";
import { pb } from "@icqqjs/icqq/lib/core";
import { Encodable } from "@icqqjs/icqq/lib/core/protobuf";
import { title } from "process";

/** 发送音乐分享(允许自定义参数) */
Expand Down

0 comments on commit 0d4e455

Please sign in to comment.