Fix FakeNitro Stickers (#1048)
This commit is contained in:
parent
bd95a25f4c
commit
474932161f
|
@ -63,9 +63,23 @@ export interface Upload {
|
||||||
uniqueId: string;
|
uniqueId: string;
|
||||||
uploadedFilename: string;
|
uploadedFilename: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MessageReplyOptions {
|
||||||
|
messageReference: Message["messageReference"];
|
||||||
|
allowedMentions?: {
|
||||||
|
parse: Array<string>;
|
||||||
|
repliedUser: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export interface MessageExtra {
|
export interface MessageExtra {
|
||||||
stickerIds?: string[];
|
stickers?: string[];
|
||||||
uploads?: Upload[];
|
uploads?: Upload[];
|
||||||
|
replyOptions: MessageReplyOptions;
|
||||||
|
content: string;
|
||||||
|
channel: Channel;
|
||||||
|
type?: any;
|
||||||
|
openWarningPopout: (props: any) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => Promisable<void | { cancel: boolean; }>;
|
export type SendListener = (channelId: string, messageObj: MessageObject, extra: MessageExtra) => Promisable<void | { cancel: boolean; }>;
|
||||||
|
@ -74,8 +88,8 @@ export type EditListener = (channelId: string, messageId: string, messageObj: Me
|
||||||
const sendListeners = new Set<SendListener>();
|
const sendListeners = new Set<SendListener>();
|
||||||
const editListeners = new Set<EditListener>();
|
const editListeners = new Set<EditListener>();
|
||||||
|
|
||||||
export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra, uploads: Upload[]) {
|
export async function _handlePreSend(channelId: string, messageObj: MessageObject, extra: MessageExtra, replyOptions: MessageReplyOptions) {
|
||||||
extra.uploads = uploads;
|
extra.replyOptions = replyOptions;
|
||||||
for (const listener of sendListeners) {
|
for (const listener of sendListeners) {
|
||||||
try {
|
try {
|
||||||
const result = await listener(channelId, messageObj, extra);
|
const result = await listener(channelId, messageObj, extra);
|
||||||
|
|
|
@ -36,10 +36,14 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: ".handleSendMessage=",
|
find: ".handleSendMessage=",
|
||||||
replacement: {
|
replacement: {
|
||||||
// checkIsMessageValid().then((function (isValidData) { ... getSendMessageOptionsForReply(data); ... sendMessage(channel.id, msg, void 0, mergeMessageSendOptions(...))
|
// props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply);
|
||||||
match: /(?<=uploads:(\i),channel:\i\}\)\.then\(\()function\((\i)\)\{(var \i=\i\.valid.+?\.getSendMessageOptionsForReply\(\i\);)(?=.+?\.sendMessage\((\i)\.id,(\i),void 0,(\i\(.+?)\):)/,
|
// Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid)
|
||||||
// checkIsMessageValid().then((async function (isValidData) { ...; if (await handlePresend(channel.id, msg, extra)) return; ...
|
match: /(props\.chatInputType.+?\.then\(\()(function.+?var (\i)=\i\.\i\.parse\((\i),.+?var (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/,
|
||||||
replace: "async function($2){$3 if (await Vencord.Api.MessageEvents._handlePreSend($4.id,$5,$6,$1)) return {shouldClear:true,shouldRefocus:true};"
|
// props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true };
|
||||||
|
replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" +
|
||||||
|
`${rest1}async ${rest2}` +
|
||||||
|
`if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` +
|
||||||
|
"return{shoudClear:true,shouldRefocus:true};"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -641,7 +641,7 @@ export default definePlugin({
|
||||||
if (!settings.enableStickerBypass)
|
if (!settings.enableStickerBypass)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
const sticker = StickerStore.getStickerById(extra?.stickerIds?.[0]!);
|
const sticker = StickerStore.getStickerById(extra.stickers?.[0]!);
|
||||||
if (!sticker)
|
if (!sticker)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ export default definePlugin({
|
||||||
link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`;
|
link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete extra.stickerIds;
|
extra.stickers!.length = 0;
|
||||||
messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`;
|
messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ function TypingIndicator({ channelId }: { channelId: string; }) {
|
||||||
if (isChannelMuted) return null;
|
if (isChannelMuted) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const myId = UserStore.getCurrentUser().id;
|
const myId = UserStore.getCurrentUser()?.id;
|
||||||
|
|
||||||
const typingUsersArray = Object.keys(typingUsers).filter(id => id !== myId && !(RelationshipStore.isBlocked(id) && !settings.store.includeBlockedUsers));
|
const typingUsersArray = Object.keys(typingUsers).filter(id => id !== myId && !(RelationshipStore.isBlocked(id) && !settings.store.includeBlockedUsers));
|
||||||
let tooltipText: string;
|
let tooltipText: string;
|
||||||
|
|
Loading…
Reference in a new issue