From db28cfbcdb3374cbe074238a91fa474140e1a3bd Mon Sep 17 00:00:00 2001 From: Sundog Date: Fri, 16 Apr 2021 18:49:51 -0700 Subject: [PATCH] add contact screen --- main.go | 33 ++++++++++++++++++++++++++++++++- screens/contact.ans | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 screens/contact.ans diff --git a/main.go b/main.go index 5c11a1d..f71fe20 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "context" "errors" "flag" + "fmt" "io" "log" "net" @@ -201,6 +202,15 @@ func menuHandler(ctx context.Context, conn net.Conn, w *gaio.Watcher) { log.Printf("error sending screenHandler from cmd `help`: %v", err) } + case "contact": + contactStr, err := screenHandler("contact", nil) + if err != nil { + log.Printf("err loading contact screen: %v\n", err) + } + if err := w.Write(ctx, conn, contactStr); err != nil { + log.Printf("error sending screenHandler from cmd `contact`: %v", err) + } + case "operator": opStr, err := screenHandler("operator", nil) if err != nil { @@ -444,9 +454,30 @@ func getUptime(wg *sync.WaitGroup) string { func getTubePeers(wg *sync.WaitGroup) string { defer wg.Done() out, err := exec.Command("/usr/local/bin/getTubesPeers.bash").Output() + outStr := "" + // clean up the output formatting a little + for _, line := range strings.Split(string(out), "\n") { + formattedLine := "" + for j, field := range strings.Fields(line) { + switch j { + case 0: + formattedLine = field + case 1: + formattedLine += "\x1b[9G" + field + case 2: + offset := 10 - len(field) + 57 + formattedLine += "\x1b[" + fmt.Sprintf("%d", offset) + "G" + field + case 3: + offset := 10 - len(field) + 74 + formattedLine += "\x1b[" + fmt.Sprintf("%d", offset) + "G" + field + } + } + outStr = outStr + formattedLine + "\n" + } + if err != nil { log.Printf("err loading getTubePeers: %v\n", err) return string(err.Error()) // again, might as well pass on the love to my future co-workers for debugging assistance } - return string(out) + return outStr } diff --git a/screens/contact.ans b/screens/contact.ans new file mode 100644 index 0000000..b685f3c --- /dev/null +++ b/screens/contact.ans @@ -0,0 +1,19 @@ + + + ______ __ __ _ _____ __  + / ____/___ ____ / /_____ ______/ /_(_)___ ____ _ / ___/__ ______ ____/ /___ ____ _  + / / / __ \/ __ \/ __/ __ `/ ___/ __/ / __ \/ __ `/ \__ \/ / / / __ \/ __ / __ \/ __ `/  + / /___/ /_/ / / / / /_/ /_/ / /__/ /_/ / / / / /_/ / ___/ / /_/ / / / / /_/ / /_/ / /_/ /  + \____/\____/_/ /_/\__/\__,_/\___/\__/_/_/ /_/\__, / /____/\__,_/_/ /_/\__,_/\____/\__, /  + /____/ /____/  + + + \rHey there! + +The easiest way to contact me is via email to dquick@versestudios.com +The second easiest way is to send an SMS to 1-650-485-3283 +And if you happen to see sundog or djsundog online anywhere, +there's a good chance that that's me as well - feel free to reach out! + + +> \ No newline at end of file