This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popcorn.go
90 lines (72 loc) · 1.89 KB
/
popcorn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"math/rand"
"strings"
"time"
"github.com/bwmarrin/discordgo"
"gitlab.com/NatoBoram/Go-Miiko/wheel"
)
// Popcorn command
func popcorn(s *discordgo.Session, c *discordgo.Channel, m *discordgo.Message) (done bool) {
// Check for popcorn keywords
contains := false
for _, keyword := range popcornStrings {
if strings.Contains(strings.ToLower(m.Content), keyword) {
contains = true
break
}
}
// Return if there's no popcorn in there
if !contains {
return false
}
// Increase the power of Phi to reduce chances.
if wheel.RandomOverPhiPower(1) {
// It's popcorn time!
s.ChannelTyping(c.ID)
_, err := s.ChannelMessageSend(c.ID, getPopcornMessage())
if err != nil {
printDiscordError("Couldn't tell everyone how much I love popcorn. Sad :(", nil, c, m, nil, err)
return false
}
// Popcorn was successful!
return true
}
// Random chance decided it wasn't popcorn time.
return false
}
func getPopcornMessage() string {
// Popcorn Messages
popcornList := [...]string{
// Exclamation
"Popcorn?",
"Popcorn!",
"Popcorn?!",
"Popcorn!?",
"**Popcorn?!**",
"**Popcorn!?**",
"Ah, popcorn!",
"Hmm, du popcorn...",
"Hmm, du *popcorn*...",
// Question
"On parle de popcorn?",
"Quelqu'un a dit popcorn?",
"Quelqu'un a dit popcorn?!",
"Quelqu'un a dit **popcorn**?!",
"Quelqu'un a parlé de popcorn?",
"Quelqu'un a parlé de popcorn?!",
"Ai-je bien entendu popcorn?",
"Ai-je bien entendu popcorn?!",
"Ai-je bien entendu **popcorn**?!",
// WTF Miiko
"Moi, j'aime le popcorn!",
"Le popcorn, c'est génial!",
// Uhh...
"Le popcorn, c'est bon et tout, mais il ne faut pas oublier les friandises. J'adore les friandises!",
"Imagine si... On mélangeait du popcorn... Avec des friandises!",
}
// Seed
random := rand.New(rand.NewSource(time.Now().UnixNano()))
// Return
return popcornList[random.Intn(len(popcornList))]
}