This commit is contained in:
1-6
2023-07-31 13:31:58 +08:00
parent 1690a2139c
commit 9ea88a080a
17 changed files with 613 additions and 245 deletions
+13 -4
View File
@@ -11,6 +11,7 @@ import (
// _ "github.com/cdle/sillyplus/adapters/qq"
"github.com/cdle/sillyplus/adapters/web"
"github.com/cdle/sillyplus/core"
"github.com/cdle/sillyplus/core/common"
"github.com/cdle/sillyplus/utils"
)
@@ -67,14 +68,17 @@ func main() {
scanner := bufio.NewScanner(os.Stdin)
a := &core.Factory{}
a.Init("terminal", "default", nil)
i := 0
a.SetReplyHandler(func(m map[string]interface{}) string {
i++
fmt.Printf("\x1b[%dm%s \x1b[0m\n", 31, m[core.CONETNT])
return fmt.Sprint(i)
})
a.SetActionHandler(func(m map[string]interface{}) string {
fmt.Println(`do action: ` + string(utils.JsonMarshal(m)))
return ""
})
// a.SetActionHandler(func(m map[string]interface{}) string {
// fmt.Println("action", m)
// return `{"a":"a"}`
// })
for scanner.Scan() {
data := scanner.Text()
s := &core.CustomSender{
@@ -83,6 +87,11 @@ func main() {
// Admin: true,
F: a,
}
i++
s.SetFsps(&common.FakerSenderParams{
Content: data,
MessageID: fmt.Sprint(i),
})
s.SetContent(data)
core.Messages <- s
}