]> git.0d.be Git - barnard.git/blob - ui.go
remove UI stuff, turn into CLI
[barnard.git] / ui.go
1 package main
2
3 import (
4         "fmt"
5         "os"
6         "strings"
7         "time"
8
9         "github.com/kennygrant/sanitize"
10         "layeh.com/gumble/gumble"
11 )
12
13 func esc(str string) string {
14         return sanitize.HTML(str)
15 }
16
17 func (b *Barnard) UpdateInputStatus(status string) {
18         fmt.Fprintf(os.Stdout, "input status: %s\n", status)
19 }
20
21 func (b *Barnard) AddOutputLine(line string) {
22         now := time.Now()
23         fmt.Fprintf(os.Stdout, "[%02d:%02d:%02d] %s\n", now.Hour(), now.Minute(), now.Second(), line)
24 }
25
26 func (b *Barnard) AddOutputMessage(sender *gumble.User, message string) {
27         if sender == nil {
28                 b.AddOutputLine(message)
29         } else {
30                 b.AddOutputLine(fmt.Sprintf("%s: %s", sender.Name, strings.TrimSpace(esc(message))))
31         }
32 }