initial persistent history implementation

This commit is contained in:
Shivaram Lingamneni 2020-02-18 19:38:42 -05:00
parent 0d5a4fd584
commit 33dac4c0ba
34 changed files with 2229 additions and 595 deletions

View file

@ -5,7 +5,13 @@ package utils
import (
"errors"
"fmt"
"strings"
"time"
)
const (
IRCv3TimestampFormat = "2006-01-02T15:04:05.000Z"
)
var (
@ -45,9 +51,9 @@ func ArgsToStrings(maxLength int, arguments []string, delim string) []string {
func StringToBool(str string) (result bool, err error) {
switch strings.ToLower(str) {
case "on", "true", "t", "yes", "y":
case "on", "true", "t", "yes", "y", "disabled":
result = true
case "off", "false", "f", "no", "n":
case "off", "false", "f", "no", "n", "enabled":
result = false
default:
err = ErrInvalidParams
@ -63,3 +69,16 @@ func SafeErrorParam(param string) string {
}
return param
}
type IncompatibleSchemaError struct {
CurrentVersion string
RequiredVersion string
}
func (err *IncompatibleSchemaError) Error() string {
return fmt.Sprintf("Database requires update. Expected schema v%s, got v%s", err.RequiredVersion, err.CurrentVersion)
}
func NanoToTimestamp(nanotime int64) string {
return time.Unix(0, nanotime).Format(IRCv3TimestampFormat)
}