https://github.com/elinazoldnere/discord-app-heic-to-jpeg
A bot for my private community server in Discord
https://github.com/elinazoldnere/discord-app-heic-to-jpeg
google-app-engine google-cloud-functions heic-to-jpeg java java-discord-api python spring-boot
Last synced: about 1 month ago
JSON representation
A bot for my private community server in Discord
- Host: GitHub
- URL: https://github.com/elinazoldnere/discord-app-heic-to-jpeg
- Owner: ElinaZoldnere
- Created: 2024-07-03T12:45:27.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-30T13:40:30.000Z (7 months ago)
- Last Synced: 2025-02-01T14:33:04.593Z (3 months ago)
- Topics: google-app-engine, google-cloud-functions, heic-to-jpeg, java, java-discord-api, python, spring-boot
- Language: Java
- Homepage:
- Size: 329 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Discord Bot (App) for HEIC Image Conversion
This repository contains a Discord App designed for automated conversion of HEIC format image files
to JPEG images within Discord text channels.## Overview
On Discord, HEIC files are treated as regular files rather than images, which prevents them from
being previewed and embedded in the text like other image formats. This can be inconvenient and
annoying, so I developed a custom solution to enhance the user experience.In this implementation, when a HEIC format attachment is uploaded in a text channel, the app
converts it to a JPEG image. The bot then posts the converted image in the same text channel.The project is developed with Java Spring Boot using Java Discord API and built with Gradle.
The app is deployed on Google App Engine.The image conversion service is separated from the app, developed as a Google Cloud Function written
in Python with Flask and using Pillow for image processing. It communicates with the
app via HTTP requests. Runtime Python 3.11.## Key Features
- Converts HEIC format images to JPEG in Discord.
- Developed with Java Spring Boot and Python Cloud Function, built with Gradle.
- Deployed on Google App Engine.## Project Structure
- `cloud-function/`: Image conversion script, executed in the cloud via Google Cloud Functions.
- `main.py`: Python script handling the image conversion logic.
- `requirements.txt`: Python dependencies for the Cloud Function.- `src/main/java/com/discordbot/`: The Java source code.
- `config/`: Configuration classes.
- `AppConfig.java`: Initializes OkHttpClient as a Spring Bean.
- `JdaInitializer.java`: Initializes JDA for a specific Discord bot using a token.
- `controller/HealthCheckRestController.java`: Responds to health check requests.
- `event/`: Event listeners.
- `EventListener.java`: Listens for Discord events.
- `EventListenerInitializer.java`: Sets up event listeners.
- `service/`: Core logic implementation.
- `DiscordService.java`: Handles image conversion.
- `FileService.java`: Manages file operations.
- `HttpService.java`: Handles HTTP requests.
- `ProcessConversionToJpeg.java`: Processes image conversion by delegating the task to the cloud function.
- `DiscordBotApplication.java`: Main class to run the Spring Boot application.## C4 model diagram
## Deployment
The deployment configuration for Google App Engine is specified in the app.yaml file. Manual instance
scaling is used to ensure continuous operation, as there is no direct traffic to the app (the app
does not have its own endpoints to serve). Google App Engine performs periodic health checks to
assess the app's liveness, so a REST controller is implemented to respond to these health checks.## Sensitive Data Handling
Sensitive data for the project is specified as environment variables. The handling of these variables
is as follows:- **Google Cloud Function:**
- Environment variables are set directly during the initial deployment process.- **Spring Boot Application:**
- Local Development:
- Environment variables are loaded from a `.env` file. The `application.properties` file contains
the configuration to load these variables (if present), and placeholders for reference.
- Deployment:
- Environment variables are specified in the `app.yaml` file.## Future Improvements
Potential future improvement ideas for the project:
- Add birthday reminder using an external database for storing user data.
- Add integration with ChatGPT for conversation generation.