This commit is contained in:
cdle
2021-10-11 21:08:26 +08:00
parent 581e238322
commit 4c499d7dd6
+29
View File
@@ -6,8 +6,11 @@ import (
"io/ioutil"
"os"
"os/exec"
"regexp"
"strings"
"time"
"github.com/beego/beego/v2/adapter/httplib"
)
func init() {
@@ -265,6 +268,32 @@ Alias=sillyGirl.service`
}
},
},
{
Rules: []string{"raw ^成语接龙$"},
Handle: func(s Sender) interface{} {
id := fmt.Sprintf("%v", s.GetChatID())
data, err := httplib.Get("http://hm.suol.cc/API/cyjl.php?id=" + id + "&msg=开始成语接龙").String()
if err != nil {
s.Reply(err)
}
s.Reply(data)
for {
s.Await(s, func(s1 string, s2 Sender, _ error) interface{} {
cy := regexp.MustCompile("^[一-龥]{4}$").FindString(s1)
if cy == "" {
s2.Disappear(time.Millisecond * 500)
return "请认真接龙,一站到底!。"
}
data, err := httplib.Get("http://hm.suol.cc/API/cyjl.php?id=" + id + "&msg=我接" + cy).String()
if err != nil {
s2.Reply(err)
return nil
}
return data
}, `[\s\S]*`, time.Duration(time.Second*300))
}
},
},
})
}