mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 11:15:12 +00:00
fix ask question
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user