
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@itsreimau/ckptw-mod
Advanced tools
This package is a fork of @mengkodingan/ckptw with enhanced WhatsApp features via baileys-mod. All original ckptw functions remain intact—refer to the original docs for complete documentation. This README only covers additional/modified features.
npm install @itsreimau/ckptw-mod
const { Client, Events, MessageType } = require("@itsreimau/ckptw-mod");
// Initialize client with basic configuration
const bot = new Client({
prefix: "!",
printQRInTerminal: true,
readIncommingMsg: true
});
// Client ready event
bot.ev.once(Events.ClientReady, (m) => {
console.log(`Bot ready as ${m.user.id}`);
});
// Basic commands
bot.command("ping", async (ctx) => ctx.reply({ text: "pong!" }));
bot.command("hi", async (ctx) => ctx.reply("Hello! String replies work too!"));
// Message handlers
bot.hears("test", async (ctx) => ctx.reply("test 1 2 3 beep boop..."));
bot.hears(MessageType.stickerMessage, async (ctx) => ctx.reply("Cool sticker!"));
bot.hears(["help", "menu"], async (ctx) => ctx.reply("Array matching works!"));
bot.hears(/(using\s?)?regex/, async (ctx) => ctx.reply("Regex matching works!"));
// Start the bot
bot.launch();
const { Client, Events } = require("@itsreimau/ckptw-mod");
const bot = new Client({
prefix: "!",
printQRInTerminal: true,
readIncommingMsg: true
});
// Client ready event
bot.ev.once(Events.ClientReady, (m) => {
console.log(`Bot ready as ${m.user.id}`);
});
// Message handling via events
bot.ev.on(Events.MessagesUpsert, (m, ctx) => {
if (m.key.fromMe) return;
if (m.content === "hello") {
ctx.reply("hi 👋");
}
});
bot.launch();
ClientOptions {
prefix: Array<string> | string | RegExp; // Bot prefix(es)
readIncommingMsg?: boolean; // Mark incoming messages as read (default: false)
authDir?: string; // Path to auth directory (default: './state')
printQRInTerminal?: boolean; // Display QR in terminal (default: false)
qrTimeout?: number; // QR regeneration timeout in ms (default: 60000)
markOnlineOnConnect?: boolean; // Mark online on connect (default: true)
phoneNumber?: string; // Bot phone number with country code (e.g. '62xxx')
usePairingCode?: boolean; // Use pairing code instead of QR (default: false)
customPairingCode?: string; // Custom pairing code
selfReply?: boolean; // Allow bot to respond to itself (default: false)
WAVersion?: [number, number, number]; // Custom WhatsApp version
autoMention?: boolean; // Auto-convert @mentions (default: false)
autoAiLabel?: boolean; // Auto AI labels for bot messages (default: false)
authAdapter?: Promise<any>; // Custom auth adapter
browser?: WABrowserDescription; // Browser configuration
}
Commands can be defined in two ways:
bot.command("ping", async (ctx) => ctx.reply("pong!"));
bot.command({
name: "ping",
aliases: ["p"], // Optional aliases
code: async (ctx) => ctx.reply("pong!"),
});
For better organization, commands can be split into separate files:
const { CommandHandler } = require("@itsreimau/ckptw-mod");
const path = require("path");
// ... client initialization ...
const cmd = new CommandHandler(bot, path.resolve(__dirname, "commands"));
cmd.load(true); // Set to false to suppress loading logs
// commands/ping.js
module.exports = {
name: "ping",
code: async (ctx) => {
ctx.reply("pong!");
}
};
// commands/greeting.js (hears type example)
module.exports = {
name: "greeting",
type: "hears", // Can be 'command' or 'hears'
code: async (ctx) => {
ctx.reply("Hello there!");
}
};
Middleware allows pre-processing of messages before command execution:
bot.use(async (ctx, next) => {
console.log(`Received message: ${ctx.msg.content}`);
// Example: Block messages from specific users
if (ctx.sender.id === "1234@s.whatsapp.net") return ctx.reply("You are blocked!");
await next(); // Continue processing
});
Key Notes:
next()
to continue processingPrevent command spamming with cooldowns:
const { Cooldown } = require("@itsreimau/ckptw-mod");
bot.command("ping", async (ctx) => {
const cd = new Cooldown(ctx, 8000); // 8 second cooldown
if (cd.onCooldown) return ctx.reply(`Please wait ${cd.timeleft}ms before using this again`);
ctx.reply("pong!");
// Optional cooldown end handler
cd.on("end", () => {
console.log("Cooldown expired");
});
});
Cooldown Properties:
onCooldown
: Boolean indicating if activetimeleft
: Remaining time in millisecondsCreate and send contact cards:
const { VCardBuilder } = require("@itsreimau/ckptw-mod");
const vcard = new VCardBuilder()
.setFullName("Ayanami Rei")
.setOrg("NERV")
.setNumber("621234567890")
.build();
ctx.reply({ contacts: { displayName: "Rei", contacts: [{ vcard }] } });
Collect messages with flexible filtering:
const col = ctx.MessageCollector({
time: 10000, // 10 second timeout
max: 5, // Max 5 messages
filter: (m) => m.sender === ctx.sender.id // Only collect from sender
});
ctx.reply("Say something... (10s timeout)");
col.on("collect", (m) => {
ctx.reply(`Collected: ${m.content}`);
});
col.on("end", (_, reason) => {
ctx.reply(`Collection ended: ${reason}`);
});
Simplified message collection:
ctx.awaitMessages({ time: 10000 })
.then((messages) => ctx.reply(`Got ${messages.length} messages`))
.catch(() => ctx.reply("Timed out"));
Download and process media attachments:
const { MessageType } = require("@itsreimau/ckptw-mod");
const fs = require("fs");
bot.ev.on(Events.MessagesUpsert, async (m, ctx) => {
if (ctx.getMessageType() === MessageType.imageMessage) {
const buffer = await ctx.msg.media.toBuffer();
fs.writeFileSync("image.jpeg", buffer);
ctx.reply("Image saved!");
}
});
Media Access Methods:
// Current message
ctx.msg.media.toBuffer();
ctx.msg.media.toStream();
// Quoted message
ctx.quoted?.media.toBuffer();
ctx.quoted?.media.toStream();
Available events for handling various WhatsApp activities:
const { Events } = require("@itsreimau/ckptw-mod");
// Example event usage
bot.ev.on(Events.MessagesUpsert, (m, ctx) => {
console.log("New message:", m);
});
Available Events:
ClientReady
: Bot initialization completeMessagesUpsert
: New message receivedQR
: QR code generatedGroupsJoin
: Bot joined a groupUserJoin
: User joined a groupUserLeave
: User left a groupPoll
: Poll createdPollVote
: Poll vote receivedReactions
: Message reactionCall
: Incoming/outgoing callConnectionUpdate
: Connection status changeVarious message types can be sent:
// Text message
ctx.reply("Hello world!");
// Image with caption
ctx.reply({ image: { url: "https://example.com/image.jpg" }, caption: "Check this out!" });
// Audio message
ctx.reply({ audio: { url: "./sound.mp3" }, mimetype: "audio/mp4", ptt: true /* Send as voice note */ });
// Video message
const fs = require("fs");
ctx.reply({ video: fs.readFileSync("./video.mp4"), caption: "Watch this!", gifPlayback: false });
// Sticker
ctx.reply({ sticker: { url: "./sticker.webp" } });
For buttons and interactive messages, refer to baileys-mod documentation.
Format messages with WhatsApp's text styles:
const { bold } = require("@itsreimau/ckptw-mod");
ctx.reply(bold("Does this impact the lore?"));
Supported formatting functions:
bold(text)
italic(text)
strikethrough(text)
quote(text)
inlineCode(text)
monospace(text)
smallCaps(text)
Edit sent messages:
const sentMsg = await ctx.reply("Does this impact the lore?");
ctx.editMessage(sentMsg.key, "Yes Rei, it does.");
Delete messages:
const sentMsg = await ctx.reply("Third Impact!");
ctx.deleteMessage(sentMsg.key);
Create polls:
ctx.sendPoll(ctx.id, { name: "Does this impact the lore?", values: ["Yes Rei, it does.", "No!"], singleSelect: true /* Allow only one selection */ });
ctx.reply({ text: "Get in the EVA, @1234!", mentions: ["1234@s.whatsapp.net"] /* Full JID required */ });
Enable in client config:
const bot = new Client({
autoMention: true // Enable automatic mention conversion
});
// Now @mentions will work automatically
ctx.reply("Get in the EVA, @62812345678!"); // No need for mentions array
Extract mentioned users from message:
ctx.reply({ text: "Get in the EVA, @1234!", mentions: ctx.getMentioned() /* Returns array of JIDs like ["1234@s.whatsapp.net"] */ });
Use alternative auth storage adapters:
const { useMySQLAuthState } = require("mysql-baileys");
const bot = new Client({
authAdapter: useMySQLAuthState({
session: "botwangsap",
password: "admin#123",
database: "baileys"
})
// ... other options
});
Comprehensive group control:
// Create group
ctx.groups.create("NERV", ["1234@s.whatsapp.net"]);
// Group utilities
const group = ctx.group(); // Current group or specify JID
// Common operations
group.inviteCode(); // Get invite code
group.revokeInviteCode(); // Reset invite code
group.leave(); // Bot leaves group
group.updateSubject("NERV"); // Rename group
group.add(["1234@s.whatsapp.net"]); // Add members
group.kick(["1234@s.whatsapp.net"]); // Remove members
group.promote(["1234@s.whatsapp.net"]); // Make admin
group.demote(["1234@s.whatsapp.net"]); // Remove admin
// Message reactions
ctx.react(ctx.id, "👍");
// Get message details
ctx.args; // Command arguments array
ctx.sender; // Message sender info
ctx.quoted; // Quoted message
ctx.me; // Bot user info
// Presence updates
ctx.simulateTyping();
ctx.simulateRecording();
// Profile management
bot.bio("GOD'S IN HIS HEAVEN, ALL'S RIGHT WITH THE WORLD"); // Update bot bio
bot.fetchBio("1234@s.whatsapp.net"); // Get user's bio
// Block management
bot.block("1234@s.whatsapp.net");
bot.unblock("1234@s.whatsapp.net");
// Utility methods
ctx.isGroup(); // Check if chat is group
ctx.getDevice("1234@s.whatsapp.net"); // Get user device info
ctx.getPushname("1234@s.whatsapp.net"); // Get push name
Special thanks to:
FAQs
Fork of @mengkodingan/ckptw
The npm package @itsreimau/ckptw-mod receives a total of 0 weekly downloads. As such, @itsreimau/ckptw-mod popularity was classified as not popular.
We found that @itsreimau/ckptw-mod demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.