-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
41 lines (31 loc) · 1.02 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
import { RvrbBotConnector } from "./lib/RvrbBotConnector";
import { Quiz } from "./lib/quiz";
import { updateUserInfos } from "./lib/utils";
import express from "express";
import { v4 } from "uuid";
export const app = express();
const quiz = new Quiz();
const rvrbBotConnector = new RvrbBotConnector();
rvrbBotConnector.setCustomPushChannelMessage((e) => {
quiz.handleCommand(e);
});
rvrbBotConnector.setCustomUpdateChannelUsers((e) => {
updateUserInfos(e);
});
rvrbBotConnector.setCustomPlayChannelTrack(() => {
quiz.askQuestion();
});
rvrbBotConnector.setCustomOnReady((channelId) => quiz.setRoomID(channelId));
rvrbBotConnector.connect();
quiz.setSendMessage((message: string) => {
rvrbBotConnector.sendMessage(message);
});
app.get("/", (req: any, res: any) => {
const path = `/api/item/${v4()}`;
res.setHeader("Content-Type", "text/html");
res.setHeader("Cache-Control", "s-max-age=1, stale-while-revalidate");
res.end(`Status: RUNNING`);
});
app.listen(3000, () => {
console.log("Listening to port 3000");
});