Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: star/unstar messages #494

Merged
merged 9 commits into from
Dec 28, 2020

Conversation

mpirescarvalho
Copy link
Contributor

adds functions to star/unstar messages to client, chat and message.

client.starMsgs([msg1, msg2]);
client.unstarMsgs([msg1, msg2]);

chat.starMsgs([msg1, msg2]);
chat.unstarMsgs([msg1, msg2]);
    
msg.star();
msg.unstar();

Usage:

client.on('message', async msg => {
    if (msg.body.startsWith('!star')) {
        const quotedMsg = await msg.getQuotedMessage();
        await quotedMsg.star();
    }

    if (msg.body.startsWith('!unstar')) {
        const quotedMsg = await msg.getQuotedMessage();
        await quotedMsg.unstar();
    }
});

Result (bot point of view):
image

Would it be better if client.starMsgs and chat.starMsgs receives an array of IDs instead of messages?

closes #481

Copy link
Owner

@pedroslopez pedroslopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good functionality-wise!

I would argue that the functions on client and chat don't seem to be really useful- calling the function directly on the Message seems to me more natural. I see you suggested using IDs for the functions on client/chat, but to be honest I think I'd prefer just leaving it on the Message and removing the functions from client/chat, unless you see a use case where it would be more convenient to have those.

@pedroslopez pedroslopez added this to the v1.12.0 milestone Dec 25, 2020
@mpirescarvalho
Copy link
Contributor Author

I think you're right. It's done.

@pedroslopez pedroslopez merged commit 0f8e7ee into pedroslopez:dev Dec 28, 2020
pedroslopez pushed a commit that referenced this pull request Dec 29, 2020
tianvier added a commit to tianvier/whatsapp-web.js that referenced this pull request Dec 31, 2020
* 'master' of https://github.com/pedroslopez/whatsapp-web.js:
  chore: mark version v1.12.0
  docs: switch links to point to the guide
  docs: fix error generating Label docs
  feat: Get message delivery information (close pedroslopez#418)
  feat: mark chat as unread (pedroslopez#475)
  feat: add GroupChat types (pedroslopez#485)
  docs: fix typo
  feat: added starred indicator to messages (pedroslopez#501)
  feat: star/unstar messages (pedroslopez#494)
  feat: get Contact's "About" text (close pedroslopez#491)
  feat: get links included in message (pedroslopez#457)
  feat: send media as stickers (pedroslopez#479)
  docs: fix slight typo
  feat: send media as document (pedroslopez#490)
  feat: Get registered ID for a given phone number (pedroslopez#483)
  feat(interface): Open chat search, open chat at message position (pedroslopez#447)
  feat: WA Business Labels support (pedroslopez#407)

# Conflicts:
#	package.json
@mpirescarvalho mpirescarvalho deleted the feat/star-unstar-messages branch January 12, 2021 14:18
Belfio pushed a commit to Belfio/whatsapp-web.js that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any way to *Star / Unstar* a message ?
2 participants