|
|
@ -5,7 +5,6 @@ import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/teris-io/shortid" |
|
|
|
"github.com/teris-io/shortid" |
|
|
|
"github.com/ugorji/go/codec" |
|
|
|
|
|
|
|
"samhofi.us/x/keybase/types/chat1" |
|
|
|
"samhofi.us/x/keybase/types/chat1" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -30,28 +29,6 @@ func getFeedbackExtendedDescription(bc botConfig) *chat1.UserBotExtendedDescript |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func encodeStructToJSONString(v interface{}) (string, error) { |
|
|
|
|
|
|
|
jh := codecHandle() |
|
|
|
|
|
|
|
var bytes []byte |
|
|
|
|
|
|
|
err := codec.NewEncoderBytes(&bytes, jh).Encode(v) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return "", err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result := string(bytes) |
|
|
|
|
|
|
|
return result, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func decodeJSONStringToStruct(v interface{}, src string) error { |
|
|
|
|
|
|
|
bytes := []byte(src) |
|
|
|
|
|
|
|
jh := codecHandle() |
|
|
|
|
|
|
|
return codec.NewDecoderBytes(bytes, jh).Decode(v) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func codecHandle() *codec.JsonHandle { |
|
|
|
|
|
|
|
var jh codec.JsonHandle |
|
|
|
|
|
|
|
return &jh |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (b *bot) logError(err error) string { |
|
|
|
func (b *bot) logError(err error) string { |
|
|
|
// generate the error id
|
|
|
|
// generate the error id
|
|
|
|
eid := shortid.MustGenerate() |
|
|
|
eid := shortid.MustGenerate() |
|
|
|