normen / whatscli

A command line interface for WhatsApp
588 stars 46 forks source link

Whatsapp multi-device support #51

Open adi-g15 opened 2 years ago

adi-g15 commented 2 years ago

Whatsapp recently provided a "Multi-device" feature, so we can use whatsapp - https://faq.whatsapp.com/general/download-and-installation/about-multi-device-beta/?lang=en

But whatscli currently can't connect when user is using this Multi-device feature, since it requires scanning QR code two times (as per my observation till now). Currently after scanning once whatscli crashes/stays but won't show another qr code, and reopening doesn't help much everytime one qr code.

Screenshot_20210919-113620

normen commented 2 years ago

I don't think this is supported in the upstream go-whatsapp library yet: https://github.com/Rhymen/go-whatsapp See this issue: https://github.com/Rhymen/go-whatsapp/issues/601

alon-z commented 2 years ago

Maybe use this? go-whatsapp dropped the issue

https://github.com/tulir/whatsmeow

normen commented 2 years ago

Maybe use this? go-whatsapp dropped the issue

https://github.com/tulir/whatsmeow

That looks very good, doesn't seem to be complete yet though. Thanks for the link. I won't get around to do the changes any time soon so if anyone wants to have a whack..

abbasudo commented 2 years ago

any plan to add this feature?

normen commented 2 years ago

any plan to add this feature?

Not more extensively than whats written here. You can send a PR if you want.

sfrique commented 2 years ago

Just to add here: https://github.com/Rhymen/go-whatsapp/issues/622 seems it will be deprecated in favor of https://github.com/tulir/whatsmeow

normen commented 2 years ago

Yeah, I saw that, I guess thats the best way forward. It will mean a lot of changes to whatscli as well but thats also a chance to clean up the message database part. But maybe tulir has other plans as well, he's got a nice matrix client for the command line, maybe he'll integrate whatsapp support, that would make whatscli obsolete then.

sfrique commented 2 years ago

I was thinking maybe the best is to write whatsmeow support for weechat but not sure how hard it is.

All those webapps use too much ram =/

normen commented 2 years ago

I was thinking maybe the best is to write whatsmeow support for weechat but not sure how hard it is. Yeah, I was looking into using weechat back when I wrote whatscli. Adding perl or python based scripts is easy, adding native plugins less so. With golang in the mix things probably won't get easier.

All those webapps use too much ram =/ Agreed. Plus god knows if my laptop is mining dogecoin or whatever for Mark Z while its open 🙄

normen commented 2 years ago

I'm currently looking into using whatsmeow in whatscli, it seems to be reasonable effort and a good chance to clean the ugly in whatscli. I hope I'll find enough time in the next days.

normen commented 2 years ago

Initial work has begun in the whatsmeow branch - things seem to be basically working, theres still work to be done to implement the old commands and support extended messages though.

sfrique commented 2 years ago

Initial work has begun in the whatsmeow branch - things seem to be basically working, theres still work to be done to implement the old commands and support extended messages though.

please let us know when it's safe to test it

normen commented 2 years ago

Well you can try it, it shouldn't break anything in your current install. It will create two databases in the current folder (not in the config/settings folder yet).

The main remaining issues are:

cetinajero commented 2 years ago

Initial work has begun in the whatsmeow branch

Thanks for that @normen!


  • Only basic text messages are received

As of e249b112b69f8683bb1f9ddc9fda3387fab12ed6, I do receive all basic text messages at login time but I don't receive any new message after it, is there currently a way to reupdate the message panel?

I'm executing the app with go run .

normen commented 2 years ago

Nah not really apart from logging out, deleting the database and logging in again.

jaitra1264 commented 2 years ago

any updates on the whatsmeow-branch , does it support multi-device?

cetinajero commented 2 years ago

any updates on the whatsmeow-branch , does it support multi-device?

Yes it does but it is a WIP

dostoievsky commented 2 years ago

I am willing trying to help on code, whats need to be done? Can we try set a TODO list @normen, so interessed people can try to help?

normen commented 2 years ago

I am willing trying to help on code, whats need to be done? Can we try set a TODO list @normen, so interessed people can try to help?

The main thing that needs to be done is storing received message info in a way that allows later recreating whatsmeows messages so extended info can be downloaded (e.g. Images etc). Currently we're storing messages in a backend-agnostic way. For downloading messages whatsmeow expects its own message "objects" and I didn't dig into whatsmeow too deep yet so I'm not sure how to best get from our data about the messages back to whatsmeows. In this thread I basically state whats missing, you'd have to dig into the code (and whatsmeow) anyway to get somewhere. Maybe look around in the code and ask me if anything is unclear.

normen commented 2 years ago

Theres also the general structure overview in the README for a general idea of what code does what: https://github.com/normen/whatscli/tree/whatsmeow#structure-overview

Its a bit outdated given that the backends are now completely separated from the session manager.

Timoyoungster commented 2 years ago

Is the whatsmeow branch usable right now?

dostoievsky commented 1 year ago

I am willing trying to help on code, whats need to be done? Can we try set a TODO list @normen, so interessed people can try to help?

The main thing that needs to be done is storing received message info in a way that allows later recreating whatsmeows messages so extended info can be downloaded (e.g. Images etc). Currently we're storing messages in a backend-agnostic way. For downloading messages whatsmeow expects its own message "objects" and I didn't dig into whatsmeow too deep yet so I'm not sure how to best get from our data about the messages back to whatsmeows. In this thread I basically state whats missing, you'd have to dig into the code (and whatsmeow) anyway to get somewhere. Maybe look around in the code and ask me if anything is unclear.

what about we use the lime protocol for that?

https://limeprotocol.org/

normen commented 1 year ago

Hm, it would fit but it sounds like its a bit overblown for this use case, also whatsmeow already keeps its own database with all that info, its just about having the right pointers in "our" database to grab it again later.

Ofc this layer of abstraction isn't strictly necessary but if I had implemented it properly in the first version of whatscli then the whatsmeow version would already be running now 😄

dostoievsky commented 1 year ago

@normen How can we debug the process while running it with go run .?

normen commented 1 year ago

Depends on your dev setup, I am using vim and debug the oldschool way, by using a lot of console output :)

In case you didn't follow the discussion, I think its best to rely completely on whatsmeows database and remove the abstraction, basically only keeping the UI part of whatscli. That way we'd be completely dependent on whatsmeow but we should be able to get results much quicker I suppose.

dostoievsky commented 1 year ago

By "rely completely on whatsmeows..." you mean we should delete the "messages" folder completly and re-write it as whatsmeows implementation?

I am not used to GO but I already read some of the code, the Whatscli UI is created almost at the main.go file, correctly?

So we must rely only on the "backends folder with whatsmeow implementation and rewrite the whole message application?

normen commented 1 year ago

Basically, yes. So this would simply be a whatsmeow frontend going along with its idiosyncrasies.

dostoievsky commented 1 year ago

Normen, I'll try to study to whatsmeow API and see if I can start something!

I guess this is the Go Horse solution, if I had any sucess contribuing to this I think we can discuss better abstractions to the project.

Thanks for the chating.