If you can fix the bot and get it running again, I will gladly welcome a pull request, but I just do not have the cognitive bandwidth between finals, the protests, and my upcoming internship to maintain the bot now that it no longer seems to work. I apologize.
With the closure of Twitter's free API, I no longer have the means to maintain this code even if I wanted to. Additionally, we are long past the point that COVID case statistics tracking is still important or relevant. I also have been merging in Dependabot PRs without testing them, so I'm unsure of the state of the code unless you go back to the last release build. Given all of these factors. I am archiving the repository. If you want to make your own version, you are free to fork it without fear of licensing, since the code is public domain.
Bot for posting information on spread of Coronavirus Disease 2019 (COVID-19) to Twitter and Discord. The official instance of this bot can be found at @COVID19Tracker.
-
Sign up for Twitter API access here and make note of your consumer key, consumer secret, access token, and access token secret. TWITTER WILL ONLY SHOW YOU YOUR ACCESS TOKEN AND ACCESS TOKEN SECRET ONCE, SO DON'T LOSE THEM. DO NOT SHARE THESE WITH ANYONE OR THEY CAN TAKE OVER YOUR TWITTER ACCOUNT.
-
Make a
credentials.py
file in the following format:
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
-
Run
Setup-nCoV.sh
. This will create your Python 3 virtual environment, install all required packages, create the launcher scripts to run the program without having to activate the virtual environment, create the cron job for the bot to run automatically, and test the script for you in notweet mode. -
Create your
config.txt
file, using config_example.txt as a base. The config file requires 9 entries to function correctly, in the following format:
[FLAG EMOJI]
[DICTIONARY KEY FOR DESIRED COUNTRY]
[OUTPUT NAME FOR COUNTRY]
[MINIMUM NUMBER OF DAYS TO CLIP OFF OF LEFT SIDE OF GRAPH]
[FILTER LIST] (comma-separated keylist if a 'country' is made up of multiple countries - NOT FOR 'World')
0
0
0
I advise you put the World
key in there somewhere, for obvious reasons.
- This bot can also post to Discord. In your Discord server settings, generate webhooks for whatever channels you want the bot to post in, and place each webhook URL on its own line in a
webhooks.txt
file.
Please note the bot will automatically overwrite your Twitter bio with a 'last updated' statistic. If you have a bio you want to use in addition to this, please create 'bio_top.txt' and 'bio_bottom.txt' files containing your desired information. The last updated count will appear between the text contained in these two files, both of which are optional.
You're done! The bot should now be working.
Cases, dead, and recovered counts are from the Johns Hopkins University CSSE tracker.'
This link leads to dashboards with visual maps as well as per-state statistics, in English, and sources information from the WHO, CDC, ECDC, NHC, DXY, 1Point3Acres, worldometers.info, BNO News, and The COVID Tracking Project. It appears to be updated by hand, and thus are not 'up-to-the-minute'.
Active cases count is derived by the following formula: (cases - dead - recovered = active)
Updates are time-and-datestamped based on time of data being fetched and posted. Time-and-datestamp does NOT refer to when the information was last updated. For that, see the links above.
Tweets are in the following format:
🕓MM/DD ##H #COVID19 #Coronavirus
🏳️😷X,XXX,XXX 🏥X,XXX,XXX 💀XXX,XXX 👍XXX,XXX
🏳️😷XXX,XXX 🏥XXX,XXX 💀XX,XXX 👍XXX,XXX
🏳️😷XXX,XXX 🏥XXX,XXX 💀XX,XXX 👍XXX,XXX
🏳️😷XXX,XXX 🏥XXX,XXX 💀XX,XXX 👍XXX,XXX
🏳️😷XXX,XXX 🏥XXX,XXX 💀XX,XXX 👍XXX,XXX
😷Total 🏥Active 💀Dead 👍Recovered
[IMAGE OF TIME-SERIES GRAPHS]
This bot also optionally can output to Discord in the form of embeds in webhook messages. Discord embeds are in the following format:
⚠️ Coronavirus Update ⚠️
🏳️ [COUNTRY NAME]: 🏳️ [COUNTRY NAME]: 🏳️ [COUNTRY NAME]:
😷 X,XXX,XXX (+XX,XXX) 😷 X,XXX,XXX (+XX,XXX) 😷 X,XXX,XXX (+XX,XXX)
🏥 X,XXX,XXX (+XX,XXX) 🏥 X,XXX,XXX (+XX,XXX) 🏥 X,XXX,XXX (+XX,XXX)
💀 XXX,XXX (+XX,XXX) 💀 XXX,XXX (+XX,XXX) 💀 XXX,XXX (+XX,XXX)
👍 XXX,XXX (+XX,XXX) 👍 XXX,XXX (+XX,XXX) 👍 XXX,XXX (+XX,XXX)
🏳️ [COUNTRY NAME]: 🏳️ [COUNTRY NAME]: 🏳️ [COUNTRY NAME]:
😷 X,XXX,XXX (+XX,XXX) 😷 X,XXX,XXX (+XX,XXX) 😷 X,XXX,XXX (+XX,XXX)
🏥 X,XXX,XXX (+XX,XXX) 🏥 X,XXX,XXX (+XX,XXX) 🏥 X,XXX,XXX (+XX,XXX)
💀 XXX,XXX (+XX,XXX) 💀 XXX,XXX (+XX,XXX) 💀 XXX,XXX (+XX,XXX)
👍 XXX,XXX (+XX,XXX) 👍 XXX,XXX (+XX,XXX) 👍 XXX,XXX (+XX,XXX)
🏳️ [COUNTRY NAME]: 🏳️ [COUNTRY NAME]: 🏳️ [COUNTRY NAME]:
😷 X,XXX,XXX (+XX,XXX) 😷 X,XXX,XXX (+XX,XXX) 😷 X,XXX,XXX (+XX,XXX)
🏥 X,XXX,XXX (+XX,XXX) 🏥 X,XXX,XXX (+XX,XXX) 🏥 X,XXX,XXX (+XX,XXX)
💀 XXX,XXX (+XX,XXX) 💀 XXX,XXX (+XX,XXX) 💀 XXX,XXX (+XX,XXX)
👍 XXX,XXX (+XX,XXX) 👍 XXX,XXX (+XX,XXX) 👍 XXX,XXX (+XX,XXX)
[IMAGE OF TIME-SERIES GRAPHS]
😷Total 🏥Active 💀Dead 👍Recovered
🕓 Last Updated: YYYY-MM-DD HH:MM UTC
In both cases, updates will contain graphs showing up to the last approximately 11 weeks of confirmed cases, active cases, deaths, and recoveries in your chosen countries, with a monimum bound of days set by your config file.
This bot will, if functioning normally, check for new data once every two hours, and only post when there is new data. If any problems arise, please report them to @Ellie the Tinkerer#7777 on Discord.
Credit to @Yuu6883 for helping write the web scraping code.
Credit to users on the Weaponsandstuff93 Discord server for helping devise the post format in early versions of the bot.
Credit to Ensheng "Frank" Dong (@Energeticodefish on Github) from the Center for Systems Science and Engineering at Johns Hopkins University for replying to my numerous emails concerning the JHU CSSE tracker.
Credit to the CDC for the official instance's Twitter profile picture.
This bot is powered by Python 3 and the Requests, Tweepy, pandas, discord-webhook, and matplotlib libraries.
Data tracked by this bot is Copyright 2020 Johns Hopkins University.
The Johns Hopkins University data tracked by this bot is provided to the public strictly for educational and academic research purposes. The data is built from publicly available data from multiple sources, that do not always agree. Both I and Johns Hopkins University hereby disclaim any and all representations and warranties with respect to the bot and related data, including accuracy, fitness for use, and merchantability. Reliance on the bot or data for medical guidance or use of the data in commerce is strictly prohibited by both me and Johns Hopkins University.