Removed module projects because it can't work like that atm. Commented out package commands.
This commit is contained in:
		
							
								
								
									
										20
									
								
								NadekoBot.Core/Modules/Searches/Common/AnimeResult.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								NadekoBot.Core/Modules/Searches/Common/AnimeResult.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| using NadekoBot.Extensions; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class AnimeResult | ||||
|     { | ||||
|         public int id; | ||||
|         public string AiringStatus => airing_status.ToTitleCase(); | ||||
|         public string airing_status; | ||||
|         public string title_english; | ||||
|         public int total_episodes; | ||||
|         public string description; | ||||
|         public string image_url_lge; | ||||
|         public string[] Genres; | ||||
|         public string average_score; | ||||
|  | ||||
|         public string Link => "http://anilist.co/anime/" + id; | ||||
|         public string Synopsis => description?.Substring(0, description.Length > 500 ? 500 : description.Length) + "..."; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										39
									
								
								NadekoBot.Core/Modules/Searches/Common/DefineModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								NadekoBot.Core/Modules/Searches/Common/DefineModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| using System.Collections.Generic; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class Audio | ||||
|     { | ||||
|         public string url { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Example | ||||
|     { | ||||
|         public List<Audio> audio { get; set; } | ||||
|         public string text { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class GramaticalInfo | ||||
|     { | ||||
|         public string type { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Sens | ||||
|     { | ||||
|         public object Definition { get; set; } | ||||
|         public List<Example> Examples { get; set; } | ||||
|         public GramaticalInfo Gramatical_info { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Result | ||||
|     { | ||||
|         public string Part_of_speech { get; set; } | ||||
|         public List<Sens> Senses { get; set; } | ||||
|         public string Url { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class DefineModel | ||||
|     { | ||||
|         public List<Result> Results { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,11 @@ | ||||
| using System; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common.Exceptions | ||||
| { | ||||
|     public class StreamNotFoundException : Exception | ||||
|     { | ||||
|         public StreamNotFoundException(string message) : base($"Stream '{message}' not found.") | ||||
|         { | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										16
									
								
								NadekoBot.Core/Modules/Searches/Common/GoogleSearchResult.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								NadekoBot.Core/Modules/Searches/Common/GoogleSearchResult.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public struct GoogleSearchResult | ||||
|     { | ||||
|         public string Title { get; } | ||||
|         public string Link { get; } | ||||
|         public string Text { get; } | ||||
|  | ||||
|         public GoogleSearchResult(string title, string link, string text) | ||||
|         { | ||||
|             this.Title = title; | ||||
|             this.Link = link; | ||||
|             this.Text = text; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										8
									
								
								NadekoBot.Core/Modules/Searches/Common/MagicItem.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								NadekoBot.Core/Modules/Searches/Common/MagicItem.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class MagicItem | ||||
|     { | ||||
|         public string Name { get; set; } | ||||
|         public string Description { get; set; } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								NadekoBot.Core/Modules/Searches/Common/MangaResult.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								NadekoBot.Core/Modules/Searches/Common/MangaResult.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class MangaResult | ||||
|     { | ||||
|         public int id; | ||||
|         public string publishing_status; | ||||
|         public string image_url_lge; | ||||
|         public string title_english; | ||||
|         public int total_chapters; | ||||
|         public int total_volumes; | ||||
|         public string description; | ||||
|         public string[] Genres; | ||||
|         public string average_score; | ||||
|         public string Link => "http://anilist.co/manga/" + id; | ||||
|         public string Synopsis => description?.Substring(0, description.Length > 500 ? 500 : description.Length) + "..."; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								NadekoBot.Core/Modules/Searches/Common/OmdbProvider.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								NadekoBot.Core/Modules/Searches/Common/OmdbProvider.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| using System; | ||||
| using System.Net.Http; | ||||
| using System.Threading.Tasks; | ||||
| using Discord; | ||||
| using NadekoBot.Extensions; | ||||
| using NadekoBot.Core.Services; | ||||
| using Newtonsoft.Json; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public static class OmdbProvider | ||||
|     { | ||||
|         private const string queryUrl = "https://omdbapi.nadekobot.me/?t={0}&y=&plot=full&r=json"; | ||||
|  | ||||
|         public static async Task<OmdbMovie> FindMovie(string name, IGoogleApiService google) | ||||
|         { | ||||
|             using (var http = new HttpClient()) | ||||
|             { | ||||
|                 var res = await http.GetStringAsync(String.Format(queryUrl,name.Trim().Replace(' ','+'))).ConfigureAwait(false); | ||||
|                 var movie = JsonConvert.DeserializeObject<OmdbMovie>(res); | ||||
|                 if (movie?.Title == null) | ||||
|                     return null; | ||||
|                 movie.Poster = await google.ShortenUrl(movie.Poster); | ||||
|                 return movie; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public class OmdbMovie | ||||
|     { | ||||
|         public string Title { get; set; } | ||||
|         public string Year { get; set; } | ||||
|         public string ImdbRating { get; set; } | ||||
|         public string ImdbId { get; set; } | ||||
|         public string Genre { get; set; } | ||||
|         public string Plot { get; set; } | ||||
|         public string Poster { get; set; } | ||||
|  | ||||
|         public EmbedBuilder GetEmbed() => | ||||
|             new EmbedBuilder().WithOkColor() | ||||
|                               .WithTitle(Title) | ||||
|                               .WithUrl($"http://www.imdb.com/title/{ImdbId}/") | ||||
|                               .WithDescription(Plot.TrimTo(1000)) | ||||
|                               .AddField(efb => efb.WithName("Rating").WithValue(ImdbRating).WithIsInline(true)) | ||||
|                               .AddField(efb => efb.WithName("Genre").WithValue(Genre).WithIsInline(true)) | ||||
|                               .AddField(efb => efb.WithName("Year").WithValue(Year).WithIsInline(true)) | ||||
|                               .WithImageUrl(Poster); | ||||
|  | ||||
|         public override string ToString() => | ||||
| $@"`Title:` {Title} | ||||
| `Year:` {Year} | ||||
| `Rating:` {ImdbRating} | ||||
| `Genre:` {Genre} | ||||
| `Link:` http://www.imdb.com/title/{ImdbId}/ | ||||
| `Plot:` {Plot}"; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										60
									
								
								NadekoBot.Core/Modules/Searches/Common/OverwatchApiModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								NadekoBot.Core/Modules/Searches/Common/OverwatchApiModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| using Newtonsoft.Json; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class OverwatchApiModel | ||||
|     { | ||||
|         public OverwatchPlayer Player { get; set; } | ||||
|  | ||||
|         public class OverwatchResponse | ||||
|         { | ||||
|             public object _request; | ||||
|             public OverwatchPlayer Eu { get; set; } | ||||
|             public OverwatchPlayer Kr { get; set; } | ||||
|             public OverwatchPlayer Us { get; set; } | ||||
|         } | ||||
|         public class OverwatchPlayer | ||||
|         { | ||||
|             public StatsField Stats { get; set; } | ||||
|         } | ||||
|  | ||||
|         public class StatsField | ||||
|         { | ||||
|             public Stats Quickplay { get; set; } | ||||
|             public Stats Competitive { get; set; } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public class Stats | ||||
|         { | ||||
|             [JsonProperty("overall_stats")] | ||||
|             public OverallStats OverallStats { get; set; } | ||||
|             [JsonProperty("game_stats")] | ||||
|             public GameStats GameStats { get; set; } | ||||
|         } | ||||
|  | ||||
|         public class OverallStats | ||||
|         { | ||||
|             public int? comprank; | ||||
|             public int level; | ||||
|             public int prestige; | ||||
|             public string avatar; | ||||
|             public int wins; | ||||
|             public int losses; | ||||
|             public int games; | ||||
|             public string rank_image; | ||||
|         } | ||||
|  | ||||
|         public class GameStats | ||||
|         { | ||||
|             [JsonProperty("time_played")] | ||||
|             public float timePlayed; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public class Competitive | ||||
|         { | ||||
|  | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										223
									
								
								NadekoBot.Core/Modules/Searches/Common/SearchImageCacher.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										223
									
								
								NadekoBot.Core/Modules/Searches/Common/SearchImageCacher.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,223 @@ | ||||
| using System; | ||||
| using System.Collections.Concurrent; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Net.Http; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using System.Xml; | ||||
| using NadekoBot.Common; | ||||
| using NadekoBot.Extensions; | ||||
| using Newtonsoft.Json; | ||||
| using NLog; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class SearchImageCacher | ||||
|     { | ||||
|         private readonly NadekoRandom _rng; | ||||
|         private readonly ConcurrentDictionary<DapiSearchType, SemaphoreSlim> _locks = new ConcurrentDictionary<DapiSearchType, SemaphoreSlim>(); | ||||
|  | ||||
|         private readonly SortedSet<ImageCacherObject> _cache; | ||||
|         private readonly Logger _log; | ||||
|         private readonly HttpClient _http; | ||||
|  | ||||
|         public SearchImageCacher() | ||||
|         { | ||||
|             _http = new HttpClient(); | ||||
|             _http.AddFakeHeaders(); | ||||
|  | ||||
|             _log = LogManager.GetCurrentClassLogger(); | ||||
|             _rng = new NadekoRandom(); | ||||
|             _cache = new SortedSet<ImageCacherObject>(); | ||||
|         } | ||||
|  | ||||
|         public async Task<ImageCacherObject> GetImage(string tag, bool forceExplicit, DapiSearchType type, | ||||
|             HashSet<string> blacklistedTags = null) | ||||
|         { | ||||
|             tag = tag?.ToLowerInvariant(); | ||||
|  | ||||
|             blacklistedTags = blacklistedTags ?? new HashSet<string>(); | ||||
|  | ||||
|             if (type == DapiSearchType.E621) | ||||
|                 tag = tag?.Replace("yuri", "female/female"); | ||||
|  | ||||
|             var _lock = GetLock(type); | ||||
|             await _lock.WaitAsync(); | ||||
|             try | ||||
|             { | ||||
|                 ImageCacherObject[] imgs; | ||||
|                 if (!string.IsNullOrWhiteSpace(tag)) | ||||
|                 { | ||||
|                     imgs = _cache.Where(x => x.Tags.IsSupersetOf(tag.Split('+')) && x.SearchType == type && (!forceExplicit || x.Rating == "e")).ToArray(); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     tag = null; | ||||
|                     imgs = _cache.Where(x => x.SearchType == type).ToArray(); | ||||
|                 } | ||||
|                 ImageCacherObject img; | ||||
|                 if (imgs.Length == 0) | ||||
|                     img = null; | ||||
|                 else | ||||
|                     img = imgs[_rng.Next(imgs.Length)]; | ||||
|  | ||||
|                 if (img != null) | ||||
|                 { | ||||
|                     _cache.Remove(img); | ||||
|                     return img; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     var images = await DownloadImages(tag, forceExplicit, type).ConfigureAwait(false); | ||||
|                     images = images | ||||
|                         .Where(x => x.Tags.All(t => !blacklistedTags.Contains(t))) | ||||
|                         .ToArray(); | ||||
|                     if (images.Length == 0) | ||||
|                         return null; | ||||
|                     var toReturn = images[_rng.Next(images.Length)]; | ||||
| #if !GLOBAL_NADEKO | ||||
|                     foreach (var dledImg in images) | ||||
|                     { | ||||
|                         if(dledImg != toReturn) | ||||
|                             _cache.Add(dledImg); | ||||
|                     } | ||||
| #endif | ||||
|                     return toReturn; | ||||
|                 }                     | ||||
|             } | ||||
|             finally | ||||
|             { | ||||
|                 _lock.Release(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         private SemaphoreSlim GetLock(DapiSearchType type) | ||||
|         { | ||||
|             return _locks.GetOrAdd(type, _ => new SemaphoreSlim(1, 1)); | ||||
|         } | ||||
|  | ||||
|         public async Task<ImageCacherObject[]> DownloadImages(string tag, bool isExplicit, DapiSearchType type) | ||||
|         { | ||||
|             tag = tag?.Replace(" ", "_").ToLowerInvariant(); | ||||
|             if (isExplicit) | ||||
|                 tag = "rating%3Aexplicit+" + tag; | ||||
|             var website = ""; | ||||
|             switch (type) | ||||
|             { | ||||
|                 case DapiSearchType.Safebooru: | ||||
|                     website = $"https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=1000&tags={tag}"; | ||||
|                     break; | ||||
|                 case DapiSearchType.E621: | ||||
|                     website = $"https://e621.net/post/index.json?limit=1000&tags={tag}"; | ||||
|                     break; | ||||
|                 case DapiSearchType.Danbooru: | ||||
|                     website = $"http://danbooru.donmai.us/posts.json?limit=100&tags={tag}"; | ||||
|                     break; | ||||
|                 case DapiSearchType.Gelbooru: | ||||
|                     website = $"http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags={tag}"; | ||||
|                     break; | ||||
|                 case DapiSearchType.Rule34: | ||||
|                     website = $"https://rule34.xxx/index.php?page=dapi&s=post&q=index&limit=100&tags={tag}"; | ||||
|                     break; | ||||
|                 case DapiSearchType.Konachan: | ||||
|                     website = $"https://konachan.com/post.json?s=post&q=index&limit=100&tags={tag}"; | ||||
|                     break; | ||||
|                 case DapiSearchType.Yandere: | ||||
|                     website = $"https://yande.re/post.json?limit=100&tags={tag}"; | ||||
|                     break; | ||||
|             } | ||||
|                  | ||||
|             if (type == DapiSearchType.Konachan || type == DapiSearchType.Yandere ||  | ||||
|                 type == DapiSearchType.E621 || type == DapiSearchType.Danbooru) | ||||
|             { | ||||
|                 var data = await _http.GetStringAsync(website).ConfigureAwait(false); | ||||
|                 return JsonConvert.DeserializeObject<DapiImageObject[]>(data) | ||||
|                     .Where(x => x.File_Url != null) | ||||
|                     .Select(x => new ImageCacherObject(x, type)) | ||||
|                     .ToArray(); | ||||
|             } | ||||
|  | ||||
|             return (await LoadXmlAsync(website, type)).ToArray(); | ||||
|         } | ||||
|  | ||||
|         private async Task<ImageCacherObject[]> LoadXmlAsync(string website, DapiSearchType type) | ||||
|         { | ||||
|             var list = new List<ImageCacherObject>(); | ||||
|             using (var reader = XmlReader.Create(await _http.GetStreamAsync(website), new XmlReaderSettings() | ||||
|             { | ||||
|                 Async = true, | ||||
|             })) | ||||
|             { | ||||
|                 while (await reader.ReadAsync()) | ||||
|                 { | ||||
|                     if (reader.NodeType == XmlNodeType.Element && | ||||
|                         reader.Name == "post") | ||||
|                     { | ||||
|                         list.Add(new ImageCacherObject(new DapiImageObject() | ||||
|                         { | ||||
|                             File_Url = reader["file_url"], | ||||
|                             Tags = reader["tags"], | ||||
|                             Rating = reader["rating"] ?? "e" | ||||
|                                 | ||||
|                         }, type)); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             return list.ToArray(); | ||||
|         } | ||||
|  | ||||
|         public void Clear() | ||||
|         { | ||||
|             _cache.Clear(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public class ImageCacherObject : IComparable<ImageCacherObject> | ||||
|     { | ||||
|         public DapiSearchType SearchType { get; } | ||||
|         public string FileUrl { get; } | ||||
|         public HashSet<string> Tags { get; } | ||||
|         public string Rating { get; } | ||||
|  | ||||
|         public ImageCacherObject(DapiImageObject obj, DapiSearchType type) | ||||
|         { | ||||
|             if (type == DapiSearchType.Danbooru) | ||||
|                 this.FileUrl = "https://danbooru.donmai.us" + obj.File_Url; | ||||
|             else | ||||
|                 this.FileUrl = obj.File_Url.StartsWith("http") ? obj.File_Url : "https:" + obj.File_Url; | ||||
|             this.SearchType = type; | ||||
|             this.Rating = obj.Rating; | ||||
|             this.Tags = new HashSet<string>((obj.Tags ?? obj.Tag_String).Split(' ')); | ||||
|         } | ||||
|  | ||||
|         public override string ToString() | ||||
|         { | ||||
|             return FileUrl; | ||||
|         } | ||||
|  | ||||
|         public int CompareTo(ImageCacherObject other) | ||||
|         { | ||||
|             return FileUrl.CompareTo(other.FileUrl); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public class DapiImageObject | ||||
|     { | ||||
|         public string File_Url { get; set; } | ||||
|         public string Tags { get; set; } | ||||
|         public string Tag_String { get; set; } | ||||
|         public string Rating { get; set; } | ||||
|     } | ||||
|  | ||||
|     public enum DapiSearchType | ||||
|     { | ||||
|         Safebooru, | ||||
|         E621, | ||||
|         Gelbooru, | ||||
|         Konachan, | ||||
|         Rule34, | ||||
|         Yandere, | ||||
|         Danbooru | ||||
|     } | ||||
| } | ||||
							
								
								
									
										55
									
								
								NadekoBot.Core/Modules/Searches/Common/SearchPokemon.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								NadekoBot.Core/Modules/Searches/Common/SearchPokemon.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| using System.Collections.Generic; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class SearchPokemon | ||||
|     { | ||||
|         public class GenderRatioClass | ||||
|         { | ||||
|             public float M { get; set; } | ||||
|             public float F { get; set; } | ||||
|         } | ||||
|         public class BaseStatsClass | ||||
|         { | ||||
|             public int HP { get; set; } | ||||
|             public int ATK { get; set; } | ||||
|             public int DEF { get; set; } | ||||
|             public int SPA { get; set; } | ||||
|             public int SPD { get; set; } | ||||
|             public int SPE { get; set; } | ||||
|  | ||||
|             public override string ToString() => $@"**HP:**  {HP,-4} **ATK:** {ATK,-4} **DEF:** {DEF,-4} | ||||
| **SPA:** {SPA,-4} **SPD:** {SPD,-4} **SPE:** {SPE,-4}"; | ||||
|         } | ||||
|         public int Id { get; set; } | ||||
|         public string Species { get; set; } | ||||
|         public string[] Types { get; set; } | ||||
|         public GenderRatioClass GenderRatio { get; set; } | ||||
|         public BaseStatsClass BaseStats { get; set; } | ||||
|         public Dictionary<string, string> Abilities { get; set; } | ||||
|         public float HeightM { get; set; } | ||||
|         public float WeightKg { get; set; } | ||||
|         public string Color { get; set; } | ||||
|         public string[] Evos { get; set; } | ||||
|         public string[] EggGroups { get; set; } | ||||
|  | ||||
| //        public override string ToString() => $@"`Name:` {Species} | ||||
| //`Types:` {string.Join(", ", Types)} | ||||
| //`Stats:` {BaseStats} | ||||
| //`Height:` {HeightM,4}m `Weight:` {WeightKg}kg | ||||
| //`Abilities:` {string.Join(", ", Abilities.Values)}"; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public class SearchPokemonAbility | ||||
|     { | ||||
|         public string Desc { get; set; } | ||||
|         public string ShortDesc { get; set; } | ||||
|         public string Name { get; set; } | ||||
|         public float Rating { get; set; } | ||||
|  | ||||
| //        public override string ToString() => $@"`Name:` : {Name} | ||||
| //`Rating:` {Rating} | ||||
| //`Description:` {Desc}"; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										95
									
								
								NadekoBot.Core/Modules/Searches/Common/StreamResponses.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								NadekoBot.Core/Modules/Searches/Common/StreamResponses.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,95 @@ | ||||
| using Newtonsoft.Json; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public interface IStreamResponse | ||||
|     { | ||||
|         int Viewers { get; } | ||||
|         string Title { get; } | ||||
|         bool Live { get; } | ||||
|         string Game { get; } | ||||
|         int FollowerCount { get; } | ||||
|         string Url { get; } | ||||
|         string Icon { get; } | ||||
|     } | ||||
|  | ||||
|     public class SmashcastResponse : IStreamResponse | ||||
|     { | ||||
|         public bool Success { get; set; } = true; | ||||
|         public int Followers { get; set; } | ||||
|         [JsonProperty("user_logo")] | ||||
|         public string UserLogo { get; set; } | ||||
|         [JsonProperty("is_live")] | ||||
|         public string IsLive { get; set; } | ||||
|  | ||||
|         public int Viewers => 0; | ||||
|         public string Title => ""; | ||||
|         public bool Live => IsLive == "1"; | ||||
|         public string Game => ""; | ||||
|         public int FollowerCount => Followers; | ||||
|         public string Icon => !string.IsNullOrWhiteSpace(UserLogo) | ||||
|             ? "https://edge.sf.hitbox.tv" + UserLogo | ||||
|             : ""; | ||||
|  | ||||
|         public string Url { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class TwitchResponse : IStreamResponse | ||||
|     { | ||||
|         public string Error { get; set; } = null; | ||||
|         public bool IsLive => Stream != null; | ||||
|         public StreamInfo Stream { get; set; } | ||||
|  | ||||
|         public class StreamInfo | ||||
|         { | ||||
|             public int Viewers { get; set; } | ||||
|             public string Game { get; set; } | ||||
|             public ChannelInfo Channel { get; set; } | ||||
|  | ||||
|             public class ChannelInfo | ||||
|             { | ||||
|                 public string Status { get; set; } | ||||
|                 public string Logo { get; set; } | ||||
|                 public int Followers { get; set; } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public int Viewers => Stream?.Viewers ?? 0; | ||||
|         public string Title => Stream?.Channel?.Status; | ||||
|         public bool Live => IsLive; | ||||
|         public string Game => Stream?.Game; | ||||
|         public int FollowerCount => Stream?.Channel?.Followers ?? 0; | ||||
|         public string Url { get; set; } | ||||
|         public string Icon => Stream?.Channel?.Logo; | ||||
|     } | ||||
|  | ||||
|     public class MixerResponse : IStreamResponse | ||||
|     { | ||||
|         public class MixerType | ||||
|         { | ||||
|             public string Parent { get; set; } | ||||
|             public string Name { get; set; } | ||||
|         } | ||||
|         public class MixerThumbnail | ||||
|         { | ||||
|             public string Url { get; set; } | ||||
|         } | ||||
|         public string Url { get; set; } | ||||
|         public string Error { get; set; } = null; | ||||
|  | ||||
|         [JsonProperty("online")] | ||||
|         public bool IsLive { get; set; } | ||||
|         public int ViewersCurrent { get; set; } | ||||
|         public string Name { get; set; } | ||||
|         public int NumFollowers { get; set; } | ||||
|         public MixerType Type { get; set; } | ||||
|         public MixerThumbnail Thumbnail { get; set; } | ||||
|  | ||||
|         public int Viewers => ViewersCurrent; | ||||
|         public string Title => Name; | ||||
|         public bool Live => IsLive; | ||||
|         public string Game => Type?.Name ?? ""; | ||||
|         public int FollowerCount => NumFollowers; | ||||
|         public string Icon => Thumbnail?.Url; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										37
									
								
								NadekoBot.Core/Modules/Searches/Common/TimeModels.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								NadekoBot.Core/Modules/Searches/Common/TimeModels.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| using Newtonsoft.Json; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class TimeZoneResult | ||||
|     { | ||||
|         public double DstOffset { get; set; } | ||||
|         public double RawOffset { get; set; } | ||||
|  | ||||
|         //public string TimeZoneId { get; set; } | ||||
|         public string TimeZoneName { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class GeolocationResult | ||||
|     { | ||||
|  | ||||
|         public class GeolocationModel | ||||
|         { | ||||
|             public class GeometryModel | ||||
|             { | ||||
|                 public class LocationModel | ||||
|                 { | ||||
|                     public float Lat { get; set; } | ||||
|                     public float Lng { get; set; } | ||||
|                 } | ||||
|  | ||||
|                 public LocationModel Location { get; set; } | ||||
|             } | ||||
|  | ||||
|             [JsonProperty("formatted_address")] | ||||
|             public string FormattedAddress { get; set; } | ||||
|             public GeometryModel Geometry { get; set; } | ||||
|         } | ||||
|  | ||||
|         public GeolocationModel[] results; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										66
									
								
								NadekoBot.Core/Modules/Searches/Common/WeatherModels.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								NadekoBot.Core/Modules/Searches/Common/WeatherModels.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| using Newtonsoft.Json; | ||||
| using System.Collections.Generic; | ||||
|  | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class Coord | ||||
|     { | ||||
|         public double Lon { get; set; } | ||||
|         public double Lat { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Weather | ||||
|     { | ||||
|         public int Id { get; set; } | ||||
|         public string Main { get; set; } | ||||
|         public string Description { get; set; } | ||||
|         public string Icon { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Main | ||||
|     { | ||||
|         public double Temp { get; set; } | ||||
|         public float Pressure { get; set; } | ||||
|         public float Humidity { get; set; } | ||||
|         [JsonProperty("temp_min")] | ||||
|         public double TempMin { get; set; } | ||||
|         [JsonProperty("temp_max")] | ||||
|         public double TempMax { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Wind | ||||
|     { | ||||
|         public double Speed { get; set; } | ||||
|         public double Deg { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Clouds | ||||
|     { | ||||
|         public int All { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class Sys | ||||
|     { | ||||
|         public int Type { get; set; } | ||||
|         public int Id { get; set; } | ||||
|         public double Message { get; set; } | ||||
|         public string Country { get; set; } | ||||
|         public double Sunrise { get; set; } | ||||
|         public double Sunset { get; set; } | ||||
|     } | ||||
|  | ||||
|     public class WeatherData | ||||
|     { | ||||
|         public Coord Coord { get; set; } | ||||
|         public List<Weather> Weather { get; set; } | ||||
|         public Main Main { get; set; } | ||||
|         public int Visibility { get; set; } | ||||
|         public Wind Wind { get; set; } | ||||
|         public Clouds Clouds { get; set; } | ||||
|         public int Dt { get; set; } | ||||
|         public Sys Sys { get; set; } | ||||
|         public int Id { get; set; } | ||||
|         public string Name { get; set; } | ||||
|         public int Cod { get; set; } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										18
									
								
								NadekoBot.Core/Modules/Searches/Common/WikipediaApiModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								NadekoBot.Core/Modules/Searches/Common/WikipediaApiModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class WikipediaApiModel | ||||
|     { | ||||
|         public WikipediaQuery Query { get; set; } | ||||
|  | ||||
|         public class WikipediaQuery | ||||
|         { | ||||
|             public WikipediaPage[] Pages { get; set; } | ||||
|  | ||||
|             public class WikipediaPage | ||||
|             { | ||||
|                 public bool Missing { get; set; } = false; | ||||
|                 public string FullUrl { get; set; } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										9
									
								
								NadekoBot.Core/Modules/Searches/Common/WoWJoke.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								NadekoBot.Core/Modules/Searches/Common/WoWJoke.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| namespace NadekoBot.Modules.Searches.Common | ||||
| { | ||||
|     public class WoWJoke | ||||
|     { | ||||
|         public string Question { get; set; } | ||||
|         public string Answer { get; set; } | ||||
|         public override string ToString() => $"`{Question}`\n\n**{Answer}**"; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user