-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path8ball.go
70 lines (59 loc) · 2.21 KB
/
8ball.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
// Copyright (c) 2020-2022, The OneBot Contributors. All rights reserved.
package main
import (
"fmt"
"github.com/TheDiscordian/onebot/onelib"
"math/rand"
)
const (
// NAME is same as filename, minus extension
NAME = "8ball"
// LONGNAME is what's presented to the user
LONGNAME = "8Ball Plugin"
// VERSION of the plugin
VERSION = "v0.0.0"
)
// Load returns the Plugin object.
func Load() onelib.Plugin {
return new(EightBallPlugin)
}
func eightball(msg onelib.Message, sender onelib.Sender) {
var formattedText string
text := msg.Text()
if len(text) < 3 {
text = fmt.Sprintf("Predicts the future. Usage: %s8ball `<y/n question>`", onelib.DefaultPrefix)
formattedText = fmt.Sprintf("Predicts the future. Usage: <code>%s8ball <y/n question></code>", onelib.DefaultPrefix)
} else {
eightballAnswers := []string{"As I see it, yes", "It is certain", "It is decidedly so", "Most likely",
"Outlook good", "Signs point to yes", "Without a doubt", "Yes", "Yes, definitely",
"You may rely on it", "Reply hazy, try again", "Ask again later",
"Better not tell you now", "Cannot predict now", "Concentrate and ask again",
"Don't count on it", "My reply is no", "My sources say no", "Outlook not so good",
"Very doubtful"}
randn := rand.Intn(len(eightballAnswers))
text = eightballAnswers[randn] + "."
formattedText = text
}
sender.Location().SendFormattedText(text, formattedText)
}
// EightBallPlugin is an object for satisfying the Plugin interface.
type EightBallPlugin int
// Name returns the name of the plugin, usually the filename.
func (eb *EightBallPlugin) Name() string {
return NAME
}
// LongName returns the display name of the plugin.
func (eb *EightBallPlugin) LongName() string {
return LONGNAME
}
// Version returns the version of the plugin, usually in the format of "v0.0.0".
func (eb *EightBallPlugin) Version() string {
return VERSION
}
// Implements returns a map of commands and monitor the plugin implements.
func (eb *EightBallPlugin) Implements() (map[string]onelib.Command, *onelib.Monitor) {
return map[string]onelib.Command{"8b": eightball, "8ball": eightball}, nil
}
// Remove is necessary to satisfy the Plugin interface, it does nothing.
func (eb *EightBallPlugin) Remove() {
}