@mengkodingan/ckptw
Advanced tools
Comparing version 4.1.1 to 4.2.0
@@ -35,2 +35,3 @@ /// <reference types="node" /> | ||
onGroupsJoin(): void; | ||
onCall(): void; | ||
/** | ||
@@ -74,4 +75,10 @@ * Create a new command. | ||
}>; | ||
/** | ||
* All the groups that the bot joins. | ||
*/ | ||
groups(): Promise<{ | ||
[_: string]: import("@whiskeysockets/baileys").GroupMetadata; | ||
}>; | ||
launch(): Promise<void>; | ||
} | ||
//# sourceMappingURL=Client.d.ts.map |
@@ -152,2 +152,9 @@ "use strict"; | ||
} | ||
onCall() { | ||
var _a; | ||
(_a = this.core) === null || _a === void 0 ? void 0 : _a.ev.on('call', (m) => { | ||
let withDecodedId = m.map(v => (Object.assign(Object.assign({}, v), { decodedFrom: (0, Functions_1.decodeJid)(v.from), decodedChatId: (0, Functions_1.decodeJid)(v.chatId) }))); | ||
this.ev.emit(Events_1.Events.Call, withDecodedId); | ||
}); | ||
} | ||
/** | ||
@@ -216,3 +223,3 @@ * Create a new command. | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let decodedJid = (0, baileys_1.jidDecode)(jid ? jid : (_b = (_a = this.core) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.id); | ||
let decodedJid = (0, Functions_1.decodeJid)(jid ? jid : (_b = (_a = this.core) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.id); | ||
let re = yield ((_c = this.core) === null || _c === void 0 ? void 0 : _c.fetchStatus(decodedJid)); | ||
@@ -222,2 +229,10 @@ return re; | ||
} | ||
/** | ||
* All the groups that the bot joins. | ||
*/ | ||
groups() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.core.groupFetchAllParticipating(); | ||
}); | ||
} | ||
launch() { | ||
@@ -258,2 +273,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
this.onGroupsJoin(); | ||
this.onCall(); | ||
}); | ||
@@ -260,0 +276,0 @@ } |
@@ -7,2 +7,4 @@ /// <reference types="node" /> | ||
import { MessageCollector } from "./Collector/MessageCollector"; | ||
import { GroupData } from "./Group/GroupData"; | ||
import { Group } from "./Group/Group"; | ||
export declare class Ctx implements ICtx { | ||
@@ -19,2 +21,3 @@ _used: { | ||
jid: string | null | undefined; | ||
decodedJid: string | null | undefined; | ||
pushName: string | null | undefined; | ||
@@ -28,2 +31,3 @@ }; | ||
get id(): string | null | undefined; | ||
get decodedId(): string | null | undefined; | ||
get args(): Array<string>; | ||
@@ -33,2 +37,3 @@ get msg(): IMessageInfo; | ||
jid: string | null | undefined; | ||
decodedJid: string | null | undefined; | ||
pushName: string | null | undefined; | ||
@@ -58,3 +63,7 @@ }; | ||
isGroup(): boolean | undefined; | ||
block(jid?: string): Promise<void>; | ||
unblock(jid?: string): Promise<void>; | ||
get groups(): Group; | ||
group(jid?: string): GroupData; | ||
} | ||
//# sourceMappingURL=Ctx.d.ts.map |
@@ -16,2 +16,4 @@ "use strict"; | ||
const MessageCollector_1 = require("./Collector/MessageCollector"); | ||
const GroupData_1 = require("./Group/GroupData"); | ||
const Group_1 = require("./Group/Group"); | ||
class Ctx { | ||
@@ -26,4 +28,7 @@ constructor(options) { | ||
jid: (0, Functions_1.getSender)(this._msg, this._client), | ||
decodedJid: null, | ||
pushName: this._msg.pushName, | ||
}; | ||
if (this._sender.jid) | ||
this._sender.decodedJid = (0, Functions_1.decodeJid)(this._sender.jid); | ||
this._config = { | ||
@@ -37,2 +42,6 @@ prefix: this._self.prefix, | ||
} | ||
get decodedId() { | ||
if (this._msg.key.remoteJid) | ||
return (0, Functions_1.decodeJid)(this._msg.key.remoteJid); | ||
} | ||
get args() { | ||
@@ -157,3 +166,29 @@ return this._args; | ||
} | ||
block(jid) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (jid) { | ||
yield this._client.updateBlockStatus((0, Functions_1.decodeJid)(jid), "block"); | ||
} | ||
else { | ||
yield this._client.updateBlockStatus((0, Functions_1.decodeJid)(this.id), "block"); | ||
} | ||
}); | ||
} | ||
unblock(jid) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (jid) { | ||
yield this._client.updateBlockStatus((0, Functions_1.decodeJid)(jid), "unblock"); | ||
} | ||
else { | ||
yield this._client.updateBlockStatus((0, Functions_1.decodeJid)(this.id), "unblock"); | ||
} | ||
}); | ||
} | ||
get groups() { | ||
return new Group_1.Group(this); | ||
} | ||
group(jid) { | ||
return new GroupData_1.GroupData(this, jid ? jid : this.id); | ||
} | ||
} | ||
exports.Ctx = Ctx; |
@@ -11,3 +11,4 @@ export declare const Events: { | ||
Reactions: string; | ||
Call: string; | ||
}; | ||
//# sourceMappingURL=Events.d.ts.map |
@@ -13,3 +13,4 @@ "use strict"; | ||
"PollVote": "PollVote", | ||
"Reactions": "Reactions" | ||
"Reactions": "Reactions", | ||
"Call": "Call" | ||
}; |
@@ -12,2 +12,3 @@ declare const _default: { | ||
Reactions: string; | ||
Call: string; | ||
}; | ||
@@ -14,0 +15,0 @@ MessageType: { |
@@ -8,2 +8,4 @@ export * from "./Classes/Client"; | ||
export * from "./Classes/Builder/TemplateButtons"; | ||
export * from "./Classes/Group/Group"; | ||
export * from "./Classes/Group/GroupData"; | ||
export * from "./Helper/Formatter"; | ||
@@ -10,0 +12,0 @@ export * from "./Common/Types"; |
@@ -24,2 +24,4 @@ "use strict"; | ||
__exportStar(require("./Classes/Builder/TemplateButtons"), exports); | ||
__exportStar(require("./Classes/Group/Group"), exports); | ||
__exportStar(require("./Classes/Group/GroupData"), exports); | ||
__exportStar(require("./Helper/Formatter"), exports); | ||
@@ -26,0 +28,0 @@ __exportStar(require("./Common/Types"), exports); |
{ | ||
"name": "@mengkodingan/ckptw", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "An easy way to make a WhatsApp Bot.", | ||
@@ -36,3 +36,3 @@ "main": "lib/index.js", | ||
"@hapi/boom": "^10.0.1", | ||
"@whiskeysockets/baileys": "^6.6.0", | ||
"@whiskeysockets/baileys": "^6.7.5", | ||
"pino": "^8.11.0", | ||
@@ -39,0 +39,0 @@ "qrcode-terminal": "^0.12.0", |
@@ -376,4 +376,4 @@ # ckptw | ||
- **Reactions** - Emitted when someone reacts to a message. | ||
- **Call** - Emitted when someone calling, call was accepted or rejected. | ||
## Sending Message | ||
@@ -450,2 +450,39 @@ | ||
## Group Stuff | ||
```ts | ||
ctx.groups.create(subject: string, members: string[]); | ||
ctx.groups.inviteCodeInfo(code: string); | ||
ctx.groups.acceptInvite(code: string); | ||
ctx.groups.acceptInviteV4(key: string | proto.IMessageKeinviteMessage: proto.Message.IGroupInviteMessage); | ||
``` | ||
```ts | ||
ctx.group(jid?: string); // jid is optional | ||
ctx.group().members(); | ||
ctx.group().inviteCode(); | ||
ctx.group().revokeInviteCode(); | ||
ctx.group().joinApproval(mode: "on" | "off"); | ||
ctx.group().leave(); | ||
ctx.group().membersCanAddMemberMode(mode: "on" | "off"); | ||
ctx.group().metadata(); | ||
ctx.group().toggleEphemeral(expiration: number); | ||
ctx.group().updateDescription(description: number); | ||
ctx.group().updateSubject(subject: number); | ||
ctx.group().membersUpdate(members: string[], actioParticipantAction); | ||
ctx.group().kick(members: string[]); | ||
ctx.group().add(members: string[]); | ||
ctx.group().promote(members: string[]); | ||
ctx.group().demote(members: string[]); | ||
ctx.group().pendingMembers(); | ||
ctx.group().pendingMembersUpdate(members: string[], action: 'reject' | 'approve'); | ||
ctx.group().approvePendingMembers(members: string[]); | ||
ctx.group().rejectPendingMembers(members: string[]); | ||
ctx.group().updateSetting(setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') | ||
ctx.group().open() | ||
ctx.group().close() | ||
ctx.group().lock() | ||
ctx.group().unlock() | ||
``` | ||
## Misc | ||
@@ -474,2 +511,3 @@ | ||
ctx.id // string | ||
ctx.decodedId // string | ||
@@ -480,3 +518,3 @@ /* get the array of arguments used */ | ||
/* get sender details */ | ||
ctx.sender // { jid: string, pushName: string } | ||
ctx.sender | ||
@@ -499,2 +537,6 @@ /* get the message type */ | ||
/* block and unblock */ | ||
await bot.block("1234@s.whatsapp.net"); | ||
await bot.unblock("1234@s.whatsapp.net"); | ||
/* get device */ | ||
@@ -501,0 +543,0 @@ ctx.getDevice(id) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111562
66
1895
547