From ad8d72ce0d1587e17811ca8218761d16eabd1299 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 8 Aug 2023 16:17:47 -0400 Subject: [PATCH] qotd --- bloat.go | 35 +++++++++++++++++++++++++++++++++++ web.go | 1 + 2 files changed, 36 insertions(+) diff --git a/bloat.go b/bloat.go index e89675f..245add8 100644 --- a/bloat.go +++ b/bloat.go @@ -14,3 +14,38 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. package main + +import ( + "io" + "net" + "time" +) + +func qotd() { + var qotdaddr string + getconfig("qotdaddr", &qotdaddr) + if qotdaddr == "" { + return + } + s, err := net.Listen("tcp", ":8017") + if err != nil { + return + } + for { + c, err := s.Accept() + if err != nil { + time.Sleep(time.Second) + continue + } + honks := getpublichonks() + for _, honk := range honks { + if !firstclass(honk) { + continue + } + io.WriteString(c, honk.Noise) + io.WriteString(c, "\n") + break + } + c.Close() + } +} diff --git a/web.go b/web.go index 2268885..905327c 100644 --- a/web.go +++ b/web.go @@ -2656,6 +2656,7 @@ func serve() { go redeliverator() go tracker() go bgmonitor() + go qotd() loadLingo() emuinit()