Update RemoteCommunication on bot modules reload

Archi, you designed that interface yourself exactly for this purpose, silly!

This way bot reload in config will trigger remote communication changes.
This commit is contained in:
Archi 2022-12-15 22:02:19 +01:00
parent 5c53f65bc1
commit 7894b0132f
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA

View file

@ -21,6 +21,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Composition;
using System.Threading.Tasks;
using ArchiSteamFarm.Core;
@ -30,12 +31,13 @@ using ArchiSteamFarm.Plugins.Interfaces;
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Steam.Storage;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SteamKit2;
namespace ArchiSteamFarm.OfficialPlugins.ItemsMatcher;
[Export(typeof(IPlugin))]
internal sealed class ItemsMatcherPlugin : OfficialPlugin, IBot, IBotIdentity {
internal sealed class ItemsMatcherPlugin : OfficialPlugin, IBot, IBotIdentity, IBotModules {
private static readonly ConcurrentDictionary<Bot, RemoteCommunication> RemoteCommunications = new();
[JsonProperty]
@ -52,7 +54,13 @@ internal sealed class ItemsMatcherPlugin : OfficialPlugin, IBot, IBotIdentity {
}
}
public async Task OnBotInit(Bot bot) {
public Task OnBotInit(Bot bot) {
ArgumentNullException.ThrowIfNull(bot);
return Task.CompletedTask;
}
public async Task OnBotInitModules(Bot bot, IReadOnlyDictionary<string, JToken>? additionalConfigProperties = null) {
ArgumentNullException.ThrowIfNull(bot);
if (RemoteCommunications.TryRemove(bot, out RemoteCommunication? remoteCommunications)) {