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',
|
tag: 'message',
|
||||||
attrs: {
|
attrs: {
|
||||||
id: msgId!,
|
id: msgId!,
|
||||||
type: 'text',
|
type: getMessageType(message),
|
||||||
...(additionalAttributes || {})
|
...(additionalAttributes || {})
|
||||||
},
|
},
|
||||||
content: binaryNodeContent
|
content: binaryNodeContent
|
||||||
@@ -577,6 +577,15 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
return msgId
|
return msgId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const getMessageType = (message: proto.IMessage) => {
|
||||||
|
if(message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3) {
|
||||||
|
return 'poll'
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'text'
|
||||||
|
}
|
||||||
|
|
||||||
const getMediaType = (message: proto.IMessage) => {
|
const getMediaType = (message: proto.IMessage) => {
|
||||||
if(message.imageMessage) {
|
if(message.imageMessage) {
|
||||||
return 'image'
|
return 'image'
|
||||||
@@ -760,7 +769,9 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
const isDeleteMsg = 'delete' in content && !!content.delete
|
const isDeleteMsg = 'delete' in content && !!content.delete
|
||||||
const isEditMsg = 'edit' in content && !!content.edit
|
const isEditMsg = 'edit' in content && !!content.edit
|
||||||
const isPinMsg = 'pin' in content && !!content.pin
|
const isPinMsg = 'pin' in content && !!content.pin
|
||||||
|
const isPollMessage = 'poll' in content && !!content.poll
|
||||||
const additionalAttributes: BinaryNodeAttributes = { }
|
const additionalAttributes: BinaryNodeAttributes = { }
|
||||||
|
const additionalNodes: BinaryNode[] = []
|
||||||
// required for delete
|
// required for delete
|
||||||
if(isDeleteMsg) {
|
if(isDeleteMsg) {
|
||||||
// if the chat is a group, and I am not the author, then delete the message as an admin
|
// 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'
|
additionalAttributes.edit = '1'
|
||||||
} else if(isPinMsg) {
|
} else if(isPinMsg) {
|
||||||
additionalAttributes.edit = '2'
|
additionalAttributes.edit = '2'
|
||||||
|
} else if(isPollMessage) {
|
||||||
|
additionalNodes.push({
|
||||||
|
tag: 'meta',
|
||||||
|
attrs: {
|
||||||
|
polltype: 'creation'
|
||||||
|
},
|
||||||
|
} as BinaryNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if('cachedGroupMetadata' in options) {
|
if('cachedGroupMetadata' in options) {
|
||||||
console.warn('cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.')
|
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) {
|
if(config.emitOwnEvents) {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
processingMutex.mutex(() => (
|
processingMutex.mutex(() => (
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2018",
|
"target": "es2018",
|
||||||
"module": "CommonJS",
|
"module": "CommonJS",
|
||||||
"moduleResolution": "NodeNext",
|
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"allowJs": false,
|
"allowJs": false,
|
||||||
"checkJs": false,
|
"checkJs": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user