NadekoBot.Extensions should now be fully annotated with nullable reference types as well as many classes from NadekoBot.Common

This commit is contained in:
Kwoth
2021-12-28 10:44:00 +01:00
parent 0634470a8a
commit 59f5056035
543 changed files with 1895 additions and 1448 deletions

View File

@@ -1,4 +1,5 @@
using AngleSharp;
#nullable disable
using AngleSharp;
using NadekoBot.Modules.Searches.Services;
using AngleSharp.Html.Dom;
@@ -184,4 +185,4 @@ public partial class Searches
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -21,4 +22,4 @@ public class AnimeResult
public string Link => "http://anilist.co/anime/" + Id;
public string Synopsis => Description?[..(Description.Length > 500 ? 500 : Description.Length)] + "...";
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -15,4 +16,4 @@ public class BibleVerse
public int Chapter { get; set; }
public int Verse { get; set; }
public string Text { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -32,4 +33,4 @@ public class Quote
public string Percent_Change_24h { get; set; }
public string Percent_Change_7d { get; set; }
public double? Volume_24h { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -37,4 +38,4 @@ public class Result
public class DefineModel
{
public List<Result> Results { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class E621Object
{
@@ -20,4 +21,4 @@ public class E621Object
public FileData File { get; set; }
public TagData Tags { get; set; }
public ScoreData Score { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common.Exceptions;
#nullable disable
namespace NadekoBot.Modules.Searches.Common.Exceptions;
public class StreamNotFoundException : Exception
{
@@ -13,4 +14,4 @@ public class StreamNotFoundException : Exception
public StreamNotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public sealed class Tag
{
@@ -40,4 +41,4 @@ public sealed class Gallery
UploadedAt = uploadedAt;
Tags = tags;
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -34,4 +35,4 @@ public class GatariUserResponse
[JsonProperty("code")] public int Code { get; set; }
[JsonProperty("users")] public List<UserData> Users { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -50,4 +51,4 @@ public class GatariUserStatsResponse
[JsonProperty("code")] public int Code { get; set; }
[JsonProperty("stats")] public UserStats Stats { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public sealed class GoogleSearchResult
{
@@ -12,4 +13,4 @@ public sealed class GoogleSearchResult
this.Link = link;
this.Text = text;
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class HearthstoneCardData
{
@@ -9,4 +10,4 @@ public class HearthstoneCardData
public string Img { get; set; }
public string ImgGold { get; set; }
public string PlayerClass { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Nsfw.Common;
#nullable disable
using NadekoBot.Modules.Nsfw.Common;
namespace NadekoBot.Modules.Searches.Common;
@@ -37,4 +38,4 @@ public class ImageCacherObject : IComparable<ImageCacherObject>
public int CompareTo(ImageCacherObject other)
=> string.Compare(FileUrl, other.FileUrl, StringComparison.InvariantCulture);
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.Json;
#nullable disable
using System.Text.Json;
namespace SystemTextJsonSamples;
@@ -8,4 +9,4 @@ public class LowerCaseNamingPolicy : JsonNamingPolicy
public override string ConvertName(string name) =>
name.ToLower();
}
}

View File

@@ -1,7 +1,8 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class MagicItem
{
public string Name { get; set; }
public string Description { get; set; }
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -21,4 +22,4 @@ public class MangaResult
public string AverageScore { get; set; }
public string Link => "http://anilist.co/manga/" + Id;
public string Synopsis => Description?[..(Description.Length > 500 ? 500 : Description.Length)] + "...";
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class MtgData
{
@@ -22,4 +23,4 @@ public class MtgResponse
}
public List<Data> Cards { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -87,4 +88,4 @@ public static class NhentaiApiModel
{
[JsonProperty("result")] public Gallery[] Result { get; set; }
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class NovelResult
{
@@ -10,4 +11,4 @@ public class NovelResult
public string Status { get; set; }
public string[] Genres { get; set; }
public string Score { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class OmdbMovie
{
@@ -9,4 +10,4 @@ public class OmdbMovie
public string Genre { get; set; }
public string Plot { get; set; }
public string Poster { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -45,4 +46,4 @@ public class OsuUserData
[JsonProperty("total_seconds_played")] public string TotalSecondsPlayed { get; set; }
[JsonProperty("pp_country_rank")] public string PpCountryRank { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -36,4 +37,4 @@ public class Leagues
[JsonProperty("endAt")]
public object EndAt { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches;
@@ -31,4 +32,4 @@ public enum TimeErrors
ApiKeyMissing,
NotFound,
Unknown
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -107,4 +108,4 @@ public class Language
[JsonProperty("id")] public int Id { get; set; }
[JsonProperty("name")] public string Name { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Db.Models;
#nullable disable
using NadekoBot.Db.Models;
namespace NadekoBot.Modules.Searches.Common;
@@ -16,4 +17,4 @@ public class StreamData
public string AvatarUrl { get; set; }
public StreamDataKey CreateKey() => new(StreamType, UniqueName.ToLower());
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
#nullable disable
using System.Text.Json.Serialization;
using NadekoBot.Db.Models;
namespace NadekoBot.Modules.Searches.Common;
@@ -14,4 +15,4 @@ public readonly struct StreamDataKey
Type = type;
Name = name;
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
//
// public class TwitchResponse
@@ -18,4 +19,4 @@
// public string ThumbnailUrl { get; set; }
// public DateTime StartedAt { get; set; }
// }
// }
// }

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -79,4 +80,4 @@ public class TwitchResponseV5
[JsonProperty("viewers")] public int Viewers { get; set; }
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -34,4 +35,4 @@ public class TwitchUsersResponseV5
// public DateTime UpdatedAt { get; set; }
}
}
}

View File

@@ -3,7 +3,6 @@ using NadekoBot.Db.Models;
using Newtonsoft.Json;
using StackExchange.Redis;
#nullable enable
namespace NadekoBot.Modules.Searches.Common.StreamNotifications;
public class NotifChecker
@@ -147,7 +146,7 @@ public class NotifChecker
}
catch (Exception ex)
{
Log.Error(ex, $"Error getting stream notifications: {ex.Message}");
Log.Error(ex, "Error getting stream notifications: {ErrorMessage}", ex.Message);
}
}
});
@@ -237,4 +236,4 @@ public class NotifChecker
public void UntrackStreamByKey(in StreamDataKey key)
=> CacheDeleteData(key);
}
}

View File

@@ -2,7 +2,6 @@
using NadekoBot.Db.Models;
using Newtonsoft.Json;
#nullable enable
namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers;
public class PicartoProvider : Provider
@@ -71,7 +70,11 @@ public class PicartoProvider : Provider
}
catch (Exception ex)
{
Log.Warning(ex, $"Something went wrong retreiving {Platform} stream data for {login}: {ex.Message}");
Log.Warning("Something went wrong retreiving {StreamPlatform} stream data for {Login}: {ErrorMessage}",
Platform,
login,
ex.Message
);
_failingStreams.TryAdd(login, DateTime.UtcNow);
}
}
@@ -93,4 +96,4 @@ public class PicartoProvider : Provider
StreamUrl = $"https://picarto.tv/{stream.Name}",
AvatarUrl = stream.Avatar
};
}
}

View File

@@ -1,6 +1,5 @@
using NadekoBot.Db.Models;
#nullable enable
namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers;
/// <summary>
@@ -55,4 +54,4 @@ public abstract class Provider
public void ClearErrorsFor(string login)
=> _failingStreams.TryRemove(login, out _);
}
}

View File

@@ -1,4 +1,5 @@
// using System;
#nullable disable
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Net.Http;
@@ -177,4 +178,4 @@
// public DateTime StartedAt { get; set; }
// }
// }
// }
// }

View File

@@ -2,7 +2,6 @@
using NadekoBot.Db.Models;
using Newtonsoft.Json;
#nullable enable
namespace NadekoBot.Modules.Searches.Common.StreamNotifications.Providers;
public class TwitchProvider : Provider
@@ -100,7 +99,11 @@ public class TwitchProvider : Provider
}
catch (Exception ex)
{
Log.Warning($"Something went wrong retreiving {Platform} stream data for {login}: {ex.Message}");
Log.Warning("Something went wrong retreiving {StreamPlatform} stream data for {Login}: {ErrorMessage}",
Platform,
login,
ex.Message
);
_failingStreams.TryAdd(login, DateTime.UtcNow);
}
}
@@ -122,4 +125,4 @@ public class TwitchProvider : Provider
StreamUrl = $"https://twitch.tv/{stream.Channel.Name}",
AvatarUrl = stream.Channel.Logo
};
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class TimeData
{
public string Address { get; set; }
public DateTime Time { get; set; }
public string TimeZoneName { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -17,4 +18,4 @@ public class LocationIqResponse
[JsonProperty("display_name")]
public string DisplayName { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class UrbanResponse
{
@@ -9,4 +10,4 @@ public class UrbanDef
public string Word { get; set; }
public string Definition { get; set; }
public string Permalink { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Common;
@@ -61,4 +62,4 @@ public class WeatherData
public int Id { get; set; }
public string Name { get; set; }
public int Cod { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
namespace NadekoBot.Modules.Searches.Common;
public class WikipediaApiModel
{
@@ -14,4 +15,4 @@ public class WikipediaApiModel
public string FullUrl { get; set; }
}
}
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot.Modules.Searches.Common;
#nullable disable
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}**";
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Services;
#nullable disable
using NadekoBot.Modules.Searches.Services;
namespace NadekoBot.Modules.Searches;
@@ -54,4 +55,4 @@ public partial class Searches
.WithImageUrl($"https://s3.coinmarketcap.com/generated/sparklines/web/7d/usd/{crypto.Id}.png")).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Services;
#nullable disable
using NadekoBot.Modules.Searches.Services;
using System.Text.RegularExpressions;
namespace NadekoBot.Modules.Searches;
@@ -36,7 +37,7 @@ public partial class Searches
(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);
if (success)
{
channel = channel ?? (ITextChannel)ctx.Channel;
channel ??= (ITextChannel)ctx.Channel;
try
{
var feeds = await CodeHollow.FeedReader.FeedReader.ReadAsync(url).ConfigureAwait(false);
@@ -104,4 +105,4 @@ public partial class Searches
}, feeds.Count, 10).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Services;
#nullable disable
using NadekoBot.Modules.Searches.Services;
namespace NadekoBot.Modules.Searches;
@@ -48,4 +49,4 @@ public partial class Searches
await SendConfirmAsync("✨" + item.Name, item.Description).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using System.Collections.Immutable;
using System.Text;
using Newtonsoft.Json;
@@ -93,4 +94,4 @@ public partial class Searches
return sb.ToString();
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Common;
#nullable disable
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches;
@@ -305,4 +306,4 @@ public partial class Searches
private static bool IsBitSet(int mods, int pos) =>
(mods & (1 << pos)) != 0;
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Common;
#nullable disable
using NadekoBot.Modules.Searches.Common;
using NadekoBot.Modules.Searches.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -306,4 +307,4 @@ public partial class Searches
return league;
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches;
#nullable disable
namespace NadekoBot.Modules.Searches;
public partial class Searches
{
@@ -69,4 +70,4 @@ public partial class Searches
await ctx.Channel.SendMessageAsync(url).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Services;
#nullable disable
using NadekoBot.Modules.Searches.Services;
using NadekoBot.Common.Pokemon;
namespace NadekoBot.Modules.Searches;
@@ -63,4 +64,4 @@ public partial class Searches
await ReplyErrorLocalizedAsync(strs.pokemon_ability_none).ConfigureAwait(false);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using AngleSharp;
#nullable disable
using AngleSharp;
using AngleSharp.Html.Dom;
using Microsoft.Extensions.Caching.Memory;
using NadekoBot.Modules.Searches.Common;
@@ -733,4 +734,4 @@ public partial class Searches : NadekoModule<SearchesService>
await ErrorLocalizedAsync(strs.specify_search_params).ConfigureAwait(false);
return false;
}
}
}

View File

@@ -1,4 +1,5 @@
using AngleSharp;
#nullable disable
using AngleSharp;
using AngleSharp.Html.Dom;
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json;
@@ -149,4 +150,4 @@ public class AnimeSearchService : INService
return null;
}
}
}
}

