-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.3.64: fix some bugs, update MessateBuilder, and create menu.js
- Loading branch information
1 parent
79d84e1
commit 5f45b1a
Showing
22 changed files
with
504 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# Amira Bot | ||
Sebuah bot asisten pada platform whatsapp yang digunakan untuk berbagai kebutuhan. | ||
![Amira Bot Base](https://telegra.ph/file/54cbfb6c7f6b2d69f85cd.jpg) | ||
|
||
# Amira Bot Base | ||
Amira bot base is a chatbot base that has many features in it to make development easier and faster, Amira bot has a base with clean, neat and structured code. We offer features that can make it easier for developers to create their whatsapp bots easily using a good command handling system as well as other additional handlers such as event handlers, plugins handlers and much more. | ||
|
||
[![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC_BY--NC_4.0-lightgrey.svg?style=for-the-badge)](https://creativecommons.org/licenses/by-nc/4.0/) ![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/t/zanixongroup/amira-bot-base?logo=github&cacheSeconds=12000&style=for-the-badge) ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/zanixongroup/amira-bot-base?style=for-the-badge) ![GitHub repo size](https://img.shields.io/github/repo-size/zanixongroup/amira-bot-base?logo=github&style=for-the-badge&link=https%3A%2F%2Fgithub.com%2Fzanixongroup%2Famira-bot-base) ![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/zanixongroup/amira-bot-base/master?style=for-the-badge&logo=github) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,65 @@ | ||
![Amira Bot Base](https://telegra.ph/file/54cbfb6c7f6b2d69f85cd.jpg) | ||
|
||
# Command Documentation | ||
This documentation will discuss the options of the command file, how to create commands and how to use commands. | ||
|
||
The command structure is a good option for creating or developing a whatsapp bot to prioritize code neatness, the advantage is that it makes maintenance easier when one of the commands is broken, it will be easier to fix because each command will have its own space scope. | ||
|
||
## Table of contents | ||
|
||
1. [Create a command](#create-a-command) | ||
1. [Command properties](#command-properties) | ||
2. [Command options properties](#command-options-properties) | ||
3. [Command code options properties](#command-code-options-properties) | ||
|
||
|
||
<br> | ||
|
||
## Create a command | ||
|
||
Create your command easily with simple documentation and simple command syntax. | ||
|
||
|
||
### Command properties | ||
| Name | Type | Required | Description | | ||
| --- | --- | --- | --- | | ||
| `tag` | `String` | `true` | Tag option is used for sorting command data for help or menu command. | | ||
| `name` | `String` | `true` | The name option is used to identify commands about what tasks it can perform. | | ||
| `command` | `Array` | `true` | The command option is a trigger function to call the command | | ||
| `options` | `Object` | `false` | Options is used to place some permission options for the command. | | ||
| `disable` | `object` | `false` | The disable option is used to disable the command with two properties: `status: Boolean` and `message: String`. | | ||
| `cooldown` | `Object` | `false` | Used for making cooldown for command with two properties inside: `status: Boolean`, `duration: Integer (ms)`, and `message: String` (with {time} property). | | ||
| `code` | `[Async function]` | `true` | Used for place your code and executing your code. | | ||
|
||
|
||
### Command options properties | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| `isAdmin` | `Boolean` | Identify the command is for admin group only. | | ||
| `isBotAdmin` | `Boolean` | Check the command if the bot is admin before executing the code. | | ||
| `isPremium` | `Boolean` | Check the user is premium or not before executing the code. | | ||
| `isOwner` | `Boolean` | Identify the command is for owner bot only. | | ||
| `isGroup` | `Boolean` | Identify the command is for group only. | | ||
| `isPrivate` | `Boolean` | Identify the command is for private chat only. | | ||
| `nonPrefix` | `Boolean` | Make the command executed without prefix. | | ||
|
||
### Command code options properties | ||
I'll not make the code options properties documentation here, because code options is a changeable properties that will updated in the future, you can check all default code options properties [HERE](https://github.com/ZanixonGroup/amira-bot-base/blob/master/src%2Fevents%2FMessage.js) or you can check localy on `/src/events/Message.js` | ||
|
||
### Example command setup | ||
```js | ||
export default [{ | ||
tag: "main", | ||
name: "help", | ||
command: ["help"], | ||
limit: { | ||
status: Boolean, | ||
amount: Integer // limit usage do you want for command | ||
}, | ||
options: { | ||
// your command options here! | ||
}, | ||
code: async({ client, m }) => { | ||
// put your code here. | ||
} | ||
}] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,46 @@ | ||
import fs from "fs"; | ||
|
||
export default [{ | ||
name: "menu", | ||
command: ["menu"], | ||
code: async({ client, m, remote, dirname, path, MessageBuilder }) => { | ||
code: async({ client, m, remote, sender, Commands, MessageBuilder, prefix, upperFirst }) => { | ||
try { | ||
const __dirname = dirname(import.meta.url); | ||
const media = fs.readFileSync(path.join(__dirname, "ztrdiamond-icon-low.png")); | ||
const mentions = ["[email protected]"]; | ||
|
||
let listCommand = ""; | ||
let commandCategory = {} | ||
Array.from(Commands.values()).map(d => { | ||
commandCategory[d.tag] = Array.from(Commands.values()).filter(cmd => cmd.tag === d.tag); | ||
}); | ||
for(let tag in commandCategory) { | ||
if(tag === "hidden") return; | ||
let commands = commandCategory[tag]; | ||
if(commands) { | ||
let filteredCommand = commands.filter(d => !d.disable.status).map(cmd => { | ||
let isPremium = cmd.options.isPremium ? "🄿" : ""; | ||
return `│・${prefix + cmd.command[0]} ${isPremium}`; | ||
}) | ||
let list = filteredCommand.sort(); | ||
listCommand += `╭─❨ *${upperFirst(tag)}* ❩\n`; | ||
listCommand += list.join("\n") + "\n"; | ||
listCommand += `╰──────────────────・\n\n`; | ||
console.log(listCommand) | ||
} | ||
} | ||
const message = new MessageBuilder() | ||
.setCaption("Testing thumbnail") | ||
.setMentions(mentions) | ||
.setImage(media) | ||
.setMimetype("image/png") | ||
.setThumbnailTitle("Title nya") | ||
.setThumbnailBody("Body nya") | ||
.setText(`Halo @${sender.split("@")[0]}, Amira disini! | ||
${listCommand}`) | ||
.setMentions([sender]) | ||
.setThumbnailMediaUrl("https://github.com/ZanixonGroup") | ||
.setThumbnailTitle("Amira Bot Base | WhatsApp Bot") | ||
.setThumbnailBody("Copyright © ZanixonGroup 2024 - All Right Reserved") | ||
.setThumbnailLarge() | ||
.setThumbnailImage("https://telegra.ph/file/d7109be0db36e7cbd56a8.jpg") | ||
.setThumbnailUrl("https://contoh.com") | ||
.setThumbnailImage("https://telegra.ph/file/54cbfb6c7f6b2d69f85cd.jpg") | ||
.setThumbnailUrl("https://github.com/ZanixonGroup") | ||
.setForwardingScore(9999) | ||
.setForwarded(true) | ||
.setNewsletterJid("120363183632297680@newsletter") | ||
.setNewsletterName("Developed by Zanixon Group™") | ||
.setNewsletterServerMessageId(125) | ||
.build() | ||
|
||
console.log(message) | ||
client.sendMessage(remote, message); | ||
client.sendMessage(remote, message, { quoted: m }); | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export default [{ | ||
tag: "example", | ||
name: "News Letter Message", | ||
command: ["news","nl","saluran","channel","newsletter"], | ||
code: async({ client, m, quoted, remote, dirname, path, fs, MessageBuilder }) => { | ||
const __dirname = dirname(import.meta.url); | ||
try { | ||
const temp = new MessageBuilder() | ||
.setText("Hello world!") | ||
.setThumbnailMediaUrl("https://github.com/ZanixonGroup") | ||
.setThumbnailTitle("Amira Bot Base | WhatsApp Bot") | ||
.setThumbnailBody("Copyright © ZanixonGroup 2024 - All Right Reserved") | ||
.setThumbnailLarge() | ||
.setThumbnailImage("https://telegra.ph/file/54cbfb6c7f6b2d69f85cd.jpg") | ||
.setThumbnailUrl("https://github.com/ZanixonGroup") | ||
.setForwardingScore(9999) | ||
.setForwarded(true) | ||
.setNewsletterJid("120363183632297680@newsletter") | ||
.setNewsletterName("Zanixon Group™") | ||
.setNewsletterServerMessageId(125) | ||
.build() | ||
let data = await client.generateMessage(remote, temp, m.key); | ||
console.log(JSON.stringify(data, null, 2)) | ||
client.relayMessage(remote, data.message, { messageId: data.key.id }); | ||
client.relayMessage(remote, data.message, { messageId: data.key.id }); | ||
} catch (e) { | ||
throw new Error(e) | ||
} | ||
} | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
export default [{ | ||
tag: "example", | ||
name: "test", | ||
command: ["test","tes"], | ||
cooldown: { | ||
status: true, | ||
duration: 86400000 | ||
}, | ||
code: async({ client, m }) => { | ||
try { | ||
m.reply("work coy!") | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
code: async({ client, m, MessageCollector }) => { | ||
m.reply("Balas dengan pesan apapun!"); | ||
|
||
// init MessageCollector | ||
const col = new MessageCollector(m, { | ||
timeout: 60000 | ||
}); | ||
|
||
// call MessageCollector | ||
col.on("collect", async(data) => { | ||
m.reply(`${JSON.stringify(data, null, 2)}`); | ||
col.exit(); | ||
}) | ||
|
||
col.on("end", () => { | ||
m.reply("Message collector diakhiri!") | ||
}) | ||
} | ||
}] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.