Update for 2022 API changes
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user