fix: 优化 urlparser 中的错误处理逻辑,移除无效的回复信息返回,确保函数在遇到错误时返回 nil
This commit is contained in:
parent
c05f3f11bf
commit
298ec153ea
@ -30,19 +30,11 @@ func plainTextUrlParser(msg model.Message) (reply *model.Reply) {
|
|||||||
url, _ = removeTrackingParams(url)
|
url, _ = removeTrackingParams(url)
|
||||||
newUrl, err := resolveFinalURL(url)
|
newUrl, err := resolveFinalURL(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &model.Reply{
|
return nil
|
||||||
ReplyMsg: "",
|
|
||||||
ReferOriginMsg: false,
|
|
||||||
FromMsg: msg,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
newUrl, _ = removeTrackingParams(newUrl)
|
newUrl, _ = removeTrackingParams(newUrl)
|
||||||
if util.IsEquivalentURL(url, newUrl) {
|
if util.IsEquivalentURL(url, newUrl) {
|
||||||
return &model.Reply{
|
return nil
|
||||||
ReplyMsg: "",
|
|
||||||
ReferOriginMsg: false,
|
|
||||||
FromMsg: msg,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return &model.Reply{
|
return &model.Reply{
|
||||||
ReplyMsg: newUrl,
|
ReplyMsg: newUrl,
|
||||||
@ -55,11 +47,7 @@ func cqJsonUrlParser(msg model.Message) (reply *model.Reply) {
|
|||||||
newMsg := strings.ReplaceAll(msg.RawMsg, "\n", "")
|
newMsg := strings.ReplaceAll(msg.RawMsg, "\n", "")
|
||||||
qqdocurl, err := extractQQDocURL(newMsg)
|
qqdocurl, err := extractQQDocURL(newMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &model.Reply{
|
return nil
|
||||||
ReplyMsg: "",
|
|
||||||
ReferOriginMsg: true,
|
|
||||||
FromMsg: msg,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.Reply{
|
return &model.Reply{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user