forked from ghaoo/rboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ping.go
43 lines (38 loc) · 896 Bytes
/
ping.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
package ping
import (
"github.com/ri0day/rboot"
"math/rand"
"time"
)
func setup(bot *rboot.Robot, in *rboot.Message) (msg []*rboot.Message) {
return rboot.NewMessages(randReply())
}
func randReply() string {
rand.Seed(int64(time.Now().UnixNano()))
replies := []string{
"yeah um.. pong?",
"WHAT?! jeeze.",
"what? oh, um SYNACKSYN? ENOSPEAKTCP.",
"RST (lulz)",
"64 bytes from go.away.your.annoying icmp_seq=0 ttl=42 time=42.596 ms",
"hmm?",
"ack. what?",
"pong. what?",
"yup. still here.",
"super busy just now.. Can I get back to you in like 5min?",
}
content := replies[rand.Intn(len(replies))]
return content
}
func init() {
rboot.RegisterPlugin(`ping`, rboot.Plugin{
Action: setup,
Ruleset: map[string]string{
`ping`: `^!(?:ping|PING)`,
},
Usage: map[string]string{
"!ping": "随机返回一句回答",
},
Description: `测试脚本`,
})
}