tgalal / yowsup

The WhatsApp lib
GNU General Public License v3.0
7.02k stars 2.23k forks source link

Write and Host Docs on Github Wiki, readthedocs.org or similar #1305

Open deepbrook opened 8 years ago

deepbrook commented 8 years ago

I've been trying to implement a bot using yowsup, and the amount of times I have wished I could just read a reference of what function/class takes what type, or is used for what, I honestly cannot count.

I don't think any mortal, non-developer should have to go through that ever again, hence I'm suggesting setting up a proper documentation; either on here, or readthedocs.org or wherever you feel is a good idea.

I'll gladly help out with writing the documentation, but I fear my understanding of the library is still quite limited. I can, however, work on a skeleton draft, where only the information and perhaps examples would have to be added.

Other than that, neat library, mate!

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

ftbarata commented 7 years ago

Hi @nlsdfnbch ! I totally agree with you. 100% ! I am facing the SAME problem. It seems that @tgalal just wrote the very little brief of the yowsup lib. It's absolutely impossible to understand what class have what methods and what data what methods expect to receive and what they return and what they are for. I honestly would like to know how the many people here help so much each other with this wiki provided by @tgalal . Or they are gods or they found documentation in somewhere. @nlsdfnbch did you find a good documentation?

deepbrook commented 7 years ago

I did not, no - however, after spending some time with the code I was able to roughly understand how messages are passed around. But as it stands now, it's not very intuitive/pythonic. Which isn't surprising, as far as I understand this entire code is based on php code.

ftbarata commented 7 years ago

Hi @nlsdfnbch thanks for replying. So, I am trying to get help for weeks here, asking people for help to integrate the sendclient with EchoLayer provided by @tgalal. I need very much a way to use the EchoLayer loop and be able to send message or media with something like pywhatsapp or sendclient without reconnecting and causing echolayer disconnects. Could you help me? Do you know how to do it? I've tried to mix sendclient and echolayer code but since I don't fully understand yowsup, I was not successfully. Thanks in advance.

deepbrook commented 7 years ago

I'm not sure I've quite understood what you're trying to do; I simply extended the basic echo client, by supplying a custom function in the ´OnMessage´ method. Technically, that example already handles most of the use cases for sending and receiving. I'm using yowsup for my whatsapp archiver and as a relay between telegram and WhatsApp.

Could you elaborate with more detail on what exactly you're trying to achieve? I'll help as much as I can. Cheers, Nils

ftbarata commented 7 years ago

Hi @nlsdfnbch !! Many thanks for replying me! Well, I am already using echo client / echo layer to receive message from whatsapp and send custom message I get from my database instead echoing. However, I need to send message or media without being the "response" situation. For example, while echo layer loop is connected and running, I need a way to send a "good morning" message or media to someone without disconnecting or breaking echolayer loop, got it? I tried pywhatsapp, wich is pretty simple and I loved it, and it would be perfect to my project, but since it makes a new authentication and send new connect signal broadcast, it breaks echolayer loop. Did you understand? I need very much your help because I already tried to learn yowsup but I was unable to do it myself. I don't know what layers to import, what callback to put and how to call this "new" callback to send message or media. The perfect scenario would be to adapt pywhatsapp code, if it is possible. Thanks again and I am ansious for your response!

deepbrook commented 7 years ago

Ah, ok. I believe I understand what you're trying to achieve. Essentially, you'll want a parallel running layer, to your echolayer (See the last bit in the architecture section of the docs). I believe you could even integrate it with the echo layer, but I believe a parallel layer would result in less cluttered code.

Parallel layers pass and receive the exact same data at the same time from upper and lower layers, hence this would allow you to send a message from a data base, while the echo layer still relays data autonomously (If @tgalal could quickly nod this off, I'd appreciate it).

The challenge would be to implement a loop which is triggered on something other than a received message - you'll have to take a dive into the code for that, once again. Although my guess would be to customize the loop() function, as seen in the sample app, under the section 'run.py II'

ftbarata commented 7 years ago

THanks @nlsdfnbch , the main problem is the "dive into the code". The documentation absense turns much higher the complexity of the understanding the lib to make these customizations you said. For example, what is the setProp method? What does it do? Where it is explained in the wiki? Same to PROP_ENDPOINT, PROP_DOMAIN and PROP_RESOURCE ... and EVENT_STATE_CONNECT...

tgalal commented 7 years ago

@nlsdfnbch See the problem is a lot of users here don't get the idea of what a library is. They insist on using the demos, or the command line client (which is also a demo) and adapt them for their projects, then complain that they can't get it to work.

I can't even remember how many time I got similar questions like that one by @ftbarata, which has absolutely nothing to do with:

@nlsdfnbch What you explained is true, however is not the "correct" solution. There is no "correct" solution or single way for the described problem. It depends on what one wants to do

If you want to send messages from a graphical user interface, you need to use another event loop associated with the UI toolkit you are going to use. If you need to create a command line client (like the demo), you need to run the command line input in a separate thread, to not block the incoming flow (see cli client demo). In both cases, one needs to read those methods' associated documentation, and not yowsup's.

In case of echo client @ftbarata is trying to use , there was no need in the demo to use neither a thread, nor a separate event loop, because it's just as simple as echoing back what it gets. So obviously cannot be used for this use case.

I do acknowledge the lack of sufficient documentation, but I believe most questions are in reality irrelevant to that.

ftbarata commented 7 years ago

Well, thanks @tgalal and @nlsdfnbch . I will TRY A LOT to do a paralell layer like he said...

deepbrook commented 7 years ago

Thanks for the explainer, @tgalal. Although I wouldn't quite state that his question doesn't have anything to do with how your lib works. I find it quite essential to understand how a library works, in order to use it properly in a project. And that's why it's unfortunate that simple things like doc strings are missing, because It somehwat promotes using the samples and customizing from there, instead of implementing it correctly (counting myself among those).

On the other hand I can absolutely understand that going back and adding doc strings to methods is about the last thing any sane individual wants to do in their spare time.

But that is why I offered a helping hand in this thread to begin with.