commit c74ac4a

Hubert Hirtz  ·  2020-08-01 11:36:06 +0000 UTC
parent 570c2c2
Randomize welcome messages
3 files changed,  +9, -2
+5, -0
 1@@ -9,11 +9,16 @@ import (
 2 	"github.com/gdamore/tcell"
 3 	"hash/fnv"
 4 	"log"
 5+	"math/rand"
 6 	"os"
 7 	"strings"
 8 	"time"
 9 )
10 
11+func init() {
12+	rand.Seed(time.Now().Unix())
13+}
14+
15 func main() {
16 	tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
17 
+1, -1
1@@ -11,7 +11,7 @@ var homeMessages = []string{
2 	"Welcome to the Internet Relay Network!",
3 	"Mentions & cie go here.",
4 	"May the IRC be with you.",
5-	"Hey! I'm senpai, you every IRC student!",
6+	"Hey! I'm senpai, you everyday IRC student!",
7 	"Student? No, I'm an IRC \x02client\x02!",
8 }
9 
+3, -1
 1@@ -3,6 +3,7 @@ package ui
 2 import (
 3 	"github.com/gdamore/tcell"
 4 	"github.com/mattn/go-runewidth"
 5+	"math/rand"
 6 	"sync/atomic"
 7 	"time"
 8 )
 9@@ -46,12 +47,13 @@ func New() (ui *UI, err error) {
10 
11 	ui.exit.Store(false)
12 
13+	hmIdx := rand.Intn(len(homeMessages))
14 	ui.bufferList = BufferList{
15 		List: []Buffer{
16 			{
17 				Title:      "home",
18 				Highlights: 0,
19-				Content:    []Line{NewLineNow(homeMessages[0])},
20+				Content:    []Line{NewLineNow(homeMessages[hmIdx])},
21 			},
22 		},
23 	}