mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: add message events for reactions
This commit is contained in:
@@ -143,7 +143,21 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const protocolMessage = normalizeMessageContent(message.message)?.protocolMessage
|
const normalizedContent = normalizeMessageContent(message.message)
|
||||||
|
const protocolMessage = normalizedContent?.protocolMessage
|
||||||
|
|
||||||
|
if(normalizedContent.reactionMessage) {
|
||||||
|
const reaction: proto.IReaction = {
|
||||||
|
...normalizedContent.reactionMessage,
|
||||||
|
key: message.key,
|
||||||
|
}
|
||||||
|
const operation = normalizedContent.reactionMessage?.text ? 'add' : 'remove'
|
||||||
|
ev.emit(
|
||||||
|
'messages.reaction',
|
||||||
|
{ reaction, key: normalizedContent.reactionMessage!.key!, operation }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// if it's a message to delete another message
|
// if it's a message to delete another message
|
||||||
if(protocolMessage) {
|
if(protocolMessage) {
|
||||||
switch (protocolMessage.type) {
|
switch (protocolMessage.type) {
|
||||||
|
|||||||
@@ -203,6 +203,16 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
chatUpdate.ephemeralExpiration = protocolMsg.ephemeralExpiration || null
|
chatUpdate.ephemeralExpiration = protocolMsg.ephemeralExpiration || null
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
} else if(content.reactionMessage) {
|
||||||
|
const reaction: proto.IReaction = {
|
||||||
|
...content.reactionMessage,
|
||||||
|
key: message.key,
|
||||||
|
}
|
||||||
|
const operation = content.reactionMessage?.text ? 'add' : 'remove'
|
||||||
|
ev.emit(
|
||||||
|
'messages.reaction',
|
||||||
|
{ reaction, key: content.reactionMessage!.key!, operation }
|
||||||
|
)
|
||||||
} else if(message.messageStubType) {
|
} else if(message.messageStubType) {
|
||||||
const meJid = authState.creds.me!.id
|
const meJid = authState.creds.me!.id
|
||||||
const jid = message.key!.remoteJid!
|
const jid = message.key!.remoteJid!
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type EventEmitter from 'events'
|
import type EventEmitter from 'events'
|
||||||
|
import { proto } from '../../WAProto'
|
||||||
import { AuthenticationCreds } from './Auth'
|
import { AuthenticationCreds } from './Auth'
|
||||||
import { Chat, PresenceData } from './Chat'
|
import { Chat, PresenceData } from './Chat'
|
||||||
import { Contact } from './Contact'
|
import { Contact } from './Contact'
|
||||||
@@ -36,6 +37,7 @@ export type BaileysEventMap<T> = {
|
|||||||
* the update will have type: "notify"
|
* the update will have type: "notify"
|
||||||
* */
|
* */
|
||||||
'messages.upsert': { messages: WAMessage[], type: MessageUpdateType }
|
'messages.upsert': { messages: WAMessage[], type: MessageUpdateType }
|
||||||
|
'messages.reaction': { key: WAMessageKey, reaction: proto.IReaction, operation: 'add' | 'remove' }
|
||||||
|
|
||||||
'message-receipt.update': MessageUserReceiptUpdate[]
|
'message-receipt.update': MessageUserReceiptUpdate[]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user