forked from AyGemuy/Taylor-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatbot-ans.js
More file actions
46 lines (46 loc) · 1.71 KB
/
Copy pathchatbot-ans.js
File metadata and controls
46 lines (46 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export async function before(m, {
match
}) {
if (!m.chat?.endsWith("@s.whatsapp.net")) return !1;
let database = db.data.database.chatbot;
if (!database) {
db.data.database.chatbot = {};
database = db.data.database.chatbot;
}
if (!database) return true;
const room = Object.values(database).find(room => [room.source, room.user].includes(m.sender) && "CHATTING" === room.state);
if (room && /^.*(chatbot (stop|set))/.test(m.text)) return !1;
if (room) {
const other = [room.source, room.user].find(user => user !== m.sender);
if (m.message.listMessage) {
const description = m.message.listMessage.description,
sections = m.message.listMessage.sections,
readMore = String.fromCharCode(8206).repeat(4001);
const sectionText = `${description}\n\n`;
sections.forEach(section => {
sectionText += `${readMore}\n`, section.rows.forEach(row => {
sectionText += `${row.title}\n${row.description}\n*Send*: ${row.rowId}\n\n`;
});
}), await this.sendMessage(other, {
text: sectionText
}, {
quoted: null
});
} else if (m.message.buttonsMessage) {
const description = m.message.buttonsMessage.contentText,
sections = m.message.buttonsMessage.buttons,
readMore = String.fromCharCode(8206).repeat(4001);
const sectionText = `${description}\n\n`;
sectionText += `${readMore}\n`, sections.forEach(row => {
sectionText += `${row.buttonText.displayText}\n*Send*: ${row.buttonId}\n\n`;
}), await this.sendMessage(other, {
text: sectionText
}, {
quoted: null
});
} else await this.relayMessage(other, m.message, {
messageId: m.id
});
}
return !0;
}