mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Added followedStreams.maxCount to searches configx
This commit is contained in:
@@ -28,6 +28,7 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
|||||||
|
|
||||||
private readonly IPubSub _pubSub;
|
private readonly IPubSub _pubSub;
|
||||||
private readonly IEmbedBuilderService _eb;
|
private readonly IEmbedBuilderService _eb;
|
||||||
|
private readonly SearchesConfigService _config;
|
||||||
|
|
||||||
public TypedKey<List<StreamData>> StreamsOnlineKey { get; }
|
public TypedKey<List<StreamData>> StreamsOnlineKey { get; }
|
||||||
public TypedKey<List<StreamData>> StreamsOfflineKey { get; }
|
public TypedKey<List<StreamData>> StreamsOfflineKey { get; }
|
||||||
@@ -49,13 +50,15 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
|||||||
IHttpClientFactory httpFactory,
|
IHttpClientFactory httpFactory,
|
||||||
Bot bot,
|
Bot bot,
|
||||||
IPubSub pubSub,
|
IPubSub pubSub,
|
||||||
IEmbedBuilderService eb)
|
IEmbedBuilderService eb,
|
||||||
|
SearchesConfigService config)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_client = client;
|
_client = client;
|
||||||
_strings = strings;
|
_strings = strings;
|
||||||
_pubSub = pubSub;
|
_pubSub = pubSub;
|
||||||
_eb = eb;
|
_eb = eb;
|
||||||
|
_config = config;
|
||||||
|
|
||||||
_streamTracker = new(httpFactory, creds);
|
_streamTracker = new(httpFactory, creds);
|
||||||
|
|
||||||
@@ -306,7 +309,6 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,7 +452,9 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
|||||||
GuildId = guildId
|
GuildId = guildId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (gc.FollowedStreams.Count >= 10)
|
var config = _config.Data;
|
||||||
|
if (config.FollowedStreams.MaxCount is not -1
|
||||||
|
&& gc.FollowedStreams.Count >= config.FollowedStreams.MaxCount)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
gc.FollowedStreams.Add(fs);
|
gc.FollowedStreams.Add(fs);
|
||||||
|
@@ -55,6 +55,15 @@ Use a fully qualified url. Example: https://my-invidious-instance.mydomain.com
|
|||||||
Instances specified must have api available.
|
Instances specified must have api available.
|
||||||
You check that by opening an api endpoint in your browser. For example: https://my-invidious-instance.mydomain.com/api/v1/trending")]
|
You check that by opening an api endpoint in your browser. For example: https://my-invidious-instance.mydomain.com/api/v1/trending")]
|
||||||
public List<string> InvidiousInstances { get; set; } = new List<string>();
|
public List<string> InvidiousInstances { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
[Comment("Maximum number of followed streams per server")]
|
||||||
|
public FollowedStreamConfig FollowedStreams { get; set; } = new FollowedStreamConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class FollowedStreamConfig
|
||||||
|
{
|
||||||
|
[Comment("Maximum number of streams that each server can follow. -1 for infinite")]
|
||||||
|
public int MaxCount { get; set; } = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum YoutubeSearcher
|
public enum YoutubeSearcher
|
||||||
|
@@ -28,6 +28,11 @@ public class SearchesConfigService : ConfigServiceBase<SearchesConfig>
|
|||||||
ConfigParsers.InsensitiveEnum,
|
ConfigParsers.InsensitiveEnum,
|
||||||
ConfigPrinters.ToString);
|
ConfigPrinters.ToString);
|
||||||
|
|
||||||
|
AddParsedProp("followedStreams.maxCount",
|
||||||
|
sc => sc.FollowedStreams.MaxCount,
|
||||||
|
ConfigParsers.InsensitiveEnum,
|
||||||
|
ConfigPrinters.ToString);
|
||||||
|
|
||||||
Migrate();
|
Migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,5 +46,13 @@ public class SearchesConfigService : ConfigServiceBase<SearchesConfig>
|
|||||||
c.WebSearchEngine = WebSearchEngine.Google_Scrape;
|
c.WebSearchEngine = WebSearchEngine.Google_Scrape;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.Version < 2)
|
||||||
|
{
|
||||||
|
ModifyConfig(c =>
|
||||||
|
{
|
||||||
|
c.Version = 2;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user