Skip to content

Commit

Permalink
featnfix: env variables and donation feature
Browse files Browse the repository at this point in the history
- optimizing environment variables, now env values is centrally stored on .env file, documented and able to be used on env.ts
- adding new feature/command : donation
- deactivating TikTok, Instagram downloader, and Gemini. Awaiting for next migration to capable hardware
- refining some information on bot-info command and on main README
  • Loading branch information
gensart-x committed Apr 17, 2024
1 parent ba8e9b3 commit d005f0a
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 65 deletions.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ The preview might take a while to load sometimes, depends on your connection.

# Technology Used <!-- {docsify-ignore} -->

> This project still on maintaining 🚧, so it might have a massive changes, so stay tuned !
> This project is still on development 🚧, so it might have a massive changes, so stay tuned !
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/Axios/axios1.svg)
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/Debian/debian1.svg)
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/Git/git1.svg)
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/Javascript/javascript3.svg)
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/JSON/json3.svg)
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/NodeJS/nodejs1.svg)
![](https://ziadoua.github.io/m3-Markdown-Badges/badges/TypeScript/typescript1.svg)
![Axios HTTP Client](https://ziadoua.github.io/m3-Markdown-Badges/badges/Axios/axios1.svg)
![Debian Bookworm 12](https://ziadoua.github.io/m3-Markdown-Badges/badges/Debian/debian1.svg)
![Git Version Control](https://ziadoua.github.io/m3-Markdown-Badges/badges/Git/git1.svg)
![Javascript](https://ziadoua.github.io/m3-Markdown-Badges/badges/Javascript/javascript3.svg)
![JSON Interexchange format](https://ziadoua.github.io/m3-Markdown-Badges/badges/JSON/json3.svg)
![Node JS runtime](https://ziadoua.github.io/m3-Markdown-Badges/badges/NodeJS/nodejs1.svg)
![Typescript](https://ziadoua.github.io/m3-Markdown-Badges/badges/TypeScript/typescript1.svg)

# Features

Expand All @@ -39,15 +39,15 @@ The preview might take a while to load sometimes, depends on your connection.
- Random Couple Anime Profile Pictures 👭
- Translate English to Indonesia, and otherwise 🌐
- Random Wise Quotes 🦜
- You have any idea ? Drop it in the Issue tab with `enhancement` label ! 😁 With your idea, I'll try to reach the feature if it's possible, and put your username in here as a contribution !✨😎
- You have any idea ? Drop it in the Issue tab with `enhancement` label ! 😁 With your idea, I'll try to reach the feature if it's possible, and put your name in here as a contribution !✨😎

# Overview

This application uses `whatsapp-web.js` as a primary library. Keep in mind if you want to use this app, I assume you did already know that :

```bash
WhatsApp terms & conditions do not allow any unofficial bots or automation on its services.
And this app should be used properly. I do not encourage any bad misuse that may hurt any person/group by the usage of this app. Please use it wisely, I create this for good reason.
🔴 WhatsApp terms & conditions do not allow any unofficial bots or automation on its services.
And this app should be used properly. I do not encourage any misuse that may hurt any person/group by the usage of this app. Please use it wisely, I create this for good reason.
```

So, I am not responsible for any banning happen to your WhatsApp account by using this app. **I strongly suggest** you to use this app with your new or backup WhatsApp number. I use my second number and still safe until now.
Expand All @@ -56,7 +56,7 @@ So, I am not responsible for any banning happen to your WhatsApp account by usin

The installation needs several steps, you might want to see the documentation for more information.

- For quick installation, first thing you can clone the app, no matter what method you use, below is the simple example one :
- For quick installation, first thing you can clone the app, no matter what method you use, below is the simple example one using Git command:

```bash
git clone https://github.com/gensart-x/sora-erlyana.git
Expand All @@ -83,9 +83,12 @@ npm run build
- Try to send `.help` to the WhatsApp you integrates in. It should return available commands as a response.

<br>
Seek the documentation at : [here](https://gensart-x.github.io/sora-erlyana)
Seek the documentation at : <a href="https://gensart-x.github.io/sora-erlyana">here</a>

Current Stable Version : `1.0.0`

![teer.id/gensart](https://ziadoua.github.io/m3-Markdown-Badges/badges/BuyMeACoffee/buymeacoffee3.svg)

---

<p align="center">
Expand Down
12 changes: 11 additions & 1 deletion env
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
IMGBB_KEY = 'api-key-of-imgbb'

GHOLA_TOKEN = 'put-ghola-token-here'
GHOLA_EMAIL = 'put-associated-ghola-email-here'
GHOLA_AI_PROFILE_ID = 'put-ghola-ai-profile-id-here'
GHOLA_AI_PROFILE_ID = 'put-ghola-ai-profile-id-here'

BOT_NAME = 'Sora Erlyana'
BOT_SHORT_NAME = 'Sora'
BOT_CODE_NAME = 'SoraErlyana'

OWNER_NAME = 'Genesaret Johnes'

BANK_ACCOUNT = 'your-bank-account-if-needed'
TRAKTEER_LINK = 'teer.id/gensart'
9 changes: 4 additions & 5 deletions src/command-hive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { indoSlangQuote } from '@services/internal/quote-indo-slang'
import { getPpCouple } from '@services/internal/pp-couple'
import { ghola } from '@services/external/ghola'
import { requestInfo } from '@services/internal/request-info'
import { instagramDownloader } from '@services/external/instagram-downloader'
import { donation } from '@services/internal/donation'
import { botInfo } from '@services/internal/bot-info'

type Commands = {
Expand All @@ -34,10 +34,6 @@ const commands: Commands = {
'.quotes': getForismaticQuotes,
'.indoquotes': indoSlangQuote,


// * Converter
'.ig': instagramDownloader,

// * Random Image
'.ppcouple': getPpCouple,

Expand Down Expand Up @@ -68,6 +64,9 @@ const commands: Commands = {
'.neon-valentine': textProSingleTextRouter,
'.neon-cube': textProSingleTextRouter,
'.blackpink-logo': textProSingleTextRouter,

// * Donation
'.donasi': donation
}

export {
Expand Down
67 changes: 49 additions & 18 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
interface EnvironmentConfiguration {
import 'dotenv/config';

/**
* This object is used as dotenv bridge
* so we can add some information
* to each variable stored on dotenv.
*/
const environmentConfiguration = {
/**
* Is sending any WhatsApp message allowed ?
* The property name clearly says it, this is for global configuration
*/
isSendingMessageEnabled: boolean,
isSendingMessageEnabled: true,

/**
* Bot full name
* Bot full name, for example : Sora Erlyana
*/
botName: string,
botName: process.env.BOT_NAME,

/**
* Bot short name
* Bot short name, for example : Sora
*/
botShortName: string,
botShortName: process.env.BOT_SHORT_NAME,

/**
* Bot codename
* Bot code name, for example : SoraErlyana
*/
botCodeName: string,
botCodeName: process.env.BOT_CODE_NAME,

/**
* Owner name of the bot
* Creator/Owner name
*/
ownerName: string
}
ownerName: process.env.OWNER_NAME,

const environmentConfiguration: EnvironmentConfiguration = {
isSendingMessageEnabled: true,
/**
* imgBB API Key, see more at https://api.imgbb.com
*/
imgBBKey: process.env.IMGBB_KEY,

botName: 'Sora Erlyana',
botShortName: 'Sora',
botCodeName: 'SoraErlyana',
ownerName: 'Genesaret Johnes'
/**
* Ghola AI chat API Token, see more at https://www.ghola.ai/developer
*/
gholaToken: process.env.GHOLA_TOKEN,

/**
* Ghola AI associated account email, see more at https://www.ghola.ai/developer
*/
gholaEmail: process.env.GHOLA_EMAIL,

/**
* Ghola AI bot profile ID, see more at https://www.ghola.ai/developer
*/
gholaProfileId: process.env.GHOLA_AI_PROFILE_ID,

// BANK_ACCOUNT = 'your-bank-account-if-needed'
// TRAKTEER_LINK = 'teer.id/gensart

/**
* Bank Account Information, use if needed.
*/
bankAccountInfo: process.env.BANK_ACCOUNT,

/**
* Trakteer Linkteer link, for donation support.
*/
trakteerLink: process.env.TRAKTEER_LINK
}

export default environmentConfiguration
5 changes: 0 additions & 5 deletions src/services/external/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const geminiText = async (text: string): Promise<GeminiResponse> => {
};

// Add API key to the URL
// todo : Google API key
geminiUrl = geminiUrl + '?key=' + 'here';

// Hit the API
Expand Down Expand Up @@ -115,8 +114,4 @@ const geminiTextOnly: Executor = async (client, message) => {
} catch (error) {
wweb.replyMessage(message, 'Maaf, terjadi kesalahan saat menjawab pertanyaan anda. Silahkan coba lagi');
}
}

export {
geminiTextOnly
}
7 changes: 3 additions & 4 deletions src/services/external/ghola.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dotenv/config'
import axios from 'axios'
import { Executor } from '@/command-hive'
import * as wweb from '@utils/wweb'
Expand All @@ -10,9 +9,9 @@ const GHOLA_CHAT_ENDPOINT = 'https://www.ghola.ai/api/v1/chat';

const retrieveGholaToken = async () => {
const response = await axios.post(GHOLA_TOKEN_ENDPOINT, {
token: process.env.GHOLA_TOKEN,
email: process.env.GHOLA_EMAIL,
profileId: process.env.GHOLA_AI_PROFILE_ID
token: config.gholaToken,
email: config.gholaEmail,
profileId: config.gholaProfileId
}, {
headers: {
'Content-Type': 'application/json'
Expand Down
3 changes: 1 addition & 2 deletions src/services/external/image-to-sticker-meme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Contact, MessageMedia } from 'whatsapp-web.js'
import 'dotenv/config'
import axios, { AxiosError } from 'axios'
import querystring from 'querystring'
import config from '@/env'
Expand All @@ -15,7 +14,7 @@ type Meme = {
const uploadImageToUrl = async (base64Image: string) => {
const queries = querystring.encode({
// API Key
key: process.env.IMGBB_KEY,
key: config.imgBBKey,

// Image auto-deletion after x seconds uploaded
expiration: 60,
Expand Down
4 changes: 0 additions & 4 deletions src/services/external/instagram-downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,4 @@ const instagramDownloader: Executor = async (client, message) => {
logger.logError('instagramDownloader - ' + err.cause ?? err.message + ' by ' + contact?.pushname ?? 'unknown');
wweb.replyMessage(message, `Maaf, ${config.botShortName} mengalami kegagalan saat memprosesnya. Silahkan coba kembali nanti ya! 🙏`);
}
}

export {
instagramDownloader
}
10 changes: 1 addition & 9 deletions src/services/external/tiktok-downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ const downloadTikTokVideo = async (tiktokUrl: string) => {
}

const tiktokDownloader: Executor = async (client, message) => {

// ! Hold the feature, it did not work well
wweb.replyMessage(message, 'Fitur ini sedang dilakukan perbaikan, harap stay tuned untuk informasi selanjutnya :).');
return 0;


const tiktokUrl = message.body.split(' ')[1];

if ((tiktokUrl == undefined) || (tiktokUrl == '')) {
Expand All @@ -89,8 +85,4 @@ const tiktokDownloader: Executor = async (client, message) => {
logger.logError('tiktokDownloader - ' + error.message + ' by ' + contact?.pushname ?? 'unknown');
wweb.replyMessage(message, 'Maaf, terjadi kesalahan saat memuat video. Silahkan coba kembali nanti ya!');
}
}

export {
tiktokDownloader
}
7 changes: 4 additions & 3 deletions src/services/internal/bot-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import config from '@/env';

const botInfo: Executor = async (client, message) => {
const informationArray = [
`⚡Informasi tentang ${config.botName}⚡`,
`⚡ Informasi tentang ${config.botName} ⚡`,
`Nama: ${config.botName}`,
`Nama Panggilan: ${config.botShortName}`,
`Owner: ${config.ownerName}\n`,

'Tahun Rilis:' + 2024,
'Versi Saat Ini:' + '1.0.0',
'Teknologi Digunakan :',
'- NodeJS',
'- NodeJS v20',
'- TypeScript',
'- whatsapp-web.js (wwebjs.dev)\n',
'- whatsapp-web.js (wwebjs.dev)',
'- Debian Bookworm 12\n',
'Gunakan `.request [isi feedbackmu]` untuk berikan feedback kepada ' + config.botShortName + ' 😊'
];
wweb.sendMessage(client, message.from, informationArray.join('\n'));
Expand Down
5 changes: 4 additions & 1 deletion src/services/internal/command-guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ const commandGuide: Executor = async (client, message) => {
'.neon-valentine',
'.neon-cube',
'.blackpink-logo\n',
'💚 Support Creator',
`Kamu bisa membantu creator ${config.botShortName} dengan menfollow GitHub nya, Instagram, atau melakukan star pada repository di github.com/gensart-x/sora-erlyana.`,
'Atau kamu juga bisa melakukan donasi lho! Ketik `.donasi` untuk informasi lebih lanjut\n',
'👨‍🔬🧪 Fitur yang akan datang',
'[❌ Hardware Support] Tiktok Downloader',
'[❌ Hardware Support] Instagram Downloader',
'[❌ Hardware Support] YouTube Downloader',
'[✅] Bot Information (versi, tech used, etc.)',
'[✅] Feedback Request Fitur',
'[] Donasi Semi-Kemanusiaan (Apaan nih ? Coming soon ya😄)\n',
'[] Donasi Semi-Kemanusiaan',
`😎 Kamu juga bisa request fitur yang belum ada lho, atau punya saran tertentu, bisa langsung kirim ke ${config.botShortName} dengan format :`,
'`.request [request fitur/saran perbaikan]`',
`Request akan ${config.botShortName} informasikan ke creator. 🫡\n`,
Expand Down
19 changes: 19 additions & 0 deletions src/services/internal/donation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Executor } from '@/command-hive';
import config from '@/env';
import * as wweb from '@utils/wweb';

const donation: Executor = async (client, message) => {
const informationArray = [
`Kamu bisa bantu perkembangan ${config.botName} dengan mentraktir creator ${config.botShortName} ke metode dibawah :`,
`Trakteer : ${config.trakteerLink}`,
`Rekening BCA : ${config.bankAccountInfo}`,
`🙋‍♂️ : _"Semi Donasi apa itu ${config.botShortName} ?"_`,
`🅰 : Jika kamu melakukan donasi ke link Trakteer, atau rekening bank diatas dengan nominal lebih dari Rp10.000, 80% dari nominal kamu akan creator donasikan kembali ke platform kitabisa.com / Dompet Dhuafa (dibulatkan kelipatan ribuan)\n`,
`Fitur ini masih dalam tahap pengembangan, karena saat kamu melakukan donasi, ${config.botShortName} perlu melakukan feedback yang tepat untuk menangani donasi kamu. Tapi creator sudah mulai open donasi saat ini kok :)`
];
wweb.replyMessage(message, informationArray.join('\n'));
}

export {
donation
}

0 comments on commit d005f0a

Please sign in to comment.