-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.js
65 lines (58 loc) · 1.44 KB
/
menu.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
61
62
63
64
65
const menus = require('./menus.json')
const {getStatusForTelegram} = require('./simplemonitor-status.js')
exports.getInline = async (key, ctx) => {
const m = menus[key]
const buttons = []
Object.assign(buttons, m.buttons)
for (let val of m.linkedMenus) {
buttons.push([{
text: '' + ctx.i18n.t('menu_'+val+'_title'),
callback_data: 'menu/'+val
}])
}
let statusText = '';
if (m.include_status) {
statusText = '\n' + await getStatusForTelegram();
}
return {
type: 'article',
id: 'menu_'+key,
title: ctx.i18n.t('menu_'+key+'_title'),
input_message_content: {
message_text: ctx.i18n.t('menu_'+key+'_text')+statusText,
parse_mode: 'HTML',
disable_web_page_preview: true
},
reply_markup: {
inline_keyboard: buttons
}
}
}
exports.get = async (key, ctx) => {
const m = menus[key]
const buttons = []
Object.assign(buttons, m.buttons)
for (let val of m.linkedMenus) {
buttons.push([{
text: '' + ctx.i18n.t('menu_'+val+'_title'),
callback_data: 'menu/'+val
}])
}
let statusText = '';
if (m.include_status) {
statusText = '\n' + await getStatusForTelegram();
}
return {
text: ctx.i18n.t('menu_'+key+'_text')+statusText,
extra: {
parse_mode: 'HTML',
disable_web_page_preview: true,
reply_markup: {
inline_keyboard: buttons
}
}
}
}
exports.exists = (key) => {
return (menus[key] !== undefined)
}