-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
34 lines (26 loc) · 994 Bytes
/
example_test.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
package singularity_test
import "github.com/JustAnotherOrganization/singularity"
var team singularity.SlackInstance
// This example shows the basic usage for deploying a bot using singularity.
func Example_basic() {
s := singularity.NewSingularity()
team := s.NewTeam("xoxb-slackToken")
if err := team.Start(); err != nil {
panic(err)
}
s.WaitForShutdown()
}
// This example shows how to register a basic handler.
func Example_registerhandler() {
team.RegisterHandler("message", func(message singularity.Message, team *singularity.SlackInstance) {
if message.SubType != "message_deleted" && message.User != "" {
team.Log(singularity.LogInfo, "%v said %v", team.GetUserByID(message.User).Name, message.Text)
}
})
}
// This example shows how to register a basic command.
func Example_registercommand() {
team.RegisterCommand("ping", func(command singularity.Command) {
command.Instance.SendMessage(singularity.Message{Text: "Pong!", Channel: command.Channel.ID})
})
}