NadekoBot Patronage system, Search commands improvements + fixes

This commit is contained in:
Kwoth
2022-06-14 07:24:33 +00:00
parent 18b10b8c6f
commit 7b5145f116
165 changed files with 14920 additions and 1457 deletions

View File

@@ -0,0 +1,47 @@
using System.Globalization;
using System.Text.Json.Serialization;
namespace NadekoBot.Modules.Searches;
public sealed class SearxSearchResult : ISearchResult
{
[JsonPropertyName("query")]
public string Query { get; set; } = null!;
[JsonPropertyName("number_of_results")]
public double NumberOfResults { get; set; }
[JsonPropertyName("results")]
public List<SearxSearchResultEntry> Results { get; set; } = new List<SearxSearchResultEntry>();
[JsonPropertyName("answers")]
public List<string> Answers { get; set; } = new List<string>();
//
// [JsonPropertyName("corrections")]
// public List<object> Corrections { get; } = new List<object>();
// [JsonPropertyName("infoboxes")]
// public List<InfoboxModel> Infoboxes { get; } = new List<InfoboxModel>();
//
// [JsonPropertyName("suggestions")]
// public List<string> Suggestions { get; } = new List<string>();
// [JsonPropertyName("unresponsive_engines")]
// public List<object> UnresponsiveEngines { get; } = new List<object>();
public string SearchTime { get; set; } = null!;
public IReadOnlyCollection<ISearchResultEntry> Entries
=> Results;
public ISearchResultInformation Info
=> new SearxSearchResultInformation()
{
SearchTime = SearchTime,
TotalResults = NumberOfResults.ToString("N", CultureInfo.InvariantCulture)
};
public string? Answer
=> Answers.FirstOrDefault();
}