mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
messages-send,tsconfig: add poll message attributes + fix tsconfig
This commit is contained in:
@@ -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(() => (
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"compilerOptions": {
|
||||
"target": "es2018",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "NodeNext",
|
||||
"experimentalDecorators": true,
|
||||
"allowJs": false,
|
||||
"checkJs": false,
|
||||
|
||||
Reference in New Issue
Block a user