Implemented

This commit is contained in:
semblanceofsense 2025-02-16 21:30:35 -07:00
parent a2aa0ebcb9
commit 6cea2789ef

View File

@ -52,22 +52,33 @@ func Run(BotToken string) {
var solutionlength string var solutionlength string
switch data.Name { switch data.Name {
case "solve-maze": case "solve-maze":
maze, err := getMaze.GetMaze(i.ApplicationCommandData().Options[0].Value.(string)) messageUrl := i.ApplicationCommandData().Options[0].Value.(string);
message, err := s.ChannelMessage(i.ChannelID, strings.Split(messageUrl, "/")[len(strings.Split(messageUrl, "/")) - 1]);
mazeFiles := message.Attachments;
if err != nil { if err != nil {
responseData = "You must provide an image! Select the maze, click \"open in browser\", and copy the link of the image" responseData = "You must provide a valid image! Provide the message link of a valid image."
} else { } else {
if (len(maze) < 1) { var maze getMaze.Maze
responseData = "You must provide an image! Select the maze, click \"open in browser\", and copy the link of the image" if len(mazeFiles) < 1 {
maze, err = getMaze.GetMaze(message.Content)
} else { } else {
points := solvemaze.FindPath(maze) maze, err = getMaze.GetMaze(mazeFiles[0].URL)
if (len(points) < 1) { }
responseData = "You must provide an image! Select the maze, click \"open in browser\", and copy the link of the image" if err != nil {
responseData = "You must provide a valid image! Provide the message link of a valid image."
} else {
if (len(maze) < 1) {
responseData = "You must provide a valid image! Provide the message link of a valid image."
} else { } else {
outputmaze.EditMaze(points, "/tmp/maze.png", "/tmp/outputmaze.png") points := solvemaze.FindPath(maze)
solutionlength = strconv.Itoa(len(points)) if (len(points) < 1) {
maze = nil responseData = "You must provide a valid image! Provide the message link of a valid image."
points = nil } else {
}}}} outputmaze.EditMaze(points, "/tmp/maze.png", "/tmp/outputmaze.png")
solutionlength = strconv.Itoa(len(points))
maze = nil
points = nil
}}}}}
if responseData == "" { if responseData == "" {
fileName := "/tmp/outputmaze.png" fileName := "/tmp/outputmaze.png"
@ -127,7 +138,12 @@ func Run(BotToken string) {
} else if (len(reply.Attachments) > 1) { } else if (len(reply.Attachments) > 1) {
s.ChannelMessageSendReply(m.ChannelID, "Too many images!", m.Reference()) s.ChannelMessageSendReply(m.ChannelID, "Too many images!", m.Reference())
} else { } else {
maze, err := getMaze.GetMaze(reply.Attachments[0].URL) var maze getMaze.Maze
if len(reply.Attachments) < 1 {
maze, err = getMaze.GetMaze(reply.Content)
} else {
maze, err = getMaze.GetMaze(reply.Attachments[0].URL)
}
if (err != nil) { if (err != nil) {
s.ChannelMessageSendReply(m.ChannelID, "Send a valid maze", m.Reference()) s.ChannelMessageSendReply(m.ChannelID, "Send a valid maze", m.Reference())
} else { } else {