baileys-tele 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +270 -0
- package/bin/cli.js +96 -0
- package/package.json +41 -0
- package/src/core/config.js +65 -0
- package/src/core/firebase.js +89 -0
- package/src/core/telegram.js +117 -0
- package/src/index.js +190 -0
- package/src/menus/anticall.js +46 -0
- package/src/menus/features.js +61 -0
- package/src/menus/main.js +46 -0
- package/src/menus/modes.js +41 -0
- package/src/menus/profile.js +82 -0
- package/src/notify/notify.js +102 -0
package/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# baileys-tele
|
|
2
|
+
|
|
3
|
+
> **Add a full Telegram control panel to any Baileys WhatsApp bot — one command, zero config headache.**
|
|
4
|
+
|
|
5
|
+
Built by **Iconic Tech** · Published by **SilentByte Platforms Inc**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What is baileys-tele?
|
|
10
|
+
|
|
11
|
+
`baileys-tele` connects your [Baileys](https://github.com/WhiskeySockets/Baileys) WhatsApp bot to a **Telegram control panel** — so you can toggle features, switch modes, edit your bot's profile, and get live notifications, all from Telegram. No dashboard needed.
|
|
12
|
+
|
|
13
|
+
### What you can do from Telegram
|
|
14
|
+
|
|
15
|
+
| Section | What you control |
|
|
16
|
+
|---|---|
|
|
17
|
+
| ⚡ **Features** | 18 toggles — Auto React, Auto Read, Auto Recording, Like/Save Status, ChatBot, Anti-Link, Welcome, Anti-Delete, and more |
|
|
18
|
+
| 🌙 **Modes** | Public / Private / Night Mode / Unavailable Mode |
|
|
19
|
+
| 📵 **Anti-Call** | Enable/disable · Block caller or Reject only |
|
|
20
|
+
| 🎨 **Profile** | Bot Name · Prefix · Status · Owner Name · Pack Name · Author · Version |
|
|
21
|
+
| 📊 **Status** | Live uptime · Active settings at a glance |
|
|
22
|
+
| 🔔 **Notifications** | Bot online · Session active · New messages · Errors |
|
|
23
|
+
|
|
24
|
+
All changes hit your Firebase Realtime Database **instantly** and your bot reads them in real-time.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- Node.js >= 16
|
|
31
|
+
- A Baileys WhatsApp bot (any version)
|
|
32
|
+
- A Firebase Realtime Database (free tier works)
|
|
33
|
+
- A Telegram bot token + your Telegram chat ID
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Step 1 — Create your Telegram Bot & get your Chat ID
|
|
38
|
+
|
|
39
|
+
### Create a bot (get token)
|
|
40
|
+
|
|
41
|
+
1. Open Telegram and search for **@BotFather**
|
|
42
|
+
2. Send `/newbot`
|
|
43
|
+
3. Follow the prompts — choose a name and username
|
|
44
|
+
4. BotFather gives you a token like:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
5839201847:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Keep this — it's your `telegramToken`.
|
|
51
|
+
|
|
52
|
+
### Get your Chat ID
|
|
53
|
+
|
|
54
|
+
1. Search for **@userinfobot** on Telegram
|
|
55
|
+
2. Start a chat and send any message
|
|
56
|
+
3. It replies with your ID like:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Id: 123456789
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
That number is your `telegramUserId`.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Step 2 — Install
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install baileys-tele
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Step 3 — Setup config
|
|
75
|
+
|
|
76
|
+
Run the interactive setup in your bot's root folder:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npx baileys-tele init
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
It asks for your token, chat ID, Firebase URL, and bot number — then generates `baileys-tele.config.js` automatically.
|
|
83
|
+
|
|
84
|
+
**Or create it manually:**
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
// baileys-tele.config.js
|
|
88
|
+
module.exports = {
|
|
89
|
+
telegramToken: '5839201847:AAFxxxxxxxxxxxxxxxxx', // from @BotFather
|
|
90
|
+
telegramUserId: '123456789', // from @userinfobot
|
|
91
|
+
firebaseUrl: 'https://your-project-default-rtdb.firebaseio.com',
|
|
92
|
+
botNumber: '2637XXXXXXXX', // your WhatsApp number, digits only
|
|
93
|
+
botName: 'My WhatsApp Bot',
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> ⚠️ Add `baileys-tele.config.js` to your `.gitignore` — never push tokens to GitHub.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Step 4 — Add to your bot
|
|
102
|
+
|
|
103
|
+
Paste this into your bot's **main file** (wherever you create your Baileys socket):
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
const { makeWASocket, useMultiFileAuthState } = require('@whiskeysockets/baileys');
|
|
107
|
+
const { initTelePanel, notifySessionActive, notifyError } = require('baileys-tele');
|
|
108
|
+
const config = require('./baileys-tele.config');
|
|
109
|
+
|
|
110
|
+
async function startBot() {
|
|
111
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth');
|
|
112
|
+
|
|
113
|
+
const sock = makeWASocket({ auth: state });
|
|
114
|
+
|
|
115
|
+
sock.ev.on('creds.update', saveCreds);
|
|
116
|
+
|
|
117
|
+
sock.ev.on('connection.update', async ({ connection }) => {
|
|
118
|
+
if (connection === 'open') {
|
|
119
|
+
console.log('✅ WhatsApp connected');
|
|
120
|
+
|
|
121
|
+
// 🚀 Start the Telegram control panel
|
|
122
|
+
await initTelePanel(config, sock);
|
|
123
|
+
|
|
124
|
+
// Notify yourself on Telegram that the bot is live
|
|
125
|
+
await notifySessionActive(config.botNumber);
|
|
126
|
+
}
|
|
127
|
+
if (connection === 'close') {
|
|
128
|
+
console.log('❌ Connection closed — reconnecting...');
|
|
129
|
+
startBot();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
134
|
+
// Your message handling logic here...
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
startBot();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
That's it. Open Telegram, send `/start` to your bot, and your panel is live. 🎉
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Notification helpers
|
|
146
|
+
|
|
147
|
+
Call these anywhere in your bot logic:
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const {
|
|
151
|
+
sendToOwner,
|
|
152
|
+
notifyOwner,
|
|
153
|
+
notifyNewMessage,
|
|
154
|
+
notifySessionActive,
|
|
155
|
+
notifyError
|
|
156
|
+
} = require('baileys-tele');
|
|
157
|
+
|
|
158
|
+
// Send any message to yourself on Telegram
|
|
159
|
+
await sendToOwner('🔔 Something happened!');
|
|
160
|
+
|
|
161
|
+
// Notify on new incoming message
|
|
162
|
+
await notifyNewMessage('263778xxxxxx', 'Hello bot!');
|
|
163
|
+
|
|
164
|
+
// Notify on an error in your bot
|
|
165
|
+
try {
|
|
166
|
+
// your logic
|
|
167
|
+
} catch (err) {
|
|
168
|
+
await notifyError('messages.upsert', err.message);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Generic event notify
|
|
172
|
+
await notifyOwner('Command Used', '.ping by 263778xxxxxx');
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Firebase data structure
|
|
178
|
+
|
|
179
|
+
`baileys-tele` reads and writes to your Firebase under this structure:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
/bots/{botNumber}/
|
|
183
|
+
settings/
|
|
184
|
+
autoreact: true/false
|
|
185
|
+
autoread: true/false
|
|
186
|
+
autoTyping: true/false
|
|
187
|
+
autoRecording: true/false
|
|
188
|
+
likestatus: true/false
|
|
189
|
+
savestatus: true/false
|
|
190
|
+
statusmessg: true/false
|
|
191
|
+
antilink: true/false
|
|
192
|
+
chatbot: true/false
|
|
193
|
+
chatbotgroup: true/false
|
|
194
|
+
welcome: true/false
|
|
195
|
+
antidelete: true/false
|
|
196
|
+
antiedit: true/false
|
|
197
|
+
autobio: true/false
|
|
198
|
+
audioblock: true/false
|
|
199
|
+
stickerBlock: true/false
|
|
200
|
+
dmUnavailable: true/false
|
|
201
|
+
chataudio: true/false
|
|
202
|
+
modes/
|
|
203
|
+
publicMode: { enabled: true }
|
|
204
|
+
nightMode: { enabled: false }
|
|
205
|
+
unavailableMode: { enabled: false }
|
|
206
|
+
anticall/
|
|
207
|
+
enabled: false
|
|
208
|
+
action: 'reject'
|
|
209
|
+
profile/
|
|
210
|
+
botname: 'My Bot'
|
|
211
|
+
prefix: '.'
|
|
212
|
+
statusText: 'Online'
|
|
213
|
+
ownername: 'Owner'
|
|
214
|
+
packname: 'My Bot'
|
|
215
|
+
author: 'Dev'
|
|
216
|
+
version: '1.0'
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Your bot reads these keys from Firebase to apply settings in real-time.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Telegram commands
|
|
224
|
+
|
|
225
|
+
| Command | Action |
|
|
226
|
+
|---|---|
|
|
227
|
+
| `/start` or `/menu` | Open the control panel |
|
|
228
|
+
| `/features` | Feature toggles |
|
|
229
|
+
| `/modes` | Mode controls |
|
|
230
|
+
| `/anticall` | Anti-call settings |
|
|
231
|
+
| `/profile` | Edit bot profile |
|
|
232
|
+
| `/status` | Live uptime + active settings |
|
|
233
|
+
| `/help` | Help menu |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Project structure
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
baileys-tele/
|
|
241
|
+
├── bin/cli.js ← npx baileys-tele init
|
|
242
|
+
├── src/
|
|
243
|
+
│ ├── core/
|
|
244
|
+
│ │ ├── telegram.js ← polling engine + send helpers
|
|
245
|
+
│ │ ├── firebase.js ← Firebase read/write
|
|
246
|
+
│ │ └── config.js ← config load/save
|
|
247
|
+
│ ├── menus/
|
|
248
|
+
│ │ ├── main.js ← main menu + thumbnail
|
|
249
|
+
│ │ ├── features.js ← 18 feature toggles (2 pages)
|
|
250
|
+
│ │ ├── modes.js ← mode controls
|
|
251
|
+
│ │ ├── anticall.js ← anti-call
|
|
252
|
+
│ │ └── profile.js ← profile editor
|
|
253
|
+
│ ├── notify/
|
|
254
|
+
│ │ └── notify.js ← notification helpers
|
|
255
|
+
│ └── index.js ← initTelePanel entry point
|
|
256
|
+
├── template/
|
|
257
|
+
│ └── baileys-tele.config.js ← config template
|
|
258
|
+
├── package.json
|
|
259
|
+
└── README.md
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT — free to use in any Baileys bot project.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
**Iconic Tech** · [SilentByte Platforms Inc](https://github.com/silentbyte-platforms)
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ============================================================
|
|
3
|
+
// baileys-tele — CLI
|
|
4
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
5
|
+
// Usage: npx baileys-tele init
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const fs = require('fs-extra');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const chalk = require('chalk');
|
|
13
|
+
const readline = require('readline');
|
|
14
|
+
|
|
15
|
+
const pkg = require('../package.json');
|
|
16
|
+
|
|
17
|
+
const BANNER = `
|
|
18
|
+
${chalk.cyan('╔══════════════════════════════════════════╗')}
|
|
19
|
+
${chalk.cyan('║')} ${chalk.bold.white('baileys-tele')} ${chalk.gray(`v${pkg.version}`)} ${chalk.cyan('║')}
|
|
20
|
+
${chalk.cyan('║')} ${chalk.gray('by Iconic Tech · SilentByte Platforms Inc')} ${chalk.cyan('║')}
|
|
21
|
+
${chalk.cyan('╚══════════════════════════════════════════╝')}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const args = process.argv.slice(2);
|
|
25
|
+
const cmd = args[0];
|
|
26
|
+
|
|
27
|
+
function ask(rl, question) {
|
|
28
|
+
return new Promise(resolve => rl.question(question, resolve));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function init() {
|
|
32
|
+
console.log(BANNER);
|
|
33
|
+
|
|
34
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
35
|
+
|
|
36
|
+
console.log(chalk.yellow('⚡ Setting up baileys-tele in your project...\n'));
|
|
37
|
+
|
|
38
|
+
const token = await ask(rl, chalk.white('Enter your Telegram Bot Token: '));
|
|
39
|
+
const userId = await ask(rl, chalk.white('Enter your Telegram Chat ID: '));
|
|
40
|
+
const fbUrl = await ask(rl, chalk.white('Enter your Firebase Realtime DB URL (leave blank to skip): '));
|
|
41
|
+
const botNum = await ask(rl, chalk.white('Enter your WhatsApp bot number (e.g. 2637XXXXXXXX): '));
|
|
42
|
+
|
|
43
|
+
rl.close();
|
|
44
|
+
|
|
45
|
+
if (!token || !userId) {
|
|
46
|
+
console.log(chalk.red('\n✖ Token and Chat ID are required. Run npx baileys-tele init again.\n'));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const configContent = `// ============================================================
|
|
51
|
+
// baileys-tele config — auto-generated by npx baileys-tele init
|
|
52
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
53
|
+
// ============================================================
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
telegramToken: '${token.trim()}',
|
|
57
|
+
telegramUserId: '${userId.trim()}',
|
|
58
|
+
firebaseUrl: '${(fbUrl || '').trim()}',
|
|
59
|
+
botNumber: '${(botNum || '').trim().replace(/\D/g, '')}',
|
|
60
|
+
};
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const dest = path.join(process.cwd(), 'baileys-tele.config.js');
|
|
64
|
+
await fs.writeFile(dest, configContent, 'utf8');
|
|
65
|
+
|
|
66
|
+
console.log(chalk.green('\n✔ Config saved → baileys-tele.config.js'));
|
|
67
|
+
console.log(chalk.cyan('\nNext: add this to your bot\'s main file:\n'));
|
|
68
|
+
console.log(chalk.gray('─────────────────────────────────────────'));
|
|
69
|
+
console.log(chalk.white(`const { initTelePanel } = require('baileys-tele');
|
|
70
|
+
const config = require('./baileys-tele.config');
|
|
71
|
+
|
|
72
|
+
// Call this after your Baileys socket connects:
|
|
73
|
+
initTelePanel(config, sock);`));
|
|
74
|
+
console.log(chalk.gray('─────────────────────────────────────────'));
|
|
75
|
+
console.log(chalk.green('\n🚀 Done! Your Telegram control panel is ready.\n'));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function help() {
|
|
79
|
+
console.log(BANNER);
|
|
80
|
+
console.log(`${chalk.bold('Usage:')}`);
|
|
81
|
+
console.log(` ${chalk.cyan('npx baileys-tele init')} — Setup config & scaffold integration`);
|
|
82
|
+
console.log(` ${chalk.cyan('npx baileys-tele help')} — Show this help\n`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!cmd || cmd === 'init') {
|
|
86
|
+
init().catch(err => {
|
|
87
|
+
console.error(chalk.red('Error:'), err.message);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
90
|
+
} else if (cmd === 'help' || cmd === '--help' || cmd === '-h') {
|
|
91
|
+
help();
|
|
92
|
+
} else {
|
|
93
|
+
console.log(chalk.red(`Unknown command: ${cmd}`));
|
|
94
|
+
help();
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "baileys-tele",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Add a full Telegram control panel to any Baileys WhatsApp bot — one command, zero config headache.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"baileys-tele": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"baileys",
|
|
14
|
+
"whatsapp",
|
|
15
|
+
"telegram",
|
|
16
|
+
"bot",
|
|
17
|
+
"control-panel",
|
|
18
|
+
"whatsapp-bot",
|
|
19
|
+
"baileys-bot",
|
|
20
|
+
"telegram-bot"
|
|
21
|
+
],
|
|
22
|
+
"author": "Iconic Tech <iconictech@silentbyte.io>",
|
|
23
|
+
"company": "SilentByte Platforms Inc",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"axios": "^1.6.0",
|
|
27
|
+
"chalk": "^4.1.2",
|
|
28
|
+
"fs-extra": "^11.2.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=16.0.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/silentbyte-platforms/baileys-tele"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/silentbyte-platforms/baileys-tele#readme",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/silentbyte-platforms/baileys-tele/issues"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/core/config.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// Loads and persists Telegram config scoped per bot number
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const axios = require('axios');
|
|
10
|
+
|
|
11
|
+
let _config = null;
|
|
12
|
+
|
|
13
|
+
// Build Firebase path scoped to this bot's number
|
|
14
|
+
function _configPath(firebaseUrl, botNumber) {
|
|
15
|
+
const num = String(botNumber || '').replace(/\D/g, '');
|
|
16
|
+
if (!num) return `${firebaseUrl}/baileys-tele/global/config.json`;
|
|
17
|
+
return `${firebaseUrl}/baileys-tele/${num}/config.json`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Load config from Firebase for the given bot number.
|
|
22
|
+
* Falls back to global path if scoped path is empty.
|
|
23
|
+
*/
|
|
24
|
+
async function loadConfig(firebaseUrl, botNumber) {
|
|
25
|
+
if (!firebaseUrl) return null;
|
|
26
|
+
try {
|
|
27
|
+
const url = _configPath(firebaseUrl, botNumber);
|
|
28
|
+
const res = await axios.get(url);
|
|
29
|
+
if (res.data && res.data.telegramToken) {
|
|
30
|
+
_config = res.data;
|
|
31
|
+
return _config;
|
|
32
|
+
}
|
|
33
|
+
// fallback
|
|
34
|
+
const fb = await axios.get(`${firebaseUrl}/baileys-tele/global/config.json`);
|
|
35
|
+
if (fb.data && fb.data.telegramToken) {
|
|
36
|
+
_config = fb.data;
|
|
37
|
+
return _config;
|
|
38
|
+
}
|
|
39
|
+
} catch { /* silent */ }
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Save config to Firebase scoped to bot number.
|
|
45
|
+
*/
|
|
46
|
+
async function saveConfig(firebaseUrl, botNumber, data) {
|
|
47
|
+
if (!firebaseUrl) return;
|
|
48
|
+
try {
|
|
49
|
+
const url = _configPath(firebaseUrl, botNumber);
|
|
50
|
+
await axios.put(url, { ...data, savedAt: new Date().toISOString() });
|
|
51
|
+
} catch { /* silent */ }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Set config in memory (used at init when config passed directly).
|
|
56
|
+
*/
|
|
57
|
+
function setConfig(data) {
|
|
58
|
+
_config = data;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getConfig() {
|
|
62
|
+
return _config;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = { loadConfig, saveConfig, setConfig, getConfig };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/core/firebase.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// Firebase Realtime Database helpers — all scoped to botNumber
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const axios = require('axios');
|
|
10
|
+
|
|
11
|
+
let _firebaseUrl = '';
|
|
12
|
+
let _botNumber = '';
|
|
13
|
+
|
|
14
|
+
function init(firebaseUrl, botNumber) {
|
|
15
|
+
_firebaseUrl = firebaseUrl;
|
|
16
|
+
_botNumber = String(botNumber || '').replace(/\D/g, '');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _base() {
|
|
20
|
+
return `${_firebaseUrl}/bots/${_botNumber}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ── Settings ──────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
async function getSettings() {
|
|
26
|
+
try {
|
|
27
|
+
const r = await axios.get(`${_base()}/settings.json`);
|
|
28
|
+
return r.data || {};
|
|
29
|
+
} catch { return {}; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function saveSetting(key, value) {
|
|
33
|
+
try {
|
|
34
|
+
await axios.put(`${_base()}/settings/${key}.json`, value);
|
|
35
|
+
} catch { /* silent */ }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ── Profile ───────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
async function getProfile() {
|
|
41
|
+
try {
|
|
42
|
+
const r = await axios.get(`${_base()}/profile.json`);
|
|
43
|
+
return r.data || {};
|
|
44
|
+
} catch { return {}; }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function saveProfile(field, value) {
|
|
48
|
+
try {
|
|
49
|
+
await axios.patch(`${_base()}/profile.json`, { [field]: value });
|
|
50
|
+
} catch { /* silent */ }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── Modes ─────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
async function getModes() {
|
|
56
|
+
try {
|
|
57
|
+
const r = await axios.get(`${_base()}/modes.json`);
|
|
58
|
+
return r.data || {};
|
|
59
|
+
} catch { return {}; }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function saveMode(modeKey, data) {
|
|
63
|
+
try {
|
|
64
|
+
await axios.patch(`${_base()}/modes/${modeKey}.json`, data);
|
|
65
|
+
} catch { /* silent */ }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ── Anti-Call ─────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
async function getAnticall() {
|
|
71
|
+
try {
|
|
72
|
+
const r = await axios.get(`${_base()}/anticall.json`);
|
|
73
|
+
return r.data || {};
|
|
74
|
+
} catch { return {}; }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function saveAnticall(data) {
|
|
78
|
+
try {
|
|
79
|
+
await axios.patch(`${_base()}/anticall.json`, data);
|
|
80
|
+
} catch { /* silent */ }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = {
|
|
84
|
+
init,
|
|
85
|
+
getSettings, saveSetting,
|
|
86
|
+
getProfile, saveProfile,
|
|
87
|
+
getModes, saveMode,
|
|
88
|
+
getAnticall, saveAnticall
|
|
89
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/core/telegram.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// Telegram polling engine + send/edit/photo helpers
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const axios = require('axios');
|
|
10
|
+
|
|
11
|
+
let _token = '';
|
|
12
|
+
let _userId = '';
|
|
13
|
+
let _offset = 0;
|
|
14
|
+
let _poll = null;
|
|
15
|
+
|
|
16
|
+
// Handlers registered by menus
|
|
17
|
+
let _onMessage = null;
|
|
18
|
+
let _onCallback = null;
|
|
19
|
+
|
|
20
|
+
const TG = () => `https://api.telegram.org/bot${_token}`;
|
|
21
|
+
|
|
22
|
+
function init(token, userId) {
|
|
23
|
+
_token = token;
|
|
24
|
+
_userId = String(userId);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function onMessage(fn) { _onMessage = fn; }
|
|
28
|
+
function onCallback(fn) { _onCallback = fn; }
|
|
29
|
+
|
|
30
|
+
// ── Polling ───────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
function startPolling() {
|
|
33
|
+
if (_poll) return;
|
|
34
|
+
_poll = setInterval(_tick, 2000);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stopPolling() {
|
|
38
|
+
if (_poll) { clearInterval(_poll); _poll = null; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function _tick() {
|
|
42
|
+
if (!_token) return;
|
|
43
|
+
try {
|
|
44
|
+
const res = await axios.get(`${TG()}/getUpdates`, {
|
|
45
|
+
params: { offset: _offset, timeout: 1, allowed_updates: ['message', 'callback_query'] },
|
|
46
|
+
timeout: 5000
|
|
47
|
+
});
|
|
48
|
+
for (const u of res.data.result || []) {
|
|
49
|
+
_offset = u.update_id + 1;
|
|
50
|
+
if (u.message && _onMessage) await _onMessage(u.message);
|
|
51
|
+
if (u.callback_query && _onCallback) await _onCallback(u.callback_query);
|
|
52
|
+
}
|
|
53
|
+
} catch { /* silent */ }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── Guards ────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
function isOwner(chatId) {
|
|
59
|
+
return String(chatId) === _userId;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ── Send helpers ──────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
async function send(chatId, text, keyboard) {
|
|
65
|
+
if (!_token) return;
|
|
66
|
+
await axios.post(`${TG()}/sendMessage`, {
|
|
67
|
+
chat_id: chatId, text, parse_mode: 'Markdown', reply_markup: keyboard
|
|
68
|
+
}).catch(() => {});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function sendOrEdit(chatId, editMsgId, text, keyboard) {
|
|
72
|
+
if (!_token) return;
|
|
73
|
+
const payload = { chat_id: chatId, text, parse_mode: 'Markdown', reply_markup: keyboard };
|
|
74
|
+
try {
|
|
75
|
+
if (editMsgId) {
|
|
76
|
+
await axios.post(`${TG()}/editMessageText`, { ...payload, message_id: editMsgId });
|
|
77
|
+
} else {
|
|
78
|
+
await axios.post(`${TG()}/sendMessage`, payload);
|
|
79
|
+
}
|
|
80
|
+
} catch {
|
|
81
|
+
if (editMsgId) await axios.post(`${TG()}/sendMessage`, payload).catch(() => {});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function sendPhoto(chatId, photoUrl, caption, keyboard) {
|
|
86
|
+
if (!_token) return;
|
|
87
|
+
await axios.post(`${TG()}/sendPhoto`, {
|
|
88
|
+
chat_id: chatId, photo: photoUrl, caption,
|
|
89
|
+
parse_mode: 'Markdown', reply_markup: keyboard
|
|
90
|
+
}).catch(async () => {
|
|
91
|
+
await send(chatId, caption, keyboard);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function answerCallback(id) {
|
|
96
|
+
if (!_token) return;
|
|
97
|
+
await axios.post(`${TG()}/answerCallbackQuery`, { callback_query_id: id }).catch(() => {});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function sendToOwner(text) {
|
|
101
|
+
if (!_token || !_userId) return { ok: false, error: 'not configured' };
|
|
102
|
+
try {
|
|
103
|
+
const res = await axios.post(`${TG()}/sendMessage`, {
|
|
104
|
+
chat_id: _userId, text, parse_mode: 'Markdown'
|
|
105
|
+
});
|
|
106
|
+
return { ok: res.data.ok };
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return { ok: false, error: e.message };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = {
|
|
113
|
+
init, onMessage, onCallback,
|
|
114
|
+
startPolling, stopPolling,
|
|
115
|
+
isOwner, send, sendOrEdit, sendPhoto,
|
|
116
|
+
answerCallback, sendToOwner
|
|
117
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/index.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
//
|
|
5
|
+
// Main entry — call initTelePanel(config, sock) in your bot.
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const tgCore = require('./core/telegram');
|
|
11
|
+
const fbCore = require('./core/firebase');
|
|
12
|
+
const cfgCore = require('./core/config');
|
|
13
|
+
|
|
14
|
+
const menuMain = require('./menus/main');
|
|
15
|
+
const menuFeatures = require('./menus/features');
|
|
16
|
+
const menuModes = require('./menus/modes');
|
|
17
|
+
const menuAnticall = require('./menus/anticall');
|
|
18
|
+
const menuProfile = require('./menus/profile');
|
|
19
|
+
|
|
20
|
+
const notify = require('./notify/notify');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* initTelePanel(config, sock)
|
|
24
|
+
*
|
|
25
|
+
* config = {
|
|
26
|
+
* telegramToken: 'YOUR_BOT_TOKEN',
|
|
27
|
+
* telegramUserId: 'YOUR_CHAT_ID',
|
|
28
|
+
* firebaseUrl: 'https://your-project-default-rtdb.firebaseio.com',
|
|
29
|
+
* botNumber: '2637XXXXXXXX',
|
|
30
|
+
* botName: 'My Bot', // optional
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* sock = your Baileys socket instance (optional — for future cmd hooks)
|
|
34
|
+
*/
|
|
35
|
+
async function initTelePanel(config, sock) {
|
|
36
|
+
const {
|
|
37
|
+
telegramToken,
|
|
38
|
+
telegramUserId,
|
|
39
|
+
firebaseUrl,
|
|
40
|
+
botNumber,
|
|
41
|
+
botName
|
|
42
|
+
} = config;
|
|
43
|
+
|
|
44
|
+
if (!telegramToken || !telegramUserId) {
|
|
45
|
+
console.error('[baileys-tele] ✖ telegramToken and telegramUserId are required.');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Init cores
|
|
50
|
+
tgCore.init(telegramToken, telegramUserId);
|
|
51
|
+
fbCore.init(firebaseUrl || '', botNumber || '');
|
|
52
|
+
cfgCore.setConfig(config);
|
|
53
|
+
|
|
54
|
+
// Init menus
|
|
55
|
+
menuMain.init(botNumber || '', botName || 'My WhatsApp Bot');
|
|
56
|
+
notify.init(botName || 'My WhatsApp Bot', botNumber || '');
|
|
57
|
+
|
|
58
|
+
// Wire message handler
|
|
59
|
+
tgCore.onMessage(async (msg) => {
|
|
60
|
+
const chatId = String(msg.chat.id);
|
|
61
|
+
if (!tgCore.isOwner(chatId)) return;
|
|
62
|
+
const text = (msg.text || '').trim();
|
|
63
|
+
|
|
64
|
+
// Profile text input takes priority
|
|
65
|
+
if (await menuProfile.handleTextInput(chatId, text)) return;
|
|
66
|
+
|
|
67
|
+
if (text === '/start' || text === '/menu') return menuMain.send(chatId);
|
|
68
|
+
if (text === '/features') return menuFeatures.sendPage1(chatId);
|
|
69
|
+
if (text === '/modes') return menuModes.send(chatId);
|
|
70
|
+
if (text === '/anticall') return menuAnticall.send(chatId);
|
|
71
|
+
if (text === '/profile') return menuProfile.send(chatId);
|
|
72
|
+
if (text === '/status') return _sendStatus(chatId);
|
|
73
|
+
if (text === '/help') return _sendHelp(chatId);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Wire callback handler
|
|
77
|
+
tgCore.onCallback(async (cb) => {
|
|
78
|
+
const chatId = String(cb.message.chat.id);
|
|
79
|
+
const msgId = cb.message.message_id;
|
|
80
|
+
const data = cb.data;
|
|
81
|
+
|
|
82
|
+
if (!tgCore.isOwner(chatId)) return;
|
|
83
|
+
await tgCore.answerCallback(cb.id);
|
|
84
|
+
|
|
85
|
+
// Navigation
|
|
86
|
+
if (data === 'menu') return menuMain.send(chatId, msgId);
|
|
87
|
+
if (data === 'status') return _sendStatus(chatId, msgId);
|
|
88
|
+
if (data === 'help') return _sendHelp(chatId, msgId);
|
|
89
|
+
|
|
90
|
+
// Features
|
|
91
|
+
if (data === 'features') return menuFeatures.sendPage1(chatId, msgId);
|
|
92
|
+
if (data === 'features2') return menuFeatures.sendPage2(chatId, msgId);
|
|
93
|
+
if (data.startsWith('feat_')) return menuFeatures.toggle(chatId, msgId, data.replace('feat_', ''));
|
|
94
|
+
|
|
95
|
+
// Modes
|
|
96
|
+
if (data === 'modes') return menuModes.send(chatId, msgId);
|
|
97
|
+
if (data === 'mode_public') return menuModes.setMode(chatId, msgId, 'publicMode', { enabled: true }, 'Public Mode', '🔓 ON');
|
|
98
|
+
if (data === 'mode_private') return menuModes.setMode(chatId, msgId, 'publicMode', { enabled: false }, 'Private Mode', '🔒 ON');
|
|
99
|
+
if (data === 'mode_night_on') return menuModes.setMode(chatId, msgId, 'nightMode', { enabled: true }, 'Night Mode', '🌙 ON');
|
|
100
|
+
if (data === 'mode_night_off') return menuModes.setMode(chatId, msgId, 'nightMode', { enabled: false }, 'Night Mode', '☀️ OFF');
|
|
101
|
+
if (data === 'mode_unavail_on') return menuModes.setMode(chatId, msgId, 'unavailableMode', { enabled: true }, 'Unavailable Mode', '⛔ ON');
|
|
102
|
+
if (data === 'mode_unavail_off') return menuModes.setMode(chatId, msgId, 'unavailableMode', { enabled: false }, 'Unavailable Mode', '✅ OFF');
|
|
103
|
+
|
|
104
|
+
// Anti-call
|
|
105
|
+
if (data === 'anticall') return menuAnticall.send(chatId, msgId);
|
|
106
|
+
if (data === 'anticall_on') return menuAnticall.setEnabled(chatId, msgId, true);
|
|
107
|
+
if (data === 'anticall_off') return menuAnticall.setEnabled(chatId, msgId, false);
|
|
108
|
+
if (data === 'anticall_block') return menuAnticall.setAction(chatId, msgId, 'block');
|
|
109
|
+
if (data === 'anticall_reject') return menuAnticall.setAction(chatId, msgId, 'reject');
|
|
110
|
+
|
|
111
|
+
// Profile
|
|
112
|
+
if (data === 'profile') return menuProfile.send(chatId, msgId);
|
|
113
|
+
if (data.startsWith('edit_')) return menuProfile.promptEdit(chatId, msgId, data.replace('edit_', ''));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Start polling
|
|
117
|
+
tgCore.startPolling();
|
|
118
|
+
|
|
119
|
+
console.log(`[baileys-tele] ✓ Telegram panel active — bot: +${botNumber || '?'}`);
|
|
120
|
+
|
|
121
|
+
// Notify owner bot is online
|
|
122
|
+
await notify.notifyBotStarted();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ── Internal status & help panels ─────────────────────────
|
|
126
|
+
|
|
127
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
128
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
129
|
+
|
|
130
|
+
async function _sendStatus(chatId, editMsgId) {
|
|
131
|
+
const u = process.uptime();
|
|
132
|
+
const h = Math.floor(u / 3600);
|
|
133
|
+
const m = Math.floor((u % 3600) / 60);
|
|
134
|
+
const s = Math.floor(u % 60);
|
|
135
|
+
const st = await fbCore.getSettings();
|
|
136
|
+
const mo = await fbCore.getModes();
|
|
137
|
+
const ac = await fbCore.getAnticall();
|
|
138
|
+
const cfg = cfgCore.getConfig();
|
|
139
|
+
const isPublic = mo?.publicMode?.enabled !== false;
|
|
140
|
+
|
|
141
|
+
await tgCore.sendOrEdit(chatId, editMsgId,
|
|
142
|
+
`📊 *Bot Status*\n${DIVIDER}\n` +
|
|
143
|
+
`🟢 Status: *Online*\n` +
|
|
144
|
+
`📱 Number: \`+${cfg?.botNumber || '?'}\`\n` +
|
|
145
|
+
`⏱ Uptime: *${h}h ${m}m ${s}s*\n` +
|
|
146
|
+
`🤖 Name: *${cfg?.botName || 'My Bot'}*\n\n` +
|
|
147
|
+
`🔓 Mode: *${isPublic ? '🔓 Public' : '🔒 Private'}*\n` +
|
|
148
|
+
`⚡ Auto React: *${st.autoreact ? '✅' : '❌'}*\n` +
|
|
149
|
+
`📵 Anti-Call: *${ac.enabled ? '✅' : '❌'}*\n` +
|
|
150
|
+
`🔗 Anti-Link: *${st.antilink ? '✅' : '❌'}*\n` +
|
|
151
|
+
`🤖 ChatBot: *${st.chatbot ? '✅' : '❌'}*\n` +
|
|
152
|
+
`👁 Auto Read: *${st.autoread ? '✅' : '❌'}*\n` +
|
|
153
|
+
`⌨️ Auto Typing: *${st.autoTyping ? '✅' : '❌'}*\n` +
|
|
154
|
+
`💾 Save Status: *${st.savestatus ? '✅' : '❌'}*\n` +
|
|
155
|
+
`❤️ Like Status: *${st.likestatus ? '✅' : '❌'}*${FOOTER}`,
|
|
156
|
+
{ inline_keyboard: [
|
|
157
|
+
[{ text: '🔄 Refresh', callback_data: 'status' }, { text: '← Menu', callback_data: 'menu' }]
|
|
158
|
+
]}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function _sendHelp(chatId, editMsgId) {
|
|
163
|
+
await tgCore.sendOrEdit(chatId, editMsgId,
|
|
164
|
+
`❓ *baileys-tele — Help*\n${DIVIDER}\n` +
|
|
165
|
+
`*Commands:*\n` +
|
|
166
|
+
`/start — Open control panel\n` +
|
|
167
|
+
`/menu — Open control panel\n` +
|
|
168
|
+
`/features — Feature toggles (18 settings)\n` +
|
|
169
|
+
`/modes — Public/Private/Night/Unavailable\n` +
|
|
170
|
+
`/anticall — Anti-call settings\n` +
|
|
171
|
+
`/profile — Edit bot profile\n` +
|
|
172
|
+
`/status — Live uptime & stats\n` +
|
|
173
|
+
`/help — This menu\n\n` +
|
|
174
|
+
`_All changes apply to your WhatsApp bot instantly via Firebase._${FOOTER}`,
|
|
175
|
+
{ inline_keyboard: [[{ text: '← Back to Menu', callback_data: 'menu' }]] }
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ── Exports ───────────────────────────────────────────────
|
|
180
|
+
|
|
181
|
+
module.exports = {
|
|
182
|
+
initTelePanel,
|
|
183
|
+
// Re-export notify helpers so user can call them directly
|
|
184
|
+
sendToOwner: notify.sendToOwner,
|
|
185
|
+
notifyOwner: notify.notifyOwner,
|
|
186
|
+
notifyNewMessage: notify.notifyNewMessage,
|
|
187
|
+
notifySessionActive: notify.notifySessionActive,
|
|
188
|
+
notifyBotStarted: notify.notifyBotStarted,
|
|
189
|
+
notifyError: notify.notifyError
|
|
190
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/menus/anticall.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const tg = require('../core/telegram');
|
|
9
|
+
const fb = require('../core/firebase');
|
|
10
|
+
|
|
11
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
12
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
13
|
+
|
|
14
|
+
async function send(chatId, editMsgId) {
|
|
15
|
+
const cfg = await fb.getAnticall();
|
|
16
|
+
const enabled = !!cfg.enabled;
|
|
17
|
+
const action = cfg.action || 'reject';
|
|
18
|
+
await tg.sendOrEdit(chatId, editMsgId,
|
|
19
|
+
`📵 *Anti-Call Settings*\n${DIVIDER}\n` +
|
|
20
|
+
`Status: *${enabled ? '✅ Enabled' : '❌ Disabled'}*\n` +
|
|
21
|
+
`Action: *${action === 'block' ? '🚫 Block Caller' : '🔇 Reject Only'}*${FOOTER}`,
|
|
22
|
+
{ inline_keyboard: [
|
|
23
|
+
[{ text: '✅ Enable', callback_data: 'anticall_on' }, { text: '❌ Disable', callback_data: 'anticall_off' }],
|
|
24
|
+
[{ text: '🚫 Block Caller', callback_data: 'anticall_block' }, { text: '🔇 Reject Only', callback_data: 'anticall_reject'}],
|
|
25
|
+
[{ text: '← Back', callback_data: 'menu' }]
|
|
26
|
+
]}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function setEnabled(chatId, msgId, enabled) {
|
|
31
|
+
await fb.saveAnticall({ enabled });
|
|
32
|
+
await tg.sendOrEdit(chatId, msgId,
|
|
33
|
+
`📵 Anti-Call → *${enabled ? '✅ Enabled' : '❌ Disabled'}*\n\n_Returning..._${FOOTER}`,
|
|
34
|
+
{ inline_keyboard: [[{ text: '← Anti-Call', callback_data: 'anticall' }]] }
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function setAction(chatId, msgId, action) {
|
|
39
|
+
await fb.saveAnticall({ action });
|
|
40
|
+
await tg.sendOrEdit(chatId, msgId,
|
|
41
|
+
`📵 Anti-Call action → *${action === 'block' ? '🚫 Block Caller' : '🔇 Reject Only'}*\n\n_Returning..._${FOOTER}`,
|
|
42
|
+
{ inline_keyboard: [[{ text: '← Anti-Call', callback_data: 'anticall' }]] }
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = { send, setEnabled, setAction };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/menus/features.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const tg = require('../core/telegram');
|
|
9
|
+
const fb = require('../core/firebase');
|
|
10
|
+
|
|
11
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
12
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
13
|
+
|
|
14
|
+
// Keys that live on page 2
|
|
15
|
+
const PAGE2 = [
|
|
16
|
+
'chatbot','chatbotgroup','welcome','antidelete',
|
|
17
|
+
'antiedit','autobio','audioblock','stickerBlock',
|
|
18
|
+
'dmUnavailable','chataudio'
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
function _tb(label, data, isOn) {
|
|
22
|
+
return { text: `${isOn ? '✅' : '❌'} ${label}`, callback_data: data };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function sendPage1(chatId, editMsgId) {
|
|
26
|
+
const s = await fb.getSettings();
|
|
27
|
+
await tg.sendOrEdit(chatId, editMsgId,
|
|
28
|
+
`⚡ *Features — Page 1*\n${DIVIDER}\n✅ = ON | ❌ = OFF\n_Tap to toggle instantly._${FOOTER}`,
|
|
29
|
+
{ inline_keyboard: [
|
|
30
|
+
[_tb('Auto Recording', 'feat_autoRecording', s.autoRecording), _tb('Auto Typing', 'feat_autoTyping', s.autoTyping)],
|
|
31
|
+
[_tb('Auto React', 'feat_autoreact', s.autoreact), _tb('Auto Read', 'feat_autoread', s.autoread)],
|
|
32
|
+
[_tb('Like Status', 'feat_likestatus', s.likestatus), _tb('Save Status', 'feat_savestatus', s.savestatus)],
|
|
33
|
+
[_tb('Status Reply', 'feat_statusmessg', s.statusmessg), _tb('Anti-Link', 'feat_antilink', s.antilink)],
|
|
34
|
+
[{ text: '▶ Page 2', callback_data: 'features2' }, { text: '← Menu', callback_data: 'menu' }]
|
|
35
|
+
]}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function sendPage2(chatId, editMsgId) {
|
|
40
|
+
const s = await fb.getSettings();
|
|
41
|
+
await tg.sendOrEdit(chatId, editMsgId,
|
|
42
|
+
`⚡ *Features — Page 2*\n${DIVIDER}\n✅ = ON | ❌ = OFF\n_Tap to toggle instantly._${FOOTER}`,
|
|
43
|
+
{ inline_keyboard: [
|
|
44
|
+
[_tb('ChatBot', 'feat_chatbot', s.chatbot), _tb('ChatBot Groups', 'feat_chatbotgroup', s.chatbotgroup)],
|
|
45
|
+
[_tb('Welcome Msg', 'feat_welcome', s.welcome), _tb('Anti Delete', 'feat_antidelete', s.antidelete)],
|
|
46
|
+
[_tb('Anti Edit', 'feat_antiedit', s.antiedit), _tb('Auto Bio', 'feat_autobio', s.autobio)],
|
|
47
|
+
[_tb('Block Audios', 'feat_audioblock', s.audioblock), _tb('Block Stickers', 'feat_stickerBlock', s.stickerBlock)],
|
|
48
|
+
[_tb('DM Unavailable', 'feat_dmUnavailable', s.dmUnavailable), _tb('Chat Audio AI', 'feat_chataudio', s.chataudio)],
|
|
49
|
+
[{ text: '◀ Page 1', callback_data: 'features' }, { text: '← Menu', callback_data: 'menu' }]
|
|
50
|
+
]}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function toggle(chatId, msgId, key) {
|
|
55
|
+
const s = await fb.getSettings();
|
|
56
|
+
const next = !s[key];
|
|
57
|
+
await fb.saveSetting(key, next);
|
|
58
|
+
return PAGE2.includes(key) ? sendPage2(chatId, msgId) : sendPage1(chatId, msgId);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { sendPage1, sendPage2, toggle };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/menus/main.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const tg = require('../core/telegram');
|
|
9
|
+
|
|
10
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
11
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
12
|
+
const THUMB = 'https://i.postimg.cc/F7v8XZM4/photo.jpg'; // swap with your own
|
|
13
|
+
|
|
14
|
+
let _botNumber = '';
|
|
15
|
+
let _botName = 'My WhatsApp Bot';
|
|
16
|
+
|
|
17
|
+
function init(botNumber, botName) {
|
|
18
|
+
_botNumber = botNumber;
|
|
19
|
+
_botName = botName || 'My WhatsApp Bot';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _keyboard() {
|
|
23
|
+
return { inline_keyboard: [
|
|
24
|
+
[{ text: '⚡ Features', callback_data: 'features' }, { text: '🌙 Modes', callback_data: 'modes' }],
|
|
25
|
+
[{ text: '📵 Anti-Call', callback_data: 'anticall' }, { text: '🎨 Profile', callback_data: 'profile' }],
|
|
26
|
+
[{ text: '📊 Status', callback_data: 'status' }, { text: '❓ Help', callback_data: 'help' }]
|
|
27
|
+
]};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function send(chatId, editMsgId) {
|
|
31
|
+
const time = new Date().toLocaleString('en-GB', { hour12: true });
|
|
32
|
+
const caption =
|
|
33
|
+
`🤖 *${_botName}*\n${DIVIDER}\n` +
|
|
34
|
+
`🟢 Bot is *Online* and ready\n` +
|
|
35
|
+
`📱 Number: \`+${_botNumber || '--'}\`\n` +
|
|
36
|
+
`⏰ ${time}\n\n` +
|
|
37
|
+
`Choose what to control 👇${FOOTER}`;
|
|
38
|
+
|
|
39
|
+
if (!editMsgId) {
|
|
40
|
+
await tg.sendPhoto(chatId, THUMB, caption, _keyboard());
|
|
41
|
+
} else {
|
|
42
|
+
await tg.sendOrEdit(chatId, editMsgId, caption, _keyboard());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = { init, send };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/menus/modes.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const tg = require('../core/telegram');
|
|
9
|
+
const fb = require('../core/firebase');
|
|
10
|
+
|
|
11
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
12
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
13
|
+
|
|
14
|
+
async function send(chatId, editMsgId) {
|
|
15
|
+
const m = await fb.getModes();
|
|
16
|
+
const isPublic = m?.publicMode?.enabled !== false;
|
|
17
|
+
const nightOn = !!m?.nightMode?.enabled;
|
|
18
|
+
const unavailOn = !!m?.unavailableMode?.enabled;
|
|
19
|
+
await tg.sendOrEdit(chatId, editMsgId,
|
|
20
|
+
`🌙 *Modes Control*\n${DIVIDER}\n` +
|
|
21
|
+
`🔓 Public Mode: *${isPublic ? '✅ ON' : '❌ OFF'}*\n` +
|
|
22
|
+
`🌙 Night Mode: *${nightOn ? '✅ ON' : '❌ OFF'}*\n` +
|
|
23
|
+
`⛔ Unavailable: *${unavailOn ? '✅ ON' : '❌ OFF'}*${FOOTER}`,
|
|
24
|
+
{ inline_keyboard: [
|
|
25
|
+
[{ text: '🔓 Public', callback_data: 'mode_public' }, { text: '🔒 Private', callback_data: 'mode_private' }],
|
|
26
|
+
[{ text: '🌙 Night ON', callback_data: 'mode_night_on' }, { text: '☀️ Night OFF', callback_data: 'mode_night_off' }],
|
|
27
|
+
[{ text: '⛔ Unavail ON', callback_data: 'mode_unavail_on' }, { text: '✅ Unavail OFF', callback_data: 'mode_unavail_off'}],
|
|
28
|
+
[{ text: '← Back', callback_data: 'menu' }]
|
|
29
|
+
]}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function setMode(chatId, msgId, modeKey, data, label, stateLabel) {
|
|
34
|
+
await fb.saveMode(modeKey, data);
|
|
35
|
+
await tg.sendOrEdit(chatId, msgId,
|
|
36
|
+
`🌙 *${label}* → *${stateLabel}*\n\n_Returning to modes..._${FOOTER}`,
|
|
37
|
+
{ inline_keyboard: [[{ text: '← Modes', callback_data: 'modes' }]] }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = { send, setMode };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/menus/profile.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const tg = require('../core/telegram');
|
|
9
|
+
const fb = require('../core/firebase');
|
|
10
|
+
|
|
11
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
12
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
13
|
+
|
|
14
|
+
// State: waiting for text input
|
|
15
|
+
let _awaiting = null; // { chatId, field, label }
|
|
16
|
+
|
|
17
|
+
const LABELS = {
|
|
18
|
+
botname: 'Bot Name',
|
|
19
|
+
prefix: 'Prefix',
|
|
20
|
+
statusText: 'WhatsApp Status',
|
|
21
|
+
ownername: 'Owner Name',
|
|
22
|
+
packname: 'Pack Name',
|
|
23
|
+
author: 'Author',
|
|
24
|
+
version: 'Version'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
async function send(chatId, editMsgId) {
|
|
28
|
+
const p = await fb.getProfile();
|
|
29
|
+
await tg.sendOrEdit(chatId, editMsgId,
|
|
30
|
+
`🎨 *Profile Settings*\n${DIVIDER}\n` +
|
|
31
|
+
`🤖 Bot Name: *${p.botname || 'My Bot'}*\n` +
|
|
32
|
+
`🔖 Prefix: *${p.prefix || '.'}*\n` +
|
|
33
|
+
`📦 Version: *${p.version || '1.0'}*\n` +
|
|
34
|
+
`👤 Owner Name: *${p.ownername || 'Owner'}*\n` +
|
|
35
|
+
`📝 Status: *${p.statusText || 'Online'}*\n` +
|
|
36
|
+
`📦 Pack Name: *${p.packname || 'My Bot'}*\n` +
|
|
37
|
+
`✍️ Author: *${p.author || 'Dev'}*\n\n` +
|
|
38
|
+
`_Tap a field to edit it._${FOOTER}`,
|
|
39
|
+
{ inline_keyboard: [
|
|
40
|
+
[{ text: '✏️ Bot Name', callback_data: 'edit_botname' }, { text: '🔖 Prefix', callback_data: 'edit_prefix' }],
|
|
41
|
+
[{ text: '📝 Status', callback_data: 'edit_statusText' }, { text: '👤 Owner Name', callback_data: 'edit_ownername' }],
|
|
42
|
+
[{ text: '📦 Pack Name', callback_data: 'edit_packname' }, { text: '✍️ Author', callback_data: 'edit_author' }],
|
|
43
|
+
[{ text: '📦 Version', callback_data: 'edit_version' }, { text: '← Back', callback_data: 'menu' }]
|
|
44
|
+
]}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function promptEdit(chatId, msgId, field) {
|
|
49
|
+
const label = LABELS[field] || field;
|
|
50
|
+
_awaiting = { chatId, field, label };
|
|
51
|
+
await tg.sendOrEdit(chatId, msgId,
|
|
52
|
+
`✏️ *Edit ${label}*\n${DIVIDER}\n` +
|
|
53
|
+
`Type the new value and send it.\nSend /cancel to go back.${FOOTER}`,
|
|
54
|
+
{ inline_keyboard: [] }
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Returns true if the message was consumed by awaiting input
|
|
59
|
+
async function handleTextInput(chatId, text) {
|
|
60
|
+
if (!_awaiting || _awaiting.chatId !== chatId) return false;
|
|
61
|
+
const { field, label } = _awaiting;
|
|
62
|
+
_awaiting = null;
|
|
63
|
+
|
|
64
|
+
if (text === '/cancel') {
|
|
65
|
+
await tg.send(chatId,
|
|
66
|
+
`❌ Cancelled.`,
|
|
67
|
+
{ inline_keyboard: [[{ text: '← Profile', callback_data: 'profile' }]] }
|
|
68
|
+
);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await fb.saveProfile(field, text);
|
|
73
|
+
await tg.send(chatId,
|
|
74
|
+
`✅ *${label}* updated!\n\n*New value:* ${text}\n\n_Applied to your bot instantly._${FOOTER}`,
|
|
75
|
+
{ inline_keyboard: [
|
|
76
|
+
[{ text: '← Profile', callback_data: 'profile' }, { text: '← Menu', callback_data: 'menu' }]
|
|
77
|
+
]}
|
|
78
|
+
);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = { send, promptEdit, handleTextInput };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// baileys-tele · src/notify/notify.js
|
|
3
|
+
// by Iconic Tech | SilentByte Platforms Inc
|
|
4
|
+
// Public notification helpers — call these from your bot logic
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const tg = require('../core/telegram');
|
|
10
|
+
|
|
11
|
+
const DIVIDER = `━━━━━━━━━━━━━━━━━━━━━━`;
|
|
12
|
+
const FOOTER = `\n\n⚡ _Powered by baileys-tele · SilentByte Platforms Inc_`;
|
|
13
|
+
const THUMB = 'https://i.postimg.cc/F7v8XZM4/photo.jpg';
|
|
14
|
+
|
|
15
|
+
let _botName = 'My WhatsApp Bot';
|
|
16
|
+
let _botNumber = '';
|
|
17
|
+
|
|
18
|
+
function init(botName, botNumber) {
|
|
19
|
+
_botName = botName || 'My WhatsApp Bot';
|
|
20
|
+
_botNumber = botNumber || '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Sent when bot connects / starts up.
|
|
25
|
+
* Includes thumbnail photo.
|
|
26
|
+
*/
|
|
27
|
+
async function notifyBotStarted() {
|
|
28
|
+
const time = new Date().toLocaleString('en-GB', { hour12: true });
|
|
29
|
+
await tg.sendPhoto(
|
|
30
|
+
tg.sendToOwner._userId || '', // handled internally by sendPhoto → owner
|
|
31
|
+
THUMB,
|
|
32
|
+
`🤖 *${_botName}*\n${DIVIDER}\n` +
|
|
33
|
+
`🟢 *Bot is now Online!*\n\n` +
|
|
34
|
+
`📱 *Number:* \`+${_botNumber || 'Connecting...'}\`\n` +
|
|
35
|
+
`⏰ *Time:* ${time}\n\n` +
|
|
36
|
+
`Send /start to open your control panel.${FOOTER}`,
|
|
37
|
+
{ inline_keyboard: [[{ text: '🚀 Open Panel', callback_data: 'menu' }]] }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Internal helper that uses sendToOwner (owner userId is set in telegram core)
|
|
42
|
+
async function _notify(text) {
|
|
43
|
+
return tg.sendToOwner(text);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Notify owner when a session becomes active.
|
|
48
|
+
* Call this after your Baileys connection.update fires 'open'.
|
|
49
|
+
*/
|
|
50
|
+
async function notifySessionActive(phoneNumber) {
|
|
51
|
+
const clean = String(phoneNumber).replace(/\D/g, '');
|
|
52
|
+
const time = new Date().toLocaleString('en-GB', { hour12: true });
|
|
53
|
+
return _notify(
|
|
54
|
+
`✅ *Session Active!*\n${DIVIDER}\n` +
|
|
55
|
+
`📱 *Number:* \`+${clean}\`\n` +
|
|
56
|
+
`🟢 *Status:* Connected & Ready\n` +
|
|
57
|
+
`⏰ *Time:* ${time}\n\n` +
|
|
58
|
+
`_Your WhatsApp bot is live._${FOOTER}`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Notify owner of a new incoming message.
|
|
64
|
+
*/
|
|
65
|
+
async function notifyNewMessage(sender, content) {
|
|
66
|
+
return _notify(
|
|
67
|
+
`📩 *New Message*\n${DIVIDER}\n` +
|
|
68
|
+
`👤 *From:* \`${sender}\`\n` +
|
|
69
|
+
`💬 ${String(content).slice(0, 200)}${FOOTER}`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Notify owner of an error in your bot logic.
|
|
75
|
+
*/
|
|
76
|
+
async function notifyError(location, errMsg) {
|
|
77
|
+
return _notify(`❌ *Error — ${location}*\n${DIVIDER}\n\`${errMsg}\`${FOOTER}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Generic notify — any event string + optional detail.
|
|
82
|
+
*/
|
|
83
|
+
async function notifyOwner(event, detail = '') {
|
|
84
|
+
return _notify(`📌 *${event}*${detail ? `\n${DIVIDER}\n${detail}` : ''}${FOOTER}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Direct send — raw text to owner.
|
|
89
|
+
*/
|
|
90
|
+
async function sendToOwner(text) {
|
|
91
|
+
return tg.sendToOwner(text);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
init,
|
|
96
|
+
notifyBotStarted,
|
|
97
|
+
notifySessionActive,
|
|
98
|
+
notifyNewMessage,
|
|
99
|
+
notifyError,
|
|
100
|
+
notifyOwner,
|
|
101
|
+
sendToOwner
|
|
102
|
+
};
|