Skip to content

Commit

Permalink
Remove ASFE DisabledCmds support
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Mar 10, 2024
1 parent 4eb902e commit 09c3934
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 10 additions & 0 deletions BoosterManager/AdapterBridge.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Steam;

// ASFEnhanced Adapter https://github.com/chr233/ASFEnhanceAdapterDemoPlugin

Expand Down Expand Up @@ -29,4 +30,13 @@ public static bool InitAdapter(string pluginName, string pluginId, string? cmdPr

return false;
}

internal static string? Response(Bot bot, EAccess access, ulong steamID, string message, string[] args) {
// ASFEnhance wants to intercept commands meant for this plugin, for the purpose of it's DisabledCmds config setting.
// Seems buggy though: https://github.com/Citrinate/FreePackages/issues/28
// Therefore I'm feeding it this dummy response function, as ASFEnhance requires that cmdHandler not be null.
// This disables DisabledCmds support, but should not effect PLUGINSUPDATE command support

return null;
}
}
10 changes: 2 additions & 8 deletions BoosterManager/BoosterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,22 @@ namespace BoosterManager {
public sealed class BoosterManager : IASF, IBotModules, IBotCommand2, IBotTradeOfferResults {
public string Name => nameof(BoosterManager);
public Version Version => typeof(BoosterManager).Assembly.GetName().Version ?? new Version("0");
private bool ASFEnhanceEnabled = false;

public Task OnLoaded() {
ASF.ArchiLogger.LogGenericInfo("BoosterManager ASF Plugin by Citrinate");

// ASFEnhanced Adapter https://github.com/chr233/ASFEnhanceAdapterDemoPlugin
var flag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
var handler = typeof(Commands).GetMethod(nameof(Commands.Response), flag);
var handler = typeof(AdapterBridge).GetMethod(nameof(AdapterBridge.Response), flag);
const string pluginId = nameof(BoosterManager);
const string cmdPrefix = "BOOSTERMANAGER";
const string repoName = "Citrinate/BoosterManager";
var registered = AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler);
ASFEnhanceEnabled = registered;
AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler);

return Task.CompletedTask;
}

public async Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) {
if (ASFEnhanceEnabled) {
return null;
}

return await Commands.Response(bot, access, steamID, message, args).ConfigureAwait(false);
}

Expand Down

0 comments on commit 09c3934

Please sign in to comment.