diff --git a/core/action/action.go b/core/action/action.go index 8b04d0c..206ecb8 100644 --- a/core/action/action.go +++ b/core/action/action.go @@ -21,13 +21,14 @@ func (spec *baseSpec) Receivers() []lib.Addressable { return spec.receivers } -func (spec *baseSpec) AddReceiver(rcv lib.Addressable) { +func (spec *baseSpec) AddReceiver(rcv lib.Addressable) lib.ActionSpec { for _, r := range spec.receivers { if r == rcv { - return + return spec } } spec.receivers = append(spec.receivers, rcv) + return spec } func Base(hdlr lib.ActionHandler, rcvs ...string) *baseSpec { @@ -38,10 +39,6 @@ func Base(hdlr lib.ActionHandler, rcvs ...string) *baseSpec { return &spec } -func BaseA(hdlr lib.ActionHandler, rcvs ...lib.Addressable) *baseSpec { - return &baseSpec{hdlr, rcvs} -} - // action selection func Select(ctx lib.Context, msg lib.Message) []lib.Action { diff --git a/matrix/matrix.go b/matrix/matrix.go index 9752516..335953d 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -40,7 +40,7 @@ func connect(src, tgt lib.Context, msg lib.Message) { } } } - cfg.AddAction(pattern, action.BaseA(handle, tgt)) + cfg.AddAction(pattern, action.Base(handle).AddReceiver(tgt)) } func handle(act lib.Action) bool { diff --git a/scopes.go b/scopes.go index ebf708d..315fb66 100644 --- a/scopes.go +++ b/scopes.go @@ -83,7 +83,7 @@ type Action interface { type ActionSpec interface { Handler() ActionHandler Receivers() []Addressable - AddReceiver(Addressable) + AddReceiver(Addressable) ActionSpec } // procedures and handlers