-
Notifications
You must be signed in to change notification settings - Fork 0
/
markup.go
110 lines (83 loc) · 2.51 KB
/
markup.go
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package main
import (
"strconv"
tele "gopkg.in/telebot.v3"
)
func generateRegisteredMenu() *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
m.Reply(
m.Row(btnUnlock, btnHelp),
m.Row(btnForgotKey),
m.Row(btnCleanMyData),
)
return m
}
func generateNonRegisteredMenu() *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
m.Reply(
m.Row(btnRegisterKey),
m.Row(btnHelp),
)
return m
}
func generateStartMenu(c tele.Context) *tele.ReplyMarkup {
registered := storage.IsUserExists(c.Sender().ID)
unlocked := locker.IsUnlocked(c.Sender().ID)
if registered && unlocked {
return generateMainMenu(c)
}
if registered {
return generateRegisteredMenu()
}
return generateNonRegisteredMenu()
}
func generateMainMenu(c tele.Context) *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
m.Reply(
m.Row(btnLock, btnHelp),
m.Row(btnPasswords, btnAddPassword),
m.Row(btnPasswordsRemove, btnCleanMyPasswords),
)
return m
}
func showPasswords(c tele.Context, passwords []Password) *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
m.InlineKeyboard = append(m.InlineKeyboard, []tele.InlineButton{*m.Data("Cancel ❌", btnCancel.Unique).Inline()})
for _, p := range passwords {
id := strconv.FormatUint(uint64(p.ID), 10)
pBtn := m.Data(p.Name, btnPassword.Unique, p.Name, id).Inline()
m.InlineKeyboard = append(m.InlineKeyboard, []tele.InlineButton{*pBtn})
}
return m
}
func showPasswordsRemove(c tele.Context, passwords []Password) *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
m.InlineKeyboard = append(m.InlineKeyboard, []tele.InlineButton{*m.Data("Cancel ❌", btnCancel.Unique).Inline()})
for _, p := range passwords {
id := strconv.FormatUint(uint64(p.ID), 10)
pBtn := m.Data(p.Name, btnPasswordRemove.Unique, p.Name, id).Inline()
m.InlineKeyboard = append(m.InlineKeyboard, []tele.InlineButton{*pBtn})
}
return m
}
func showClean(c tele.Context) *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
yesBtn := m.Data("Yes", btnYesClean.Unique).Inline()
noBtn := m.Data("No", btnNoClean.Unique).Inline()
m.InlineKeyboard = append(m.InlineKeyboard, []tele.InlineButton{*yesBtn, *noBtn})
return m
}
func showCleanData(c tele.Context) *tele.ReplyMarkup {
m := bot.NewMarkup()
m.ResizeKeyboard = true
yesBtn := m.Data("Yes", btnYesCleanData.Unique).Inline()
noBtn := m.Data("No", btnNoCleanData.Unique).Inline()
m.InlineKeyboard = append(m.InlineKeyboard, []tele.InlineButton{*yesBtn, *noBtn})
return m
}