-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (27 loc) · 1.01 KB
/
app.js
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
import { config } from "dotenv";
import { Common, OnBot } from "./services/index.js";
import { bot } from "./config/index.js"
import { servicesName, warning, choiceIs } from "./constants/index.js"
config()
let menuIsOpened = false;
const { IMAGE_GENERATOR, QNA, CODE_WRITER, MENU } = choiceIs
const { DALLE, ChatGBT, CODEX } = servicesName
bot.start(async (ctx) => {
if (!menuIsOpened || ctx.startPayload) {
ctx.state.openedMenu = true
await Common.startMenuReply({ ctx });
return menuIsOpened = true
}
await ctx.reply(warning.MENU)
});
bot.action(IMAGE_GENERATOR, (ctx) => Common.btnAction({ ctx, name: DALLE }))
bot.action(QNA, (ctx) => Common.btnAction({ ctx, name: ChatGBT }))
bot.action(CODE_WRITER, (ctx) => Common.btnAction({ ctx, name: CODEX }))
bot.action(MENU, async (ctx) => {
Common.currentSelectedBot = ""
await ctx.deleteMessage()
await Common.startMenuReply({ ctx });
})
bot.hears(/.*/, async (ctx) => OnBot.botHears({ ctx }));
// Start the bot
bot.launch();