@@ -176,6 +176,7 @@ func (self WechatLogic) AutoReply(ctx context.Context, reqData []byte) (*model.W
176
176
} else if strings .Contains (wechatMsg .Content , "图书" ) || strings .Contains (wechatMsg .Content , "book" ) {
177
177
return self .bookContent (ctx , wechatMsg )
178
178
} else {
179
+ // 用户获取验证码用
179
180
user := DefaultUser .FindOne (ctx , "username" , wechatMsg .Content )
180
181
if user .Uid > 0 {
181
182
var content string
@@ -188,13 +189,28 @@ func (self WechatLogic) AutoReply(ctx context.Context, reqData []byte) (*model.W
188
189
return self .wechatResponse (ctx , content , wechatMsg )
189
190
}
190
191
192
+ // 关键词回复
193
+ autoReply := & model.WechatAutoReply {}
194
+ MasterDB .Where ("word LIKE ?" , "%" + wechatMsg .Content + "%" ).Get (autoReply )
195
+ if autoReply .Id != 0 {
196
+ wechatMsg .MsgType = autoReply .MsgType
197
+ return self .wechatResponse (ctx , autoReply .Content , wechatMsg )
198
+ }
199
+
191
200
return self .searchContent (ctx , wechatMsg )
192
201
}
193
202
case model .WeMsgTypeEvent :
194
203
switch wechatMsg .Event {
195
204
case model .WeEventSubscribe :
196
205
wechatMsg .MsgType = model .WeMsgTypeText
197
206
welcomeText := strings .ReplaceAll (config .ConfigFile .MustValue ("wechat" , "subscribe" ), "\\ n" , "\n " )
207
+
208
+ autoReply := & model.WechatAutoReply {}
209
+ _ , err = MasterDB .Where ("typ=?" , model .AutoReplyTypSubscribe ).Get (autoReply )
210
+ if err == nil {
211
+ welcomeText = autoReply .Content
212
+ }
213
+
198
214
return self .wechatResponse (ctx , welcomeText , wechatMsg )
199
215
}
200
216
}
0 commit comments