Discord Image Uploader is an efficient Python module designed to upload images to Discord via a webhook. The module ensures image validation, robust error handling, and implements efficient request streaming and concurrent retries for failed uploads.
To use the script, clone the repository or download and unpack the latest release, the run:
python src/discord_aiu.py --webhook_url <your webhook>
You may also change the hardcoded webhook URL in the script itself.
To contribute, install Discord Image Uploader, use PDM (Python Development Master):
-
Install PDM:
- Follow the installation instructions here.
-
Clone the Repository:
- Clone the
Discord Image Uploaderrepository to your local machine.
- Clone the
-
Install Dependencies:
-
Navigate to the repository's root directory and run:
pdm install
-
-
Configure Webhook URL:
- Replace
YOUR_WEBHOOK_URL_HEREinWEBHOOK_URLwith your Discord webhook URL.
- Replace
-
Place Images:
- Place images in
./images/directory.
- Place images in
-
Run the Module:
- Execute
pdm run ./src/discord_aiu.py. The module will validate and upload the images, logging the process.
- Execute
-
Check Logs:
- Review
image_uploader.logfor logs and metrics related to the uploads.
- Review
-
Request Streaming: Utilizes
requests.Sessionfor efficient connection handling. -
Session Reuse: The same session is used for resending failed images, ensuring connection reuse.
-
Concurrent Retries: Failed images are retried concurrently using
ThreadPoolExecutor. -
Image Validation: Validates image size and dimensions before upload.
-
Error Handling: Appropriately logs errors.
-
Periodic Metrics Logging: Logs metrics periodically during the upload process.
This project is licensed under the GNU Affero General Public License (APL).