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

isGroup is undefined & group chat being identified as PrivateChat #3390

Closed
2 tasks done
notedwin-dev opened this issue Nov 27, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@notedwin-dev
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Is this a problem caused by your code, or is it specifically because of the library?

  • I have double-checked my code carefully.

Describe the bug.

isGroup is undefined & group chat being identified as PrivateChat.

Workaround:

const { Client, LocalAuth } = require("whatsapp-web.js");

const client = new Client({
    puppeteer: {
      headless: true,
      args: ["--no-sandbox", "--disable-setuid-sandbox"],
    },
    authStrategy: new LocalAuth(),
    webVersionCache: {
      type: "remote",
      remotePath:
        "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.3000.1018501131-alpha.html",
    },
  });
  
client.on("message", async (msg) => {
    const { from } = msg;
    const chat = await msg.getChat();
    let contact = await chat.getContact();

    if (contact.isGroup === true) {
      console.log("Ignoring group message");
      return;
    } else {
      console.log("Message received:", msg.body);
     }
 });

### Expected Behavior

I expected chat.isGroup to be true or false, instead, I got undefined.

Chat: PrivateChat {
id: {
server: 'g.us',
user: 'aaa',
_serialized: '[email protected]'
},
name: '',
isGroup: undefined,
isReadOnly: false,
unreadCount: 0,
timestamp: 1732716353,
archived: undefined,
pinned: false,
isMuted: undefined,
muteExpiration: 0,
lastMessage: Message {
_data: {
id: [Object],
viewed: false,
body: 'hi',
type: 'chat',
t: 1732716421,
notifyName: 'aaa',
from: [Object],
to: [Object],
author: [Object],
ack: 1,
invis: false,
isNewMsg: true,
star: false,
kicNotified: false,
recvFresh: true,
isFromTemplate: false,
pollInvalidated: false,
isSentCagPollCreation: false,
latestEditMsgKey: null,
latestEditSenderTimestampMs: null,
mentionedJidList: [],
groupMentions: [],
isEventCanceled: false,
eventInvalidated: false,
isVcardOverMmsDocument: false,
isForwarded: false,
hasReaction: false,
viewMode: 'VISIBLE',
messageSecret: [Object],
productHeaderImageRejected: false,
lastPlaybackProgress: 0,
isDynamicReplyButtonsMsg: false,
isCarouselCard: false,
parentMsgId: null,
isMdHistoryMsg: false,
stickerSentTs: 0,
isAvatar: false,
lastUpdateFromServerTs: 0,
invokedBotWid: null,
bizBotType: null,
botResponseTargetId: null,
botPluginType: null,
botPluginReferenceIndex: null,
botPluginSearchProvider: null,
botPluginSearchUrl: null,
botPluginSearchQuery: null,
botPluginMaybeParent: false,
botReelPluginThumbnailCdnUrl: null,
botMsgBodyType: null,
requiresDirectConnection: false,
bizContentPlaceholderType: null,
hostedBizEncStateMismatch: false,
senderOrRecipientAccountTypeHosted: false,
placeholderCreatedWhenAccountIsHosted: false,
links: []
},
mediaKey: undefined,
id: {
fromMe: false,
remote: '[email protected]',
id: '3A179859486398FC30D6',
participant: [Object],
_serialized: 'false_120363371704224503@[email protected]'
},
ack: 1,
hasMedia: false,
body: 'hi',
type: 'chat',
timestamp: 1732716421,
from: '[email protected]',
to: '[email protected]',
author: '[email protected]',
deviceType: 'ios',
isForwarded: false,
forwardingScore: 0,
isStatus: false,
isStarred: false,
broadcast: undefined,
fromMe: false,
hasQuotedMsg: false,
hasReaction: false,
duration: undefined,
location: undefined,
vCards: [],
inviteV4: undefined,
mentionedIds: [],
groupMentions: [],
orderId: undefined,
token: undefined,
isGif: false,
isEphemeral: undefined,
links: []
}
}
Message received: hi


### Steps to Reproduce the Bug or Issue

```js
const { Client, LocalAuth } = require("whatsapp-web.js");

const client = new Client({
    puppeteer: {
      headless: true,
      args: ["--no-sandbox", "--disable-setuid-sandbox"],
    },
    authStrategy: new LocalAuth(),
    webVersionCache: {
      type: "remote",
      remotePath:
        "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.3000.1018501131-alpha.html",
    },
  });
  
client.on("message", async (msg) => {
    const { from } = msg;
    const chat = await msg.getChat();
    console.log("Chat:", chat);

    if (chat.isGroup === true) {
      console.log("Ignoring group message");
      return;
    } else {
      console.log("Message received:", msg.body);
    }
   });

WhatsApp Account Type

Standard

Browser Type

Google Chrome (Mac OS)

Operation System Type

Mac OS

Phone OS Type

Android

WhatsApp-Web.js Version

1.26.0

WhatsApp Web Version

2.3000.1018501131

Node.js Version

v21.5.0

Authentication Strategy

LocalAuth

Additional Context

No response

@notedwin-dev notedwin-dev added the bug Something isn't working label Nov 27, 2024
@Halphas
Copy link

Halphas commented Nov 27, 2024

same here setsubject etc. therefore stopped working. god....

@alechkos
Copy link
Collaborator

Fixed in #3380

Use

npm install [email protected]

Repository owner locked as resolved and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants