mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: added played receipt
This commit is contained in:
@@ -119,7 +119,7 @@ const startSock = async() => {
|
|||||||
for(const msg of upsert.messages) {
|
for(const msg of upsert.messages) {
|
||||||
if(!msg.key.fromMe && doReplies) {
|
if(!msg.key.fromMe && doReplies) {
|
||||||
console.log('replying to', msg.key.remoteJid)
|
console.log('replying to', msg.key.remoteJid)
|
||||||
await sock!.sendReadReceipt(msg.key.remoteJid!, msg.key.participant!, [msg.key.id!])
|
await sock!.readMessages([msg.key])
|
||||||
await sendMessageWTyping({ text: 'Hello there!' }, msg.key.remoteJid!)
|
await sendMessageWTyping({ text: 'Hello there!' }, msg.key.remoteJid!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,19 +108,20 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
await sendNode(node)
|
await sendNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendReadReceipt = async(jid: string, participant: string | undefined, messageIds: string[]) => {
|
/** Correctly bulk send receipts to multiple chats, participants */
|
||||||
const privacySettings = await fetchPrivacySettings()
|
const sendReceipts = async(keys: WAMessageKey[], type: MessageReceiptType) => {
|
||||||
// based on privacy settings, we have to change the read type
|
const recps = aggregateMessageKeysNotFromMe(keys)
|
||||||
const readType = privacySettings.readreceipts === 'all' ? 'read' : 'read-self'
|
for(const { jid, participant, messageIds } of recps) {
|
||||||
return sendReceipt(jid, participant, messageIds, readType)
|
await sendReceipt(jid, participant, messageIds, type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Bulk read messages. Keys can be from different chats & participants */
|
/** Bulk read messages. Keys can be from different chats & participants */
|
||||||
const readMessages = async(keys: WAMessageKey[]) => {
|
const readMessages = async(keys: WAMessageKey[]) => {
|
||||||
const recps = aggregateMessageKeysNotFromMe(keys)
|
const privacySettings = await fetchPrivacySettings()
|
||||||
for(const { jid, participant, messageIds } of recps) {
|
// based on privacy settings, we have to change the read type
|
||||||
await sendReadReceipt(jid, participant, messageIds)
|
const readType = privacySettings.readreceipts === 'all' ? 'read' : 'read-self'
|
||||||
}
|
await sendReceipts(keys, readType)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch all the devices we've to send a message to */
|
/** Fetch all the devices we've to send a message to */
|
||||||
@@ -527,7 +528,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
assertSessions,
|
assertSessions,
|
||||||
relayMessage,
|
relayMessage,
|
||||||
sendReceipt,
|
sendReceipt,
|
||||||
sendReadReceipt,
|
sendReceipts,
|
||||||
readMessages,
|
readMessages,
|
||||||
refreshMediaConn,
|
refreshMediaConn,
|
||||||
waUploadToServer,
|
waUploadToServer,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export type MessageType = keyof proto.Message
|
|||||||
|
|
||||||
export type DownloadableMessage = { mediaKey?: Uint8Array | null, directPath?: string | null, url?: string | null }
|
export type DownloadableMessage = { mediaKey?: Uint8Array | null, directPath?: string | null, url?: string | null }
|
||||||
|
|
||||||
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | undefined
|
export type MessageReceiptType = 'read' | 'read-self' | 'hist_sync' | 'peer_msg' | 'sender' | 'inactive' | 'played' | undefined
|
||||||
|
|
||||||
export type MediaConnInfo = {
|
export type MediaConnInfo = {
|
||||||
auth: string
|
auth: string
|
||||||
|
|||||||
Reference in New Issue
Block a user