INNER CODE UNIT · Go
gamename
instead-hub/instead · src/tiny/ifbot/ifbot/server.go:206
func gamename(dir string) string {
file, err := os.Open("./games/" + dir + "/main3.lua")
if err != nil {
return dir
}
defer file.Close()
scanner := bufio.NewScanner(file)
var commentID = regexp.MustCompile(`^[ \t]*--`)
var nameID = regexp.MustCompile(`^[ \t]*--[ \t]*\$Name:[ \t]*(.+)`)
for scanner.Scan() {
if !commentID.MatchString(scanner.Text()) {
break
}
if !nameID.MatchString(scanner.Text()) {
continue
}