Comments (13)
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.
Thanks man! I'll be sure to check it out soon.
from go-whatsapp.
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.
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.
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.
from go-whatsapp.
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.
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.
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.
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.
I still don't see anything getting printed to the console and I can also still only send 1 message
from go-whatsapp.
Without further information we cant´t help you. Ensure that you pulled from the repo or clone it again.
from go-whatsapp.
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)
- No Online Acknowledge HOT 1
- How to encrypt chats data
- Any way to update client's status through api HOT 5
- invalid media hmac for audio messages, sended with drag-n-drop HOT 1
- cannot unmarshal array into Go value of type map[string]interface {} HOT 2
- Imposible scan the api qrcode from Whatsapp Bussines after today updates HOT 6
- Error after scan QR Code HOT 6
- I created an api but it has an error
- error creating connection: couldn't dial whatsapp web websocket: websocket: bad handshake HOT 3
- multidevice support HOT 1
- qrcode scan issue from Whatsapp Bussines after today update HOT 4
- I understand the code was abandoned ? HOT 1
- Use this API to send messages
- > error logging in: error during login: error decoding login resp: json: cannot unmarshal array into Go value of type map[string]interface {} HOT 2
- Is it possible to make the instance occupied 30-50mb RAM?
- Error try login
- websocket bad handsake HOT 3
- I also have a new version,And update in real-time
- new function Check is whatsapp number or not HOT 1
- is whatsapp registeration available?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-whatsapp.