all repos — paprika @ 812bfbf89dc1a08aaf6a7174442126c9ff88f451

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	}
29}
30
31func (Meme) Execute(m *irc.Message) (string, error) {
32	parts := strings.SplitN(m.Trailing(), " ", 2)
33	trigger := parts[0]
34	rand.Seed(time.Now().Unix())
35	var target string
36	if len(parts) > 1 {
37		target = parts[1]
38	} else {
39		target = m.Prefix.Name
40	}
41
42	switch trigger {
43	case "." + string(n):
44		// lol
45		if m.Prefix.Name == "IRSSucks" {
46			target = "IRSSucks"
47		}
48		word := string(n)
49		if rand.Intn(10) == 8 {
50			// Easter egg! Only teh cool h4x0rz will get this.
51			word = "bmlnZ2Vy"
52		}
53		return fmt.Sprintf("%s is a %s", target, word), nil
54	case ".kiss", ".love":
55		kaomoji := []string{
56			"(●´□`)", "(。・ω・。)ノ", "(。’▽’。)",
57			"(ෆ ͒•∘̬• ͒)◞", "( •ॢ◡-ॢ)-", "⁽⁽ପ( •ु﹃ •ु)​.⑅*",
58			"(๑ Ỡ ◡͐ Ỡ๑)ノ", "◟(◔ั₀◔ั )◞ ༘",
59		}
60		return fmt.Sprintf(
61			"%s \x02\x034 。。・゜゜・。。・❤️ %s ❤️ \x03\x02",
62			kaomoji[rand.Intn(len(kaomoji))],
63			target,
64		), nil
65	case ".increase", ".decrease":
66		return fmt.Sprintf(
67			"\x02[QUALITY OF CHANNEL SIGNIFICANTLY %sD]\x02",
68			strings.ToUpper(trigger[1:]),
69		), nil
70	case ".sniff":
71		return fmt.Sprintf("huffs %s's hair while sat behind them on the bus.", target), nil
72
73	}
74	return "", nil
75}