-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove.go
44 lines (37 loc) · 898 Bytes
/
remove.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
package main
import (
"fmt"
"strings"
hbot "github.com/whyrusleeping/hellabot"
)
// RemoveTrigger lists all of the commands current available.
var RemoveTrigger = hbot.Trigger{
Condition: removeCondition,
Action: removeAction,
}
func removeCondition(b *hbot.Bot, m *hbot.Message) bool {
if strings.HasPrefix(m.Content, "!remove ") {
for _, name := range Mods {
if name == m.From {
return true
}
}
}
return false
}
const removeUsage = "!delete must have exactly two arguments.\nUsage: !delete <command>"
func removeAction(b *hbot.Bot, m *hbot.Message) bool {
args := strings.Split(m.Content, " ")
if len(args) != 2 {
b.Reply(m, removeUsage)
return false
}
name := args[1]
result := DeleteCommand(name)
if !result {
b.Reply(m, fmt.Sprintf("No such command: %s", name))
return false
}
b.Reply(m, fmt.Sprintf("Deleted command: %s", name))
return true
}