|
|
|
@ -13,7 +13,7 @@ import (
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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 { |
|
|
|
|