fix ask question

This commit is contained in:
Asim Aslam
2021-06-30 15:25:50 +01:00
parent 054e60a864
commit 9600a24a71
3 changed files with 7 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ package handler
import (
"context"
"github.com/ajanicij/goduckgo/goduckgo"
"github.com/m3o/goduckgo/goduckgo"
"github.com/micro/micro/v3/service/errors"
pb "github.com/micro/services/ask/proto"
)
@@ -25,13 +25,13 @@ func (a *Ask) Question(ctx context.Context, req *pb.QuestionRequest, rsp *pb.Que
} else if len(msg.AbstractText) > 0 {
rsp.Answer = msg.AbstractText
} else if len(msg.RelatedTopics) > 0 {
rsp.Answer = msg.RelatedTopics[0].Text
rsp.Answer = "Don't have an answer for that but here's a related topic: " + msg.RelatedTopics[0].Text
} else {
rsp.Answer = "Sorry I don't know 😞"
return nil
}
if len(msg.AbstractURL) > 0 {
if (len(msg.AbstractURL) > 0) && (len(msg.Abstract) > 0 || len(msg.AbstractText) > 0) {
rsp.Url = msg.AbstractURL
} else if len(msg.RelatedTopics) > 0 {
rsp.Url = msg.RelatedTopics[0].FirstURL