import type { proto } from "@whiskeysockets/baileys"; import { describe, expect, it } from "vitest"; import { extractMentionedJids } from "./extract.js";
it("returns direct mentions from the current message", () => { const message: proto.IMessage = {
extendedTextMessage: {
text: "Hey @bot",
contextInfo: {
mentionedJid: [botJid],
},
},
};
expect(extractMentionedJids(message)).toEqual([botJid]);
});
it("ignores mentionedJids from quoted messages", () => { const message: proto.IMessage = {
extendedTextMessage: {
text: "I agree",
contextInfo: { // The quoted message originally @mentioned the bot, but the // current message does not — this should NOT leak through.
quotedMessage: {
extendedTextMessage: {
text: "Hey @bot what do you think?",
contextInfo: {
mentionedJid: [botJid],
},
},
},
},
},
};
expect(extractMentionedJids(message)).toBeUndefined();
});
it("returns direct mentions even when quoted message also has mentions", () => { const message: proto.IMessage = {
extendedTextMessage: {
text: "Hey @other",
contextInfo: {
mentionedJid: [otherJid],
quotedMessage: {
extendedTextMessage: {
text: "Hey @bot",
contextInfo: {
mentionedJid: [botJid],
},
},
},
},
},
}; // Should return only the direct mention, not the quoted one.
expect(extractMentionedJids(message)).toEqual([otherJid]);
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.