Skip to content

Commit

Permalink
Fixed sending multiple messages and files. Closes:#128
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioSilva committed Apr 3, 2020
1 parent 69fe2c7 commit 1fbe9f7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ WAPI.waitNewMessages(false, async (data) => {
console.log(response);
WAPI.sendSeen(message.from._serialized);
//replying to the user based on response
WAPI.sendMessage2(message.from._serialized, response[0].text);
//sending files if there is any
if(response[0].files){
if (response[0].files.length > 0) {
response[0].files.forEach((file) => {
WAPI.sendImage(file.file, message.from._serialized , file.name);
})
}
}
if (response && response.length > 0){
response.forEach(itemResponse => {
WAPI.sendMessage2(message.from._serialized, itemResponse.text);
//sending files if there is any
if(itemResponse.files && itemResponse.files.length > 0 ){
itemResponse.files.forEach((itemFile) => {
WAPI.sendImage(itemFile.file, message.from._serialized , itemFile.name);
})
}
});
}
}).catch(function (error) {
console.log(error);
});
Expand Down

0 comments on commit 1fbe9f7

Please sign in to comment.