all repos — paprika @ bb94c73d8044300715bfbb15bddc34634ef755ab

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	var target string
35	if len(parts) > 1 {
36		target = parts[1]
37	} else {
38		target = m.Prefix.Name
39	}
40
41	switch trigger {
42	case "." + string(n):
43		// lol
44		if m.Prefix.Name == "IRSSucks" {
45			target = "IRSSucks"
46		}
47		return fmt.Sprintf("%s is a %s", target, string(n)), nil
48	case ".kiss", ".love":
49		rand.Seed(time.Now().Unix())
50		kaomoji := []string{
51			"(●´□`)", "(。・ω・。)ノ", "(。’▽’。)",
52			"(ෆ ͒•∘̬• ͒)◞", "( •ॢ◡-ॢ)-", "⁽⁽ପ( •ु﹃ •ु)​.⑅*",
53			"(๑ Ỡ ◡͐ Ỡ๑)ノ", "◟(◔ั₀◔ั )◞ ༘",
54		}
55		return fmt.Sprintf(
56			"%s \x02\x034 。。・゜゜・。。・❤️ %s ❤️ \x03\x02",
57			kaomoji[rand.Intn(len(kaomoji))],
58			target,
59		), nil
60	case ".increase", ".decrease":
61		return fmt.Sprintf(
62			"\x02[QUALITY OF CHANNEL SIGNIFICANTLY %sD]\x02",
63			strings.ToUpper(trigger[1:]),
64		), nil
65	}
66	return "", nil
67}