No description
Find a file
2026-02-08 11:34:16 -06:00
images Added some more detailed instructions 2022-10-26 10:19:46 -05:00
.gitignore Added initial logging 2023-06-22 09:59:51 -05:00
AppSettings.py A bit of cleanup 2026-02-08 11:34:16 -06:00
ComicLogger.py A bit of cleanup 2026-02-08 11:34:16 -06:00
Environment.py A bit of cleanup 2026-02-08 11:34:16 -06:00
MessageTesting.http #8: Moved title/link into content section to set it apart a bit better (#9) 2023-04-29 12:33:29 -05:00
PennyArcadeBot.py Added initial logging 2023-06-22 09:59:51 -05:00
README.md Added some Arch Linux specifics to README 2024-09-02 06:42:07 -05:00
XkcdBot.py Added initial logging 2023-06-22 09:59:51 -05:00

Deiussum.DiscordComics

This project contains some python scripts that can be used to post the latest XKCD and/or Penny Arcade comics to a discord channel.

Quick install instructions

  1. Create a webhook in Discord
  2. Clone this repo
  3. Create a .env file in the root folder of the repo or create environment variables for PENNY_HOOK and XKCD_HOOK that is set to the web hooks you created in step 1
  4. Install latest python 3.x
  5. Install the required python modules using pip
    • requests
    • pyquery
    • python-dotenv
  6. Setup a scheduler to run the XKCD/Penny Arcade scripts at regular intervals when the new comics are usually released

Detailed install instructions

Create a webhook in Discord

Before you can create a webhook in Discord, you will need to be in a role that has the Manage Webhooks permission. This can be setup under Server Settings -> Roles.

Mange Webhooks

To create a web hook in Discord, go to the "Edit Channel" of the channel you want the web hook to post in and select the Integrations option. Under web hooks you click on New Webhook. Give it a meaningful name and if you wish, you can also set the profile picture that will be used by the webhook.

Webhook

Use the Copy Webhook URL to copy the URL to your clipboard. The URL will be used below.

Clone the repo

Using your favorite git client, clone https://github.com/deiussum/Deiussum.DiscordComics.git.

If you have the git command line installed, you can simply type the following from whichever directory you want to create the project in:

git clone https://github.com/deiussum/Deiussum.DiscordComics.git

Create a .env file or create environment variables

Using your favorite text editor, create a file that looks something like so:

PENNY_HOOK=<paste in the webhook URL from your Penny Arcade webhook here>
XKCD_HOOK=<paste in the webhook URL from your xkcd webhook here>

Note that you can setup a single webhook and use the same URL for both of these. Using a separate webhook allows you to name them and give them their own profile pictures, though.

You can also setup environment variables with the same names and values. How you do this will depend on the OS you are using.

If you want to post the same comic to multiple endpoints, you can instead name the environment variables with an index number on the end. These must be sequential and start with 1. For example, if you wanted to post Xkcd to endpoints on 2 different discord servers, it might look something like so:

XKCD_HOOK1=https://webhook.url/1
XKCD_HOOK2=https://webhook.url/2

Install python 3.x

How you install Python depends on your operating system. Visit Python.org for instructions.

Install required python modules

You can install the required python modules by using the following command-line commands:

python -m pip install requests
python -m pip install pyquery
python -m pip install python-dotenv

Arch Linux note:

If you are using Arch linux and have installed Python using pacman, you may need pacman to install these modules as well using the following commands.

sudo pacman -S python-requests
sudo pacman -S python-pyquery
sudo pacman -S python-dotenv

Setup a scheduler

Setting up a scheduler depends on what operating system you are using. Each comic can be scheduled indidually, or you can create a script that runs them all. Currently, the comics that can be posted include:

  • Penny Arcade - python PennyArcadeBot.py
  • xkcd - python XkcdBot.py

New comics for these are posted on Mondays, Wednesdays, and Fridays. Penny Arcade seems to be published fairly regularly, but the exact xkcd publish time seems to be sporadic, so you may want to schedule it to try multiple times. The script is designed in a way that it can be run multiple times and will only make a new post to Discord if the comic has changed since the last time it posted to Discord.

Linux crontab example

If you are using Linux to schedule the comics. You can use cron. To edit your crontab file use:

crontab -e

To add a line to the crontab file, you can use something like this to run a script every hour on Mon,Wed,Fri:

0 * * * 1,3,5 python /home/username/path-to-script/script