Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

超级表情 #515

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions lib/message/converter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { deflateSync } from "zlib"
import { FACE_OLD_BUF, facemap } from "./face"
import { Image } from "./image"
import { AtElem, BfaceElem, Quotable, MessageElem, TextElem,
import {
AtElem, BfaceElem, Quotable, MessageElem, TextElem,
FaceElem, FlashElem, ImageElem, JsonElem, LocationElem, MfaceElem, ReplyElem,
MiraiElem, PokeElem, PttElem, Sendable, ShareElem, VideoElem, XmlElem, FileElem } from "./elements"
MiraiElem, PokeElem, PttElem, Sendable, ShareElem, VideoElem, XmlElem, FileElem, LottieElem
} from "./elements"
import { pb } from "../core"
import { escapeXml } from "../common"
import { Anonymous, rand2uuid, parseDmMessageId, parseGroupMessageId } from "./message"
Expand Down Expand Up @@ -101,7 +103,7 @@ export class Converter {
// 频道中的AT
this.elems.push({
1: {
1: text || (id === "all" ? "@全体成员" : ("@"+id)),
1: text || (id === "all" ? "@全体成员" : ("@" + id)),
12: {
3: 2,
5: id === "all" ? 0 : BigInt(id)
Expand Down Expand Up @@ -130,6 +132,37 @@ export class Converter {
this._text(display, attr6)
}

private lottie(elem: LottieElem) {
let { id, text } = elem;
if (!text)
text = "超级表情" + id;
id = Number(id);
this.elems.push({
53: {
1: 37,
2: {
1: "1",
2: "19",
3: id,
4: 1,
5: 1,
6: "",
7: text,
8: "",
9: 1
},
3: 1
}
});
this.elems.push({
1: {
1: text,
12: {
1: "[" + text.replace("/", "") + "]你需要升级一下QQ啦~"
}
}
});
}
private face(elem: FaceElem) {
let { id, text } = elem
id = Number(id)
Expand Down Expand Up @@ -257,9 +290,11 @@ export class Converter {
throw new Error("非法的视频元素: " + file)
const buf = Buffer.from(file.replace("protobuf://", ""), "base64")
this.elems.push({ 19: buf })
this.elems.push({ 1: {
1: "你的QQ暂不支持查看视频短片,请期待后续版本。"
} })
this.elems.push({
1: {
1: "你的QQ暂不支持查看视频短片,请期待后续版本。"
}
})
this.brief += "[视频]"
this.is_chain = false
}
Expand Down Expand Up @@ -444,7 +479,7 @@ export class Converter {
quote(source: Quotable) {
const elems = new Converter(source.message || "", this.ext).elems
const tmp = this.brief
if(!this.ext?.dm){
if (!this.ext?.dm) {
this.at({ type: "at", qq: source.user_id })
this.elems.unshift(this.elems.pop()!)
}
Expand Down
16 changes: 14 additions & 2 deletions lib/message/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export interface FaceElem {
text?: string
}

/** 超级表情 */
export interface LottieElem{
type: "lottie"
id: number
text?: string
}

/** 原创表情 */
export interface BfaceElem {
type: "bface"
Expand Down Expand Up @@ -181,7 +188,7 @@ export type ChainElem = TextElem | FaceElem | BfaceElem | MfaceElem | ImageElem

/** 注意:只有`ChainElem`中的元素可以组合发送,其他元素只能单独发送 */
export type MessageElem = TextElem | FaceElem | BfaceElem | MfaceElem | ImageElem | AtElem | MiraiElem | ReplyElem |
FlashElem | PttElem | VideoElem | JsonElem | XmlElem | PokeElem | LocationElem | ShareElem | FileElem
FlashElem | PttElem | VideoElem | JsonElem | XmlElem | PokeElem | LocationElem | ShareElem | FileElem | LottieElem;

/** 可通过sendMsg发送的类型集合 (字符串、元素对象,或它们的数组) */
export type Sendable = string | MessageElem | (string | MessageElem)[]
Expand All @@ -206,6 +213,11 @@ export const segment = {
type: "sface", id, text
}
},
lottie(id: number, text?: string | undefined): LottieElem{
return {
type: "lottie", id, text
}
},
/** 原创表情(file规则不明) */
bface(file: string, text: string): BfaceElem {
return {
Expand Down Expand Up @@ -334,7 +346,7 @@ function unescapeCQInside(s: string) {
return ""
}
function qs(s: string, sep = ",", equal = "=") {
const ret: any = { }
const ret: any = {}
const split = s.split(sep)
for (let v of split) {
const i = v.indexOf(equal)
Expand Down
Loading