forked from furtidev/the-farting-whale
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ffbfb6ae1d | ||
|
f82a89f9b5 | ||
|
d9eef1c1f3 | ||
|
2201a35120 | ||
|
cc18c89cd4 | ||
feacda166a | |||
94c9dd3d57 | |||
cba680d6e1 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.env
|
||||
hop.yml
|
40
main.go
40
main.go
@ -7,7 +7,8 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"strings"
|
||||
"regexp"
|
||||
"time"
|
||||
"math/rand"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/spf13/viper"
|
||||
@ -65,6 +66,31 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(m.Content, "!ask") {
|
||||
possibleAnswers := []string{
|
||||
"Better not tell you now.",
|
||||
"Signs point to yes.",
|
||||
"My reply is no.",
|
||||
"Yes.",
|
||||
"Without a doubt.",
|
||||
"I don't think so.",
|
||||
"I doubt it.",
|
||||
"NO!",
|
||||
"Well... can't say for sure but maybe.",
|
||||
"I think you need sleep.",
|
||||
"Depends.",
|
||||
"Skibidi dop dop dop yes yes yes gang gang!!!111",
|
||||
"I don't think this is a good idea, honestly.",
|
||||
"SHUT. THE. FUCK. UP",
|
||||
"Hmm, let me think about that for a bit.",
|
||||
}
|
||||
rand.Seed(time.Now().Unix())
|
||||
reply := possibleAnswers[rand.Intn(len(possibleAnswers))]
|
||||
s.ChannelMessageSend(m.ChannelID, reply)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
if strings.HasPrefix(m.Content, "!fart") {
|
||||
c := strings.Fields(m.Content)
|
||||
if len(c) == 1 {
|
||||
@ -74,16 +100,4 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// check for reddit/twitter links and replace them with open source frontends
|
||||
re := regexp.MustCompile(`(?i)((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)`)
|
||||
result := re.FindStringSubmatch(m.Content)
|
||||
// hard coded, group 2 contains the base url
|
||||
if len(result) >= 3 {
|
||||
if result[2] == "https://www.reddit.com" || result[2] == "https://reddit.com"{
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<https://tedd.it%s>", result[4]))
|
||||
} else if result[2] == "https://www.twitter.com" || result[2] == "https://twitter.com" {
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<https://nitter.it%s>", result[4]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user