Skip to main content

An easy generator of Captcha for Discord bots, creating embeds and images.

Project description

DisCaPty

DisCaPty is a Python module to generate Captcha challenge more easily and with more flexibility. Principally made for Discord bot developers but available for everyone!

PyPI PyPI - Python Version PyPI - Downloads

Installing

DisCaPty is available on PyPi!

python -m pip install -U discapty

You can also clone the module using git:

python -m pip install -U git+https://github.com/Predeactor/DisCapTy

It is still recommended to use PyPi.

Creating Captcha

DisCapTy include 3 differents types of Captcha style.

  • text: A Captcha that use plain text. This type is particular as it include a zero width space character between each letter/number to unallow the user to copy/paste the captcha.
  • wheezy: An image Captcha, pretty basic and easy to read. Configurable
  • image: An image Captcha, a bit more hard to read, less user friendly. Configurable.

You can choose which type to use when creating a Captcha object.

Example:

import discapty

captcha = discapty.Captcha("wheezy")
# You are initializing a Captcha object that is the "wheezy" type.
# If you want to show the image/captcha, use generate_captcha()
captcha_image = captcha.generate_captcha() # <_io.BytesIO object at XxXXX>

However, using the "text" type will not return a BytesIO object but a string.

import discapty

captcha = discapty.Captcha("text")
captcha_image = captcha.generate_captcha() # This will return a string, not a BytesIO object.

You can also easily create an embed.

import discapty

async def send_captcha(ctx):
    captcha = discapty.Captcha("image")
    captcha_image = discord.File(captcha.generate_captcha(), filename="captcha.png") # This is # # important to put this filename, otherwise Discord will send the image outside of the embed.
    # You can change it when generating the embed. 
    captcha_embed = captcha.generate_embed(ctx.guild.name)
    await ctx.channel.send(embed=captcha_embed, file=captcha_image)

Create more complex Captcha

The power of DisCapTy is how it let you customize your Captcha by using the setup function. When using this function, it is recommended to use number that are reasonable enough to not overload your machine. Image creation may take time if you abuse of it, and memory can also go high.

import discapty

def generate_captcha():
    captcha = discapty.Captcha("wheezy")

    # This function is what allow developers to set addition settings for their captcha, refer to the function's help for more parameters to use.
    captcha.setup(width=400, height=400, noise_color="#FF0000")

    return discapty.generate_embed() # Return the image with the settings that has been set.

Contact

You can join my Discord server for any help: https://discord.gg/aPVupKAxxP

DisCapTy is licensied under MIT: PyPI - License DisCapTy use the Roboto font as default font. This font is licensied under Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DisCapTy-1.0.2.tar.gz (102.4 kB view details)

Uploaded Source

Built Distribution

DisCapTy-1.0.2-py3-none-any.whl (102.0 kB view details)

Uploaded Python 3

File details

Details for the file DisCapTy-1.0.2.tar.gz.

File metadata

  • Download URL: DisCapTy-1.0.2.tar.gz
  • Upload date:
  • Size: 102.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for DisCapTy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4a575ee45c5b302f60b6d5812d5b013eccbf039789129baa7c7da3e1cf34ffe3
MD5 c159c484d3bb268c4534a70e75a44d00
BLAKE2b-256 6d1e7f12d304c2734201906cb5d0262dc58a323763f87e1d96ff993aaa10655e

See more details on using hashes here.

File details

Details for the file DisCapTy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: DisCapTy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 102.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for DisCapTy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a19ac501de3445cacdb0ac925e034dcff6c8a8fcbe4351eb8da058d1d9bfc986
MD5 0d2b60ab66d569f498cb1b50db664a00
BLAKE2b-256 e3e749b18434dd996db69751044bfb84c8c13afaf7f4761ab5104b26efe92eac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page