@themarkymark's Get Shit Done Contest EntrysteemCreated with Sketch.

in #blog6 years ago (edited)

bot.png

Among the many benefits of Steem as a platform, I have come to realize are the sharing of knowledge, experiences, and skills. One of the skills I attempted to acquire is programming in Python. I was first introduced to Python by @locikll when we were discussing more efficient ways of curating back in 2017. Later @carlgnash introduced me to SQL and @steemsql. Combining Python and SQL, and with the help of @locikll, @carlgnash, and @markangeltrueman I was able to write some scripts for curating purposes. However, I never managed to go beyond the basics of programming.

Before the end of 2018, I decided to put in more effort and time to learn and possibly master Python in 2019. New Year started out good, I got some books and a couple of Udemy courses. As part of this endeavor, I decided to write useful scripts as I continue learning. I started creating a discord bot for Archdruid Gaming. The bot would perform a simple task of fetching posts upvoted by @archdruid and post them in the designated channel, so that community members could also see the curated posts.

In no time, I was able to set up a VPS to host the bot, learned a little about Beem, wrote the script, and created the bot on discord. By Jan 10th, 2019 I had a working bot. Then it stopped working after a few hours. I tried to fix the problem many times, nothing seemed to be fixing the problem. It got very annoying, and I gave up. That served as a discouraging experience and I stopped continuing to learn Python altogether.

A couple of days ago I saw @themarkymark's #getshitdone contest post. That reminded me of my bot project and I decided to give it another try with a thought if I fail again, maybe I could ask @themarkymark to help.

After two days of carefully researching and troubleshooting, I finally came up with a solution. Deployed the scripts and now bot is running in three community discord servers and seems to be ok for now. Now I can move on with exploring Python programming language even more.

What was the problem?

Apparently, discord bot environment doesn't like its event loop to be stolen by other functions for a longer time. Especially, when there are API requests to outside sources, this kind of issue seems to happen. The most annoying part was the bot would work fine when started, and it would stop after running for 7-10 hours.

What was the solution?

I had to split the script up into two, one for discord actions, another for requests to get the data from the blockchain using Beem. One script gets the updated information from blockchain and saves in a simple text file. Another script reads the same file and if there is new information sends it to discord channel.

I will try to write up a step by step guide how to set up a bot with full codes if anybody is interested in using something like this. While it is a simple bot, once boilerplate is set-up, many more functions can be added.

Impact

One of the reasons I like Steem is here we can gain knowledge​, skills, experiences, motivations, ​and inspirations that can translate into our lives beyond Steem. I was introduced to Python on Steem, I decided to master it this year. This one bug was being an obstacle that almost made me give up. Getting it done gave me more confidence that with enough determination, time and effort any bugs can be resolved. Thanks for this contest this project is done. Moving on to the next one.

Sort:  

ǝɹǝɥ sɐʍ ɹoʇɐɹnƆ pɐW ǝɥ┴

˙ǝɹǝɥ noʎ ǝǝs oʇ pooפ ˙noʎ ʞuɐɥ┴

Good show. If you had kept it as one program, you would have likely had to similarly split the program, but via a multi-tasking library. That's a lot more work though.

Thank you. Yes, you are right. There were other options too, I went with the ​easiest one.

python is too hungry and only appeals to reverse high-level understanders

structured people

but you SHOULD what you should is take and get the tool that works for whatever you need to express

and make that work

Wow! Congratulations on "getting shit done" @geekgirl

So glad you found a solution!! -
Cuz I can imagine how many hours of troubleshooting that must have taken. And you're back on track with your goal.

I recently fell off the wagon on my daily goal and now getting back on track has been challenging. So it's nice to read all of @themarkymark's entries.

So motivating!

All the best in achieving your goal for 2019

Posted using Partiko Android

Can confirm the bot is working wonderfully in @Archdruid. Thank you so much!

the deeper you go the more headache u will get, this is why lot of men dont have hair on their head. Now u can setup that witness server.

Lol, that probably is not true. I don't see a need for a setting up a witness, we have plenty of witnesses.

Congrats @geekgirl!

I remember one of your posts, long time ago where you wrote that you want to learn Python and where I recommended you book ''Think Python'', I'm glad to see that you didn't give up! :)

I remember that. Reading books is good. But what I realized is learning by doing is much more effective.

Of course, doing examples is the most important :D


This post was shared in the Curation Collective Discord community for curators, and upvoted and resteemed by the @c-squared community account after manual review.
@c-squared runs a community witness. Please consider using one of your witness votes on us here

Hey, @geekgirl!

Thank you for your contribution to the crowd. We are the Steem community project dedicated to empowering The Wisdom of Crowds. You can find more about us on our official website or whitepaper and you can support us by voting for our witness and joining our curation trail on Steemauto . We are also inviting you to join Crowdmind Discord server. Don't forget to use the #crowdmind hashtag and happy crowdsourcing!

To listen to the audio version of this article click on the play image.

Brought to you by @tts. If you find it useful please consider upvoting this reply.

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63525.26
ETH 2583.76
USDT 1.00
SBD 2.80