-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
86 lines (82 loc) · 2.4 KB
/
index.ts
File metadata and controls
86 lines (82 loc) · 2.4 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { sendMessage } from "nyx-bot-client";
import client from "nyx-bot-client/nyx-client";
import { initializeAPI } from "./api/api";
import { handlerCallbackQueryAnalytics } from "./pipelines/callback_query/analytics";
import { handlerCallbackQueryContest } from "./pipelines/callback_query/contest";
import { handlerCallbackQueryDefault } from "./pipelines/callback_query/default";
import { handlerCallbackQueryFlood } from "./pipelines/callback_query/flood";
import { handlerInlineQueryAnalytics } from "./pipelines/inline_query/analytics";
import { handlerInlineQueryContest } from "./pipelines/inline_query/contest";
import { handlerInlineQueryFlood } from "./pipelines/inline_query/flood";
import { handlerInlineQueryNotFound } from "./pipelines/inline_query/not-found";
import { handlerMessageAnalytics } from "./pipelines/message/analytics";
import { handlerMessageGroups } from "./pipelines/message/group";
import { handlerMessagePrivate } from "./pipelines/message/private";
import { updateAnalyticsCounter } from "./utils/analytics";
import { db } from "./utils/database";
import { env } from "./utils/env";
import { initializeEventHandlers } from "./utils/handlers";
import { pools } from "./utils/pool";
client.initialize({
botConfig: {
admin_id: env.BOT_ADMIN_ID,
api: env.BOT_API_SERVER,
token: env.BOT_TOKEN,
username: env.BOT_USERNAME,
},
pipelines: {
message: [
handlerMessageAnalytics,
handlerMessagePrivate,
handlerMessageGroups,
],
callback_query: [
handlerCallbackQueryAnalytics,
handlerCallbackQueryFlood,
handlerCallbackQueryContest,
handlerCallbackQueryDefault,
],
inline_query: [
handlerInlineQueryAnalytics,
handlerInlineQueryFlood,
handlerInlineQueryContest,
handlerInlineQueryNotFound,
],
},
injections: async () => {
updateAnalyticsCounter("total");
return {
injections: {
db: db,
pg: pools.pg,
redis: pools.redis,
},
onFinish: async () => {},
};
},
onStartup: async () => {
if (env.BOT_ADMIN_ID) {
sendMessage({
chat_id: env.BOT_ADMIN_ID,
text: "Bot started",
disable_notification: true,
});
}
},
onShutdown: async () => {
if (env.BOT_ADMIN_ID) {
await sendMessage({
chat_id: env.BOT_ADMIN_ID,
text: "Bot shutdown",
disable_notification: true,
});
}
},
redis: {
host: env.REDIS_HOST,
port: env.REDIS_PORT,
},
benchmark: false,
});
initializeAPI();
initializeEventHandlers();