Add dtext to markdown for tickets and appeals
This commit is contained in:
Generated
+91
-2
@@ -5,12 +5,14 @@
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@clynamic/dmark": "^0.0.7",
|
||||
"@redis/client": "5.1.0",
|
||||
"body-parser": "2.2.2",
|
||||
"discord.js": "14.26.4",
|
||||
"dotenv": "16.5.0",
|
||||
"express": "5.1.0",
|
||||
"express-session": "1.19.0",
|
||||
"markdown-it": "14.2.0",
|
||||
"memorystore": "1.6.7",
|
||||
"sqlite": "5.1.1",
|
||||
"sqlite3": "6.0.1"
|
||||
@@ -27,6 +29,15 @@
|
||||
"typescript-eslint": "8.32.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@clynamic/dmark": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://npm.clynamic.net/%40clynamic%2Fdmark/-/0.0.7/dmark-0.0.7.tgz",
|
||||
"integrity": "sha512-sz/rf0kSUkprTVFO+3dQjHg+jxbtfcqmWIVcSvsYU7Uz6ywAAd5RI4igZ7bsBGrOfXcgyEKRE6/XjygYHKPjQA==",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"markdown-it": "^14.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/builders": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.14.1.tgz",
|
||||
@@ -1340,8 +1351,7 @@
|
||||
"node_modules/argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||
"dev": true
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
@@ -1777,6 +1787,18 @@
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/env-paths": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
|
||||
@@ -2656,6 +2678,25 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/linkify-it": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.1.tgz",
|
||||
"integrity": "sha512-wVoTjP4Q6R0NW5hiZkVJaFZPWgtXfoGF+6LucL3/FtiNjmcHhYjEr5f1Kqjirc1nBW07J/ZuRFumqr2oqccEWg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/markdown-it"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"uc.micro": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||
@@ -2694,6 +2735,33 @@
|
||||
"integrity": "sha512-afO2mnxW7GDTXMm5/AoN1WuOcdoKhtgXjIvHmobqTD1grNplhGdv3PFOyjCVmrnOZBIT/gD/koDKpYG+0mvHcg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/markdown-it": {
|
||||
"version": "14.2.0",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.2.0.tgz",
|
||||
"integrity": "sha512-1TGiQiJVRQ3NPmZH6sx5Cfnmg6GQm9jvC1ch4TK511NjSJvjzKLzn5pPfZRNZkRPZP0HqCioSndqH8v2nRaWVQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/puzrin"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/markdown-it"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1",
|
||||
"entities": "^4.4.0",
|
||||
"linkify-it": "^5.0.1",
|
||||
"mdurl": "^2.0.0",
|
||||
"punycode.js": "^2.3.1",
|
||||
"uc.micro": "^2.1.0"
|
||||
},
|
||||
"bin": {
|
||||
"markdown-it": "bin/markdown-it.mjs"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
@@ -2702,6 +2770,12 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/mdurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
|
||||
@@ -3207,6 +3281,15 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/punycode.js": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
||||
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.15.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
||||
@@ -4103,6 +4186,12 @@
|
||||
"typescript": ">=4.8.4 <5.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uc.micro": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
|
||||
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uid-safe": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
"typescript-eslint": "8.32.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clynamic/dmark": "^0.0.7",
|
||||
"@redis/client": "5.1.0",
|
||||
"body-parser": "2.2.2",
|
||||
"discord.js": "14.26.4",
|
||||
"dotenv": "16.5.0",
|
||||
"express": "5.1.0",
|
||||
"express-session": "1.19.0",
|
||||
"markdown-it": "14.2.0",
|
||||
"memorystore": "1.6.7",
|
||||
"sqlite": "5.1.1",
|
||||
"sqlite3": "6.0.1"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { formatMarkdown, parseDTextToAST } from '@clynamic/dmark';
|
||||
|
||||
export function dtextToMarkdown(dtext: string): string {
|
||||
return formatMarkdown(parseDTextToAST(dtext)).output;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { APIEmbedField, EmbedAuthorOptions } from 'discord.js';
|
||||
import { config } from '../config';
|
||||
import { getE621Post, PostAction, spoilerOrBlacklist } from './e621-utils';
|
||||
import { appealIDRegex, blipIDRegex, commentIDRegex, flagIDRegex, forumTopicIDRegex, poolIDRegex, postIDRegex, recordIDRegex, searchLinkRegex, setIDRegex, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from './message-matcher-regex';
|
||||
import { dtextToMarkdown } from './dtext-utils';
|
||||
|
||||
// TODO: Condense this and the message event handler regex array.
|
||||
const linkReplacers = [
|
||||
@@ -134,7 +135,7 @@ export async function getLinks(input: string, limit: number = Number.MAX_SAFE_IN
|
||||
}
|
||||
|
||||
export async function getDescription(data: { reason: string }): Promise<string> {
|
||||
return data.reason.length <= MAX_DESCRIPTION_LENGTH ? await getLinks(data.reason) : await getLinks(data.reason, MAX_DESCRIPTION_LENGTH);
|
||||
return dtextToMarkdown(data.reason.length <= MAX_DESCRIPTION_LENGTH ? await getLinks(data.reason) : await getLinks(data.reason, MAX_DESCRIPTION_LENGTH));
|
||||
}
|
||||
|
||||
export function getAuthor(data: { user_id: number, user: string }): EmbedAuthorOptions {
|
||||
|
||||
+3
-1
@@ -8,9 +8,11 @@ export * from './channel-utils';
|
||||
export * from './commands';
|
||||
export * from './debug-utils';
|
||||
export * from './discord-user-utils';
|
||||
export * from './embed-utils';
|
||||
export * from './dtext-utils';
|
||||
export * from './e621-utils';
|
||||
export * from './embed-utils';
|
||||
export * from './event-log-utils';
|
||||
export * from './event-utils';
|
||||
export * from './file-utils';
|
||||
export * from './github-user-utils';
|
||||
export * from './interaction-utils';
|
||||
|
||||
Reference in New Issue
Block a user