This commit is contained in:
cdle
2021-10-15 10:26:24 +08:00
parent a7b0f393c4
commit ffd6943a2c
+25 -3
View File
@@ -275,6 +275,11 @@ Alias=sillyGirl.service`
{ {
Rules: []string{"raw ^成语接龙$"}, Rules: []string{"raw ^成语接龙$"},
Handle: func(s Sender) interface{} { Handle: func(s Sender) interface{} {
begin := ""
fword := func(cy string) string {
begin := regexp.MustCompile(`([一-龥])】`).FindString(cy)
return begin
}
id := fmt.Sprintf("%v", s.GetUserID()) id := fmt.Sprintf("%v", s.GetUserID())
start: start:
data, err := httplib.Get("http://hm.suol.cc/API/cyjl.php?id=" + id + "&msg=开始成语接龙").String() data, err := httplib.Get("http://hm.suol.cc/API/cyjl.php?id=" + id + "&msg=开始成语接龙").String()
@@ -282,6 +287,7 @@ Alias=sillyGirl.service`
s.Reply(err) s.Reply(err)
} }
s.Reply(data) s.Reply(data)
fword(data)
stop := false stop := false
goon := false goon := false
win := false win := false
@@ -298,6 +304,15 @@ Alias=sillyGirl.service`
} }
s.Await(s, func(s2 Sender) interface{} { s.Await(s, func(s2 Sender) interface{} {
ct := s2.GetContent() ct := s2.GetContent()
me := s2.GetUserID() == s.GetUserID()
if regexp.MustCompile("^"+begin).FindString(ct) == "" {
if me {
return fmt.Sprintf("现在是接【%s】开头的成语哦。", begin)
} else {
s2.Continue()
return nil
}
}
if strings.Contains(ct, "认输") { if strings.Contains(ct, "认输") {
stop = true stop = true
return nil return nil
@@ -319,17 +334,24 @@ Alias=sillyGirl.service`
if strings.Contains(data, "你赢") { if strings.Contains(data, "你赢") {
stop = true stop = true
win = true win = true
defer s.Reply("反正不是你赢,嘿嘿。")
} else if strings.Contains(data, "我赢") { } else if strings.Contains(data, "我赢") {
stop = true stop = true
win = false win = false
} else if strings.Contains(data, "恭喜") { } else if strings.Contains(data, "恭喜") {
fword(data)
if !me {
defer s2.Reply("你很可拷,观棋不语真君子懂不懂啊。")
}
} else { } else {
if me {
data += "玩不过就认输呗。" data += "玩不过就认输呗。"
} else {
data += "你以为你会,结果出丑了吧。"
}
} }
return data return data
}) }, ForGroup)
} }
time.Sleep(time.Microsecond * 100) time.Sleep(time.Microsecond * 100)
s.Reply("还玩吗?[Y/n]") s.Reply("还玩吗?[Y/n]")