As a newbie to coding, I was also introduced to Twitter, via the #100DaysOfCode tag. From there, I found #WomenWhoCode, #GirlsWhoCode, and much more recently #HelpMeCode all retweet your posts. This really helped me meet new people, learn, and grow from the coding community around me. These hashtags are a great way to promote and support those who use them. With this in mind, I realized I didn't really know of any other veterans in the coding community. So, I started playing with the idea of building a bot to help. I started using #VetsWhoCode a few months back, but that wasn't going to be enough to build a community. So, the planning began.
Before doing any project you have to know things. You don't have to know everything, but it helps to know the basics.
First off, I needed to know what language I planned to use. As I have solely been learning Python, this was the obvious choice.
From there I needed to know where I was going to save my repo. I chose GitHub over GitLab, based solely on my own familiarity with GitHub.
I also knew I would need Heroku, to do something. I'm still not super sure what it's doing, other than hosting, but it's there. It also caused me a lot of frustration because I had no understanding of how it works or what to do in order to host my bot.
Apply for the dev with the account that will run the bot. This may be obvious to some, but I originally applied with my personal account. The keys you receive with the dev account are only for the account you applied with.
Using the Python module
Tweepy was new to me. It made the script for the bot very concise and short.
I had also never used environment variables. The variables were very frustrating to me. This tweet sums up my thoughts.
Liquid error: internal
I have since learned more about environments and the use of
Once I had the script done and pushed to GitHub, I thought I was pretty much done. I was sadly mistaken.
I learned more, dealing with Heroku than I did writing the actual bot.
Every Heroku thing needs a
Procfile, which contains something about
In order to work, Heroku must identify your language(s). To do this, there are certain files your repo must have in order to be viewed as a [insert your language(s)].
For Python, I required a
setup.py. For reference, their contents are below.
from os import environ from flask import Flask app = Flask(__name__) app.run(host='0.0.0.0', port=environ.get('PORT'))
From here, everything was loaded and now the bot should work, right? No. Very wrong. I knew the last thing to the bot was to make sure it kept running. To be honest, it still isn't running constantly and I don't know why. In order to try, I set up the Heroku scheduler add-on to run every 10 minutes. It asked for a command and some googling and guessing led me to
$ Heroku run retweet.py. It works, I think. Then again, the tweets aren't always getting retweeted.
Edit: Turns out, Heroku scheduler desired
python retweet.py not
heroku run retweet.py.
Liquid error: internal
- Get the bot to run 24/7/365 with minimal downtime
- Build tests
- Decide on blocking words or not
Vicki Langer@vicki_langerOn second thought, should I make the bot screen tweets?
Every time I think of a word, I realize there is a way to use it in a perfectly acceptable way.
I think ________ is an unacceptable thing to retweet about.
Wait, what if they were tweeting against _______? twitter.com/vicki_langer/s…18:43 PM - 31 Dec 2019Vicki Langer @vicki_langerI’m setting up @VetsWhoCodeBot to avoid retweeting offensive stuff. I found a list, but it’s way too strict Is there a list out there that I can use? #VetsWhoCode #WomenWhoCode
A link to the bot on Twitter