Update for 2022 API changes

This commit is contained in:
2022-12-01 07:28:02 -06:00
parent ee6a26629f
commit 09a662a8cd
5 changed files with 39 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"strconv"
"strings"
"time"
@@ -109,3 +110,18 @@ func (m *BotModel) GetString(path []string) (string, error) {
func (m *BotModel) SetString(path []string, val string) error {
return m.SetBytes(path, []byte(val))
}
func (m *BotModel) GetInt(path []string) (int, error) {
bts, err := m.GetBytes(path)
if err != nil {
return 0, err
}
if len(bts) == 0 {
return 0, nil
}
return strconv.Atoi(string(bts))
}
func (m *BotModel) SetInt(path []string, val int) error {
return m.SetString(path, strconv.Itoa(val))
}