From e19cd7095d41248b9237ac050578ee92bc84e989 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Thu, 27 Jan 2022 17:23:33 -0700 Subject: [PATCH] add zip to configs --- config.json | 4 ++++ config.main_test.json | 4 ++++ config/config.go | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 1f2243f..25ec8ff 100644 --- a/config.json +++ b/config.json @@ -48,6 +48,10 @@ "States": [ "NC" ], + "UseZips": true, + "Zips": [ + "27006" + ], "IDs": { "Matrix": "@bel:m.bltrucks.top" }, diff --git a/config.main_test.json b/config.main_test.json index 0af08fe..9480d35 100644 --- a/config.main_test.json +++ b/config.main_test.json @@ -48,6 +48,10 @@ "States": [ "NC" ], + "UseZips": true, + "Zips": [ + "27006" + ], "IDs": { "Matrix": "@bel:m.bltrucks.top" }, diff --git a/config/config.go b/config/config.go index 31c6a34..6c82d72 100644 --- a/config/config.go +++ b/config/config.go @@ -87,8 +87,10 @@ type Config struct { } type Client struct { - States []State - IDs struct { + UseZips bool + States []State + Zips []string + IDs struct { Matrix string } Available Time @@ -115,6 +117,20 @@ func Clients(t time.Time) map[string]Client { return result } +func AllZips() []string { + zipm := map[string]struct{}{} + for _, v := range Clients(time.Now().Add(time.Hour * 24 * 365)) { + for _, state := range v.Zips { + statem[state] = struct{}{} + } + } + zips := make([]State, 0, len(statem)+1) + for k := range statem { + zips = append(zips, k) + } + return zips +} + func AllStates() []State { statem := map[State]struct{}{} for _, v := range Clients(time.Now().Add(time.Hour * 24 * 365)) {