mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
backport of public nsfw module
This commit is contained in:
43
src/NadekoBot/Modules/Nsfw/Common/ImageData.cs
Normal file
43
src/NadekoBot/Modules/Nsfw/Common/ImageData.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NadekoBot.Modules.Nsfw.Common
|
||||
{
|
||||
public class ImageData : IComparable<ImageData>
|
||||
{
|
||||
public Booru SearchType { get; }
|
||||
public string FileUrl { get; }
|
||||
public HashSet<string> Tags { get; }
|
||||
public string Rating { get; }
|
||||
|
||||
public ImageData(string url, Booru type, string[] tags, string rating)
|
||||
{
|
||||
if (type == Booru.Danbooru && !Uri.IsWellFormedUriString(url, UriKind.Absolute))
|
||||
{
|
||||
this.FileUrl = "https://danbooru.donmai.us" + url;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FileUrl = url.StartsWith("http", StringComparison.InvariantCulture) ? url : "https:" + url;
|
||||
}
|
||||
|
||||
this.SearchType = type;
|
||||
this.FileUrl = url;
|
||||
this.Tags = tags.ToHashSet();
|
||||
this.Rating = rating;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return FileUrl;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => FileUrl.GetHashCode();
|
||||
public override bool Equals(object obj)
|
||||
=> obj is ImageData ico && ico.FileUrl == this.FileUrl;
|
||||
|
||||
public int CompareTo(ImageData other)
|
||||
=> string.Compare(FileUrl, other.FileUrl, StringComparison.InvariantCulture);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user