@satorijs/adapter-kook
Advanced tools
Comparing version 4.1.3 to 4.2.0
212
lib/index.js
@@ -38,2 +38,3 @@ var __create = Object.create; | ||
__export(src_exports, { | ||
Card: () => Card, | ||
GuildMute: () => GuildMute, | ||
@@ -69,2 +70,3 @@ HttpServer: () => HttpServer, | ||
__export(utils_exports, { | ||
Card: () => Card, | ||
GuildMute: () => GuildMute, | ||
@@ -109,2 +111,10 @@ Internal: () => Internal, | ||
})(Type || {}); | ||
var Card; | ||
((Card2) => { | ||
Card2.Theme = ["primary", "secondary", "warning", "danger", "info", "none", "success"]; | ||
let Button; | ||
((Button2) => { | ||
Button2.Theme = ["primary", "secondary", "warning", "danger", "info", "none", "success"]; | ||
})(Button = Card2.Button || (Card2.Button = {})); | ||
})(Card || (Card = {})); | ||
var UserStatus = /* @__PURE__ */ ((UserStatus2) => { | ||
@@ -296,3 +306,3 @@ UserStatus2[UserStatus2["normal"] = 0] = "normal"; | ||
function adaptMessageMeta(base, data, message = {}, payload = message) { | ||
var _a; | ||
var _a, _b, _c; | ||
if (base.type === 1 /* text */) { | ||
@@ -310,12 +320,40 @@ message.content = base.content.replace(/@(.+?)#(\d+)/, (_, name, id) => (0, import_satori.h)("at", { id, name }).toString()).replace(/@全体成员/, () => (0, import_satori.h)("at", { type: "all" }).toString()).replace(/@在线成员/, () => (0, import_satori.h)("at", { type: "here" }).toString()).replace(/@role:(\d+);/, (_, role) => (0, import_satori.h)("at", { role }).toString()).replace(/#channel:(\d+);/, (_, id) => import_satori.h.sharp(id).toString()); | ||
} else if (base.type === 9 /* kmarkdown */) { | ||
message.content = base.content.replace(/\(met\)all\(met\)/g, () => (0, import_satori.h)("at", { type: "all" }).toString()).replace(/\(met\)here\(met\)/g, () => (0, import_satori.h)("at", { type: "here" }).toString()).replace(/\(chn\)(\d+)\(chn\)/g, (_, id) => import_satori.h.sharp(id).toString()); | ||
for (const mention of data.kmarkdown.mention_part) { | ||
message.content = message.content.replace(`(met)${mention.id}(met)`, import_satori.h.at(mention.id, { name: mention.username }).toString()); | ||
let content = base.content; | ||
let buffer = ""; | ||
let cap; | ||
const elements = []; | ||
const flushText = /* @__PURE__ */ __name(() => { | ||
if (!buffer) | ||
return; | ||
elements.push(import_satori.h.text(buffer.replace(/\\(.)/g, (_, char) => char))); | ||
buffer = ""; | ||
}, "flushText"); | ||
while (content) { | ||
if (content.startsWith("\\") && content.length > 1) { | ||
buffer += content[1]; | ||
content = content.slice(2); | ||
} else if (cap = /^(\((met|chn|rol)\))(\w+)\1/.exec(content)) { | ||
content = content.slice(cap[0].length); | ||
flushText(); | ||
if (cap[2] === "met") { | ||
if (cap[3] === "all" || cap[3] === "here") { | ||
elements.push((0, import_satori.h)("at", { type: cap[3] })); | ||
} else { | ||
const name = (_b = data.kmarkdown.mention_part.find((mention) => mention.id === cap[3])) == null ? void 0 : _b.username; | ||
elements.push((0, import_satori.h)("at", { id: cap[3], name })); | ||
} | ||
} else if (cap[2] === "chn") { | ||
elements.push(import_satori.h.sharp(cap[3])); | ||
} else if (cap[2] === "rol") { | ||
const name = (_c = data.kmarkdown.mention_role_part.find((mention) => mention.role_id + "" === cap[3])) == null ? void 0 : _c.name; | ||
elements.push((0, import_satori.h)("at", { role: cap[3], name })); | ||
} | ||
} else { | ||
buffer += content[0]; | ||
content = content.slice(1); | ||
} | ||
} | ||
for (const mention of data.kmarkdown.mention_role_part) { | ||
const element = (0, import_satori.h)("at", { role: mention.role_id, name: mention.name }); | ||
message.content = message.content.replace(`(rol)${mention.role_id}(rol)`, element.toString()); | ||
} | ||
message.content = message.content.replace(/\\\*/g, () => "*").replace(/\\\\/g, () => "\\").replace(/\\\(/g, () => "(").replace(/\\\)/g, () => ")"); | ||
message.elements = import_satori.h.parse(message.content); | ||
flushText(); | ||
message.content = elements.join(""); | ||
message.elements = elements; | ||
} | ||
@@ -556,3 +594,3 @@ if (data.author) { | ||
constructor(ctx, bot) { | ||
super(); | ||
super(ctx); | ||
let { path } = bot.config; | ||
@@ -597,3 +635,2 @@ path = (0, import_satori3.sanitize)(path); | ||
var import_form_data = __toESM(require("form-data")); | ||
var attachmentTypes = ["image", "video", "audio", "file"]; | ||
function isDirectChannel(channelId) { | ||
@@ -608,3 +645,6 @@ return channelId.length > 30; | ||
textBuffer = ""; | ||
cardBuffer = []; | ||
cardBuffer = { | ||
type: "card", | ||
modules: [] | ||
}; | ||
async prepare() { | ||
@@ -660,62 +700,2 @@ if (isDirectChannel(this.session.channelId)) { | ||
} | ||
async _sendCard(chain, useMarkdown) { | ||
const type = useMarkdown ? "kmarkdown" : "plain-text"; | ||
let text = { type, content: "" }; | ||
let card = { type: "card", modules: [] }; | ||
const output = []; | ||
const flushText = /* @__PURE__ */ __name(() => { | ||
text.content = text.content.trim(); | ||
if (!text.content) | ||
return; | ||
card.modules.push({ type: "section", text }); | ||
text = { type, content: "" }; | ||
}, "flushText"); | ||
const flushCard = /* @__PURE__ */ __name(() => { | ||
flushText(); | ||
if (!card.modules.length) | ||
return; | ||
output.push(card); | ||
card = { type: "card", modules: [] }; | ||
}, "flushCard"); | ||
for (const element of chain) { | ||
const { type: type2, attrs } = element; | ||
if (type2 === "text") { | ||
text.content += attrs.content; | ||
} else if (type2 === "at") { | ||
if (attrs.id) { | ||
text.content += `@user#${attrs.id}`; | ||
} else if (attrs.type === "all") { | ||
text.content += "@全体成员"; | ||
} else if (attrs.type === "here") { | ||
text.content += "@在线成员"; | ||
} else if (attrs.role) { | ||
text.content += `@role:${attrs.role};`; | ||
} | ||
} else if (type2 === "sharp") { | ||
text.content += `#channel:${attrs.id};`; | ||
} else if (attachmentTypes.includes(type2)) { | ||
flushText(); | ||
await this.transformUrl(element); | ||
if (type2 === "image") { | ||
card.modules.push({ | ||
type: "image-group", | ||
elements: [{ | ||
type: "image", | ||
src: attrs.url | ||
}] | ||
}); | ||
} else { | ||
card.modules.push({ | ||
type: type2, | ||
src: attrs.url | ||
}); | ||
} | ||
} else if (type2 === "card") { | ||
flushCard(); | ||
output.push(JSON.parse(attrs.content)); | ||
} | ||
} | ||
flushCard(); | ||
await this.post(10 /* card */, JSON.stringify(output)); | ||
} | ||
flushText() { | ||
@@ -726,3 +706,3 @@ const content = this.textBuffer.trim(); | ||
this.textBuffer = ""; | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: "section", | ||
@@ -736,9 +716,9 @@ text: { | ||
async flush() { | ||
if (this.cardBuffer.length) { | ||
if (this.cardBuffer.modules.length) { | ||
this.flushText(); | ||
await this.post(10 /* card */, JSON.stringify([{ | ||
await this.post(10 /* card */, JSON.stringify([this.cardBuffer])); | ||
this.cardBuffer = { | ||
type: "card", | ||
modules: this.cardBuffer | ||
}])); | ||
this.cardBuffer = []; | ||
modules: [] | ||
}; | ||
} else { | ||
@@ -754,2 +734,3 @@ const content = this.textBuffer.trim(); | ||
async visit(element) { | ||
var _a; | ||
const { type, attrs, children } = element; | ||
@@ -808,31 +789,42 @@ if (type === "text") { | ||
this.textBuffer += `(chn)${attrs.id}(chn)`; | ||
} else if (["image", "video", "audio", "file"].includes(type)) { | ||
} else if (["video", "audio", "file", "kook:video", "kook:audio", "kook:file"].includes(type)) { | ||
this.flushText(); | ||
const url = await this.transformUrl(element); | ||
if (type === "image") { | ||
this.cardBuffer.push({ | ||
type: "container", | ||
elements: [{ | ||
type: "image", | ||
src: url | ||
}] | ||
this.cardBuffer.modules.push({ | ||
type: type.startsWith("kook:") ? type.slice(5) : type, | ||
src: await this.transformUrl(element), | ||
title: attrs.title | ||
}); | ||
} else if (type === "image" || type === "kook:image") { | ||
this.flushText(); | ||
this.cardBuffer.modules.push({ | ||
type: "container", | ||
elements: [{ | ||
type: "image", | ||
src: await this.transformUrl(element) | ||
}] | ||
}); | ||
} else if (type === "kook:image-group") { | ||
this.flushText(); | ||
const elements = await Promise.all(element.children.map(async (child) => ({ | ||
type: "image", | ||
src: await this.transformUrl(child), | ||
title: child.attrs.title | ||
}))); | ||
while (elements.length) { | ||
this.cardBuffer.modules.push({ | ||
type: "image-group", | ||
elements: elements.splice(0, 9) | ||
}); | ||
} else { | ||
this.cardBuffer.push({ | ||
type, | ||
src: url, | ||
title: attrs.title | ||
}); | ||
} | ||
} else if (type === "button") { | ||
} else if (type === "button" || type === "kook:button") { | ||
this.flushText(); | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: "action-group", | ||
elements: [encodeButton(element)] | ||
}); | ||
} else if (type === "button-group") { | ||
} else if (type === "button-group" || type === "kook:action-group") { | ||
this.flushText(); | ||
const elements = element.children.map(encodeButton); | ||
while (elements.length) { | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: "action-group", | ||
@@ -842,10 +834,19 @@ elements: elements.splice(0, 4) | ||
} | ||
} else if (type === "hr") { | ||
} else if (type === "hr" || type === "kook:divider") { | ||
this.flushText(); | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: "divider" | ||
}); | ||
} else if (type === "kook:header") { | ||
this.flushText(); | ||
this.cardBuffer.modules.push({ | ||
type: "header", | ||
text: { | ||
type: "plain-text", | ||
content: attrs.content | ||
} | ||
}); | ||
} else if (type === "kook:countdown") { | ||
this.flushText(); | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: "countdown", | ||
@@ -858,6 +859,12 @@ startTime: attrs.startTime, | ||
this.flushText(); | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: "invite", | ||
code: attrs.code | ||
}); | ||
} else if (type === "kook:card") { | ||
await this.flush(); | ||
this.cardBuffer.theme = (_a = attrs["kook:theme"]) != null ? _a : Card.Theme.includes(attrs.class) ? attrs.class : "primary"; | ||
this.cardBuffer.size = attrs["kook:size"]; | ||
await this.render(children); | ||
await this.flush(); | ||
} else if (type === "quote") { | ||
@@ -1070,2 +1077,3 @@ await this.flush(); | ||
0 && (module.exports = { | ||
Card, | ||
GuildMute, | ||
@@ -1072,0 +1080,0 @@ HttpServer, |
@@ -14,3 +14,2 @@ import { Context, h, MessageEncoder, Schema } from '@satorijs/satori'; | ||
private transformUrl; | ||
private _sendCard; | ||
flushText(): void; | ||
@@ -17,0 +16,0 @@ flush(): Promise<void>; |
@@ -110,7 +110,7 @@ import { Quester } from '@satorijs/satori'; | ||
size?: 'lg' | 'sm'; | ||
color?: string; | ||
modules: Card.Module[]; | ||
} | ||
export declare namespace Card { | ||
type Theme = 'primary' | 'secondary' | 'warning' | 'danger' | 'info' | 'none' | 'success'; | ||
const Theme: readonly ["primary", "secondary", "warning", "danger", "info", "none", "success"]; | ||
type Theme = typeof Theme[number]; | ||
type Module = Section | Container | ImageGroup | ActionGroup | Header | Divider | Invite | File | Countdown | Context; | ||
@@ -152,3 +152,4 @@ interface Text { | ||
namespace Button { | ||
type Theme = 'primary' | 'secondary' | 'warning' | 'danger' | 'info' | 'success'; | ||
const Theme: readonly ["primary", "secondary", "warning", "danger", "info", "none", "success"]; | ||
type Theme = typeof Theme[number]; | ||
} | ||
@@ -155,0 +156,0 @@ interface ImageGroup { |
{ | ||
"name": "@satorijs/adapter-kook", | ||
"description": "KOOK (开黑啦) Adapter for Satorijs", | ||
"version": "4.1.3", | ||
"version": "4.2.0", | ||
"main": "lib/index.js", | ||
@@ -35,3 +35,3 @@ "typings": "lib/index.d.ts", | ||
"peerDependencies": { | ||
"@satorijs/satori": "^3.1.2" | ||
"@satorijs/satori": "^3.1.5" | ||
}, | ||
@@ -38,0 +38,0 @@ "dependencies": { |
@@ -12,3 +12,3 @@ import { Adapter, Context, Logger, sanitize, Schema } from '@satorijs/satori' | ||
constructor(ctx: C, bot: KookBot<C>) { | ||
super() | ||
super(ctx) | ||
let { path } = bot.config as HttpServer.Config | ||
@@ -15,0 +15,0 @@ path = sanitize(path) |
@@ -7,4 +7,2 @@ import { Context, h, MessageEncoder, Schema } from '@satorijs/satori' | ||
const attachmentTypes = ['image', 'video', 'audio', 'file'] | ||
export function isDirectChannel(channelId: string) { | ||
@@ -19,3 +17,6 @@ return channelId.length > 30 | ||
private textBuffer: string = '' | ||
private cardBuffer: Kook.Card.Module[] = [] | ||
private cardBuffer: Kook.Card = { | ||
type: 'card', | ||
modules: [], | ||
} | ||
@@ -74,62 +75,2 @@ async prepare() { | ||
private async _sendCard(chain: h[], useMarkdown: boolean) { | ||
const type = useMarkdown ? 'kmarkdown' : 'plain-text' | ||
let text: Kook.Card.Text = { type, content: '' } | ||
let card: Kook.Card = { type: 'card', modules: [] } | ||
const output: Kook.Card[] = [] | ||
const flushText = () => { | ||
text.content = text.content.trim() | ||
if (!text.content) return | ||
card.modules.push({ type: 'section', text }) | ||
text = { type, content: '' } | ||
} | ||
const flushCard = () => { | ||
flushText() | ||
if (!card.modules.length) return | ||
output.push(card) | ||
card = { type: 'card', modules: [] } | ||
} | ||
for (const element of chain) { | ||
const { type, attrs } = element | ||
if (type === 'text') { | ||
text.content += attrs.content | ||
} else if (type === 'at') { | ||
if (attrs.id) { | ||
text.content += `@user#${attrs.id}` | ||
} else if (attrs.type === 'all') { | ||
text.content += '@全体成员' | ||
} else if (attrs.type === 'here') { | ||
text.content += '@在线成员' | ||
} else if (attrs.role) { | ||
text.content += `@role:${attrs.role};` | ||
} | ||
} else if (type === 'sharp') { | ||
text.content += `#channel:${attrs.id};` | ||
} else if (attachmentTypes.includes(type)) { | ||
flushText() | ||
await this.transformUrl(element) | ||
if (type === 'image') { | ||
card.modules.push({ | ||
type: 'image-group', | ||
elements: [{ | ||
type: 'image', | ||
src: attrs.url, | ||
}], | ||
}) | ||
} else { | ||
card.modules.push({ | ||
type: type as never, | ||
src: attrs.url, | ||
}) | ||
} | ||
} else if (type === 'card') { | ||
flushCard() | ||
output.push(JSON.parse(attrs.content)) | ||
} | ||
} | ||
flushCard() | ||
await this.post(Kook.Type.card, JSON.stringify(output)) | ||
} | ||
flushText() { | ||
@@ -139,3 +80,3 @@ const content = this.textBuffer.trim() | ||
this.textBuffer = '' | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: 'section', | ||
@@ -150,9 +91,9 @@ text: { | ||
async flush() { | ||
if (this.cardBuffer.length) { | ||
if (this.cardBuffer.modules.length) { | ||
this.flushText() | ||
await this.post(Kook.Type.card, JSON.stringify([{ | ||
await this.post(Kook.Type.card, JSON.stringify([this.cardBuffer])) | ||
this.cardBuffer = { | ||
type: 'card', | ||
modules: this.cardBuffer, | ||
}])) | ||
this.cardBuffer = [] | ||
modules: [], | ||
} | ||
} else { | ||
@@ -220,31 +161,42 @@ const content = this.textBuffer.trim() | ||
this.textBuffer += `(chn)${attrs.id}(chn)` | ||
} else if (['image', 'video', 'audio', 'file'].includes(type)) { | ||
} else if (['video', 'audio', 'file', 'kook:video', 'kook:audio', 'kook:file'].includes(type)) { | ||
this.flushText() | ||
const url = await this.transformUrl(element) | ||
if (type === 'image') { | ||
this.cardBuffer.push({ | ||
type: 'container', | ||
elements: [{ | ||
type: 'image', | ||
src: url, | ||
}], | ||
this.cardBuffer.modules.push({ | ||
type: (type.startsWith('kook:') ? type.slice(5) : type) as never, | ||
src: await this.transformUrl(element), | ||
title: attrs.title, | ||
}) | ||
} else if (type === 'image' || type === 'kook:image') { | ||
this.flushText() | ||
this.cardBuffer.modules.push({ | ||
type: 'container', | ||
elements: [{ | ||
type: 'image', | ||
src: await this.transformUrl(element), | ||
}], | ||
}) | ||
} else if (type === 'kook:image-group') { | ||
this.flushText() | ||
const elements = await Promise.all(element.children.map<Promise<Kook.Card.Image>>(async (child: h) => ({ | ||
type: 'image', | ||
src: await this.transformUrl(child), | ||
title: child.attrs.title, | ||
}))) | ||
while (elements.length) { | ||
this.cardBuffer.modules.push({ | ||
type: 'image-group', | ||
elements: elements.splice(0, 9), | ||
}) | ||
} else { | ||
this.cardBuffer.push({ | ||
type: type as never, | ||
src: url, | ||
title: attrs.title, | ||
}) | ||
} | ||
} else if (type === 'button') { | ||
} else if (type === 'button' || type === 'kook:button') { | ||
this.flushText() | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: 'action-group', | ||
elements: [encodeButton(element)], | ||
}) | ||
} else if (type === 'button-group') { | ||
} else if (type === 'button-group' || type === 'kook:action-group') { | ||
this.flushText() | ||
const elements = element.children.map(encodeButton) | ||
while (elements.length) { | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: 'action-group', | ||
@@ -254,10 +206,19 @@ elements: elements.splice(0, 4), | ||
} | ||
} else if (type === 'hr') { | ||
} else if (type === 'hr' || type === 'kook:divider') { | ||
this.flushText() | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: 'divider', | ||
}) | ||
} else if (type === 'kook:header') { | ||
this.flushText() | ||
this.cardBuffer.modules.push({ | ||
type: 'header', | ||
text: { | ||
type: 'plain-text', | ||
content: attrs.content, | ||
}, | ||
}) | ||
} else if (type === 'kook:countdown') { | ||
this.flushText() | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: 'countdown', | ||
@@ -270,6 +231,12 @@ startTime: attrs.startTime, | ||
this.flushText() | ||
this.cardBuffer.push({ | ||
this.cardBuffer.modules.push({ | ||
type: 'invite', | ||
code: attrs.code, | ||
}) | ||
} else if (type === 'kook:card') { | ||
await this.flush() | ||
this.cardBuffer.theme = attrs['kook:theme'] ?? (Kook.Card.Theme.includes(attrs.class) ? attrs.class : 'primary') | ||
this.cardBuffer.size = attrs['kook:size'] | ||
await this.render(children) | ||
await this.flush() | ||
} else if (type === 'quote') { | ||
@@ -276,0 +243,0 @@ await this.flush() |
@@ -142,3 +142,2 @@ /* eslint-disable max-len */ | ||
size?: 'lg' | 'sm' | ||
color?: string | ||
modules: Card.Module[] | ||
@@ -148,3 +147,4 @@ } | ||
export namespace Card { | ||
export type Theme = 'primary' | 'secondary' | 'warning' | 'danger' | 'info' | 'none' | 'success' | ||
export const Theme = ['primary', 'secondary', 'warning', 'danger', 'info', 'none', 'success'] as const | ||
export type Theme = typeof Theme[number] | ||
export type Module = Section | Container | ImageGroup | ActionGroup | Header | Divider | Invite | File | Countdown | Context | ||
@@ -193,3 +193,4 @@ | ||
export namespace Button { | ||
export type Theme = 'primary' | 'secondary' | 'warning' | 'danger' | 'info' | 'success' | ||
export const Theme = ['primary', 'secondary', 'warning', 'danger', 'info', 'none', 'success'] as const | ||
export type Theme = typeof Theme[number] | ||
} | ||
@@ -196,0 +197,0 @@ |
@@ -75,20 +75,41 @@ import { Context, h, isNullable, Session, Universal } from '@satorijs/satori' | ||
} else if (base.type === Kook.Type.kmarkdown) { | ||
message.content = base.content | ||
.replace(/\(met\)all\(met\)/g, () => h('at', { type: 'all' }).toString()) | ||
.replace(/\(met\)here\(met\)/g, () => h('at', { type: 'here' }).toString()) | ||
.replace(/\(chn\)(\d+)\(chn\)/g, (_, id) => h.sharp(id).toString()) | ||
for (const mention of data.kmarkdown.mention_part) { | ||
message.content = message.content | ||
.replace(`(met)${mention.id}(met)`, h.at(mention.id, { name: mention.username }).toString()) | ||
let content = base.content | ||
let buffer = '' | ||
let cap: RegExpExecArray | ||
const elements: h[] = [] | ||
const flushText = () => { | ||
if (!buffer) return | ||
// https://github.com/koishijs/koishi/issues/1050 | ||
// https://github.com/koishijs/koishi/issues/1227 | ||
elements.push(h.text(buffer.replace(/\\(.)/g, (_, char) => char))) | ||
buffer = '' | ||
} | ||
for (const mention of data.kmarkdown.mention_role_part) { | ||
const element = h('at', { role: mention.role_id, name: mention.name }) | ||
message.content = message.content.replace(`(rol)${mention.role_id}(rol)`, element.toString()) | ||
while (content) { | ||
if (content.startsWith('\\') && content.length > 1) { | ||
buffer += content[1] | ||
content = content.slice(2) | ||
} else if ((cap = /^(\((met|chn|rol)\))(\w+)\1/.exec(content))) { | ||
content = content.slice(cap[0].length) | ||
flushText() | ||
if (cap[2] === 'met') { | ||
if (cap[3] === 'all' || cap[3] === 'here') { | ||
elements.push(h('at', { type: cap[3] })) | ||
} else { | ||
const name = data.kmarkdown.mention_part.find(mention => mention.id === cap[3])?.username | ||
elements.push(h('at', { id: cap[3], name })) | ||
} | ||
} else if (cap[2] === 'chn') { | ||
elements.push(h.sharp(cap[3])) | ||
} else if (cap[2] === 'rol') { | ||
const name = data.kmarkdown.mention_role_part.find(mention => mention.role_id + '' === cap[3])?.name | ||
elements.push(h('at', { role: cap[3], name })) | ||
} | ||
} else { | ||
buffer += content[0] | ||
content = content.slice(1) | ||
} | ||
} | ||
message.content = message.content | ||
.replace(/\\\*/g, () => '*') | ||
.replace(/\\\\/g, () => '\\') | ||
.replace(/\\\(/g, () => '(') | ||
.replace(/\\\)/g, () => ')') | ||
message.elements = h.parse(message.content) | ||
flushText() | ||
message.content = elements.join('') | ||
message.elements = elements | ||
} | ||
@@ -95,0 +116,0 @@ if (data.author) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150353
3512