-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
258 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
/* | ||
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN | ||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mMMMMMMMMMNNNmmNNNMMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mmNMMNMMMMNNNNNmmmddhdddNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mddNMMNy:/odNmmddmmNNmdhhddmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
NmmdNMNd:--+dNmmddhhddmmhsyhhmdmmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
NmNmdNmy:.-oyNmmmhmdhho+sososyhhhddNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
NmmNdh+-`.:oyNNdmmdmmdo-://oysssyhhhdmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
Nmmmoyyyo+osdNmdmmddNNhs+/::/+osyssydyhdNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
NNmhsymMMNmmmmdmdNNddNmsso+++////ossssyyhdmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mhhhmNNMNNNhssshhmmddmmssyooooso/::+oysshhhhmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mmdhdddNNdyoosyhdmddmmmsoooooyysyys/::/oyyhhhyMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mdddhddmhsooshdmdmdhhyyyysso/ooo+syhhs/-/+shyhMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
dyyhdmd+ososhdmdmyyhhhhhhhyo++o/+///+ohhso++sdMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
dhdmNNdsossyhmdmsydhssssyhhs/++o/o+//:++yhhy+/hNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
mdmNNNNmhysshddyshdyyy/oss+s::/:://++///++++/::hmNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
NNMNNNmmNNdymNNhshdshdyhdysh+sy+-:++osssosss++yNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM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MMMMMMMMM | ||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMMMMMMMMMMMMNMMNMNMMMNMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMMNMNMMMNMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNMMNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | ||
*/ | ||
/** | ||
* Send List menu | ||
* @param {string} to the numberid xxx@c.us | ||
* @param {string} title the titulo | ||
* @param {string} subtitle the subtitle | ||
* @param {string} description the description | ||
* @param {string} buttonText the name button | ||
* @param {array} menu List menu | ||
*/ | ||
export async function sendListMenu( | ||
to, | ||
title, | ||
subTitle, | ||
description, | ||
buttonText, | ||
menu | ||
) { | ||
if (!title && typeof title != 'string') { | ||
return WAPI.scope(null, true, 404, 'Enter the title variable as an string'); | ||
} | ||
|
||
if (!subTitle && typeof subTitle != 'string') { | ||
return WAPI.scope( | ||
null, | ||
true, | ||
404, | ||
'Enter the SubTitle variable as an string' | ||
); | ||
} | ||
|
||
if (!description && typeof description != 'string') { | ||
return WAPI.scope( | ||
null, | ||
true, | ||
404, | ||
'Enter the description variable as an string' | ||
); | ||
} | ||
|
||
if (!buttonText && typeof buttonText != 'string') { | ||
return WAPI.scope( | ||
null, | ||
true, | ||
404, | ||
'Enter the buttonText variable as an string' | ||
); | ||
} | ||
|
||
if (!menu && Array.isArray(menu) === false) { | ||
return WAPI.scope(null, true, 404, 'Enter the menu variable as an array'); | ||
} | ||
|
||
for (let index in menu) { | ||
if (index !== 'remove') { | ||
if ( | ||
!!menu[index].title && | ||
typeof menu[index].title === 'string' && | ||
menu[index].title.length | ||
) { | ||
if ( | ||
!!menu[index].rows && | ||
Array.isArray(menu[index].rows) && | ||
menu[index].rows.length | ||
) { | ||
for (let i in menu[index].rows) { | ||
if (i !== 'remove') { | ||
if ( | ||
!!menu[index].rows[i].title && | ||
menu[index].rows[i].title.length | ||
) { | ||
if ( | ||
!!menu[index].rows[i].description && | ||
menu[index].rows[i].description.length | ||
) { | ||
menu[index].rows[i].rowId = `dessert_${i}`; | ||
} else { | ||
return WAPI.scope( | ||
null, | ||
true, | ||
404, | ||
'Enter the Description variable as an string' | ||
); | ||
} | ||
} else { | ||
return WAPI.scope( | ||
null, | ||
true, | ||
404, | ||
'Enter the Title variable as an string' | ||
); | ||
} | ||
} | ||
} | ||
} else { | ||
return WAPI.scope(null, true, 404, 'Rows must be an object array'); | ||
} | ||
} else { | ||
return WAPI.scope(null, true, 404, 'Incorrect Title passed in menu'); | ||
} | ||
} | ||
} | ||
|
||
const chat = await WAPI.sendExist(to); | ||
|
||
if (chat && chat.status != 404) { | ||
const newMsgId = await window.WAPI.getNewMessageId(chat.id); | ||
const fromwWid = await window.Store.Conn.wid; | ||
const inChat = await WAPI.getchatId(chat.id).catch(() => {}); | ||
|
||
if (inChat) { | ||
chat.lastReceivedKey._serialized = inChat._serialized; | ||
chat.lastReceivedKey.id = inChat.id; | ||
} | ||
|
||
const message = { | ||
id: newMsgId, | ||
ack: 0, | ||
from: fromwWid, | ||
to: chat.id, | ||
local: !0, | ||
self: 'out', | ||
t: parseInt(new Date().getTime() / 1000), | ||
isNewMsg: !0, | ||
invis: true, | ||
footer: subTitle, | ||
notifyName: '', | ||
type: 'list', | ||
interactiveAnnotations: true, | ||
interactiveMessage: true, | ||
star: false, | ||
broadcast: false, | ||
fromMe: false, | ||
list: { | ||
title: title, | ||
description: description, | ||
buttonText: buttonText, | ||
listType: 1, | ||
sections: menu | ||
} | ||
}; | ||
|
||
var result = ( | ||
await Promise.all(window.Store.addAndSendMsgToChat(chat, message)) | ||
)[1]; | ||
if (result === 'success' || result === 'OK') { | ||
return WAPI.scope(newMsgId, false, result, null); | ||
} else { | ||
return WAPI.scope(newMsgId, true, result, null); | ||
} | ||
} else { | ||
return chat; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters