diff --git a/README.md b/README.md index adbc821d..8d880c36 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,21 @@ # oicq -[![npm version](https://img.shields.io/npm/v/oicq/beta.svg)](https://www.npmjs.com/package/oicq) +[![npm version](https://img.shields.io/npm/v/oicq/latest.svg)](https://www.npmjs.com/package/oicq) [![dm](https://shields.io/npm/dm/oicq)](https://www.npmjs.com/package/oicq) -[![node engine](https://img.shields.io/node/v/oicq/beta.svg)](https://nodejs.org) +[![node engine](https://img.shields.io/node/v/oicq/latest.svg)](https://nodejs.org) [![discord](https://img.shields.io/static/v1?label=chat&message=on%20discord&color=7289da&logo=discord)](https://discord.gg/gKnU7BARzv) * QQ(安卓)协议基于Node.js的实现,支持最低node版本为 v14 * 若你不熟悉Node.js或不会组织代码,可通过 [template](https://github.com/takayama-lily/oicq-template) 创建一个简单的应用程序 * [API Reference](#api-reference) / [Type Docs](https://takayama-lily.github.io/oicq/) -* [从v1.x升级](https://github.com/takayama-lily/oicq/projects/3#column-16638290) +* [从v1.x升级](https://github.com/takayama-lily/oicq/projects/3#column-16638290) (v1在master分支) ---- **Install:** -> 此分支(v2.0)暂时处于beta状态 - ```bash -> npm i oicq@beta # or > yarn add oicq@beta +> npm i oicq # or > yarn add oicq ``` **Usage:** @@ -28,12 +26,12 @@ const account = 147258369 const client = createClient(account) client.on("system.online", () => console.log("Logged in!")) -client.on("message", msg => { - console.log(msg) - msg.reply("hello world") +client.on("message", e => { + console.log(e) + e.reply("hello world", true) //true表示引用对方的消息 }) -client.on("system.login.qrcode", function (event) { +client.on("system.login.qrcode", function (e) { //扫码后按回车登录 process.stdin.once("data", () => { this.login() @@ -146,7 +144,7 @@ client.on("system.login.qrcode", function (event) { ### Class: Group -> 所有的`notice.group`和`message.group`事件中含有此实例 +> 所有的`notice.group`和`message.group`事件的上报数据中含有此实例 (`e.group`访问) |Method|Description| |-|-| @@ -212,7 +210,7 @@ client.on("system.login.qrcode", function (event) { ### Class: Friend > 继承 [User](#class-user) 的所有方法和属性 -> 所有的`notice.friend`和`message.private`事件中含有此实例 +> 所有的`notice.friend`和`message.private`事件中含有此实例 (`e.friend`访问) |Method|Description| |-|-| @@ -235,7 +233,7 @@ client.on("system.login.qrcode", function (event) { ### Class: Member > 继承 [User](#class-user) 的所有方法和属性 -> 所有的`message.group`事件中含有此实例 +> 所有的`message.group`事件中含有此实例 (`e.member`访问) |Method|Description| |-|-| diff --git a/lib/index.ts b/lib/index.ts index f9fd0299..e297d191 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -10,7 +10,7 @@ export { Message, PrivateMessage, GroupMessage, DiscussMessage, ForwardMessage, MusicPlatform, Sendable, Anonymous, MessageElem, FileElem, ReplyElem, TextElem, AtElem, FaceElem, BfaceElem, MfaceElem, ImageElem, MiraiElem, FlashElem, PttElem, VideoElem, XmlElem, JsonElem, ShareElem, LocationElem, PokeElem, - parseDmMessageId, parseGroupMessageId, parseImageFileParam, segment } from "./message" + parseDmMessageId, parseGroupMessageId, parseImageFileParam, getGroupImageUrl, segment } from "./message" export { PrivateMessageEvent, GroupMessageEvent, DiscussMessageEvent, MessageRet, MessageEvent, RequestEvent, FriendNoticeEvent, GroupNoticeEvent, FriendRequestEvent, GroupRequestEvent, GroupInviteEvent, EventMap, @@ -19,7 +19,3 @@ export { PrivateMessageEvent, GroupMessageEvent, DiscussMessageEvent, MessageRet GroupAdminEvent, GroupMuteEvent, GroupTransferEvent } from "./events" export { ApiRejection, Device, Apk, Platform, Domain } from "./core" export * as core from "./core" - -export function getGroupImageUrl(md5: string) { - return `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toUpperCase()}/0` -} diff --git a/lib/message/index.ts b/lib/message/index.ts index ed45da6c..c42c76a6 100644 --- a/lib/message/index.ts +++ b/lib/message/index.ts @@ -2,4 +2,5 @@ export * from "./message" export * from "./elements" export * from "./image" export * from "./converter" +export * from "./parser" export * from "./music" diff --git a/lib/message/parser.ts b/lib/message/parser.ts index e6ea83e5..5b93c029 100644 --- a/lib/message/parser.ts +++ b/lib/message/parser.ts @@ -314,7 +314,7 @@ export class Parser { elem = { type, file: buildImageFileParam(proto[13].toHex(), proto[25], proto[22], proto[23], proto[20]), - url: proto[16] ? `https://gchat.qpic.cn${proto[16]}` : `https://gchat.qpic.cn/gchatpic_new/0/0-0-${proto[13].toHex().toUpperCase()}/0`, + url: proto[16] ? `https://gchat.qpic.cn${proto[16]}` : getGroupImageUrl(proto[13].toHex()), } if (elem.type === "image") elem.asface = proto[34]?.[1] === 1 @@ -322,3 +322,7 @@ export class Parser { return elem } } + +export function getGroupImageUrl(md5: string) { + return `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toUpperCase()}/0` +} diff --git a/package.json b/package.json index 68f466f6..222a5506 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "oicq", - "version": "2.1.2-beta", - "upday": "2021/11/01", + "version": "2.1.3", + "upday": "2021/11/07", "description": "QQ protocol!", "main": "lib/index.js", "types": "lib/index.d.ts",