File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ type Config struct {
28
28
MaxProcessTime time.Duration `json:"max_process_time"` // 事件最大处理时间 (默认4min)
29
29
MarkMessage bool `json:"mark_message"` // 自动标记消息为已读
30
30
KeepAtMeMessage bool `json:"keep_at_me_message"` // 是否保留at me的原始消息
31
+ AddSpaceAfterAt bool `json:"at_space"` // 是否在At消息后没有空格时自动添加空格
31
32
Driver []Driver `json:"-"` // 通信驱动
32
33
}
33
34
Original file line number Diff line number Diff line change @@ -113,6 +113,21 @@ func (ctx *Ctx) Send(msg interface{}) message.ID {
113
113
114
114
// SendChain 快捷发送消息/合并转发-消息链
115
115
func (ctx * Ctx ) SendChain (msg ... message.Segment ) message.ID {
116
+ if BotConfig .AddSpaceAfterAt && len (msg ) > 0 {
117
+ newMsg := make (message.Message , 0 , len (msg )* 2 )
118
+ for i := 0 ; i < len (msg )- 1 ; i ++ {
119
+ newMsg = append (newMsg , msg [i ])
120
+ if msg [i ].Type != "at" {
121
+ continue
122
+ }
123
+ if msg [i + 1 ].Type != "text" ||
124
+ (len (msg [i + 1 ].Data ["text" ]) > 0 && msg [i + 1 ].Data ["text" ][0 ] != ' ' ) {
125
+ newMsg = append (newMsg , message .Text (" " ))
126
+ }
127
+ }
128
+ newMsg = append (newMsg , msg [len (msg )- 1 ])
129
+ msg = newMsg
130
+ }
116
131
return ctx .Send ((message .Message )(msg ))
117
132
}
118
133
You can’t perform that action at this time.
0 commit comments