open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.14k stars 600 forks source link

Implement a function that return the last message sent by the bot in a chat #924

Closed pedrogrisolia closed 4 years ago

pedrogrisolia commented 4 years ago

It would be nice if there was a function that would return the last message sent by the bot in a given chat. The currently method that I'm using is to call getAllMessagesInChat() and then loop it backwards until I find the last bot message. But, getAllMessagesInChat() takes a while to return the list of messages.

smashah commented 4 years ago

@github-actions run

âš¡ Release! âš¡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i`); exec(`npm run release-ci`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 4 years ago

Changelog

🚀 Release 2.0.32 (2020-10-12)

smashah commented 4 years ago

@pedrogrisolia https://open-wa.github.io/wa-automate-nodejs/classes/client.html#getmylastmessage

pedrogrisolia commented 4 years ago

@pedrogrisolia https://open-wa.github.io/wa-automate-nodejs/classes/client.html#getmylastmessage

You are awesome, thanks!