Loggy updates
This commit is contained in:
7
chess.go
7
chess.go
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func chessCommand(m chat1.MsgSummary) {
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("chessCommand")
|
||||
convID := string(m.ConvID)
|
||||
parts := strings.Split(m.Content.Text.Body, " ")
|
||||
if g, ok := config.Games[convID]; ok {
|
||||
@ -28,6 +28,7 @@ func chessCommand(m chat1.MsgSummary) {
|
||||
submitMove(m, &g)
|
||||
return
|
||||
}
|
||||
log.LogInfo("Game not found")
|
||||
if len(parts) < 3 {
|
||||
return
|
||||
}
|
||||
@ -66,7 +67,7 @@ func chessCommand(m chat1.MsgSummary) {
|
||||
}
|
||||
|
||||
func showBoard(m chat1.MsgSummary, g *Game) {
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("showBoard")
|
||||
// create file
|
||||
f, err := os.Create(fmt.Sprintf("/home/chessbot/chessbot/games/%+v.svg", m.ConvID))
|
||||
if err != nil {
|
||||
@ -103,7 +104,7 @@ func showBoard(m chat1.MsgSummary, g *Game) {
|
||||
}
|
||||
|
||||
func submitMove(m chat1.MsgSummary, g *Game) {
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("submitMove")
|
||||
defer saveConfig()
|
||||
parts := strings.Split(m.Content.Text.Body, " ")
|
||||
if g.Move {
|
||||
|
||||
@ -13,7 +13,7 @@ func loadConfig() Config {
|
||||
}
|
||||
|
||||
func saveConfig() {
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("saveConfig")
|
||||
log.LogInfo("Saving config.")
|
||||
file, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
|
||||
3
go.mod
3
go.mod
@ -5,9 +5,8 @@ go 1.15
|
||||
require (
|
||||
git.nightmare.haus/rudi/chessv2 v0.0.0-20201030161310-809f6e9c5b9b
|
||||
github.com/ajstarks/svgo v0.0.0-20200725142600-7a3c8b57fecb // indirect
|
||||
github.com/bwmarrin/discordgo v0.22.0
|
||||
github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e
|
||||
github.com/rogpeppe/misc v0.0.0-20200516092017-43a33a8f4c44
|
||||
github.com/rudi9719/loggy v0.0.0-20201030144506-35d9b032ab93
|
||||
github.com/rudi9719/loggy v0.0.0-20201031035735-9438c484de9a
|
||||
samhofi.us/x/keybase/v2 v2.0.6
|
||||
)
|
||||
|
||||
2
go.sum
2
go.sum
@ -16,6 +16,8 @@ github.com/rogpeppe/misc v0.0.0-20200516092017-43a33a8f4c44 h1:osBnWuJgXxjdv/zUO
|
||||
github.com/rogpeppe/misc v0.0.0-20200516092017-43a33a8f4c44/go.mod h1:hT7K6J2LNwUaaq7rtwF5VMB9kQ9yf7HgYFNVOOf41OI=
|
||||
github.com/rudi9719/loggy v0.0.0-20201030144506-35d9b032ab93 h1:GjCI3CXdGt2PysVpObVzmKqMgKf3RlsKLBnaSOqPpUk=
|
||||
github.com/rudi9719/loggy v0.0.0-20201030144506-35d9b032ab93/go.mod h1:s1ANCN8bF6HwwTpJLR458MFVGua9oqKKDbph/2jptL4=
|
||||
github.com/rudi9719/loggy v0.0.0-20201031035735-9438c484de9a h1:4rkaWoLCWOmra5Mw/dLAWjtDLT/+i5uTX1qhlMVL8WA=
|
||||
github.com/rudi9719/loggy v0.0.0-20201031035735-9438c484de9a/go.mod h1:s1ANCN8bF6HwwTpJLR458MFVGua9oqKKDbph/2jptL4=
|
||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
|
||||
6
main.go
6
main.go
@ -25,7 +25,7 @@ var (
|
||||
)
|
||||
|
||||
func printChat(m chat1.MsgSummary) {
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("printChat")
|
||||
if m.Sender.Username == k.Username {
|
||||
return
|
||||
}
|
||||
@ -40,7 +40,7 @@ func main() {
|
||||
fmt.Println("Starting log")
|
||||
log = loggy.NewLogger(config.LogOpts)
|
||||
fmt.Println("Log configured")
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("main")
|
||||
log.LogInfo("Logger configured")
|
||||
chat := printChat
|
||||
err := log.LogErrorType
|
||||
@ -52,7 +52,7 @@ func main() {
|
||||
k.Run(handlers, &keybase.RunOptions{})
|
||||
}
|
||||
func svgToPNG(path string) bool {
|
||||
defer log.PanicSafe()
|
||||
defer log.PanicSafe("svgToPNG")
|
||||
file, err := os.Open(fmt.Sprintf("%+v.svg", path))
|
||||
if err != nil {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user