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