diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index f5eea0a..6bedde4 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -532,7 +532,7 @@ export const makeMessagesSocket = (config: SocketConfig) => { tag: 'message', attrs: { id: msgId!, - type: 'text', + type: getMessageType(message), ...(additionalAttributes || {}) }, content: binaryNodeContent @@ -577,6 +577,15 @@ export const makeMessagesSocket = (config: SocketConfig) => { return msgId } + + const getMessageType = (message: proto.IMessage) => { + if(message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3) { + return 'poll' + } + + return 'text' + } + const getMediaType = (message: proto.IMessage) => { if(message.imageMessage) { return 'image' @@ -760,7 +769,9 @@ export const makeMessagesSocket = (config: SocketConfig) => { const isDeleteMsg = 'delete' in content && !!content.delete const isEditMsg = 'edit' in content && !!content.edit const isPinMsg = 'pin' in content && !!content.pin + const isPollMessage = 'poll' in content && !!content.poll const additionalAttributes: BinaryNodeAttributes = { } + const additionalNodes: BinaryNode[] = [] // required for delete if(isDeleteMsg) { // if the chat is a group, and I am not the author, then delete the message as an admin @@ -773,13 +784,20 @@ export const makeMessagesSocket = (config: SocketConfig) => { additionalAttributes.edit = '1' } else if(isPinMsg) { additionalAttributes.edit = '2' + } else if(isPollMessage) { + additionalNodes.push({ + tag: 'meta', + attrs: { + polltype: 'creation' + }, + } as BinaryNode) } if('cachedGroupMetadata' in options) { console.warn('cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.') } - await relayMessage(jid, fullMsg.message!, { messageId: fullMsg.key.id!, useCachedGroupMetadata: options.useCachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList }) + await relayMessage(jid, fullMsg.message!, { messageId: fullMsg.key.id!, useCachedGroupMetadata: options.useCachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList, additionalNodes }) if(config.emitOwnEvents) { process.nextTick(() => { processingMutex.mutex(() => ( diff --git a/tsconfig.json b/tsconfig.json index 598e2f6..2fe7ae3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,6 @@ "compilerOptions": { "target": "es2018", "module": "CommonJS", - "moduleResolution": "NodeNext", "experimentalDecorators": true, "allowJs": false, "checkJs": false,