-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
60 lines (53 loc) · 2.14 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const Telegram = require("telegram-node-bot");
const mongoose = require("mongoose");
const TextCommand = Telegram.TextCommand;
const RegexpCommand = Telegram.RegexpCommand;
const bot = require("./helpers/botConnection").get();
const StartController = require("./Controllers/startController");
const GroupController = require("./Controllers/groupController");
const AttendanceController = require("./Controllers/attendanceController");
const HelpController = require("./Controllers/helpController");
const OtherwiseController = require("./Controllers/otherwiseController");
const CallbackQueryController = require("./callbackQueries");
const { MONGO_URI } = require("./helpers/config");
mongoose.connect(MONGO_URI, { useNewUrlParser: true });
mongoose.Promise = global.Promise;
const db = mongoose.connection;
db.on("error", err => console.log(err));
db.once("open", () => {
console.log("DB has been opened");
});
bot.router
.when(new TextCommand("/start", "startCommand"), new StartController())
.when(new TextCommand("/newgroup", "addGroupCommand"), new GroupController())
.when(new TextCommand("/mygroups", "getGroupCommand"), new GroupController())
.when(new TextCommand("/rename", "renameGroupCommand"), new GroupController())
.when(
new TextCommand("/addstudent", "addStudentsCommand"),
new GroupController()
)
.when(
new TextCommand("/deletegroup", "deleteGroupCommand"),
new GroupController()
)
// .when(
// new TextCommand("/newattendance", "takeAttendanceCommand"),
// new AttendanceController()
// )
.when(
new TextCommand("/viewattendance", "getAttendanceCommand"),
new AttendanceController()
)
.when(
new TextCommand("View Result", "getAttendanceCommand"),
new AttendanceController()
)
.when(
new TextCommand("/editattendance", "updateAttendanceCommand"),
new AttendanceController()
)
.when(new TextCommand("/help", "helpCommand"), new HelpController())
.when(new TextCommand("/test", "testCommand"), new StartController())
// .when(new RegexpCommand(/test/g, "testHandler"), new GroupController())
.otherwise(new OtherwiseController())
.callbackQuery(new CallbackQueryController());