add contact screen

This commit is contained in:
Sundog Jones 2021-04-16 18:49:51 -07:00
parent 6211d07ca4
commit db28cfbcdb
2 changed files with 51 additions and 1 deletions

33
main.go
View File

@ -5,6 +5,7 @@ import (
"context" "context"
"errors" "errors"
"flag" "flag"
"fmt"
"io" "io"
"log" "log"
"net" "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) 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": case "operator":
opStr, err := screenHandler("operator", nil) opStr, err := screenHandler("operator", nil)
if err != nil { if err != nil {
@ -444,9 +454,30 @@ func getUptime(wg *sync.WaitGroup) string {
func getTubePeers(wg *sync.WaitGroup) string { func getTubePeers(wg *sync.WaitGroup) string {
defer wg.Done() defer wg.Done()
out, err := exec.Command("/usr/local/bin/getTubesPeers.bash").Output() 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 { if err != nil {
log.Printf("err loading getTubePeers: %v\n", err) 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(err.Error()) // again, might as well pass on the love to my future co-workers for debugging assistance
} }
return string(out) return outStr
} }

19
screens/contact.ans Normal file
View File

@ -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!
>