This project is a Discord bot that analyzes user messages to determine if they can be represented using symbols from the periodic table of elements. If a message qualifies, the bot responds with the decomposition of the message into periodic table symbols.
- Responds to messages in Discord channels.
- Checks if a message can be represented entirely using periodic table symbols.
- Sends a congratulatory message with the decomposition of the message if successful.
- Logs the decomposition to the console for debugging and verification.
- Python 3.8+ (for running natively).
- Docker and Docker Compose (for containerized usage).
- A Discord account and bot token.
- Required Python libraries (see
requirements.txt).
-
Clone the repository:
git clone https://github.com/yourusername/discord-p-table-bot.git cd discord-p-table-bot -
Set up a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the root directory and add your bot token:TOKEN=your_discord_bot_token
-
Enable the MESSAGE CONTENT INTENT for your bot in the Discord Developer Portal:
- Go to the Bot section of your application settings.
- Enable the MESSAGE CONTENT INTENT.
-
Run the bot:
python main.py
The bot is also ready to run in a Docker container. Ensure Docker and Docker Compose are installed on your system.
-
Clone the repository:
git clone https://github.com/yourusername/discord-p-table-bot.git cd discord-p-table-bot -
Create a
.envfile in the root directory and add your bot token:TOKEN=your_discord_bot_token
-
Start the bot using Docker Compose:
docker compose up -d
This command will:
- Build the Docker image.
- Start the bot container in detached mode.
-
To view logs from the running container:
docker logs -f <container_name>
Replace
<container_name>with the name of the container (e.g.,discord-p-table-bot_main). -
To stop the bot:
docker compose down
main.py: The main bot script.ptable.py: Contains thedecompose_into_symbolsfunction to break a message into periodic table symbols..env: File for storing the bot token (not included in the repository for security).requirements.txt: List of Python dependencies.Dockerfile: Configuration for building the bot's Docker image.compose.yml: Docker Compose file for managing the containerized bot.
Message:
Neon
Bot Response:
Congratulations! Your message can be written only using symbols from the periodic table! (`Ne`, `O`, `N`)
Console Log:
Decomposed message: Neon -> ['Ne', 'O', 'N']
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
