-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.ts
31 lines (29 loc) · 809 Bytes
/
app.ts
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
import bot from "./app/bot";
import * as dotenv from "dotenv";
import botUse from "./app/index";
dotenv.config();
(async () => {
await botUse();
if (process.env.WEBHOOK_URL && process.env.PORT) {
const webhook_url = String(process.env.WEBHOOK_URL);
const port = Number(process.env.PORT);
await bot
.launch({
webhook: {
domain: webhook_url,
port: port,
},
})
.then(() =>
console.log(
`${bot.botInfo.first_name} is Online! 🚀 \nURL: ${webhook_url}\nPORT: ${port}`
)
);
} else {
bot
.launch()
.then(() => console.log(`${bot.botInfo.first_name} is Online! 🚀`));
}
})();
process.once("SIGINT", async () => bot.stop("SIGINT"));
process.once("SIGTERM", async () => bot.stop("SIGTERM"));