Yakiyo / welpy

Generating dynamic welcome images with user avatars in Carl-bot's welcome messages.

Home Page:https://welpy.deta.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welpy

Generating dynamic welcome images with user avatars in Carl-bot's welcome messages.

Carl bot is a great bot with tons of features, but it lacks the ability to generate welcome messages with a custom image with the user avatar. To resolve this issue in the Tsurekano Discord Server, I made a custom bot but with Heroku closing their free trial, the bot was shut down. So in response to that, I created welpy, a REST api with python and Pillow that generates dynamic images with user avatars. This is only available for the Tsurekano Discord Server and since the image is hardcoded, I don't believe it can be used anywhere else anyway. For self hosting please refer to this section.

Usage

Make a get request with a id param specifying the user's discord id

GET /img?id=012345678912345678

Returns: image/png

On any error, it just returns the base empty image since it is not possible to customize carl bot from the user end to handle errors.

Self-Hosting

Its pretty straight forward and works in a simple manner. The entry point is main.py where it handles the incoming http requests. On a GET request to the img endpoint, it takes the id param and fetches info from discord on that user (see fetch.py). It then passes the user info to the image constructing function (at image.py) and does required modifications and returns the image.

Steps

  1. Fork this repo.
  2. Replace welcome.png with your background image.
  3. With a bit of python knowledge, you can fiddle around with image.py and make the image show up as you want. If you don't know enough python, you can use a image thats similar to the current image so that even if the avatar shows up in the same spot, it looks cool. Or just put some effort and learn python. Its pretty cool and you can flex to your friends.
  4. Create a file named .env and add a discord bot token, this is required for making requests to discord.
DISCORD_TOKEN=your-token-here
  1. The repo is configured to work with Deta Space. Read more on deploying to deta space here

Demo Usage

https://welpy-1-p4917091.deta.app/img?id=695307292815654963

Author

welpy © Yakiyo. Authored and maintained by Yakiyo.

Released under MIT License

About

Generating dynamic welcome images with user avatars in Carl-bot's welcome messages.

https://welpy.deta.dev

License:MIT License


Languages

Language:Python 100.0%