Open alormzpaez opened 2 weeks ago
Can you explain this part a little better to me, when you say that answering a poll is, for example, that you send a survey and the bot answers it?
Can you explain this part a little better to me, when you say that answering a poll is, for example, that you send a survey and the bot answers it?
Yeah. For this example, we'll take your examples/bot.ts:
botBaileys.on('message', async (message) => {
if (!awaitingResponse) {
await botBaileys.sendPoll(message.from, 'Select an option', {
options: ['text', 'media', 'file', 'sticker'],
multiselect: false
});
awaitingResponse = true;
} else {
const command = message.body.toLowerCase().trim();
switch (command) {
case 'text':
await botBaileys.sendText(message.from, 'Hello world');
break;
case 'media':
await botBaileys.sendMedia(message.from, 'https://www.w3schools.com/w3css/img_lights.jpg', 'Hello world');
break;
case 'file':
await botBaileys.sendFile(message.from, 'https://github.com/pedrazadixon/sample-files/raw/main/sample_pdf.pdf');
break;
case 'sticker':
await botBaileys.sendSticker(message.from, 'https://gifimgs.com/animations/anime/dragon-ball-z/Goku/goku_34.gif', { pack: 'User', author: 'Me' });
break;
default:
await botBaileys.sendText(message.from, 'Sorry, I did not understand that command. Please select an option from the poll.');
break;
}
awaitingResponse = false;
}
});
When an user vote 'text', I want bot to vote 'text' too. So, the final result has to be the next:
@andresayac , have you tried this? I'm imaging some logic has to be here:
// ...
case 'text':
await botBaileys.sendText(message.from, 'Hello world');
// Some logic for send vote too
break;
// ...
When an user vote in a poll, I want bot to vote in the same option (working like a "verification" in my personal project). @andresayac have you tried this?
I ask this because I look several methods starting with send (sendPoll, sendText, ...), but I don't know if there are someone starting like reply or something 😅