diff --git a/core/function.go b/core/function.go index c177a67..2ba13a6 100644 --- a/core/function.go +++ b/core/function.go @@ -81,8 +81,8 @@ func AddCommand(prefix string, cmds []Function) { func handleMessage(sender Sender) { defer sender.Finish() key := fmt.Sprintf("u=%v&c=%v&i=%v", sender.GetUserID(), sender.GetChatID(), sender.GetImType()) - fmt.Println(key, sender.GetContent()) - fmt.Println(waits.Load(key)) + // fmt.Println(key, sender.GetContent()) + // fmt.Println(waits.Load(key)) if v, ok := waits.Load(key); ok { c := v.(Carry) diff --git a/core/im.go b/core/im.go index 947425a..b062448 100644 --- a/core/im.go +++ b/core/im.go @@ -30,7 +30,7 @@ type Sender interface { Finish() Continue() IsContinue() bool - Await(func(string, error) interface{}, ...interface{}) + Await(Sender, func(string, error) interface{}, ...interface{}) } type Edit int @@ -134,6 +134,7 @@ func (sender *Faker) Finish() { type BaseSender struct { matches [][]string goon bool + child Sender } func (sender *BaseSender) SetMatch(ss []string) { @@ -222,7 +223,7 @@ type Carry struct { Result chan interface{} } -func (sender *BaseSender) Await(callback func(string, error) interface{}, params ...interface{}) { +func (_ *BaseSender) Await(sender Sender, callback func(string, error) interface{}, params ...interface{}) { c := Carry{} timeout := time.Second * 20 for _, param := range params { diff --git a/core/test.go b/core/test.go index f8978b2..ee4c83c 100644 --- a/core/test.go +++ b/core/test.go @@ -164,7 +164,7 @@ func initSys() { old := b.Get(s.Get(1)) b.Set(s.Get(1), s.Get(2)) go func() { - s.Await(func(_ string, e error) interface{} { + s.Await(s, func(_ string, e error) interface{} { if e != nil { return nil }