/xkcdbot

A reddit bot that automatically links xkcd comics in the /r/xkcd subreddit 🤖

Primary LanguagePythonMIT LicenseMIT

XKCD Bot

A bot for /r/xkcd that posts detailed comments about xkcd comics

About The Project

After seeing this suggestion on the /r/xkcd subreddit, I began working on this bot. It is intended to be a non-intrusive bot that provides a detailed and well formatted comment with information regarding the relevant comic.

It is currently running 24/7 in the cloud. You can find the bot at /u/BobbyTablesBot.

Example

There are two ways to use the bot.

  • The first way is to post a comment in /r/xkcd with the number of the xkcd comic you would like to link prefixed by an exclamation mark (!) or a pound sign (#).
    Examples:

    !327

    or

    #327

    or even

    Show me !327

  • The second way is to mention the bot from any subreddit with the number of the xkcd comic you would like to link. If the bot is mentioned, the comic number does not need to be prefixed.
    Examples:

    /u/BobbyTablesBot 327

    or

    /u/BobbyTablesBot !327

    or even

    Hey /u/BobbyTablesBot, can you link me 327?

In any of the previous cases, the bot would respond with:

327: Exploits of a Mom
Alt-text: Her daughter is named Help I'm trapped in a driver's license factory.
Image
Mobile
Explanation

xkcd.com | Feedback | Stop Replying | GitHub | Programmer

Getting Started

To host your own xkcd bot, follow these simple example steps.

Prerequisites

  • Python 3.8
  • A Reddit Account

Installation

  • Clone the repo

    git clone git@github.com:joeyvanlierop/xkcdbot.git
    
  • Create an app here

    • Create a copy of config.example.json and rename it to config.json
    • Paste the appropritate credentials into the newly created config.json
    • Make sure to also add an appropriate user agent in the config.json
  • Install the requirements

      pip install -r requirements.txt
    

Running the bot

  • From the base directory run:

      python -m bot.bot
    

Running the tests

  • From the base directory run:

      python -m unittest
    

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT