I created a Twitter Bot to Tweet Crypto News and Prices using Two FOSS Projects

TLDR: I'm combing the two projects together and will release a Python Twitter Cryptobot to rule them all. Check back on this post or my GitHub for updates.

Do Nerds Dream of Androids?

I was sitting in my System Administrator Workshop today feeling a bit bored. We were going over something that I know entirely too much about and my mind started to wander, I felt like I was in a meadow, a cool summer breeze caressing my cheeks (you can decide which ones 🤣), and the sound of birds chirping and tweeting their little hearts out. Then it hit me, "I need to make a Crypto Twitter Bot."

I had dabbled in Twitter bots using Python back in 2018 while on a train bound for Manhattan, so it wasn't a totally foreign concept. However, with age comes wisdom, and knowing that someone else brighter out there has probably built something close to what I needed already, I headed over to GitHub. I first decided to check out my bot but quickly realized that mine was too basic and unfit for the job. It was a simple Tweet THIS line from THIS text file every hour that tweeted Gruntilda quotes of Banjo-Kazooie fame. Its name was lovingly given as "GruntyBot", but again, it would not suit my purpose. What did suit my needs from GruntyBot was the Twitter Profile it used to be. I repurposed the account instead of creating a new one, generated new API keys, removed all the content using a tool through the Twitter API, and rebranded it as CryptoCondition (Boo! Your name sucks!).

After searching around back over at GitHub, I found two projects that did exactly what I wanted, but in different ways. The first project I found was MrCyrptoT's Crypto_Price Python Bot. This bot uses CoinGeko and CoinMarketCap to poll the markets and get a treasure trove of data. After a bit of tooling around and realizing that I couldn't use coins that have a hyphen in their name with CoinGeko, I disabled that portion of the bot to get the debugging to print the prices and what the Tweet would eventually look like. I have forked this on my GitHub profile and will be attempting to correct that issue to merge with the master branch.

untitled.gif

Once all that was working and tweeting the hourly prices to the account, I started looking for another bot that would tweet news stories from an RSS feed. I found one even better than what I thought I wanted. PeterDalle's twitterbot allows you to not only post from an RSS feed but also retweets other accounts based on specified hashtags. The only issue that I found with this bot was it uses only a single RSS feed. The way I worked around this was using RSSMix.com to combine the top Crypto News sites from around the web into a single XML feed. Once I added my hashtags and blacklist a few others, I aimed my bot at my API keys and set up a cron to run the script in different intervals as to not make the Twitter API angry. With a single follower (yours truly) my bot set out to engage with the Twittersphere.

My kitty Orion is the mascot! Though yawning might not project the right tone...

Within its first few hours, it gained 5 organic followers, multiple retweets, and likes from people in the Twitter Crypto communities. So why did I write this post? Well, I decided that since both of the projects are great and do what one might want to do in tandem just fine, what if they were combined? Since they are both open-source, I am able to remix the two into a single, powerful bot. I will of course submit any bug fixes to the original project and link back to them directly as they are both excellent tools in their own right.

Keep an eye out on this post or my GitHub for future updates. You really have to love open source and the communities revolving around them. Remember, it's okay to stand on the shoulders of giants but also remember to give back and allow others to sit upon your shoulders in the future.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now