1.11.31 • Published 3 years ago

@snowflake-snss/captcha-generator-custom v1.11.31

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
3 years ago

Captcha Generator is a Node library for quickly and easily generating captcha images. Forked from HaileyBot/captcha-generator for colorful alphanumeric captchas.

Sample

Installation

Use the package manager npm to install Captcha Generator

npm i captcha-generator-alphanumeric

Usage

Basic

// Import the module
const Captcha = require("captcha-generator-alphanumeric").default;

// Create a new Captcha object
//  - Optional argument to specify image height (250 to 400px, default 250)
//    - Image width is 400px
//  - Returned object will contain 4 properties
//    - "PNGStream" is a stream object for the image file in PNG format
//    - "JPEGStream" is a stream object for the image file in JPEG format
//    - "dataURL" is a data URL containing the JPEG image data
//    - "value" is the 6 character code the image contains
let captcha = new Captcha();
console.log(captcha.value);

Save to file example

const path = require("path"),
	fs = require("fs"),
	Captcha = require("captcha-generator-alphanumeric").default;

let captcha = new Captcha();
captcha.PNGStream.pipe(fs.createWriteStream(path.join(__dirname, `${captcha.value}.png`)));
captcha.JPEGStream.pipe(fs.createWriteStream(path.join(__dirname, `${captcha.value}.jpeg`)));

Discord Example

This example assumes you already have the core framework of a Discord Bot set up

const Captcha = require("captcha-generator-alphanumeric").default;

// Use this function for blocking certain commands or features from automated self-bots
function verifyHuman(msg) {
	let captcha = new Captcha();
	msg.channel.send(
		"**Enter the text shown in the image below:**",
		new Discord.MessageAttachment(captcha.JPEGStream, "captcha.jpeg")
	);
	let collector = msg.channel.createMessageCollector(m => m.author.id === msg.author.id);
	collector.on("collect", m => {
		if (m.content.toUpperCase() === captcha.value) msg.channel.send("Verified Successfully!");
		else msg.channel.send("Failed Verification!");
		collector.stop();
	});
}

License

This project is licensed under GPL-3.0

1.11.31

3 years ago

1.11.30

3 years ago

1.11.29

3 years ago

1.11.28

3 years ago

1.11.27

3 years ago

1.11.26

3 years ago

1.11.25

3 years ago

1.11.24

3 years ago

1.11.23

3 years ago

1.11.22

3 years ago

1.11.21

3 years ago

1.11.20

3 years ago

1.11.19

3 years ago

1.11.18

3 years ago

1.11.17

3 years ago

1.11.16

3 years ago

1.11.15

3 years ago

1.11.14

3 years ago

1.11.13

3 years ago

1.11.12

3 years ago

1.11.11

3 years ago

1.11.10

3 years ago

1.11.9

3 years ago

1.11.8

3 years ago

1.11.7

3 years ago

1.11.6

3 years ago

1.11.5

3 years ago

1.11.4

3 years ago

1.11.3

3 years ago

1.11.2

3 years ago

1.11.1

3 years ago

1.11.0

3 years ago