MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / reply

Method reply

plugin/baiduaudit/model.go:223–259  ·  view source on GitHub ↗

生成回复文本

(bdres *baiduRes)

Source from the content-addressed store, hash-verified

221
222// 生成回复文本
223func (g *group) reply(bdres *baiduRes) message.Message {
224 g.mu.Lock()
225 defer g.mu.Unlock()
226 // 建立消息段
227 msgs := make([]message.Segment, 0, 8)
228 // 生成简略审核结果回复
229 msgs = append(msgs, message.Text(bdres.Conclusion, "\n"))
230 // 查看是否开启详细审核内容提示, 并确定审核内容值为疑似, 或者不合规
231 if !g.MoreRemind {
232 return msgs
233 }
234 // 遍历返回的不合规数据, 生成详细违规内容
235 for i, datum := range bdres.Data {
236 msgs = append(msgs, message.Text("[", i, "]:", datum.Msg, "\n"))
237 // 检查命中词条是否大于0
238 if len(datum.Hits) == 0 {
239 return msgs
240 }
241 // 遍历打印命中的违规词条
242 for _, hit := range datum.Hits {
243 if len(datum.Hits) == 0 {
244 return msgs
245 }
246 msgs = append(msgs, message.Text("("))
247 for i4, i3 := range hit.Words {
248 // 检查是否是最后一个要打印的词条, 如果是则不加上逗号
249 if i4 != len(hit.Words)-1 {
250 msgs = append(msgs, message.Text(i3, ","))
251 } else {
252 msgs = append(msgs, message.Text(i3))
253 }
254 }
255 msgs = append(msgs, message.Text(")"))
256 }
257 }
258 return msgs
259}
260
261type mark bool
262

Callers 2

auditMethod · 0.80
initFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected