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: get pinned messages #3004

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

alechkos
Copy link
Collaborator

@alechkos alechkos commented May 2, 2024

Table of Contents

- Description

- Usage Example

- I Want to Test this PR

- I Got an Error While Testing This PR ❌

- How Has the PR Been Tested (latest test on 04.05.2024)

- Types of Changes


Description

The PR adds Client.getPinnedMessages and Chat.getPinnedMessages methods to retrieve all pinned messages from a chat or a group by providing the chat ID.

Methods return an array of Message instances, or an empty array if there are no pinned messages in a chat/group.


Usage Example

// client initialization...

client.on('ready', async () => {
    const chatId = '[email protected]';

    let pinnedMsg = await client.getPinnedMessages(chatId);
    console.log(pinnedMsg);

    // OR
    const chat = await client.getChatById(chatId);
    pinnedMsg = await chat.getPinnedMessages();
    console.log(pinnedMsg);
});

To test this PR by yourself you should do two steps:

1. Install the PR by running one of the following commands:

  • NPM
npm install github:alechkos/whatsapp-web.js#get-pinned-msg
  • YARN
yarn add github:alechkos/whatsapp-web.js#get-pinned-msg

2. Lock your WWeb version on 2.2412.54:

const wwebVersion = '2.2412.54';

const client = new Client({
    authStrategy: new LocalAuth(), // your authstrategy here
    puppeteer: {
        // puppeteer args here
    },
    // locking the wweb version
    webVersionCache: {
        type: 'remote',
        remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html`,
    },
});

If you encounter any errors while testing this PR, please provide in a comment:

  1. The code you've used without any sensitive information (use syntax highlighting for more readability)
  2. The error you got
  3. The library version
  4. The WWeb version: console.log(await client.getWWebVersion());
  5. The browser (Chrome/Chromium)

Important

You have to reapply the PR each time it is changed (new commits were pushed since your last application)


How Has The PR Been Tested (latest test on 04.05.2024)

Tested with a code provided in usage example.

Tested On:

Types of accounts:

  • Personal
  • Buisness

Environment:

  • Android 10:
    • WhatsApp: latest
    • WA Business: latest
  • Windows 10:
    • WWebJS: v1.23.1-alpha.6
    • WWeb: v2.2412.54
    • Puppeteer: v18.2.1
    • Node: v18.17.1
    • Chrome: latest

Types of Changes

  • Dependency change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix/feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • I have updated the usage example accordingly (example.js)
  • I have updated the documentation accordingly (index.d.ts)

@alechkos alechkos requested review from tuyuribr and shirser121 May 2, 2024 20:57
src/Client.js Outdated Show resolved Hide resolved
@alechkos alechkos marked this pull request as draft May 3, 2024 14:17
@alechkos alechkos requested a review from shirser121 May 4, 2024 07:46
@alechkos alechkos marked this pull request as ready for review May 4, 2024 07:50
@joweste

This comment was marked as off-topic.

@alechkos alechkos marked this pull request as draft July 3, 2024 20:55
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.

3 participants