WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
3.1k stars 1.07k forks source link

Community support #255

Open unilogica opened 11 months ago

unilogica commented 11 months ago

I would suggest community support. I've seen WPPConnect implement this and would like to take the opportunity and ask if anyone knows how I can port this to the Baileys. Exists some doc to explain how can I inspect WhatsApp to create this feature?

https://github.com/wppconnect-team/wppconnect/blob/master/src/api/layers/community.layer.ts

Auties00 commented 11 months ago

I would suggest community support. I've seen WPPConnect implement this and would like to take the opportunity and ask if anyone knows how I can port this to the Baileys. Exists some doc to explain how can I inspect WhatsApp to create this feature?

https://github.com/wppconnect-team/wppconnect/blob/master/src/api/layers/community.layer.ts

I can probably port it from my library cobalt tomorrow. I'll open a PR once I'm done

unilogica commented 11 months ago

Wow! I started reading the documentation of your Cobalt repo, what a fantastic job 👏

Auties00 commented 11 months ago

Uhm I'm having some problems with the community create node. It looks right, but it's throwing: Received node Node[description=iq, attributes={from=g.us, id=d329cc8a1b, type=error}, content=[Node[description=error, attributes={code=400, text=bad-request}]]] I'll try to fix it asap so I can open the PR

unilogica commented 11 months ago

I saw some of your repos and noticed the WhatsappWebRequestAnalyzer. Java and Kotlin aren't even close to my most familiar stacks, but from what I understand this project uses Chrome 90 injected with a layer that takes every request made by WhatsApp.

Is that how you were able to reverse engineer this community feature originally for Cobalt?

Auties00 commented 11 months ago

I saw some of your repos and noticed the WhatsappWebRequestAnalyzer. Java and Kotlin aren't even close to my most familiar stacks, but from what I understand this project uses Chrome 90 injected with a layer that takes every request made by WhatsApp.

Is that how you were able to reverse engineer this community feature originally for Cobalt?

Yeah, actually I use chrome 114, but you should be able to use any Chrome ≥ 111 To give you a gist, the analyzer:

  1. Starts an instance of Chrome
  2. Goes to Whatsapp web
  3. Instantly finds the line where the crypto keys are loaded and places a breakpoint there
  4. As the page gets loaded immediately after, the breakpoint is triggered and the keys are extracted
  5. I then listen for all web socket events, incoming and outgoing, to decode the Nodes

You also need to understand the original Whatsapp web source code most of the times, but having the raw node is definitely a good start.

To see the mobile's app nodes download the Whatsapp beta and run the following adb command: adb shell logcat | grep WhatsApp: You might need an APK from may 2023 because afaict new versions don't print them out.

guiguicdd commented 11 months ago

I used this code to make the IQ request. Bug getting 400. Any Idea?

communityCreate: async (subject: string) => {
  const result = await groupQuery("@g.us", "set", [
    {
      tag: "create",
      attrs: {
        subject,
      },
      content: [
        {
          tag: "description",
          attrs: {
            id: generateMessageTag(),
          },
          content: [
            {
              tag: "body",
              attrs: {},
              content: Buffer.from("The community description", "utf-8"),
            },
          ],
        },
        {
          tag: "parent",
          attrs: {
            default_membership_approval_mode: "request_required",
          },
        },
      ],
    },
  ]);

  console.log(result);

  // return extractGroupMetadata(result)
};

Inside the "example.ts", make an request to WA servers using:

const createCommunitResponse = await sock.communityCreate('Community name')

console.log('DEBUG:', createCommunitResponse)

The expected result is something like this:

<notification from="XXXXXXXXXXXXXXXXXX@g.us" type="w:gp2" id="PPPPPPPPP"
    participant="KKKKKKKKKK@s.whatsapp.net" addressing_mode="pn" notify="Guilherme ي"
    t="TTTTTTTT">
    <create type="new">
        <group subject="Community name" creator="KKKKKKKKKK@s.whatsapp.net" s_o="KKKKKKKKKK@s.whatsapp.net"
            id="XXXXXXXXXXXXXXXXXX" creation="YYYYYYYY" s_t="YYYYYYYY" size="1"
            p_v_id="JJJJJJJJJJJJJJJ" a_v_id="JJJJJJJJJJJJJJJ">
            <participant jid="KKKKKKKKKK@s.whatsapp.net" type="superadmin" />
            <description participant="KKKKKKKKKK@s.whatsapp.net" id="AAAA.AAAAA-AAA"
                t="YYYYYYYY">
                <body>"The community description"</body>
            </description>
            <parent default_membership_approval_mode="request_required" />
            <member_add_mode>"admin_add"</member_add_mode>
        </group>
    </create>
</notification>
tizum commented 10 months ago

any news on this subject? it would be great to be able to count communities so you can message them mainly in the general notices group.

luizsvl commented 9 months ago

Up

Auties00 commented 9 months ago

If someone still needs it I could port it from my library as I found the fix

iannortnau commented 8 months ago

Any updates on the matter, I would really like to use the community functions, I saw that @Auties00 had found a solution, but has it already been incorporated into Baileys?

Auties00 commented 8 months ago

Any updates on the matter, I would really like to use the community functions, I saw that @Auties00 had found a solution, but has it already been incorporated into Baileys?

I should add support for both communities and channels in the near future. I'd like to do it this week, but I have to study as my mid terms are coming up for uni. I'll do it asap tho

iannortnau commented 8 months ago

Any updates on the matter, I would really like to use the community functions, I saw that @Auties00 had found a solution, but has it already been incorporated into Baileys?

I should add support for both communities and channels in the near future. I'd like to do it this week, but I have to study as my mid terms are coming up for uni. I'll do it asap tho

Thank you for the response and the attention, I will be waiting and good luck with your studies.

Auties00 commented 8 months ago

Any updates on the matter, I would really like to use the community functions, I saw that @Auties00 had found a solution, but has it already been incorporated into Baileys?

I should add support for both communities and channels in the near future. I'd like to do it this week, but I have to study as my mid terms are coming up for uni. I'll do it asap tho

Thank you for the response and the attention, I will be waiting and good luck with your studies.

Thanks :)

luanhduarte commented 8 months ago

I'm looking forward to receive this new feature in baileys!!!

luangduartedev commented 7 months ago

Are there some news?

luispimenta commented 6 months ago

Are there some news to receive this new feature in baileys?

SatzzDev commented 1 month ago

any update?