Skip to content

A simple Discord bot to fetch schedule-related tweets

License

Notifications You must be signed in to change notification settings

Steeven9/ScheduleTweetBot

Repository files navigation

ScheduleTweetBot

License C/C++ CI Lines

A simple Discord bot to fetch schedule-related tweets and spaces to feed our Hololive and Nijisanji calendars.

Setup

  1. Obtain a Discord bot token.

  2. Clone the repo and install the requirements:

    pip install --no-cache-dir -r requirements.txt
  3. Set the BOT_TOKEN and API_URL environment variables with the token from step 1 and the blooop URL respectively.

  4. Customize the configuration for scraping and notifying: edit the data.py file and fill in all the values.

  5. Finally, run python main.py. If everything went well, you should see an output similar to this:

    2023-02-18 00:26:56 [NAME] Loaded <n> extra pings
    2023-02-18 00:26:56 [NAME] Logged in as <your bot name and ID>

Usage

The bot automatically sends new tweets in the specified channel every 60 seconds (the timeout is configurable in main.py), pinging the specified role if any keyword matches. The watched talents and keywords can be set in the data.py file.

Optionally you can also use /fetch to fetch and display new tweets and spaces manually. If you don't see the slash command in your server, wait around one hour to allow it to sync, or check that you invited the bot with the applications.commands scope.

The already scraped tweets and spaces are saved each time so you won't see the same one twice; by default the IDs are written in the config/[NAME]_tweets.ini and config/[NAME]_spaces.ini files (configurable in main.py as well).

Run in Docker

Create a .env file with the environment variables mentioned in step 3, then build or pull the image from Dockerhub and run it:

    docker build . -t scheduletweetbot
    docker run --name scheduletweetbot --env-file .env scheduletweetbot

Credits

Logo by the one and only DuDuL!

Twitter data is provided by blooop.

Huge thanks to the teams of KFP | The Office and Nijisanji EN Schedule Team for helping with debugging and feature suggestions.