@@ -71,20 +71,20 @@ func init() {
7171 opMulAction .AsChild (delOp )
7272 opMulAction .AsChild (opList )
7373 opMulAction .AsChild (opPBase ) // 插件管理父行动
74- opMulAction .AsChild (help .AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
74+ opMulAction .AsChild (help .AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
7575 recvMsg .Content = admin .help ()
76- return * recvMsg , nil
76+ return * recvMsg , true , nil
7777 }))
7878
7979 opAddM := opM .And ().N (atSomeOneM )
8080 opAddByAt := plugins .DefaultActionHandler ("op_add" , true ).AsMatcher (opAddM )
81- opAddByAt .AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
81+ opAddByAt .AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
8282 content , ok := admin .addOpByAt (recvMsg )
8383 if ! ok {
8484 logging .Debug ("艾特方式添加管理员失败了" , map [string ]interface {}{"msg" : * recvMsg })
8585 }
8686 recvMsg .Content = content
87- return * recvMsg , nil
87+ return * recvMsg , true , nil
8888 })
8989
9090 // 绑定action
@@ -95,55 +95,55 @@ func init() {
9595
9696func PLFunc () * plugins.ActionHandler {
9797 PLM := matcher .Default ().And ().N (matcher.PrefixMatcher {Prefix : "list" , IsCut : true , IsCaseSensitive : false })
98- PL := plugins .DefaultActionHandler ("op -p list" , true ).AsMatcher (PLM ).AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
98+ PL := plugins .DefaultActionHandler ("op -p list" , true ).AsMatcher (PLM ).AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
9999 var buf bytes.Buffer
100100 buf .WriteString ("插件列表\n " )
101101 register := plugins .GetAutoRegister ()
102102 for i , p := range register .Plugins () {
103- buf .WriteString (fmt .Sprintf ("【%d 插件名称: %s \n 状态: %v\n 等级: 第%d级 】" , i + 1 , (* p ).GetName (), (* p ).GetPluginOpt ().Enable , (* p ).GetPluginOpt ().Level ))
103+ buf .WriteString (fmt .Sprintf ("【%d 插件名称: %s \n 状态: %v\n 等级: 第%d级 】\n " , i + 1 , (* p ).GetName (), (* p ).GetPluginOpt ().Enable , (* p ).GetPluginOpt ().Level ))
104104 }
105105 recvMsg .Content = buf .String ()
106- return * recvMsg , nil
106+ return * recvMsg , true , nil
107107 })
108108 return PL
109109}
110110
111111func onPFunc () * plugins.ActionHandler {
112112 onPM := matcher .Default ().And ().N (matcher.PrefixMatcher {Prefix : "on" , IsCut : true , IsCaseSensitive : false })
113- onP := plugins .DefaultActionHandler ("op -p on" , true ).AsMatcher (onPM ).AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
113+ onP := plugins .DefaultActionHandler ("op -p on" , true ).AsMatcher (onPM ).AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
114114 name := strings .TrimSpace (recvMsg .Content )
115115 ar := plugins .GetAutoRegister ()
116116 if name == "admin" {
117117 recvMsg .Content = "管理员插件禁止操作"
118- return * recvMsg , nil
118+ return * recvMsg , true , nil
119119 }
120120 b := ar .EnableByName (name ) // 启用某插件
121121 if b {
122122 recvMsg .Content = fmt .Sprintf ("启用 %s 成功" , name )
123123 } else {
124124 recvMsg .Content = fmt .Sprintf ("启用 %s 失败" , name )
125125 }
126- return * recvMsg , nil
126+ return * recvMsg , true , nil
127127 })
128128 return onP
129129}
130130
131131func offPFunc () * plugins.ActionHandler {
132132 offPM := matcher .Default ().And ().N (matcher.PrefixMatcher {Prefix : "off" , IsCut : true , IsCaseSensitive : false })
133- offP := plugins .DefaultActionHandler ("op -p on" , true ).AsMatcher (offPM ).AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
133+ offP := plugins .DefaultActionHandler ("op -p on" , true ).AsMatcher (offPM ).AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
134134 name := strings .TrimSpace (recvMsg .Content )
135135 ar := plugins .GetAutoRegister ()
136136 if name == "admin" {
137137 recvMsg .Content = "管理员插件禁止操作"
138- return * recvMsg , nil
138+ return * recvMsg , true , nil
139139 }
140140 b := ar .DisableByName (name ) // 启用某插件
141141 if b {
142142 recvMsg .Content = fmt .Sprintf ("禁用 %s 成功" , name )
143143 } else {
144144 recvMsg .Content = fmt .Sprintf ("禁用 %s 失败" , name )
145145 }
146- return * recvMsg , nil
146+ return * recvMsg , true , nil
147147 })
148148 return offP
149149}
@@ -157,13 +157,13 @@ func helpFunc(isSelfJudge matcher.BaseMatcher, adminJudge matcher.Custom) *plugi
157157func delOpFunc (isSelfJudge matcher.BaseMatcher , adminJudge matcher.Custom , admin * Admin ) * plugins.ActionHandler {
158158 delM := matcher .Default ().And ().N (matcher.PrefixMatcher {Prefix : "-d" , IsCaseSensitive : false , IsCut : true }, matcher .Default ().Or ().N (isSelfJudge , adminJudge ))
159159 delOp := plugins .DefaultActionHandler ("op -d" , true ).AsMatcher (delM )
160- delOp .AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
160+ delOp .AsActionFunc (func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
161161 content , ok := admin .delOpByAt (recvMsg )
162162 if ! ok {
163163 logging .Debug ("艾特方式删除管理员失败了" , map [string ]interface {}{"msg" : * recvMsg })
164164 }
165165 recvMsg .Content = content
166- return * recvMsg , nil
166+ return * recvMsg , ok , nil
167167 })
168168 return delOp
169169}
@@ -177,13 +177,13 @@ func opPluginFunc(isSelfJudge matcher.BaseMatcher, adminJudge matcher.Custom) (m
177177func opListFunc (isSelfJudge matcher.BaseMatcher , adminJudge matcher.Custom , admin * Admin ) * plugins.ActionHandler {
178178 opListM := matcher .Default ().And ().N (matcher.PrefixMatcher {Prefix : "list" , IsCaseSensitive : false , IsCut : true }, matcher .Default ().Or ().N (isSelfJudge , adminJudge ))
179179 opList := plugins .DefaultActionHandler ("op list" , true ).AsMatcher (opListM )
180- opList .Action = func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , err error ) {
180+ opList .Action = func (ctx context.Context , recvMsg * message.Message ) (reply message.Message , ok bool , err error ) {
181181 var buf bytes.Buffer
182182 buf .WriteString ("管理员列表\n " )
183183 idList := admin .cache .AdminIdList ()
184184 if idList == nil || len (idList ) == 0 {
185185 recvMsg .Content = "暂无管理员"
186- return * recvMsg , nil
186+ return * recvMsg , true , nil
187187 }
188188 for _ , wxid := range idList {
189189 m := admin .Cli .GetMember (wxid , true )
@@ -192,7 +192,7 @@ func opListFunc(isSelfJudge matcher.BaseMatcher, adminJudge matcher.Custom, admi
192192 }
193193 }
194194 recvMsg .Content = buf .String ()
195- return * recvMsg , nil
195+ return * recvMsg , true , nil
196196 }
197197 return opList
198198}
0 commit comments