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

Community support #255

Open
unilogica opened this issue Jul 17, 2023 · 18 comments · May be fixed by #1157
Open

Community support #255

unilogica opened this issue Jul 17, 2023 · 18 comments · May be fixed by #1157
Labels
enhancement New feature or request

Comments

@unilogica
Copy link

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
Copy link
Collaborator

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
Copy link
Author

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

@Auties00
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Contributor

guiguicdd commented Aug 10, 2023

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="[email protected]" type="w:gp2" id="PPPPPPPPP"
    participant="[email protected]" addressing_mode="pn" notify="Guilherme ي"
    t="TTTTTTTT">
    <create type="new">
        <group subject="Community name" creator="[email protected]" s_o="[email protected]"
            id="XXXXXXXXXXXXXXXXXX" creation="YYYYYYYY" s_t="YYYYYYYY" size="1"
            p_v_id="JJJJJJJJJJJJJJJ" a_v_id="JJJJJJJJJJJJJJJ">
            <participant jid="[email protected]" type="superadmin" />
            <description participant="[email protected]" 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
Copy link

tizum commented Aug 24, 2023

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
Copy link

luizsvl commented Sep 20, 2023

Up

@Auties00
Copy link
Collaborator

Auties00 commented Oct 4, 2023

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

@Auties00 Auties00 changed the title [FEATURE REQUEST] Community support Community support Oct 5, 2023
@Auties00 Auties00 added the enhancement New feature or request label Oct 5, 2023
@iannortnau
Copy link

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
Copy link
Collaborator

Auties00 commented Nov 4, 2023

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
Copy link

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
Copy link
Collaborator

Auties00 commented Nov 4, 2023

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
Copy link

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

@luangduartedev
Copy link

Are there some news?

@luispimenta
Copy link

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

@SatzzDev
Copy link

any update?

@joaosouz4dev joaosouz4dev linked a pull request Dec 8, 2024 that will close this issue
@joaosouz4dev
Copy link

@SatzzDev @luispimenta @luangduartedev @luanhduarte @Auties00 @iannortnau @luizsvl @tizum @guiguicdd

I created a support for communities, can you test it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.