1
0
mirror of https://github.com/osmarks/autobotrobot synced 2025-01-03 04:10:27 +00:00

Show first five results only in search

This commit is contained in:
osmarks 2018-11-15 21:28:44 +00:00
parent f4050b4202
commit 10c27c216f

View File

@ -220,15 +220,20 @@ command!(search(_context, message, args) {
url: none_if_empty(result.abstract_url)
})?,
ddg::Type::Disambiguation => {
let mut results = vec![];
for related_topic in result.related_topics {
for topic in get_topics(related_topic) {
send_search_result(channel, SearchResult {
results.push(topic);
}
}
for topic in results.drain(..5) {
send_search_result(channel, SearchResult {
url: none_if_empty(topic.first_url),
image: none_if_empty(topic.icon.url),
title: query.clone(),
text: topic.text
})?;
}
}
},
ddg::Type::Exclusive => {