This commit is contained in:
2025-09-23 01:07:24 +07:00
parent 9f484366bb
commit 0657f36206
12 changed files with 322 additions and 150 deletions
+9 -5
View File
@@ -13,15 +13,19 @@ type Team struct {
}
func (t *Team) GetTeamUrl() (string, error) {
ips, err := getLocalIPs()
if err != nil {
return "", err
}
ip := ips[0]
ip := selectIP()
u := fmt.Sprintf("http://%s:8100?name=%s&password=%s", ip, url.PathEscape(t.Name), t.Password)
return u, nil
}
func selectIP() string {
ips, err := getLocalIPs()
if err != nil || len(ips) == 0 {
return "127.0.0.1"
}
return ips[0]
}
func getLocalIPs() ([]string, error) {
var ips []string
addrs, err := net.InterfaceAddrs()
@@ -59,6 +59,13 @@ func NewStoryService(filepath string) (*StoryService, error) {
}
func (s *StoryService) GetPlace(code string) *Place {
if strings.HasPrefix(code, "[") || strings.HasSuffix(code, "]") {
return &Place{
Code: code,
Name: "Не найдено",
Text: "Уважаемые детективы внимательно прочитайте правила.",
}
}
code = clearCode(code)
for _, place := range s.story.Places {
if clearCode(place.Code) == code {