go-roflcopter/main.go

40 lines
654 B
Go
Raw Normal View History

2021-12-12 02:12:56 +03:00
package main
import (
2022-02-12 02:12:00 +03:00
"log"
2021-12-12 02:12:56 +03:00
"time"
2022-02-12 02:12:00 +03:00
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
"morozovad.ddns.net/lnd212/go-roflcopter/roflcopter"
)
var (
count time.Duration = 15 * time.Second
str string = ""
p *widgets.Paragraph
2022-02-12 02:12:00 +03:00
)
const (
playSound = true
timer = 15*time.Second
2021-12-12 02:12:56 +03:00
)
func updateScreen() {
2022-02-12 02:12:00 +03:00
if err := ui.Init(); err != nil {
log.Fatalf("failed to initialize termui: %v", err)
}
defer ui.Close()
p.Text = str
p.SetRect(0, 0, 25, 12)
2022-02-12 02:12:00 +03:00
ui.Render(p)
2021-12-12 02:12:56 +03:00
}
func main() {
p = widgets.NewParagraph()
rofl := roflcopter.NewRoflcopter(timer, &str, playSound, updateScreen)
rofl.Start()
time.Sleep(timer)
2021-12-12 02:12:56 +03:00
}