This commit is contained in:
cdle
2021-10-12 16:51:22 +08:00
parent 96122aaf77
commit aa8460e8a5
2 changed files with 52 additions and 2 deletions
+1 -2
View File
@@ -12,5 +12,4 @@ data
dwz
replies
qinglongs
sets.conf
xiaoai.go
sets.conf
+51
View File
@@ -0,0 +1,51 @@
package core
import (
"fmt"
"time"
"github.com/beego/beego/v2/client/httplib"
)
func init() {
AddCommand("", []Function{
{
Rules: []string{
"^小爱(.*)$",
},
Handle: func(s Sender) interface{} {
api := sillyGirl.Get("小爱同学")
if api == "" {
return "未设置小同学api"
}
reply := func(str string) string {
str, _ = httplib.Get(fmt.Sprintf(api, str)).String()
if str == "" {
str = "暂时无法回复。"
}
return str
}
msg := s.Get()
if msg == "对话模式" {
stop := false
for {
if stop {
break
}
s.Await(s, func(s2 Sender) interface{} {
msg := s2.Get()
if msg == "闭嘴" {
stop = true
}
return reply(msg)
}, `[\s\S]*`, time.Duration(time.Second*300))
}
}
if msg == "" {
msg = "小爱"
}
return name()
},
},
})
}