_cmdWithMedia.js 965 B

1234567891011121314151617181920212223242526
  1. const { proto, generateWAMessage, areJidsSameUser } = (await import('@whiskeysockets/baileys')).default
  2. export async function all(m, chatUpdate) {
  3. if (m.isBaileys) return;
  4. if (!m.message) return;
  5. if (!m.msg.fileSha256) return;
  6. if (!(Buffer.from(m.msg.fileSha256).toString('base64') in global.db.data.sticker)) return;
  7. const hash = global.db.data.sticker[Buffer.from(m.msg.fileSha256).toString('base64')];
  8. const {text, mentionedJid} = hash;
  9. const messages = await generateWAMessage(m.chat, {text: text, mentions: mentionedJid}, {
  10. userJid: this.user.id,
  11. quoted: m.quoted && m.quoted.fakeObj,
  12. });
  13. messages.key.fromMe = m.isBaileys || (m.sender === m.conn?.user?.jid)
  14. messages.key.id = m.key.id
  15. messages.pushName = m.pushName
  16. if (m.isGroup) messages.participant = m.sender
  17. const msg = {
  18. ...chatUpdate,
  19. messages: [proto.WebMessageInfo.fromObject(messages)],
  20. type: 'append',
  21. };
  22. this.ev.emit('messages.upsert', msg);
  23. }