-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
165 lines (124 loc) · 5 KB
/
Copy pathindex.js
File metadata and controls
165 lines (124 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const express = require('express');
const TelegramBot = require('node-telegram-bot-api');
const premiumManager = require('./premiumManager');
const commands = require('./commands');
const app = express();
const PORT = process.env.PORT || 3000;
const bot = new TelegramBot('8241799134:AAFYq-w-7NOP3TD_F0LrJ8jjOt2GGwCYd5o', { polling: true });
app.get('/', (req, res) => {
res.send(`
<html>
<head><title>Bot Status</title></head>
<body style="text-align: center; margin-top: 50px; font-family: Arial, sans-serif;">
<h1 style="color: green;">✅ Bot Connected to Telegram</h1>
<p>Your bot is up and running!</p>
</body>
</html>
`);
});
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
console.log('Telegram Bot Connected');
});
bot.on('message', async (msg) => {
const chatId = msg.chat.id;
const text = msg.text;
const username = msg.from.username;
const userId = msg.from.id;
console.log('━━━━━━━━━━━━━━━━━━━━━━');
console.log('📨 Message reçu de:');
console.log(' User ID:', userId);
console.log(' Username:', username);
console.log(' Commande:', text);
console.log('━━━━━━━━━━━━━━━━━━━━━━');
if (!text || !text.startsWith('/')) return;
const parts = text.split(' ');
const command = parts[0].toLowerCase().replace('/', '');
const args = parts.slice(1);
const premiumCommands = ['video', 'spotify', 'applemusic', 'instagram', 'facebook', 'tiktok'];
if (premiumCommands.includes(command)) {
console.log('🔒 Vérification premium pour:', userId);
const isPremium = await premiumManager.checkPremium(userId);
console.log('✅ Résultat premium:', isPremium);
if (!isPremium) {
return bot.sendMessage(chatId,
'🔒 *Cette commande est réservée aux utilisateurs Premium*\n\n' +
'Pour obtenir un accès Premium, contactez l\'administrateur.\n\n' +
'@senstephane' +
'*ᴘᴏᴡᴇʀᴇᴅ ʙʏ ꜱᴛᴇᴘʜ ᴛᴇᴄʜ*',
{ parse_mode: 'Markdown' }
);
}
}
try {
switch (command) {
case 'start':
await commands.handleStart(bot, chatId, username);
break;
case 'help':
await commands.handleHelp(bot, chatId);
break;
case 'myid':
await commands.handleMyId(bot, chatId, args, msg);
break;
case 'play':
case 'song':
await commands.handlePlay(bot, chatId, args, msg);
break;
case 'qr':
await commands.handleQR(bot, chatId, args, msg);
break;
case 'translate':
await commands.handleTranslate(bot, chatId, args, msg);
break;
case 'img':
await commands.handleImageSearch(bot, chatId, args, msg);
break;
case 'video':
await commands.handleVideo(bot, chatId, args, msg);
break;
case 'tiktok':
await commands.handleTikTok(bot, chatId, args, msg);
break;
case 'instagram':
case 'igdl':
await commands.handleInstagram(bot, chatId, args, msg);
break;
case 'facebook':
case 'fb':
await commands.handleFacebook(bot, chatId, args, msg);
break;
case 'spotify':
await commands.handleSpotify(bot, chatId, args, msg);
break;
case 'applemusic':
await commands.handleAppleMusic(bot, chatId, args, msg);
break;
case 'addpremium':
await commands.handleAddPremium(bot, chatId, userId, args, msg);
break;
case 'removepremium':
await commands.handleRemovePremium(bot, chatId, userId, args, msg);
break;
case 'checkpremium':
await commands.handleCheckPremium(bot, chatId, args, msg);
break;
case 'listpremium':
await commands.handleListPremium(bot, chatId, userId, msg);
break;
default:
bot.sendMessage(chatId,
'❌ Commande inconnue. Utilisez /help pour voir toutes les commandes disponibles.',
{ parse_mode: 'Markdown' }
);
break;
}
} catch (error) {
console.error(`Erreur dans la commande ${command}:`, error);
bot.sendMessage(chatId,
'❌ Une erreur s\'est produite lors de l\'exécution de cette commande.',
{ parse_mode: 'Markdown' }
);
}
});
console.log('Bot démarré avec succès!');