decord/source/modules/messages/renderMessageMarkup.tsx

165 lines
7.5 KiB
TypeScript
Raw Normal View History

2026-08-27 16:17:25 +00:00
// Module ID: 7564
// Function ID: 7565
2026-07-29 08:29:29 +00:00
// Name: getInitialParserState
2026-08-27 16:17:25 +00:00
// Dependencies: [7565, 4435, 2]
2026-07-29 08:29:29 +00:00
// Exports: default, getInitialParserStateFromMessage, renderAutomodMessageMarkup, renderAutomodMessageMarkupToAST, renderMessageContentMarkup, renderMessageMarkupToAST, renderMessageMarkupWithParser
2026-07-20 16:05:17 +00:00
2026-08-27 16:17:25 +00:00
// Module 7564 (getInitialParserState)
2026-08-24 06:08:38 +00:00
import set from "set" /* 2 */;
2026-08-27 16:17:25 +00:00
import get_defaultRulesDefault from "get defaultRules" /* 4435 */;
2026-08-24 06:08:38 +00:00
2026-07-29 08:29:29 +00:00
function getInitialParserState(channelId) {
const renderOptions = channelId.renderOptions;
2026-08-06 08:05:19 +00:00
return { channelId: channelId.channelId, messageId: channelId.messageId, authorId: channelId.authorId, allowLinks: Boolean(renderOptions.allowLinks), allowDevLinks: Boolean(renderOptions.allowDevLinks), allowGameMentions: Boolean(renderOptions.allowGameMentions), allowTimeMentionInput: Boolean(renderOptions.allowTimeMentionInput), formatInline: Boolean(renderOptions.formatInline), noStyleAndInteraction: Boolean(renderOptions.noStyleAndInteraction), allowHeading: Boolean(renderOptions.allowHeading), allowList: Boolean(renderOptions.allowList), previewLinkTarget: Boolean(renderOptions.previewLinkTarget), disableAnimatedEmoji: Boolean(renderOptions.disableAnimatedEmoji), allowEmojiLinks: false, disableAutoBlockNewlines: true, mentionChannels: [], soundboardSounds: [], muted: false, unknownUserMentionPlaceholder: true, viewingChannelId: renderOptions.viewingChannelId, forceWhite: Boolean(renderOptions.forceWhite), textColor: renderOptions.textColor, disablePressableChannelMention: Boolean(renderOptions.disablePressableChannelMention) };
2026-07-29 08:29:29 +00:00
}
function render(arg0, channelId, toAST) {
2026-08-24 06:08:38 +00:00
closure_0 = channelId;
2026-07-29 08:29:29 +00:00
toAST = toAST.toAST;
2026-08-24 06:08:38 +00:00
closure_1 = undefined !== toAST && toAST;
2026-07-29 08:29:29 +00:00
const hideSimpleEmbedContent = toAST.hideSimpleEmbedContent;
2026-08-24 06:08:38 +00:00
closure_2 = undefined === hideSimpleEmbedContent || hideSimpleEmbedContent;
2026-07-29 08:29:29 +00:00
const formatInline = toAST.formatInline;
2026-08-24 06:08:38 +00:00
closure_3 = undefined !== formatInline && formatInline;
2026-07-29 08:29:29 +00:00
({ postProcessor: render, contentMessage } = toAST);
2026-08-24 06:08:38 +00:00
c6 = false;
c7 = false;
2026-07-29 08:29:29 +00:00
if (contentMessage == null) {
contentMessage = channelId;
}
const content = contentMessage.content;
let obj = { channelId: channelId.channel_id, messageId: channelId.id, authorId: null, renderOptions: null };
const author = channelId.author;
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (author != null) {
2026-07-20 16:05:17 +00:00
id = author.id;
}
2026-07-29 08:29:29 +00:00
obj[2] = id;
obj[3] = toAST;
const tmpResult = closure_3(obj);
2026-07-20 16:05:17 +00:00
obj = {};
const merged = Object.assign(tmpResult);
let allowLinks = tmp4;
2026-07-29 08:29:29 +00:00
if (null == channelId.webhookId) {
2026-07-20 16:05:17 +00:00
allowLinks = tmpResult.allowLinks;
}
2026-07-29 08:29:29 +00:00
obj.allowLinks = allowLinks;
obj.allowEmojiLinks = null != channelId.webhookId;
2026-08-06 08:05:19 +00:00
({ mentionChannels: obj2.mentionChannels, soundboardSounds } = channelId);
2026-07-29 08:29:29 +00:00
if (soundboardSounds == null) {
2026-07-20 16:05:17 +00:00
soundboardSounds = [];
}
2026-07-29 08:29:29 +00:00
obj.soundboardSounds = soundboardSounds;
obj = {
2026-07-23 10:11:24 +00:00
hasSpoilerEmbeds: c6,
hasBailedAst: c7,
2026-07-29 08:29:29 +00:00
content: arg0(content, true, obj, (ast, inline) => {
let flag = arg2;
if (arg2 == null) {
flag = false;
}
let obj = channelId(table[0]);
obj = { ast, inline, hasBailedAst: flag, message: channelId, contentMessage, messageContent: content, hideSimpleEmbedContent: table, formatInline: closure_3, toAST: closure_1 };
2026-07-20 16:05:17 +00:00
const result = obj.runMessageMarkupPostProcessors(obj);
2026-07-23 10:11:24 +00:00
({ ast, hasSpoilerEmbeds: c6 } = result);
2026-07-20 16:05:17 +00:00
let tmp2 = ast;
2026-07-29 08:29:29 +00:00
if (null != callback) {
tmp2 = callback(ast, inline);
2026-07-20 16:05:17 +00:00
}
return tmp2;
})
};
2026-07-29 08:29:29 +00:00
return obj;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let result = set.fileFinishedImporting("modules/messages/renderMessageMarkup.tsx");
2026-07-20 16:05:17 +00:00
export default function renderMessageMarkup(arg0) {
let obj = arg1;
if (arg1 === undefined) {
obj = {};
}
2026-08-24 06:08:38 +00:00
const tmp2 = get_defaultRulesDefault;
2026-07-20 16:05:17 +00:00
return render(obj.formatInline ? tmp2.parseInlineReply : tmp2.parse, arg0, obj);
};
2026-07-29 08:29:29 +00:00
export const getInitialParserStateFromMessage = function getInitialParserStateFromMessage(message, closure_7) {
let obj = { channelId: message.channel_id, messageId: message.id, authorId: null, renderOptions: null };
const author = message.author;
let id;
if (author != null) {
id = author.id;
}
obj[2] = id;
obj[3] = closure_7;
const tmpResult = getInitialParserState(obj);
obj = {};
const merged = Object.assign(tmpResult);
let allowLinks = tmp4;
if (null == message.webhookId) {
allowLinks = tmpResult.allowLinks;
}
obj.allowLinks = allowLinks;
obj.allowEmojiLinks = null != message.webhookId;
2026-08-06 08:05:19 +00:00
({ mentionChannels: obj2.mentionChannels, soundboardSounds } = message);
2026-07-29 08:29:29 +00:00
if (soundboardSounds == null) {
soundboardSounds = [];
}
obj.soundboardSounds = soundboardSounds;
return obj;
};
2026-07-20 16:05:17 +00:00
export { getInitialParserState };
2026-07-29 08:29:29 +00:00
export const renderMessageMarkupWithParser = function renderMessageMarkupWithParser(NativeSearchResultLinkPreviewParser, arg1, arg2) {
2026-07-20 16:05:17 +00:00
let obj = arg2;
if (arg2 === undefined) {
obj = {};
}
2026-07-29 08:29:29 +00:00
return render(NativeSearchResultLinkPreviewParser, arg1, obj);
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
export const renderMessageMarkupToAST = function renderMessageMarkupToAST(message, result) {
let obj = result;
if (result === undefined) {
2026-07-20 16:05:17 +00:00
obj = {};
}
2026-08-24 06:08:38 +00:00
const tmp2 = get_defaultRulesDefault;
2026-07-20 16:05:17 +00:00
obj = {};
const merged = Object.assign(obj);
2026-07-29 08:29:29 +00:00
obj.toAST = true;
2026-07-20 16:05:17 +00:00
return render(obj.formatInline ? tmp2.parseInlineReplyToAST : tmp2.parseToAST, message, obj);
};
2026-08-06 08:05:19 +00:00
export const renderMessageContentMarkup = function renderMessageContentMarkup(notifCenterV2MessagePreviewParser, guildId, arg2) {
2026-08-03 11:20:01 +00:00
let obj = arg2;
if (arg2 === undefined) {
obj = {};
}
if (obj === undefined) {
obj = {};
}
2026-08-06 08:05:19 +00:00
obj = { allowLinks: false, allowDevLinks: false, allowEmojiLinks: false, allowGameMentions: false, mentionChannels: [], soundboardSounds: [], formatInline: true, noStyleAndInteraction: false, allowHeading: false, allowList: false, disableAutoBlockNewlines: true, previewLinkTarget: false, disableAnimatedEmoji: true, guildId: guildId.guildId, channelId: guildId.channelId, messageId: guildId.messageId, authorId: guildId.authorId, muted: false, disablePressableChannelMention: true, textColor: obj.textColor };
return notifCenterV2MessagePreviewParser(guildId.content, true, obj, (arg0) => {
2026-07-29 08:29:29 +00:00
let tmp = arg0;
if (!Array.isArray(arg0)) {
const items = [arg0];
tmp = items;
}
return tmp;
});
2026-07-20 16:05:17 +00:00
};
2026-08-06 08:05:19 +00:00
export const renderAutomodMessageMarkup = function renderAutomodMessageMarkup(arg0, highlightWord, channelId) {
2026-08-24 06:08:38 +00:00
return get_defaultRulesDefault.parseAutoModerationSystemMessage(arg0, true, { allowLinks: false, allowDevLinks: false, allowEmojiLinks: false, allowGameMentions: false, mentionChannels: [], soundboardSounds: [], formatInline: false, noStyleAndInteraction: false, allowHeading: false, allowList: false, disableAutoBlockNewlines: true, highlightWord, disableAnimatedEmoji: false, channelId, muted: false }, (arg0) => {
2026-07-29 08:29:29 +00:00
let tmp = arg0;
if (!Array.isArray(arg0)) {
const items = [arg0];
tmp = items;
}
return tmp;
});
2026-07-20 16:05:17 +00:00
};
2026-08-06 08:05:19 +00:00
export const renderAutomodMessageMarkupToAST = function renderAutomodMessageMarkupToAST(arg0, highlightWord, channelId) {
2026-08-24 06:08:38 +00:00
return get_defaultRulesDefault.parseAutoModerationSystemMessageToAST(arg0, true, { allowLinks: false, allowDevLinks: false, allowEmojiLinks: false, allowGameMentions: false, mentionChannels: [], soundboardSounds: [], formatInline: false, noStyleAndInteraction: false, allowHeading: false, allowList: false, disableAutoBlockNewlines: true, highlightWord, disableAnimatedEmoji: false, channelId, muted: false }, (arg0) => {
2026-07-29 08:29:29 +00:00
let tmp = arg0;
if (!Array.isArray(arg0)) {
const items = [arg0];
tmp = items;
}
return tmp;
});
2026-07-20 16:05:17 +00:00
};