Quick bot I made for our discord that reports numbers for Covid-19 from https://www.worldometers.info/coronavirus/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Alex Huddleston e1a82655cf Quick patch to remove debug code. 1 year ago
config Refactored database integration code to be more modular, updated template config. 1 year ago
lib Quick patch to remove debug code. 1 year ago
.gitignore Postgres database fully integrated. Should be merged with master. 1 year ago
Dockerfile Able to get reporting to semi-work with database input. Need to fix forced capitalization, move away from postgres to sqlite to minimize local debugging setup. 1 year ago
Dockerfile_report Able to get reporting to semi-work with database input. Need to fix forced capitalization, move away from postgres to sqlite to minimize local debugging setup. 1 year ago
Pipfile Able to get reporting to semi-work with database input. Need to fix forced capitalization, move away from postgres to sqlite to minimize local debugging setup. 1 year ago
README.md Updated README. 1 year ago
covid_bot.py Refactored database integration code to be more modular, updated template config. 1 year ago
covid_report.py Refactored database integration code to be more modular, updated template config. 1 year ago
docker-compose.yml Modified docker-compose.yml to allow restarting after system reboot. 1 year ago

README.md

COVID-19 Discord Bot

It's just reporting some numbers and stats from https://www.worldometers.info/coronavirus/

Configuration

You should copy the template_config.json from the config/ directory of this project to config/config.json and modify the values present.

You should also create a file called pgdb.key in the config/ directory with one line defining the password to be used for the database.

If you're using the docker-compose setup, which I highly recommend, you should only need to worry about the following variables:

  • api_key
  • report_channel_id
  • report_timezones
  • report_selections
  • report_top_number

api_key

Follow the link in the template config to learn how to set up a bot user with Discord's API. Then put the api_key value in place of that URL in the config.

report_channel_id

This ID specifies the channel you want the bot to send periodic reports to. You can get that ID by enabling developer mode in Discord, right clicking the channel you want to report to, and clicking "Copy ID"

report_timezones

This shouldn't be a plural variable but here we are.

This variable sets the timezone that the reporter will use to determine what times to give reports at.

report_times

This is an array of numbers in military time specifying the times the bot is to send a report to the specified channel.

report_selections

This is an array of strings that specified which selections from the table to include data from in the report.

report_top_number

The report will also include a "ranking" of the number of cases per selection. This specifies how many from the top number of cases will be shown.

Ex: 5 will show the top 5 cases currently.

Setup

Please for the love of god just use the docker-compose.yml because I don't want to explain how to set up pipenv and postgres again.

docker-compose.yml

You should be in the root directory of this project and issue:

sudo docker-compose up --build -d

That will build the images for the containers needed and start the cluster.

Usage

The bot does two things:

  • send periodic reports to a specified channel
  • respond to commands with speified data

Reports

Using the values specified in the config file, the bot will generate reports from the data that has most recently been parsed and send that information as a report to the specified channel. It should by default look something like this:

Selection: USA
Total Cases: 311,357
New Cases: 34,196
Total Deaths: 8,452
New Deaths: 1,048
Total Recovered: 14,741
Active Cases: 288,164
Serious Critical: 8,206
Total Cases / One Mil: 941

Selection: Total
Total Cases: 1,201,473
New Cases: 84,812
Total Deaths: 64,691
New Deaths: 5,517
Total Recovered: 246,383
Active Cases: 890,399
Serious Critical: 42,288
Total Cases / One Mil: 154.1

# 1
USA: 311,357
# 2
Spain: 126,168
# 3
Italy: 124,632
# 4
Germany: 96,092
# 5
France: 89,953

Commands

All commands are appended with !. For example, if I want to use the report command I would say !report [selection].

!report

This command takes the second argument as a selection from the table. As an example, here is something similar to the response you would get for sending !report taiwan:

Selection: Taiwan
Total Cases: 355
New Cases: 7
Total Deaths: 5
New Deaths: 
Total Recovered: 50
Active Cases: 300
Serious Critical: 
Total Cases / One Mil: 15

!top

This command takes hte second argument as the number of top selections to report cases of. For example, at the time of writing the command !top 5 would produce:

# 1
USA: 311,357
# 2
Spain: 126,168
# 3
Italy: 124,632
# 4
Germany: 96,092
# 5
France: 89,953

Contact

If you have any questions or need help setting up (or want to report a bug), you can contact me in the following places most effectively:

Discord: shadow8t4#8276

Telegram: @shadow8t4

Matrix: @shadow8t4:matrix.werefox.dev