Giter VIP home page Giter VIP logo

Comments (13)

Rhymen avatar Rhymen commented on June 2, 2024

I just merged our current master tree from our private repository with a working implementation to send messages. Keep in mind, that this is still very early development and that signatures may change.

Inline the comments in the main.go file from line 35 - 45 and enter a jid ([email protected]) and a custom text. Start the program with go run main.go, scan the qr code in your terminal and after a couple of seconds you should see the message in your whatsapp app.

If you want to check out the code, look at the conn.go, sending.go files and the composing package. For more detailed information on the crypto and binary parts check out sigalor/whatsapp-web-reveng.

from go-whatsapp.

coolnickname avatar coolnickname commented on June 2, 2024

Thanks man! I'll be sure to check it out soon.

from go-whatsapp.

coolnickname avatar coolnickname commented on June 2, 2024

It works pretty neat, I think you're actually the first person to implement this 🤔

Some things I have noticed is that it only works if the message sent from the wrapper is the first message in the conversation, so I have to keep clearing the chat in order to send a message. Also is the ID hardcoded? It seems like it's the same String every time.

If both of these are true I can see how they're connected.

from go-whatsapp.

SchulteMK avatar SchulteMK commented on June 2, 2024

The ID is not hardcoded, it is generated by the random number generator provided in the math package if not specified in the MessageInfo struct. The seed was not changed and so it generated the same message tags every time you start the program. Your WhatsApp-Client (APK) recognizes the message tag and does not sent the “same” message again.
Now the seed is changed at package initialization and it should works as expected.

from go-whatsapp.

coolnickname avatar coolnickname commented on June 2, 2024

Thanks for the quick reply! Unforntunately this doesn't seem to have solved the issue. From what I can see in the console the ID is still the same, and I also still can't send multiple messages.
The output in the console is:

[] 1 discarded msg: D1E2C64981855AD8681D,

[] 1 discarded msg: D1E2C64981855AD8681D,{"status":200,"t":1530115677}

[] 1 discarded msg: s7,["Msg",{"cmd":"ack","id":"D1E2C64981855AD8681D","ack":2,"from":"[email protected]","to":"[email protected]","t":1530115677}]

I assume in this case D1E2C64981855AD8681D is the ID?

I believe the ID doesn't matter as long as it isn't empty right? So could you point me to where I can manually set it so I can fiddle around with it?

EDIT: I'm new to golang and I couldn't figure out how to use the go get command, so I just cloned the repo. Could this cause the new init method that changes the randomizer seed to not trigger?

from go-whatsapp.

SchulteMK avatar SchulteMK commented on June 2, 2024

from go-whatsapp.

coolnickname avatar coolnickname commented on June 2, 2024

I'm not used to Go so please excuse me if I'm making a rookie mistake, but the method that sets the new Id doesn't seem to be called? For debugging I imported fmt in message.go and changed the code to:

fmt.Printf("Current Id: ", info.Id)
	if info.Id == "" || len(info.Id) < 2 {
		fmt.Printf("Id is too short")
		b := make([]byte, 10)
		rand.Read(b)
		info.Id = strings.ToUpper(hex.EncodeToString(b))
	}
	
	fmt.Printf("New Id: ", info.Id)

However none of these messages appear in the console. Also since no attempt to change the Id so far seems to work I've decided to just use empty Id's. If it works it should now be pretty easy to spot, and I'm using throwaway accounts anyway to avoid getting banned.

from go-whatsapp.

SchulteMK avatar SchulteMK commented on June 2, 2024

If I set a breakpoint at the if-statement(ln. 35-39), I can see that the code block gets called every time. I am not specifying any ID´s in my code manually. I cannot reproduce the issue any more after the latest fix. Can you show me/us your code interacting with our package?

from go-whatsapp.

coolnickname avatar coolnickname commented on June 2, 2024

All I have changed is removing the comment signs in main.go to send the message, and what I posted above in whatsapp/message.go.
Could you show me exactly which line I'd need to edit to set the ID?

Like I said before, could this be caused by me using git clone instead of go get? Also I'm not sure how to print messages to the console on Go so I just copied something I saw you were using.

from go-whatsapp.

SchulteMK avatar SchulteMK commented on June 2, 2024

Retrieving the package by git clone should not change anything. You just have to resolve the dependencies manually. Did you pull the latest commit?
Change your test code to:

	fmt.Printf("Current Id: %v\n", info.Id)
	status := proto.WebMessageInfo_STATUS(1)
	if info.Id == "" || len(info.Id) < 2 {
		b := make([]byte, 10)
		rand.Read(b)
		info.Id = strings.ToUpper(hex.EncodeToString(b))
	}
	fmt.Printf("New Id: %v\n", info.Id) 

See godoc for more information on how to use fmt.Printf

from go-whatsapp.

coolnickname avatar coolnickname commented on June 2, 2024

I still don't see anything getting printed to the console and I can also still only send 1 message

from go-whatsapp.

SchulteMK avatar SchulteMK commented on June 2, 2024

Without further information we cant´t help you. Ensure that you pulled from the repo or clone it again.

from go-whatsapp.

Rhymen avatar Rhymen commented on June 2, 2024

BTW: You should be able to set a custom id for every message. As @SchulteMK mentioned, we can't reproduce the issue, so maybe this helps you out.

text := whatsapp.TextMessage{
	Info: whatsapp.MessageInfo{
		Id: "id",
		RemoteJid: "[email protected]",
	},
	Text: "text",
}
err = wac.Send(text)

from go-whatsapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.