Skip to content

Commit

Permalink
release v4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JastinXyz committed Aug 12, 2024
1 parent 83eb94b commit b03d2a7
Show file tree
Hide file tree
Showing 39 changed files with 1,137 additions and 572 deletions.
98 changes: 71 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Create powerful WhatsApp bots easily.
* [Button](#button)
* [Sections](#sections)
* [Contact](#contact)
* [Template Buttons](#template-buttons)
* [Template Buttons (⚠ DEPRCATED! Use button builder instead.)](#template-buttons-deprcated-use-button-builder-instead)
- [Collector](#collector)
* [Message Collector](#message-collector)
* [Awaited Messages](#awaited-messages)
Expand Down Expand Up @@ -231,43 +231,74 @@ cd.timeleft; // number

## Builder

> ⚠ The button and section are now deprecated!
- ### Button
Make a button message with Button Builder.

```ts
import { ButtonBuilder } from "@mengkodingan/ckptw";
export type ButtonType = 'cta_url' | 'cta_call' | 'cta_copy' | 'cta_reminder' | 'cta_cancel_reminder' | 'address_message' | 'send_location' | 'quick_reply';
```

// you can use more than 1 builder
const btn = new ButtonBuilder()
.setId("id1") // button id
.setDisplayText("button 1") // button text
.setType(1); // type
```ts
import { ButtonBuilder } from "@mengkodingan/ckptw";

// pass it into buttons array
ctx.sendMessage(ctx.id, { text: "buttons", buttons: [btn] });
let button = new ButtonBuilder()
.setId('!ping')
.setDisplayText('command Ping')
.setType('quick_reply')
.build();

let button2 = new ButtonBuilder()
.setId('id2')
.setDisplayText('copy code')
.setType('cta_copy')
.setCopyCode('hello world')
.build();

let button3 = new ButtonBuilder()
.setId('id3')
.setDisplayText('@mengkodingan/ckptw')
.setType('cta_url')
.setMerchantURL('https://github.com/mengkodingan/ckptw')
.build();

// use sendInteractiveMessage if you dont want to quote the message.
ctx.replyInteractiveMessage({
body: 'this is body',
footer: 'this is footer',
nativeFlowMessage: { buttons: [button, button2, button3] }
})
```

- ### Sections
Sections message is like a list.

```ts
import { SectionBuilder } from "@mengkodingan/ckptw";

// you can use more than 1 like buttons
const mysection = new SectionBuilder()
.setTitle("title") // sections title
.setRows(
{ title: "abc", rowId: 1 },
{ title: "b", rowId: 2, description: "a" }
); // make a rows

ctx.sendMessage(ctx.id, {
text: "sections",
buttonText: "button text", // buttonText is for the display text for the button
sections: [mysection], // pass it into sections array
});
import { SectionsBuilder } from "@mengkodingan/ckptw";

let section1 = new SectionsBuilder()
.setDisplayText("Click me")
.addSection({
title: 'Title 1',
rows: [
{ header: "Row Header 1", title: "Row Title 1", description: "Row Description 1", id: "Row Id 1" },
{ header: "Row Header 2", title: "Row Title 2", description: "Row Description 2", id: "Row Id 2" }
]
})
.addSection({
title: 'This is title 2',
rows: [
{ title: "Ping", id: "!ping" },
{ title: "Hello world", id: "hello world" },
]
})
.build();


ctx.sendInteractiveMessage(ctx.id!, {
body: 'this is body',
footer: 'this is footer',
nativeFlowMessage: { buttons: [section1] } // pass it to the buttons property
})
```

- ### Contact
Expand All @@ -285,7 +316,7 @@ cd.timeleft; // number
ctx.reply({ contacts: { displayName: "John D", contacts: [{ vcard }] }});
```

- ### Template Buttons
- ### Template Buttons (⚠ DEPRCATED! Use button builder instead.)
Send a button with "attachment".

```ts
Expand Down Expand Up @@ -489,6 +520,10 @@ ctx.group().unlock()
ctx.reply({ text: "test" });
ctx.reply("you can use string as a first parameter too!");

/* using interactive message */
ctx.sendInteractiveMessage(jid: string, content: IInteractiveMessageContent, options: MessageGenerationOptionsFromContent | {} = {});
ctx.replyInteractiveMessage(content: IInteractiveMessageContent, options: MessageGenerationOptionsFromContent | {} = {});

/* same with bot.command but without prefix */
bot.hears('test', async(ctx) => ctx.reply('test 1 2 3 beep boop...'));

Expand All @@ -513,9 +548,18 @@ ctx.args // Array<string>
/* get sender details */
ctx.sender

/* get quoted */
ctx.quoted

/* get the message type */
ctx.getMessageType()

/* get content type */
ctx.getContentType(content: WAProto.IMessage | undefined)

/* download content from message */
ctx.downloadContentFromMessage(downloadable: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions)

/* read the message */
ctx.read()

Expand Down
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

150 changes: 103 additions & 47 deletions docs/classes/ButtonBuilder.html

Large diffs are not rendered by default.

80 changes: 41 additions & 39 deletions docs/classes/Client.html

Large diffs are not rendered by default.

34 changes: 18 additions & 16 deletions docs/classes/Collector.html

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions docs/classes/CommandHandler.html

Large diffs are not rendered by default.

Loading

0 comments on commit b03d2a7

Please sign in to comment.