mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +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
|
||||
|
||||
3
go.mod
3
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/Masterminds/semver/v3 v3.1.1
|
||||
github.com/PuerkitoBio/goquery v1.6.1
|
||||
github.com/SlyMarbo/rss v1.0.1
|
||||
github.com/ajanicij/goduckgo v0.0.0-20150205231829-61f9a275272f
|
||||
github.com/ajanicij/goduckgo v0.0.0-20150205231829-61f9a275272f // indirect
|
||||
github.com/cdipaolo/goml v0.0.0-20190412180403-e1f51f713598 // indirect
|
||||
github.com/cdipaolo/sentiment v0.0.0-20200617002423-c697f64e7f10
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
||||
@@ -27,6 +27,7 @@ require (
|
||||
github.com/kevinburke/rest v0.0.0-20210506044642-5611499aa33c // indirect
|
||||
github.com/kevinburke/twilio-go v0.0.0-20210327194925-1623146bcf73
|
||||
github.com/lib/pq v1.9.0 // indirect
|
||||
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945
|
||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a // indirect
|
||||
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e
|
||||
github.com/micro/micro/v3 v3.3.1-0.20210611161948-fd9821dd4f52
|
||||
|
||||
2
go.sum
2
go.sum
@@ -322,6 +322,8 @@ github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
|
||||
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA=
|
||||
github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVLEIG/i5J9cyixzQ=
|
||||
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945 h1:jcOqgh+pYNSaPoPOgDaaU5t9j45JzHG3wOBLXUMBfQ0=
|
||||
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945/go.mod h1:wQOw7PY6509VQbepPrclbyXfbQ5lpOtIoHdBKbB+OGc=
|
||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a h1:rnrxZue85aKdMU4nJ50GgKA31lCaVbft+7Xl8OXj55U=
|
||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a/go.mod h1:hJJYoBMTZIONmUEpX3+9v2057zuRM0n3n77U4Ob4wE4=
|
||||
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e h1:cj+w63ez19o7y7vunA8Q3rUIWwKEOUx7foqjnr4qbtI=
|
||||
|
||||
Reference in New Issue
Block a user