mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Fixed around 140 wrong namings and other refactorings which were marked as warnings
This commit is contained in:
@@ -26,53 +26,53 @@ public class EmbedBuilderService : IEmbedBuilderService, INService
|
||||
public sealed class DiscordEmbedBuilderWrapper : IEmbedBuilder
|
||||
{
|
||||
private readonly BotConfig _botConfig;
|
||||
private EmbedBuilder _embed;
|
||||
private EmbedBuilder embed;
|
||||
|
||||
public DiscordEmbedBuilderWrapper(in BotConfig botConfig, EmbedBuilder embed = null)
|
||||
{
|
||||
_botConfig = botConfig;
|
||||
_embed = embed ?? new EmbedBuilder();
|
||||
this.embed = embed ?? new EmbedBuilder();
|
||||
}
|
||||
|
||||
public IEmbedBuilder WithDescription(string desc)
|
||||
=> Wrap(_embed.WithDescription(desc));
|
||||
=> Wrap(embed.WithDescription(desc));
|
||||
|
||||
public IEmbedBuilder WithTitle(string title)
|
||||
=> Wrap(_embed.WithTitle(title));
|
||||
=> Wrap(embed.WithTitle(title));
|
||||
|
||||
public IEmbedBuilder AddField(string title, object value, bool isInline = false)
|
||||
=> Wrap(_embed.AddField(title, value, isInline));
|
||||
=> Wrap(embed.AddField(title, value, isInline));
|
||||
|
||||
public IEmbedBuilder WithFooter(string text, string iconUrl = null)
|
||||
=> Wrap(_embed.WithFooter(text, iconUrl));
|
||||
=> Wrap(embed.WithFooter(text, iconUrl));
|
||||
|
||||
public IEmbedBuilder WithAuthor(string name, string iconUrl = null, string url = null)
|
||||
=> Wrap(_embed.WithAuthor(name, iconUrl, url));
|
||||
=> Wrap(embed.WithAuthor(name, iconUrl, url));
|
||||
|
||||
public IEmbedBuilder WithUrl(string url)
|
||||
=> Wrap(_embed.WithUrl(url));
|
||||
=> Wrap(embed.WithUrl(url));
|
||||
|
||||
public IEmbedBuilder WithImageUrl(string url)
|
||||
=> Wrap(_embed.WithImageUrl(url));
|
||||
=> Wrap(embed.WithImageUrl(url));
|
||||
|
||||
public IEmbedBuilder WithThumbnailUrl(string url)
|
||||
=> Wrap(_embed.WithThumbnailUrl(url));
|
||||
=> Wrap(embed.WithThumbnailUrl(url));
|
||||
|
||||
public IEmbedBuilder WithColor(EmbedColor color)
|
||||
=> color switch
|
||||
{
|
||||
EmbedColor.Ok => Wrap(_embed.WithColor(_botConfig.Color.Ok.ToDiscordColor())),
|
||||
EmbedColor.Pending => Wrap(_embed.WithColor(_botConfig.Color.Pending.ToDiscordColor())),
|
||||
EmbedColor.Error => Wrap(_embed.WithColor(_botConfig.Color.Error.ToDiscordColor())),
|
||||
EmbedColor.Ok => Wrap(embed.WithColor(_botConfig.Color.Ok.ToDiscordColor())),
|
||||
EmbedColor.Pending => Wrap(embed.WithColor(_botConfig.Color.Pending.ToDiscordColor())),
|
||||
EmbedColor.Error => Wrap(embed.WithColor(_botConfig.Color.Error.ToDiscordColor())),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(color), "Unsupported EmbedColor type")
|
||||
};
|
||||
|
||||
public Embed Build()
|
||||
=> _embed.Build();
|
||||
=> embed.Build();
|
||||
|
||||
private IEmbedBuilder Wrap(EmbedBuilder eb)
|
||||
{
|
||||
_embed = eb;
|
||||
embed = eb;
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -7,25 +7,25 @@ namespace NadekoBot.Services;
|
||||
public sealed class BehaviorExecutor : IBehaviourExecutor, INService
|
||||
{
|
||||
private readonly IServiceProvider _services;
|
||||
private IEnumerable<ILateExecutor> _lateExecutors;
|
||||
private IEnumerable<ILateBlocker> _lateBlockers;
|
||||
private IEnumerable<IEarlyBehavior> _earlyBehaviors;
|
||||
private IEnumerable<IInputTransformer> _transformers;
|
||||
private IEnumerable<ILateExecutor> lateExecutors;
|
||||
private IEnumerable<ILateBlocker> lateBlockers;
|
||||
private IEnumerable<IEarlyBehavior> earlyBehaviors;
|
||||
private IEnumerable<IInputTransformer> transformers;
|
||||
|
||||
public BehaviorExecutor(IServiceProvider services)
|
||||
=> _services = services;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_lateExecutors = _services.GetServices<ILateExecutor>();
|
||||
_lateBlockers = _services.GetServices<ILateBlocker>();
|
||||
_earlyBehaviors = _services.GetServices<IEarlyBehavior>().OrderByDescending(x => x.Priority);
|
||||
_transformers = _services.GetServices<IInputTransformer>();
|
||||
lateExecutors = _services.GetServices<ILateExecutor>();
|
||||
lateBlockers = _services.GetServices<ILateBlocker>();
|
||||
earlyBehaviors = _services.GetServices<IEarlyBehavior>().OrderByDescending(x => x.Priority);
|
||||
transformers = _services.GetServices<IInputTransformer>();
|
||||
}
|
||||
|
||||
public async Task<bool> RunEarlyBehavioursAsync(SocketGuild guild, IUserMessage usrMsg)
|
||||
{
|
||||
foreach (var beh in _earlyBehaviors)
|
||||
foreach (var beh in earlyBehaviors)
|
||||
if (await beh.RunBehavior(guild, usrMsg))
|
||||
return true;
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed class BehaviorExecutor : IBehaviourExecutor, INService
|
||||
public async Task<string> RunInputTransformersAsync(SocketGuild guild, IUserMessage usrMsg)
|
||||
{
|
||||
var messageContent = usrMsg.Content;
|
||||
foreach (var exec in _transformers)
|
||||
foreach (var exec in transformers)
|
||||
{
|
||||
string newContent;
|
||||
if ((newContent = await exec.TransformInput(guild, usrMsg.Channel, usrMsg.Author, messageContent))
|
||||
@@ -51,10 +51,10 @@ public sealed class BehaviorExecutor : IBehaviourExecutor, INService
|
||||
|
||||
public async Task<bool> RunLateBlockersAsync(ICommandContext ctx, CommandInfo cmd)
|
||||
{
|
||||
foreach (var exec in _lateBlockers)
|
||||
foreach (var exec in lateBlockers)
|
||||
if (await exec.TryBlockLate(ctx, cmd.Module.GetTopLevelModule().Name, cmd))
|
||||
{
|
||||
Log.Information("Late blocking User [{0}] Command: [{1}] in [{2}]",
|
||||
Log.Information("Late blocking User [{User}] Command: [{Command}] in [{Module}]",
|
||||
ctx.User,
|
||||
cmd.Aliases[0],
|
||||
exec.GetType().Name);
|
||||
@@ -66,7 +66,7 @@ public sealed class BehaviorExecutor : IBehaviourExecutor, INService
|
||||
|
||||
public async Task RunLateExecutorsAsync(SocketGuild guild, IUserMessage usrMsg)
|
||||
{
|
||||
foreach (var exec in _lateExecutors)
|
||||
foreach (var exec in lateExecutors)
|
||||
try
|
||||
{
|
||||
await exec.LateExecute(guild, usrMsg);
|
||||
|
@@ -13,10 +13,10 @@ namespace NadekoBot.Services;
|
||||
|
||||
public class GoogleApiService : IGoogleApiService, INService
|
||||
{
|
||||
private const string SearchEngineId = "018084019232060951019:hs5piey28-e";
|
||||
private const string SEARCH_ENGINE_ID = "018084019232060951019:hs5piey28-e";
|
||||
|
||||
private static readonly Regex
|
||||
plRegex = new("(?:youtu\\.be\\/|list=)(?<id>[\\da-zA-Z\\-_]*)", RegexOptions.Compiled);
|
||||
_plRegex = new("(?:youtu\\.be\\/|list=)(?<id>[\\da-zA-Z\\-_]*)", RegexOptions.Compiled);
|
||||
|
||||
public IReadOnlyDictionary<string, string> Languages { get; } = new Dictionary<string, string>
|
||||
{
|
||||
@@ -151,9 +151,9 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
{ "yi", "yi" }
|
||||
};
|
||||
|
||||
private readonly YouTubeService yt;
|
||||
private readonly UrlshortenerService sh;
|
||||
private readonly CustomsearchService cs;
|
||||
private readonly YouTubeService _yt;
|
||||
private readonly UrlshortenerService _sh;
|
||||
private readonly CustomsearchService _cs;
|
||||
|
||||
//private readonly Regex YtVideoIdRegex = new Regex(@"(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)(?<id>[a-zA-Z0-9_-]{6,11})", RegexOptions.Compiled);
|
||||
private readonly IBotCredentials _creds;
|
||||
@@ -166,9 +166,9 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
|
||||
var bcs = new BaseClientService.Initializer { ApplicationName = "Nadeko Bot", ApiKey = _creds.GoogleApiKey };
|
||||
|
||||
yt = new(bcs);
|
||||
sh = new(bcs);
|
||||
cs = new(bcs);
|
||||
_yt = new(bcs);
|
||||
_sh = new(bcs);
|
||||
_cs = new(bcs);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<string>> GetPlaylistIdsByKeywordsAsync(string keywords, int count = 1)
|
||||
@@ -180,9 +180,9 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
if (count <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
||||
var match = plRegex.Match(keywords);
|
||||
var match = _plRegex.Match(keywords);
|
||||
if (match.Length > 1) return new[] { match.Groups["id"].Value };
|
||||
var query = yt.Search.List("snippet");
|
||||
var query = _yt.Search.List("snippet");
|
||||
query.MaxResults = count;
|
||||
query.Type = "playlist";
|
||||
query.Q = keywords;
|
||||
@@ -199,7 +199,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
|
||||
if (count <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
var query = yt.Search.List("snippet");
|
||||
var query = _yt.Search.List("snippet");
|
||||
query.MaxResults = count;
|
||||
query.RelatedToVideoId = id;
|
||||
query.Type = "video";
|
||||
@@ -215,7 +215,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
if (count <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
||||
var query = yt.Search.List("snippet");
|
||||
var query = _yt.Search.List("snippet");
|
||||
query.MaxResults = count;
|
||||
query.Q = keywords;
|
||||
query.Type = "video";
|
||||
@@ -234,7 +234,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
if (count <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
||||
var query = yt.Search.List("snippet");
|
||||
var query = _yt.Search.List("snippet");
|
||||
query.MaxResults = count;
|
||||
query.Q = keywords;
|
||||
query.Type = "video";
|
||||
@@ -256,7 +256,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
|
||||
try
|
||||
{
|
||||
var response = await sh.Url.Insert(new() { LongUrl = url }).ExecuteAsync();
|
||||
var response = await _sh.Url.Insert(new() { LongUrl = url }).ExecuteAsync();
|
||||
return response.Id;
|
||||
}
|
||||
catch (GoogleApiException ex) when (ex.HttpStatusCode == HttpStatusCode.Forbidden)
|
||||
@@ -288,7 +288,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
var toGet = count > 50 ? 50 : count;
|
||||
count -= toGet;
|
||||
|
||||
var query = yt.PlaylistItems.List("contentDetails");
|
||||
var query = _yt.PlaylistItems.List("contentDetails");
|
||||
query.MaxResults = toGet;
|
||||
query.PlaylistId = playlistId;
|
||||
query.PageToken = nextPageToken;
|
||||
@@ -318,7 +318,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
var toGet = remaining > 50 ? 50 : remaining;
|
||||
remaining -= toGet;
|
||||
|
||||
var q = yt.Videos.List("contentDetails");
|
||||
var q = _yt.Videos.List("contentDetails");
|
||||
q.Id = string.Join(",", videoIdsList.Take(toGet));
|
||||
videoIdsList = videoIdsList.Skip(toGet).ToList();
|
||||
var items = (await q.ExecuteAsync()).Items;
|
||||
@@ -334,9 +334,9 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
|
||||
var req = cs.Cse.List();
|
||||
var req = _cs.Cse.List();
|
||||
req.Q = query;
|
||||
req.Cx = SearchEngineId;
|
||||
req.Cx = SEARCH_ENGINE_ID;
|
||||
req.Num = 1;
|
||||
req.Fields = "items(image(contextLink,thumbnailLink),link)";
|
||||
req.SearchType = CseResource.ListRequest.SearchTypeEnum.Image;
|
||||
|
@@ -15,7 +15,7 @@ public class RedisCache : IDataCache
|
||||
private readonly string _redisKey;
|
||||
private readonly EndPoint _redisEndpoint;
|
||||
|
||||
private readonly object timelyLock = new();
|
||||
private readonly object _timelyLock = new();
|
||||
|
||||
public RedisCache(
|
||||
ConnectionMultiplexer redis,
|
||||
@@ -36,77 +36,77 @@ public class RedisCache : IDataCache
|
||||
// can re-use the same image/anime data
|
||||
public async Task<(bool Success, byte[] Data)> TryGetImageDataAsync(Uri key)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
byte[] x = await _db.StringGetAsync("image_" + key);
|
||||
var db = Redis.GetDatabase();
|
||||
byte[] x = await db.StringGetAsync("image_" + key);
|
||||
return (x is not null, x);
|
||||
}
|
||||
|
||||
public Task SetImageDataAsync(Uri key, byte[] data)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
return _db.StringSetAsync("image_" + key, data);
|
||||
var db = Redis.GetDatabase();
|
||||
return db.StringSetAsync("image_" + key, data);
|
||||
}
|
||||
|
||||
public async Task<(bool Success, string Data)> TryGetAnimeDataAsync(string key)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
string x = await _db.StringGetAsync("anime_" + key);
|
||||
var db = Redis.GetDatabase();
|
||||
string x = await db.StringGetAsync("anime_" + key);
|
||||
return (x is not null, x);
|
||||
}
|
||||
|
||||
public Task SetAnimeDataAsync(string key, string data)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
return _db.StringSetAsync("anime_" + key, data, TimeSpan.FromHours(3));
|
||||
var db = Redis.GetDatabase();
|
||||
return db.StringSetAsync("anime_" + key, data, TimeSpan.FromHours(3));
|
||||
}
|
||||
|
||||
public async Task<(bool Success, string Data)> TryGetNovelDataAsync(string key)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
string x = await _db.StringGetAsync("novel_" + key);
|
||||
var db = Redis.GetDatabase();
|
||||
string x = await db.StringGetAsync("novel_" + key);
|
||||
return (x is not null, x);
|
||||
}
|
||||
|
||||
public Task SetNovelDataAsync(string key, string data)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
return _db.StringSetAsync("novel_" + key, data, TimeSpan.FromHours(3));
|
||||
var db = Redis.GetDatabase();
|
||||
return db.StringSetAsync("novel_" + key, data, TimeSpan.FromHours(3));
|
||||
}
|
||||
|
||||
public TimeSpan? AddTimelyClaim(ulong id, int period)
|
||||
{
|
||||
if (period == 0)
|
||||
return null;
|
||||
lock (timelyLock)
|
||||
lock (_timelyLock)
|
||||
{
|
||||
var time = TimeSpan.FromHours(period);
|
||||
var _db = Redis.GetDatabase();
|
||||
if ((bool?)_db.StringGet($"{_redisKey}_timelyclaim_{id}") is null)
|
||||
var db = Redis.GetDatabase();
|
||||
if ((bool?)db.StringGet($"{_redisKey}_timelyclaim_{id}") is null)
|
||||
{
|
||||
_db.StringSet($"{_redisKey}_timelyclaim_{id}", true, time);
|
||||
db.StringSet($"{_redisKey}_timelyclaim_{id}", true, time);
|
||||
return null;
|
||||
}
|
||||
|
||||
return _db.KeyTimeToLive($"{_redisKey}_timelyclaim_{id}");
|
||||
return db.KeyTimeToLive($"{_redisKey}_timelyclaim_{id}");
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAllTimelyClaims()
|
||||
{
|
||||
var server = Redis.GetServer(_redisEndpoint);
|
||||
var _db = Redis.GetDatabase();
|
||||
var db = Redis.GetDatabase();
|
||||
foreach (var k in server.Keys(pattern: $"{_redisKey}_timelyclaim_*"))
|
||||
_db.KeyDelete(k, CommandFlags.FireAndForget);
|
||||
db.KeyDelete(k, CommandFlags.FireAndForget);
|
||||
}
|
||||
|
||||
public bool TryAddAffinityCooldown(ulong userId, out TimeSpan? time)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
time = _db.KeyTimeToLive($"{_redisKey}_affinity_{userId}");
|
||||
var db = Redis.GetDatabase();
|
||||
time = db.KeyTimeToLive($"{_redisKey}_affinity_{userId}");
|
||||
if (time is null)
|
||||
{
|
||||
time = TimeSpan.FromMinutes(30);
|
||||
_db.StringSet($"{_redisKey}_affinity_{userId}", true, time);
|
||||
db.StringSet($"{_redisKey}_affinity_{userId}", true, time);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -115,12 +115,12 @@ public class RedisCache : IDataCache
|
||||
|
||||
public bool TryAddDivorceCooldown(ulong userId, out TimeSpan? time)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
time = _db.KeyTimeToLive($"{_redisKey}_divorce_{userId}");
|
||||
var db = Redis.GetDatabase();
|
||||
time = db.KeyTimeToLive($"{_redisKey}_divorce_{userId}");
|
||||
if (time is null)
|
||||
{
|
||||
time = TimeSpan.FromHours(6);
|
||||
_db.StringSet($"{_redisKey}_divorce_{userId}", true, time);
|
||||
db.StringSet($"{_redisKey}_divorce_{userId}", true, time);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,42 +129,43 @@ public class RedisCache : IDataCache
|
||||
|
||||
public Task SetStreamDataAsync(string url, string data)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
return _db.StringSetAsync($"{_redisKey}_stream_{url}", data, TimeSpan.FromHours(6));
|
||||
var db = Redis.GetDatabase();
|
||||
return db.StringSetAsync($"{_redisKey}_stream_{url}", data, TimeSpan.FromHours(6));
|
||||
}
|
||||
|
||||
public bool TryGetStreamData(string url, out string dataStr)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
dataStr = _db.StringGet($"{_redisKey}_stream_{url}");
|
||||
var db = Redis.GetDatabase();
|
||||
dataStr = db.StringGet($"{_redisKey}_stream_{url}");
|
||||
|
||||
return !string.IsNullOrWhiteSpace(dataStr);
|
||||
}
|
||||
|
||||
public TimeSpan? TryAddRatelimit(ulong id, string name, int expireIn)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
if (_db.StringSet($"{_redisKey}_ratelimit_{id}_{name}",
|
||||
var db = Redis.GetDatabase();
|
||||
if (db.StringSet($"{_redisKey}_ratelimit_{id}_{name}",
|
||||
0, // i don't use the value
|
||||
TimeSpan.FromSeconds(expireIn),
|
||||
When.NotExists))
|
||||
return null;
|
||||
|
||||
return _db.KeyTimeToLive($"{_redisKey}_ratelimit_{id}_{name}");
|
||||
return db.KeyTimeToLive($"{_redisKey}_ratelimit_{id}_{name}");
|
||||
}
|
||||
|
||||
public bool TryGetEconomy(out string data)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
if ((data = _db.StringGet($"{_redisKey}_economy")) is not null) return true;
|
||||
var db = Redis.GetDatabase();
|
||||
data = db.StringGet($"{_redisKey}_economy");
|
||||
if (data is not null) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetEconomy(string data)
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
_db.StringSet($"{_redisKey}_economy", data, TimeSpan.FromMinutes(3));
|
||||
var db = Redis.GetDatabase();
|
||||
db.StringSet($"{_redisKey}_economy", data, TimeSpan.FromMinutes(3));
|
||||
}
|
||||
|
||||
public async Task<TOut> GetOrAddCachedDataAsync<TParam, TOut>(
|
||||
@@ -174,9 +175,9 @@ public class RedisCache : IDataCache
|
||||
TimeSpan expiry)
|
||||
where TOut : class
|
||||
{
|
||||
var _db = Redis.GetDatabase();
|
||||
var db = Redis.GetDatabase();
|
||||
|
||||
var data = await _db.StringGetAsync(key);
|
||||
var data = await db.StringGetAsync(key);
|
||||
if (!data.HasValue)
|
||||
{
|
||||
var obj = await factory(param);
|
||||
@@ -184,7 +185,7 @@ public class RedisCache : IDataCache
|
||||
if (obj is null)
|
||||
return default;
|
||||
|
||||
await _db.StringSetAsync(key, JsonConvert.SerializeObject(obj), expiry);
|
||||
await db.StringSetAsync(key, JsonConvert.SerializeObject(obj), expiry);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ namespace NadekoBot.Services;
|
||||
|
||||
public static class RedisImageExtensions
|
||||
{
|
||||
private const string OldCdnUrl = "nadeko-pictures.nyc3.digitaloceanspaces.com";
|
||||
private const string NewCdnUrl = "cdn.nadeko.bot";
|
||||
private const string OLD_CDN_URL = "nadeko-pictures.nyc3.digitaloceanspaces.com";
|
||||
private const string NEW_CDN_URL = "cdn.nadeko.bot";
|
||||
|
||||
public static Uri ToNewCdn(this Uri uri)
|
||||
=> new(uri.ToString().Replace(OldCdnUrl, NewCdnUrl));
|
||||
=> new(uri.ToString().Replace(OLD_CDN_URL, NEW_CDN_URL));
|
||||
}
|
@@ -58,7 +58,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_client.ChannelCreated += c =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
_= Task.Run(() =>
|
||||
{
|
||||
if (c is ITextChannel)
|
||||
Interlocked.Increment(ref textChannels);
|
||||
@@ -71,7 +71,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_client.ChannelDestroyed += c =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
_= Task.Run(() =>
|
||||
{
|
||||
if (c is ITextChannel)
|
||||
Interlocked.Decrement(ref textChannels);
|
||||
@@ -84,7 +84,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_client.GuildAvailable += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
_= Task.Run(() =>
|
||||
{
|
||||
var tc = g.Channels.Count(cx => cx is ITextChannel);
|
||||
var vc = g.Channels.Count - tc;
|
||||
@@ -96,7 +96,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_client.JoinedGuild += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
_= Task.Run(() =>
|
||||
{
|
||||
var tc = g.Channels.Count(cx => cx is ITextChannel);
|
||||
var vc = g.Channels.Count - tc;
|
||||
@@ -108,7 +108,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_client.GuildUnavailable += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
_= Task.Run(() =>
|
||||
{
|
||||
var tc = g.Channels.Count(cx => cx is ITextChannel);
|
||||
var vc = g.Channels.Count - tc;
|
||||
@@ -121,7 +121,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
|
||||
_client.LeftGuild += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
_= Task.Run(() =>
|
||||
{
|
||||
var tc = g.Channels.Count(cx => cx is ITextChannel);
|
||||
var vc = g.Channels.Count - tc;
|
||||
|
@@ -14,13 +14,13 @@ public class YtdlOperation
|
||||
|
||||
private Process CreateProcess(string[] args)
|
||||
{
|
||||
args = args.Map(arg => arg.Replace("\"", ""));
|
||||
var newArgs = args.Map(arg => (object)arg.Replace("\"", ""));
|
||||
return new()
|
||||
{
|
||||
StartInfo = new()
|
||||
{
|
||||
FileName = "youtube-dl",
|
||||
Arguments = string.Format(_baseArgString, args),
|
||||
Arguments = string.Format(_baseArgString, newArgs),
|
||||
UseShellExecute = false,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardOutput = true,
|
||||
|
@@ -9,12 +9,12 @@ namespace NadekoBot.Services;
|
||||
/// </summary>
|
||||
public sealed class BotConfigService : ConfigServiceBase<BotConfig>
|
||||
{
|
||||
private const string FilePath = "data/bot.yml";
|
||||
private static readonly TypedKey<BotConfig> changeKey = new("config.bot.updated");
|
||||
private const string FILE_PATH = "data/bot.yml";
|
||||
private static readonly TypedKey<BotConfig> _changeKey = new("config.bot.updated");
|
||||
public override string Name { get; } = "bot";
|
||||
|
||||
public BotConfigService(IConfigSeria serializer, IPubSub pubSub)
|
||||
: base(FilePath, serializer, pubSub, changeKey)
|
||||
: base(FILE_PATH, serializer, pubSub, _changeKey)
|
||||
{
|
||||
AddParsedProp("color.ok", bs => bs.Color.Ok, Rgba32.TryParseHex, ConfigPrinters.Color);
|
||||
AddParsedProp("color.error", bs => bs.Color.Error, Rgba32.TryParseHex, ConfigPrinters.Color);
|
||||
|
Reference in New Issue
Block a user