Thursday, 10 December 2020

Release 0.4.3 - The End of Something Great

 


Hello my wonderful followers!

It is here... It is finally here. The end of this nightmarish semester is finally here.
I have to say the past two weeks have been really tough for me, with all the final assignments/ labs/ projects.... AND exams bearing and breathing down my neck as the due dates approached.

Needless to say, I got through it. Pulled a couple all nighters and multiple 14/16 hour days worth of work. It feels GOOD though. I found this semester to be the hardest/ most amount of work that needed to be done. Yet, I finished and cannot express how many things I have learned over the course of this semester. 
I have to give my koodos to the very knowledgeable and helpful professor HumphD (OSD600 - Open Source professor). Without him, and this course, I would never have entered the world of open source and have my transition into becoming an open source dev/ contributor go so smoothly. 

Anyways, back to the point. For my last PR of this wonderful course, I chose to do yet another issue for the repo of automating whatsapp web platform. This one was tougher than the last or any previous issues I've done for this repo. 

I think my biggest downfall is finding out how to get python and selenium to collaborate with me without an issue.


So. Let's start by explanation of what I had to do.

I had to open whatsapp. Once connection was established through the bot, I had to cycle through all individual chats and open them.
Once opened the chat info drop down had to be clicked and navigation to delete chat (of the opened already chat) was to be made. Once over the delete element (which is found using a CSS Selector), the element had to be clicked. 



Clicking the "outter" delete would trigger another pop-up box/event to be opened. The bot would have to wait for the presence of the element to be available. Navigates to the element using a CSS Selector and clicks the element.


I ran into problems with the above step because the bot would hang even after the element appeared. I contacted my friend Navpreet (maintainer of the repo) and asked him why this was happening. He quickly glanced at my code when we were on discord with him (late at night because he lives in India) and he explained I was not waiting for the element to become available. So as I mentioned above. The bot would have to wait for the presence of said element "delete" and then execute the follow up functions. He told me it was hanging because it was throwing an uncaught exception and did not know what to do after the exception was thrown. Interesting stuff to be honest. I would have to remember that for next time I contribute to his repo, or other projects :D

After adding that little function in. All I had to do was close the chat info with the function "close_info()". I tested it one final time and made my PR.

I noticed a small problem with the bot behaving strangely on other functionalities that were implemented previously.

I noticed that some of them were not working how they should have been and mentioned it to Navpreet. He said he is aware of this issue and it was happening because of whatsapp changed their CSS Selectors. Thus making pretty much all the main functions break since the selectors did not exist anymore. He thanked me for noticing it as well and said he will make an issue about this when he has time, or fix it himself. 


To be honest, I will probably help him over the winter break since we are buddies now.

Well. Now that I am done with OSD and all my exams. Which by the way could not have ended on the most perfect date than the 9th of December... because CYBERPUNK 2077 came out. AND let me tell you guys. WOW. what an amazing game it has been so far. I have only played about an hour because I was dead tired yesterday, but I was at a loss for words. 8 years in the making was well worth the wait.

Anyways, 

I would like to thank professor Humphrey one last time this semester for giving my colleagues and I the tools and knowledge to gain tremendous amounts of experience this semester and work on whatever we wanted and found enjoyable. 

THANK YOU!


For the last time this semester...

Till next time, 
XOXO,
Gossip Plamen

Thursday, 3 December 2020

Release 0.4.2 - Progression Tree

 

Hello fellow programmers/ followers.
I sincerely hope this past week has been treating you great, because I sure have gotten stomped to the ground due to various things in my academic career -cough- Game Dev... #ThanksGeorge
I also got shot down hard by someone in my personal life. But that is too personal for the internet.

So anyyyyways.......

This week is a little bit of a continuation of the plans I made for my open source development ventures last week. A little bit of a recap.. Last week I decided to pick a repo that I have contributed to in the past. Seeing as my schedule is super tight until the end of the semester, I decided to go back a month and revisit the automating whatsapp web platform. I picked two issues because one was easier than the other and I had created something similar.

Ok!

So I saw that most people on the issues that have been assigned have made little or no progress. I asked Navpreet (the owner/maintainer of the repo) if I could take this issue. He gave me the green light. Although, to be honest I already had started working on the issue before he said it is fine (I knew it would be fine). 

I was tasked with creating a function similar to one that already existed. I had to create a function to remove Administrative privileges from a person/people in a whatsapp group.

As I began working I first examined the steps I had to manually take to remove admin privileges in order to replicate them and adding them into the automation bot.
Since the main logic is being done by Selector constants I had to find the selectors that were responsible for removing admin status from a person in a group.


I inspected the element with the chrome dev tools and quickly found exactly what I was looking for (this took me a while in Release 0.2, but I knew what to look for now).


P.S. The steps you take to removing an admin all lead to using the same selector regardless.

Now that I had my selector. It was time to actually put it in the constants .py file that is used for everything.
GROUPS__REMOVE_ADMIN = (By.CSS_SELECTOR, '._1OwwW ._3oTCZ[title="Dismiss as admin"]')

After that was done it was time to start writing the actual code.

The first thing I had to do was to iterate through the groups and find group name with the passed in one. This is being done by querying the selector and looking for it to match with whatever element you are on. Once the group chat was open, the bot needed to open the group chat info and navigate to the participants section. From there it searches for the name(s) passed in to remove admin privileges from, this is done by finding if the admin logo is present on their name. Clicks their name box and selects "Dismiss as admin". 

Everything worked. there was a couple of bugs at first. I was not checking if the user of the group was already an admin or not and the bot started hanging because it was trying to find an element to click on that did not exist yet. Another problem I actually ran into was that I had to tweak the CSS selector a bit because it is the same selector for making an admin and removing an admin. This is why in the above snippet I decided to include the title as well so it does not create an admin by accident.

Now, that I was done with this feature I could hurry back to Navpreet and have him run it on his end. I submitted a PR and since Navpreet and I are somewhat acquainted from my previous contributions, he knows my secret love most hated feeling is towards python and everything python related. So he gave me a little praise to help me with the next big issue I was going to do for him.


Everything is going swell. My PR even got merged. ONTO better things... not really. OSD is probably my most enjoyed course right now. Everything else feels like such a drag and there is sooo much work.

Anyways this is where I end things for my ventures of open source this week. I have actually started working on my other issue for Navpreet but it is proving to be a little more difficult than I expected. 0.4 amiright?!

I am now going to crack open a beer and enjoy the rest of my night, and try not to think about stupid little details.


Till next time,
XOXO,
Gossip Plamen

Release 0.4.3 - The End of Something Great

  Hello my wonderful followers! It is here... It is finally here. The end of this nightmarish semester is finally here. I have to say the pa...