add db
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-03-11 17:30:38 +07:00
parent b6b017c9bb
commit 57755d28d2
2 changed files with 58 additions and 27 deletions
+9 -10
View File
@@ -16,15 +16,8 @@ import (
const (
version = "v1.0.0"
userStateNone = userState("None")
userStateGo = userState("Go")
)
var (
state = userStateNone
)
type userState string
type Opts struct {
Token string `short:"t" long:"token" description:"Telegram api token"`
@@ -90,7 +83,13 @@ func run() {
chatID := update.Message.Chat.ID
// username := update.Message.From.UserName
if state == userStateGo {
userInfoDTO, err := db.GetUserInfo(chatID)
if err != nil {
log.Println(err)
continue
}
if userInfoDTO.GetStatus() == db.UserStateGo {
count, err := strconv.Atoi(text)
if err != nil {
continue
@@ -101,7 +100,7 @@ func run() {
msg := tgbot.NewMessage(chatID, fmt.Sprintf("Отлично, %s, записал.", text))
msg.ReplyMarkup = tgbot.NewHideKeyboard(false)
_, _ = bot.Send(msg)
state = userStateNone
db.SetStatusInUser(chatID, db.UserStateNone)
continue
}
@@ -123,7 +122,7 @@ func run() {
),
)
if _, err = bot.Send(msg); err == nil {
state = userStateGo
db.SetStatusInUser(chatID, db.UserStateGo)
}
}
}