-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0e39f
commit 30073b3
Showing
1 changed file
with
34 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,52 @@ | ||
# 🎉 Discord Random Image Bot (Recuerdate) | ||
# 🤖 Hall of Fame with Google Drive CSV Integration 📊 | ||
|
||
## 🚀 Overview | ||
Welcome to the **Hall of Fame** project! This bot fetches messages and images from a CSV file stored in Google Drive and posts them to a specified Discord channel. | ||
|
||
The **Discord Random Image Bot** is your go-to tool for spicing up your Discord server! This bot posts random image URLs from a CSV file hosted on Google Drive, directly into your chosen channel at intervals you set. It's fully customizable, Docker-ready, and super easy to use! | ||
## 🌟 Features | ||
|
||
### ✨ Features | ||
- **Fetch Data from Google Drive**: The bot reads a CSV file stored on Google Drive. | ||
- **Message Filtering**: Only fetches and posts messages with **8 or more reactions**. | ||
- **Flexible Posting**: Posts messages to a Discord channel at a specific time every day. 🕒 | ||
- **Custom Message Format**: Outputs messages in the format: `name + message + message_link + image_url (if available)`. | ||
|
||
- 🎲 **Random Image Posting**: Automatically shares a random image URL from a Google Drive CSV file. | ||
- ⏲️ **Customizable Interval**: Set how often the bot should post using an environment variable. | ||
- 🐳 **Dockerized**: Simple to deploy anywhere Docker runs. | ||
- 🔐 **Secure Configuration**: Manage your sensitive data securely with environment variables. | ||
## 🚀 Getting Started | ||
|
||
## 📚 Table of Contents | ||
### 1. Prerequisites | ||
|
||
- [✨ Features](#-features) | ||
- [📦 Prerequisites](#-prerequisites) | ||
- [🛠️ Setup](#️-setup) | ||
- [🔗 Google Drive Setup](#-google-drive-setup) | ||
- [🤖 Discord Bot Setup](#-discord-bot-setup) | ||
- [🌍 Environment Variables](#-environment-variables) | ||
- [▶️ Running the Bot](#️-running-the-bot) | ||
- [🐋 Build the Docker Image](#-build-the-docker-image) | ||
- [🚀 Run the Docker Container](#-run-the-docker-container) | ||
- [🎨 Customization](#-customization) | ||
- [🐞 Troubleshooting](#-troubleshooting) | ||
Before running the bot, make sure you have the following: | ||
|
||
## 📦 Prerequisites | ||
- **.NET Core SDK** installed. | ||
- **Google Cloud Platform** account with a project that has access to Google Drive API. | ||
- **Discord Bot Token**: You can create one by following the [Discord Developer Portal](https://discord.com/developers/applications). | ||
- **CSV File on Google Drive** containing your data. | ||
|
||
Before you get started, make sure you have the following: | ||
### 2. Environment Variables | ||
|
||
- 🐋 [Docker](https://www.docker.com/get-started) installed. | ||
- 🤖 A [Discord bot token](https://discord.com/developers/applications) from the Discord Developer Portal. | ||
- 🌍 A [Google Cloud Project](https://console.cloud.google.com/) with the Google Drive API enabled and your `credentials.json` downloaded. | ||
Set the following environment variables to configure your bot: | ||
|
||
## 🛠️ Setup | ||
|
||
### 🔗 Google Drive Setup | ||
|
||
1. **Create a Google Cloud Project**: | ||
- Head over to the [Google Cloud Console](https://console.cloud.google.com/). | ||
- Enable the Google Drive API. | ||
- Generate OAuth 2.0 credentials and download the `credentials.json` file. | ||
|
||
2. **Upload Your CSV File**: | ||
- Upload a CSV file containing image URLs to Google Drive. | ||
- Share the file with the email linked to your Google Cloud project. | ||
|
||
3. **Get the File ID**: | ||
- Right-click on your CSV file in Google Drive and select "Get link." | ||
- Extract the file ID from the URL (e.g., `1A2B3C4D5E6F7G8H9I`). | ||
|
||
### 🤖 Discord Bot Setup | ||
|
||
1. **Create Your Bot**: | ||
- Go to the [Discord Developer Portal](https://discord.com/developers/applications). | ||
- Create a new application and add a bot to it. | ||
- Copy the bot token for later use. | ||
|
||
2. **Invite the Bot to Your Server**: | ||
- Generate an OAuth2 URL with the bot and the necessary permissions. | ||
- Use this URL to invite the bot to your Discord server. | ||
|
||
### 🌍 Environment Variables | ||
|
||
You'll need the following environment variables to configure your bot: | ||
|
||
- **`DISCORD_BOT_TOKEN`**: Your Discord bot token. | ||
- **`DISCORD_CHANNEL_ID`**: The ID of the channel where the bot will post images. | ||
- **`GOOGLE_DRIVE_FILE_ID`**: The Google Drive file ID for your CSV. | ||
- **`GOOGLE_CREDENTIALS_PATH`**: Path to your `credentials.json` inside the Docker container (usually `/app/credentials.json`). | ||
- **`POST_INTERVAL_SECONDS`**: The interval (in seconds) between each image post. | ||
|
||
## ▶️ Running the Bot | ||
|
||
### 🐋 Build the Docker Image | ||
|
||
To build the Docker image, navigate to the project directory and run: | ||
|
||
```bash | ||
docker build -t discord-bot-example . | ||
```plaintext | ||
DISCORD_BOT_TOKEN=your-discord-bot-token | ||
DISCORD_CHANNEL_ID=your-discord-channel-id | ||
GOOGLE_DRIVE_FILE_ID=your-google-drive-file-id | ||
GOOGLE_CREDENTIALS_PATH=path-to-your-google-credentials.json | ||
POST_TIME=HH:mm:ss (time in Spain to post) | ||
``` | ||
|
||
### 🚀 Run the Docker Container | ||
|
||
Run the container with the necessary environment variables: | ||
|
||
```bash | ||
docker run -e DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN" \ | ||
-e DISCORD_CHANNEL_ID="YOUR_CHANNEL_ID" \ | ||
-e GOOGLE_DRIVE_FILE_ID="YOUR_FILE_ID" \ | ||
-e GOOGLE_CREDENTIALS_PATH="/app/credentials.json" \ | ||
-e POST_INTERVAL_SECONDS="30" \ # Adjust the interval as needed | ||
discord-bot-example | ||
``` | ||
### 3. CSV File Structure | ||
|
||
Make sure to replace `"YOUR_BOT_TOKEN"`, `"YOUR_CHANNEL_ID"`, and `"YOUR_FILE_ID"` with your actual values. Adjust the `POST_INTERVAL_SECONDS` variable to control how often the bot posts. | ||
Your CSV file should have the following columns: | ||
|
||
## 🎨 Customization | ||
- **name**: The name of the person or bot. | ||
- **message**: The content of the message. | ||
- **message_link**: A link to the original message. | ||
- **image_url**: (Optional) A link to the image. | ||
- **has_spoilers**: Whether the message contains spoilers. | ||
- **total_reactions**: The number of reactions. | ||
|
||
- **Change the Posting Interval**: Modify the `POST_INTERVAL_SECONDS` environment variable to set how often the bot should post. | ||
- **Update the Image List**: Simply update the CSV file on Google Drive—no need to restart the bot! | ||
|
||
## 🐞 Troubleshooting | ||
## 🛠️ Customization | ||
|
||
- **Bot Not Posting?**: | ||
- Ensure the bot has the correct permissions in the Discord channel. | ||
- Check the bot’s logs for any error messages. | ||
You can easily modify the bot's behavior by editing the `Program.cs` file: | ||
|
||
- **Can't Access Google Drive File?**: | ||
- Double-check that the file is shared with the correct Google service account. | ||
- Ensure the file ID is correct. | ||
- **Posting Time**: Change the `POST_TIME` to adjust when the bot posts. | ||
- **Message Format**: Modify the message format in the code to suit your needs. |