-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (40 loc) · 1.26 KB
/
Copy pathindex.js
File metadata and controls
52 lines (40 loc) · 1.26 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
const express = require("express");
const TelegramBot = require("node-telegram-bot-api");
const token = process.env.BOT_TOKEN;
const url = process.env.RENDER_EXTERNAL_URL;
const bot = new TelegramBot(token);
bot.setWebHook(`${url}/bot${token}`);
const app = express();
app.use(express.json());
app.post(`/bot${token}`, (req, res) => {
bot.processUpdate(req.body);
res.sendStatus(200);
});
// فلترة الرسائل
bot.on("message", async (msg) => {
const chatId = msg.chat.id;
try {
// حذف forwarded
if (msg.forward_date) {
return bot.deleteMessage(chatId, msg.message_id);
}
// حذف inline buttons
if (msg.reply_markup) {
return bot.deleteMessage(chatId, msg.message_id);
}
let text = (msg.text || "") + (msg.caption || "");
// حذف روابط
if (/https?:\/\/|t\.me|www\./i.test(text)) {
return bot.deleteMessage(chatId, msg.message_id);
}
// حذف كلمات
if (/f[\W_]*u[\W_]*l[\W_]*l|🔞|xxx|porn|sex/i.test(text)) {
return bot.deleteMessage(chatId, msg.message_id);
}
} catch (e) {
console.log(e);
}
});
app.listen(3000, () => {
console.log("Bot is running...");
});