forked from nnev/frank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.go
52 lines (42 loc) · 1013 Bytes
/
admin.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
package main
import (
"log"
"strings"
)
func runnerAdmin(parsed Message) {
if !IsPrivateQuery(parsed) {
return
}
n := Nick(parsed)
if !IsNickAdmin(parsed) {
// log.Printf("Not executing admin command for normal user %s", n)
return
}
msg := parsed.Trailing
if strings.HasPrefix(msg, "msg ") {
cmd := strings.SplitN(msg, " ", 3)
if len(cmd) >= 3 {
channel := cmd[1]
msg = cmd[2]
log.Printf("ADMIN %s: posting “%s” to %s", n, msg, channel)
Privmsg(channel, msg)
}
}
if msg == "quit" || msg == "exit" {
Privmsg(Nick(parsed), "If you really want "+*nick+" to exit, type: REALLY_QUIT")
}
if msg == "REALLY_QUIT" {
Privmsg(n, "As you wish.")
log.Printf("ADMIN %s: quitting", n)
kill()
}
if msg == "memprofile" {
path := writeMemoryProfile()
Privmsg(Nick(parsed), "Wrote memory profile to "+path+", have a look on the server.")
}
if strings.HasPrefix(msg, "settopic #") {
cmd := strings.SplitN(msg, " ", 2)
channel := cmd[1]
setTopic(channel)
}
}