View File

@@ -1,4 +1,5 @@
using LinqToDB.EntityFrameworkCore;
#nullable disable
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
@@ -10,4 +11,4 @@ public static class AtlExtensions
=> set
.Include(x => x.Users)
.FirstOrDefaultAsyncEF(x => x.ChannelId == channelId);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Common;
#nullable disable
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches.Services;
@@ -95,4 +96,4 @@ public class CryptoService : INService
getCryptoLock.Release();
}
}
}
}

View File

@@ -1,4 +1,5 @@
using CodeHollow.FeedReader.Feeds;
#nullable disable
using CodeHollow.FeedReader.Feeds;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
using NadekoBot.Db;
@@ -228,4 +229,4 @@ public class FeedsService : INService
return true;
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches;
#nullable disable
namespace NadekoBot.Modules.Searches;
public interface ITranslateService
{
@@ -7,4 +8,4 @@ public interface ITranslateService
IEnumerable<string> GetLanguages();
Task<bool?> RegisterUserAsync(ulong userId, ulong channelId, string @from, string to);
Task<bool> UnregisterUser(ulong channelId, ulong userId);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Searches.Common;
#nullable disable
using NadekoBot.Modules.Searches.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SixLabors.ImageSharp;
@@ -650,4 +651,4 @@ public class SearchesService : INService
fullQueryLink,
"0");
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Modules.Searches.Common;
using NadekoBot.Modules.Searches.Common.StreamNotifications;
@@ -555,4 +556,4 @@ public sealed class StreamNotificationService : INService
public StreamDataKey Key { get; init; }
public ulong GuildId { get; init; }
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Net;
#nullable disable
using System.Net;
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
@@ -222,4 +223,4 @@ public sealed class TranslateService : ITranslateService, ILateExecutor, IReadyE
}
public IEnumerable<string> GetLanguages() => _google.Languages.Select(x => x.Key);
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches.Services;
#nullable disable
namespace NadekoBot.Modules.Searches.Services;
// public class YtTrackService : INService
// {
@@ -131,4 +132,4 @@
//
// return true;
// }
// }
// }

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Modules.Searches.Services;
using NadekoBot.Db;
using NadekoBot.Db.Models;
@@ -211,4 +212,4 @@ public partial class Searches
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches;
#nullable disable
namespace NadekoBot.Modules.Searches;
public partial class Searches
{
@@ -89,4 +90,4 @@ public partial class Searches
public async Task Translangs()
=> await ctx.Channel.SendTableAsync(_service.GetLanguages(), str => $"{str,-15}", 3).ConfigureAwait(false);
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Modules.Searches;
@@ -89,4 +90,4 @@ public partial class Searches
public string ImageLink { get; set; }
public string Alt { get; set; }
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Modules.Searches;
#nullable disable
namespace NadekoBot.Modules.Searches;
public partial class Searches
{
@@ -50,4 +51,4 @@ public partial class Searches
// //}
// }
// }
}
}