Coder Social home page Coder Social logo

welpy's Introduction

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

welpy's People

Contributors

yakiyo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

xiaotang0126

welpy's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.