-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 845 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 845 Bytes
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
const express = require("express");
const bot = require("./bot");
const { PORT } = require("./bot/config");
const app = express();
// Health check route
app.get("/", (_, res) => res.send("🤖 Telegram bot is running."));
app.listen(PORT, () => {
console.log(`🚀 Express running on port ${PORT}`);
bot.launch()
.then(() => console.log("🤖 Telegram bot launched"))
.catch((err) => console.error("❌ Error launching bot:", err));
});
// Graceful shutdown
process.once("SIGINT", () => {
console.log("🛑 SIGINT received. Stopping bot...");
bot.stop("SIGINT");
});
process.once("SIGTERM", () => {
console.log("🛑 SIGTERM received. Stopping bot...");
bot.stop("SIGTERM");
});
// Error handling
process.on("uncaughtException", (error) => {
console.error("❌ Uncaught Exception:", error);
});