all repos — paprika @ d3726eaba953300cf706e0ed05455309840d9661

go rewrite of taigabot

plugins/meme.go (view raw)

 1package plugins
 2
 3import (
 4	"encoding/base64"
 5	"fmt"
 6	"math/rand"
 7	"strings"
 8	"time"
 9
10	"gopkg.in/irc.v3"
11)
12
13func init() {
14	Register(Meme{})
15}
16
17type Meme struct{}
18
19var n []byte
20
21func (Meme) Triggers() []string {
22	n, _ = base64.StdEncoding.DecodeString("bmlnZ2Vy")
23	return []string{
24		"." + string(n),
25		".kiss",
26		".increase",
27		".decrease",
28		".sniff",
29		".hug",
30	}
31}
32
33func (Meme) Execute(m *irc.Message) (string, error) {
34	parts := strings.SplitN(m.Trailing(), " ", 2)
35	trigger := parts[0]
36	rand.Seed(time.Now().Unix())
37	var target string
38	if len(parts) > 1 {
39		target = parts[1]
40	} else {
41		target = m.Prefix.Name
42	}
43
44	switch trigger {
45	case "." + string(n):
46		// lol
47		if m.Prefix.Name == "IRSSucks" {
48			target = "IRSSucks"
49		}
50		word := string(n)
51		if rand.Intn(10) == 8 {
52			// Easter egg! Only teh cool h4x0rz will get this.
53			word = "bmlnZ2Vy"
54		}
55		return fmt.Sprintf("%s is a %s", target, word), nil
56	case ".kiss", ".love":
57		kaomoji := []string{
58			"(●´□`)", "(。・ω・。)ノ", "(。’▽’。)",
59			"(ෆ ͒•∘̬• ͒)◞", "( •ॢ◡-ॢ)-", "⁽⁽ପ( •ु﹃ •ु)​.⑅*",
60			"(๑ Ỡ ◡͐ Ỡ๑)ノ", "◟(◔ั₀◔ั )◞ ༘",
61		}
62		return fmt.Sprintf(
63			"%s \x02\x034 。。・゜゜・。。・❤️ %s ❤️ \x03\x02",
64			kaomoji[rand.Intn(len(kaomoji))],
65			target,
66		), nil
67	case ".increase", ".decrease":
68		return fmt.Sprintf(
69			"\x02[QUALITY OF CHANNEL SIGNIFICANTLY %sD]\x02",
70			strings.ToUpper(trigger[1:]),
71		), nil
72	case ".sniff":
73		return fmt.Sprintf("huffs %s's hair while sat behind them on the bus.", target), nil
74	case ".hug":
75		return fmt.Sprintf("(>^_^)>❤️ %s ❤️<(^o^<)", target), nil
76
77	}
78	return "", nil
79}