mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-20 16:28:38 +00:00
* Start work on #2500 * Update Bot.cs * Misc refactor * Update Bot.cs * Add fallback for older plugins * Misc * Apply feedback
This commit is contained in:
committed by
GitHub
parent
ab6e0a1e1b
commit
4258fed873
@@ -28,7 +28,6 @@ using ArchiSteamFarm.Core;
|
|||||||
using ArchiSteamFarm.Plugins.Interfaces;
|
using ArchiSteamFarm.Plugins.Interfaces;
|
||||||
using ArchiSteamFarm.Steam;
|
using ArchiSteamFarm.Steam;
|
||||||
using ArchiSteamFarm.Steam.Data;
|
using ArchiSteamFarm.Steam.Data;
|
||||||
using ArchiSteamFarm.Steam.Storage;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using SteamKit2;
|
using SteamKit2;
|
||||||
@@ -41,7 +40,7 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin;
|
|||||||
// Your plugin class should inherit the plugin interfaces it wants to handle
|
// Your plugin class should inherit the plugin interfaces it wants to handle
|
||||||
// If you do not want to handle a particular action (e.g. OnBotMessage that is offered in IBotMessage), it's the best idea to not inherit it at all
|
// If you do not want to handle a particular action (e.g. OnBotMessage that is offered in IBotMessage), it's the best idea to not inherit it at all
|
||||||
// This will keep your code compact, efficient and less dependent. You can always add additional interfaces when you'll need them, this example project will inherit quite a bit of them to show you potential usage
|
// This will keep your code compact, efficient and less dependent. You can always add additional interfaces when you'll need them, this example project will inherit quite a bit of them to show you potential usage
|
||||||
internal sealed class ExamplePlugin : IASF, IBot, IBotCommand, IBotConnection, IBotFriendRequest, IBotMessage, IBotModules, IBotTradeOffer {
|
internal sealed class ExamplePlugin : IASF, IBot, IBotCommand2, IBotConnection, IBotFriendRequest, IBotMessage, IBotModules, IBotTradeOffer {
|
||||||
// This is used for identification purposes, typically you want to use a friendly name of your plugin here, such as the name of your main class
|
// This is used for identification purposes, typically you want to use a friendly name of your plugin here, such as the name of your main class
|
||||||
// Please note that this property can have direct dependencies only on structures that were initialized by the constructor, as it's possible to be called before OnLoaded() takes place
|
// Please note that this property can have direct dependencies only on structures that were initialized by the constructor, as it's possible to be called before OnLoaded() takes place
|
||||||
public string Name => nameof(ExamplePlugin);
|
public string Name => nameof(ExamplePlugin);
|
||||||
@@ -86,11 +85,11 @@ internal sealed class ExamplePlugin : IASF, IBot, IBotCommand, IBotConnection, I
|
|||||||
// Since ASF already had to do initial parsing in order to determine that the command is unknown, args[] are splitted using standard ASF delimiters
|
// Since ASF already had to do initial parsing in order to determine that the command is unknown, args[] are splitted using standard ASF delimiters
|
||||||
// If by any chance you want to handle message in its raw format, you also have it available, although for usual ASF pattern you can most likely stick with args[] exclusively. The message has CommandPrefix already stripped for your convenience
|
// If by any chance you want to handle message in its raw format, you also have it available, although for usual ASF pattern you can most likely stick with args[] exclusively. The message has CommandPrefix already stripped for your convenience
|
||||||
// If you do not recognize the command, just return null/empty and allow ASF to gracefully return "unknown command" to user on usual basis
|
// If you do not recognize the command, just return null/empty and allow ASF to gracefully return "unknown command" to user on usual basis
|
||||||
public async Task<string?> OnBotCommand(Bot bot, ulong steamID, string message, string[] args) {
|
public async Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) {
|
||||||
// In comparison with OnBotMessage(), we're using asynchronous CatAPI call here, so we declare our method as async and return the message as usual
|
// In comparison with OnBotMessage(), we're using asynchronous CatAPI call here, so we declare our method as async and return the message as usual
|
||||||
// Notice how we handle access here as well, it'll work only for FamilySharing+
|
// Notice how we handle access here as well, it'll work only for FamilySharing+
|
||||||
switch (args[0].ToUpperInvariant()) {
|
switch (args[0].ToUpperInvariant()) {
|
||||||
case "CAT" when bot.HasAccess(steamID, BotConfig.EAccess.FamilySharing):
|
case "CAT" when access >= EAccess.FamilySharing:
|
||||||
// Notice how we can decide whether to use bot's AWH WebBrowser or ASF's one. For Steam-related requests, AWH's one should always be used, for third-party requests like those it doesn't really matter
|
// Notice how we can decide whether to use bot's AWH WebBrowser or ASF's one. For Steam-related requests, AWH's one should always be used, for third-party requests like those it doesn't really matter
|
||||||
// Still, it makes sense to pass AWH's one, so in case you get some errors or alike, you know from which bot instance they come from. It's similar to using Bot's ArchiLogger compared to ASF's one
|
// Still, it makes sense to pass AWH's one, so in case you get some errors or alike, you know from which bot instance they come from. It's similar to using Bot's ArchiLogger compared to ASF's one
|
||||||
string? randomCatURL = await CatAPI.GetRandomCatURL(bot.ArchiWebHandler.WebBrowser).ConfigureAwait(false);
|
string? randomCatURL = await CatAPI.GetRandomCatURL(bot.ArchiWebHandler.WebBrowser).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -54,12 +54,6 @@ public sealed class CommandController : ArchiController {
|
|||||||
return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.Command))));
|
return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(request.Command))));
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong steamOwnerID = ASF.GlobalConfig?.SteamOwnerID ?? GlobalConfig.DefaultSteamOwnerID;
|
|
||||||
|
|
||||||
if (steamOwnerID == 0) {
|
|
||||||
return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(ASF.GlobalConfig.SteamOwnerID))));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bot? targetBot = Bot.Bots?.OrderBy(static bot => bot.Key, Bot.BotsComparer).Select(static bot => bot.Value).FirstOrDefault();
|
Bot? targetBot = Bot.Bots?.OrderBy(static bot => bot.Key, Bot.BotsComparer).Select(static bot => bot.Value).FirstOrDefault();
|
||||||
|
|
||||||
if (targetBot == null) {
|
if (targetBot == null) {
|
||||||
@@ -80,7 +74,7 @@ public sealed class CommandController : ArchiController {
|
|||||||
command = command[commandPrefix.Length..];
|
command = command[commandPrefix.Length..];
|
||||||
}
|
}
|
||||||
|
|
||||||
string? response = await targetBot.Commands.Response(steamOwnerID, command).ConfigureAwait(false);
|
string? response = await targetBot.Commands.Response(EAccess.Owner, command).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(new GenericResponse<string>(response));
|
return Ok(new GenericResponse<string>(response));
|
||||||
}
|
}
|
||||||
|
|||||||
6
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
6
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
@@ -1029,12 +1029,6 @@ namespace ArchiSteamFarm.Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string InteractiveConsoleNotAvailable {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("InteractiveConsoleNotAvailable", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string BotGamesToRedeemInBackgroundCount {
|
public static string BotGamesToRedeemInBackgroundCount {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("BotGamesToRedeemInBackgroundCount", resourceCulture);
|
return ResourceManager.GetString("BotGamesToRedeemInBackgroundCount", resourceCulture);
|
||||||
|
|||||||
@@ -551,10 +551,6 @@
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Интерактивната конзола е вече активна, натиснете 'c' за да влезето в команден режим.</value>
|
<value>Интерактивната конзола е вече активна, натиснете 'c' за да влезето в команден режим.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Интерактивната конзола не е налична, защото липсва {0} конфигурирана стойност.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Ботът има {0} игри оставащи в опашката на заден фон.</value>
|
<value>Ботът има {0} игри оставащи в опашката на заден фон.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -637,10 +637,6 @@ StackTrace:
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interaktivní konzole je nyní aktivní, napište "c" pro vstup do příkazového režimu.</value>
|
<value>Interaktivní konzole je nyní aktivní, napište "c" pro vstup do příkazového režimu.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interaktivní konzole není dostupná z důvodu chybějící {0} konfigurace.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot má {0} zbývajících her ve frontě.</value>
|
<value>Bot má {0} zbývajících her ve frontě.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -556,10 +556,6 @@ Processens oppetid: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Den interaktive konsol er nu aktiv, tast "c" for at skifte til kommando-mode.</value>
|
<value>Den interaktive konsol er nu aktiv, tast "c" for at skifte til kommando-mode.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Den interaktive konsol den ikke tilgængelig på grund af at {0} mangler en eller flere konfigurationsindstillinger.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot har {0} spil tilbage i sin baggrundskø.</value>
|
<value>Bot har {0} spil tilbage i sin baggrundskø.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -637,10 +637,6 @@ Prozesslaufzeit: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interaktive Konsole ist jetzt aktiv, geben Sie 'c' ein, um den Befehlsmodus zu wechseln.</value>
|
<value>Interaktive Konsole ist jetzt aktiv, geben Sie 'c' ein, um den Befehlsmodus zu wechseln.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Die interaktive Konsole ist aufgrund der fehlenden Konfigurationseigenschaften {0} nicht verfügbar.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot hat {0} Spiele, die in seiner Hintergrundwarteschlange verbleiben.</value>
|
<value>Bot hat {0} Spiele, die in seiner Hintergrundwarteschlange verbleiben.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -634,10 +634,6 @@ StackTrace:
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Η διαδραστική κονσόλα είναι ενεργή, πατήστε 'c' για να εισάγετε εντολή.</value>
|
<value>Η διαδραστική κονσόλα είναι ενεργή, πατήστε 'c' για να εισάγετε εντολή.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Η διαδραστική κονσόλα δεν είναι διαθέσιμη διότι λείπει η ιδιότητα {0} από το αρχείο διαμόρφωσης.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Το bot έχει {0} παιχνίδια που απομένουν στην ουρά.</value>
|
<value>Το bot έχει {0} παιχνίδια που απομένουν στην ουρά.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -636,10 +636,6 @@ Tiempo de actividad del proceso: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>La consola interactiva está activa, presiona 'c' para entrar al modo de comandos.</value>
|
<value>La consola interactiva está activa, presiona 'c' para entrar al modo de comandos.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>La consola interactiva no está disponible debido a que falta la propiedad de configuración {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>El bot tiene {0} juegos restantes en la cola en segundo plano.</value>
|
<value>El bot tiene {0} juegos restantes en la cola en segundo plano.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -543,10 +543,6 @@ StackTrace:
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Vuorovaikutteinen konsoli on nyt aktiivinen. Paina 'c' siirtyäksesi komento-tilaan.</value>
|
<value>Vuorovaikutteinen konsoli on nyt aktiivinen. Paina 'c' siirtyäksesi komento-tilaan.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Vuorovaikutteinen konsoli ei ole käytettävissä, koska {0} asetus puuttuu.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Botilla on {0} peliä jäljellä taustajonossa.</value>
|
<value>Botilla on {0} peliä jäljellä taustajonossa.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -634,10 +634,6 @@ Durée de fonctionnement : {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>La console interactive est maintenant active, tapez 'c' pour entrer en mode commande.</value>
|
<value>La console interactive est maintenant active, tapez 'c' pour entrer en mode commande.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>La console interactive n'est pas disponible en raison de la propriété de configuration {0} manquante.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Le bot a {0} jeux restants dans sa file d'attente.</value>
|
<value>Le bot a {0} jeux restants dans sa file d'attente.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -562,10 +562,6 @@ Ennyi ideje fut: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Az interaktív konzol aktív, nyomd meg a 'c' billentyűt, hogy a parancs módba lépj.</value>
|
<value>Az interaktív konzol aktív, nyomd meg a 'c' billentyűt, hogy a parancs módba lépj.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Az interaktív konzol nem elérhető mivel a(z) {0} tulajdonság hiányzik a konfigurációból.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>A botnak {0} játéka maradt a várólistán.</value>
|
<value>A botnak {0} játéka maradt a várólistán.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -635,10 +635,6 @@ Tempo di attività: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>La console interattiva è stata attivata, digita 'c' per entrare nella modalità comando.</value>
|
<value>La console interattiva è stata attivata, digita 'c' per entrare nella modalità comando.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>La console interattiva non è disponibile a causa della proprietà di configurazione {0} mancante.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Il bot ha {0} giochi rimanenti nella coda di background.</value>
|
<value>Il bot ha {0} giochi rimanenti nella coda di background.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -597,10 +597,6 @@ Process uptime: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>対話型コンソールがアクティブになりました。コマンドモードに入るには「c」と入力します。</value>
|
<value>対話型コンソールがアクティブになりました。コマンドモードに入るには「c」と入力します。</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>{0} の設定が見つからないため、対話型コンソールが無効にしました。</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>bot のバックグラウンドキューに {0} つのゲームが残っています。</value>
|
<value>bot のバックグラウンドキューに {0} つのゲームが残っています。</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -632,10 +632,6 @@ StackTrace:
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>대화형 콘솔이 활성화되었습니다. 명령어 모드로 들어가려면 ' c '를 입력하십시오.</value>
|
<value>대화형 콘솔이 활성화되었습니다. 명령어 모드로 들어가려면 ' c '를 입력하십시오.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>환경설정 속성값 {0} 이 누락되어 대화형 콘솔을 사용할 수 없습니다.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>{0} 개의 게임이 이 봇의 배경 큐에 남아있습니다.</value>
|
<value>{0} 개의 게임이 이 봇의 배경 큐에 남아있습니다.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -552,10 +552,6 @@ Proceso veikimo laikas: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interaktyvi konsolė aktyvuota, norėdami pateikti į komandų rėžimą paspauskite „c“.</value>
|
<value>Interaktyvi konsolė aktyvuota, norėdami pateikti į komandų rėžimą paspauskite „c“.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interaktyvi konsolė yra negalima dėl trūkstamų konfigūracinių parametrų: {0}</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Boto foninėje eilėje yra likę {0} žaidimai.</value>
|
<value>Boto foninėje eilėje yra likę {0} žaidimai.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -560,10 +560,6 @@ Darbspējas laiks: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interaktīvā konsole ir pieejama, raksti 'c', lai piekļūtu komandu rindai.</value>
|
<value>Interaktīvā konsole ir pieejama, raksti 'c', lai piekļūtu komandu rindai.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interaktīvā konsole nav pieejama, jo konfigurācijā trūkst {0} vērtība.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Botam palikušas {0} rindā stāvošas spēles.</value>
|
<value>Botam palikušas {0} rindā stāvošas spēles.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -571,10 +571,6 @@ Proces uptime: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>De interactieve console is nu actief, typ 'c' om naar de opdrachtprompt te gaan.</value>
|
<value>De interactieve console is nu actief, typ 'c' om naar de opdrachtprompt te gaan.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>De interactieve console is niet beschikbaar vanwege de ontbrekende configuratie-eigenschap {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot heeft {0} spellen resterend in de achtergrondwachtrij.</value>
|
<value>Bot heeft {0} spellen resterend in de achtergrondwachtrij.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -637,10 +637,6 @@ Czas procesu: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interaktywna konsola jest teraz aktywna, wciśnij 'c', aby przejść do trybu poleceń.</value>
|
<value>Interaktywna konsola jest teraz aktywna, wciśnij 'c', aby przejść do trybu poleceń.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interaktywna konsola nie jest dostępna ze względu na brakującą konfigurację {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot ma {0} gier oczekujących w tle.</value>
|
<value>Bot ma {0} gier oczekujących w tle.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -634,10 +634,6 @@ Tempo de execução: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>O console interativo está ativo, digite 'c' para enviar comandos.</value>
|
<value>O console interativo está ativo, digite 'c' para enviar comandos.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>O console interativo não está disponível devido à falta da propriedade de configuração {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Há {0} jogos restantes na lista de ativação em segundo plano desse bot.</value>
|
<value>Há {0} jogos restantes na lista de ativação em segundo plano desse bot.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -637,10 +637,6 @@ Process uptime: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interactive console is now active, type 'c' in order to enter command mode.</value>
|
<value>Interactive console is now active, type 'c' in order to enter command mode.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interactive console is not available due to missing {0} config property.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot has {0} games remaining in its background queue.</value>
|
<value>Bot has {0} games remaining in its background queue.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -634,10 +634,6 @@ Proces: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Consola interactivă este acum activă, tastați 'c' pentru a introduce modul de comandă.</value>
|
<value>Consola interactivă este acum activă, tastați 'c' pentru a introduce modul de comandă.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Consola interactivă nu este disponibilă deoarece lipsesc {0} din configurare.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Botul are {0} jocuri rămase la rând în fundal.</value>
|
<value>Botul are {0} jocuri rămase la rând în fundal.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -637,10 +637,6 @@
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Включена интерактивная консоль, нажмите 'c' чтобы перейти в режим команд.</value>
|
<value>Включена интерактивная консоль, нажмите 'c' чтобы перейти в режим команд.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Интерактивная консоль недоступна из-за отсутствия параметра конфигурации {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>У бота в фоновой очереди осталось {0} игр.</value>
|
<value>У бота в фоновой очереди осталось {0} игр.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -635,10 +635,6 @@ Doba prevádzky procesu: {1}</value>
|
|||||||
<value>Interaktivní konzole je nyní aktivní, napište "c" pro vstup do příkazového režimu.
|
<value>Interaktivní konzole je nyní aktivní, napište "c" pro vstup do příkazového režimu.
|
||||||
Interaktívna konzola je teraz aktívna, napíšte "c" pre vstup do príkazového režimu.</value>
|
Interaktívna konzola je teraz aktívna, napíšte "c" pre vstup do príkazového režimu.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interaktívna konzola nie je dostupná z dôvodu chýbajúcej {0} konfigurácie.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot má {0} zostávajúcich hier vo fronte.</value>
|
<value>Bot má {0} zostávajúcich hier vo fronte.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -610,10 +610,6 @@ Vrijeme rada procesa: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Interaktivna konsola je dostupna, pritisnice "c" da bi ste je koristili.</value>
|
<value>Interaktivna konsola je dostupna, pritisnice "c" da bi ste je koristili.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Interaktivna konsola nije dostupna zbog nedostatka {0} u konfiguraciji.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot ima {0} igricu/e preostale u pozadinskom redu.</value>
|
<value>Bot ima {0} igricu/e preostale u pozadinskom redu.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -637,10 +637,6 @@ Süreç çalışma zamanı: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Etkileşimli konsol şimdi etkin, komut girme moduna girmek için 'c' tuşuna basın.</value>
|
<value>Etkileşimli konsol şimdi etkin, komut girme moduna girmek için 'c' tuşuna basın.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Etkileşimli konsol eksik {0} yapılandırma özelliği nedeniyle kullanılamıyor.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot kuyruğunda {0} oyun kaldı.</value>
|
<value>Bot kuyruğunda {0} oyun kaldı.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -556,10 +556,6 @@
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Інтерактивну консоль активовано, натисніть 'c' щоб перейти до режиму команд.</value>
|
<value>Інтерактивну консоль активовано, натисніть 'c' щоб перейти до режиму команд.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Інтерактивну консоль не активовано через відсутність параметру конфігурації {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Бот має {0} ігор у фоновій черзі.</value>
|
<value>Бот має {0} ігор у фоновій черзі.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -634,10 +634,6 @@ Thời gian hoạt động: {1}</value>
|
|||||||
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
<data name="InteractiveConsoleEnabled" xml:space="preserve">
|
||||||
<value>Bảng điều khiển tương tác hiện đang hoạt động, ấn 'c' để vào chế độ lệnh.</value>
|
<value>Bảng điều khiển tương tác hiện đang hoạt động, ấn 'c' để vào chế độ lệnh.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="InteractiveConsoleNotAvailable" xml:space="preserve">
|
|
||||||
<value>Bảng điều khiển tương tác không khả dụng do thiếu thuộc tính cấu hình {0}.</value>
|
|
||||||
<comment>{0} will be replaced by the name of the missing config property (string)</comment>
|
|
||||||
</data>
|
|
||||||
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
<data name="BotGamesToRedeemInBackgroundCount" xml:space="preserve">
|
||||||
<value>Bot có {0} trò chơi còn lại trong hàng chờ.</value>
|
<value>Bot có {0} trò chơi còn lại trong hàng chờ.</value>
|
||||||
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
<comment>{0} will be replaced by remaining number of games in BGR's queue</comment>
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ public sealed class ArchiLogger {
|
|||||||
|
|
||||||
internal void LogInvite(SteamID steamID, bool? handled = null, [CallerMemberName] string? previousMethodName = null) {
|
internal void LogInvite(SteamID steamID, bool? handled = null, [CallerMemberName] string? previousMethodName = null) {
|
||||||
if ((steamID == null) || (steamID.AccountType == EAccountType.Invalid)) {
|
if ((steamID == null) || (steamID.AccountType == EAccountType.Invalid)) {
|
||||||
throw new ArgumentNullException(nameof(steamID));
|
throw new ArgumentOutOfRangeException(nameof(steamID));
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong steamID64 = steamID;
|
ulong steamID64 = steamID;
|
||||||
|
|||||||
@@ -240,12 +240,6 @@ internal static class Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static void StartInteractiveConsole() {
|
internal static void StartInteractiveConsole() {
|
||||||
if ((ASF.GlobalConfig == null) || (ASF.GlobalConfig.SteamOwnerID == 0)) {
|
|
||||||
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.InteractiveConsoleNotAvailable, nameof(ASF.GlobalConfig.SteamOwnerID)));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utilities.InBackground(HandleConsoleInteractively, true);
|
Utilities.InBackground(HandleConsoleInteractively, true);
|
||||||
ASF.ArchiLogger.LogGenericInfo(Strings.InteractiveConsoleEnabled);
|
ASF.ArchiLogger.LogGenericInfo(Strings.InteractiveConsoleEnabled);
|
||||||
}
|
}
|
||||||
@@ -368,10 +362,8 @@ internal static class Logging {
|
|||||||
|
|
||||||
Console.WriteLine($@"<> {Strings.Executing}");
|
Console.WriteLine($@"<> {Strings.Executing}");
|
||||||
|
|
||||||
ulong steamOwnerID = ASF.GlobalConfig?.SteamOwnerID ?? GlobalConfig.DefaultSteamOwnerID;
|
|
||||||
|
|
||||||
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
|
||||||
string? response = await targetBot.Commands.Response(steamOwnerID, command!).ConfigureAwait(false);
|
string? response = await targetBot.Commands.Response(EAccess.Owner, command!).ConfigureAwait(false);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(response)) {
|
if (string.IsNullOrEmpty(response)) {
|
||||||
ASF.ArchiLogger.LogNullError(nameof(response));
|
ASF.ArchiLogger.LogNullError(nameof(response));
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ArchiSteamFarm.Steam;
|
using ArchiSteamFarm.Steam;
|
||||||
using ArchiSteamFarm.Storage;
|
using ArchiSteamFarm.Storage;
|
||||||
@@ -27,6 +28,7 @@ using JetBrains.Annotations;
|
|||||||
namespace ArchiSteamFarm.Plugins.Interfaces;
|
namespace ArchiSteamFarm.Plugins.Interfaces;
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
|
[Obsolete($"Use {nameof(IBotCommand2)} instead, this one will be removed soon.", true)]
|
||||||
public interface IBotCommand : IPlugin {
|
public interface IBotCommand : IPlugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ASF will call this method for unrecognized commands.
|
/// ASF will call this method for unrecognized commands.
|
||||||
|
|||||||
41
ArchiSteamFarm/Plugins/Interfaces/IBotCommand2.cs
Normal file
41
ArchiSteamFarm/Plugins/Interfaces/IBotCommand2.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// _ _ _ ____ _ _____
|
||||||
|
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
||||||
|
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
||||||
|
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
||||||
|
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
||||||
|
// |
|
||||||
|
// Copyright 2015-2022 Łukasz "JustArchi" Domeradzki
|
||||||
|
// Contact: JustArchi@JustArchi.net
|
||||||
|
// |
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// |
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// |
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ArchiSteamFarm.Steam;
|
||||||
|
using ArchiSteamFarm.Storage;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ArchiSteamFarm.Plugins.Interfaces;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public interface IBotCommand2 : IPlugin {
|
||||||
|
/// <summary>
|
||||||
|
/// ASF will call this method for unrecognized commands.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bot">Bot object related to this callback.</param>
|
||||||
|
/// <param name="access">Access of user executing the command.</param>
|
||||||
|
/// <param name="message">Command message in its raw format, stripped of <see cref="GlobalConfig.CommandPrefix" />.</param>
|
||||||
|
/// <param name="args">Pre-parsed message using standard ASF delimiters.</param>
|
||||||
|
/// <param name="steamID">Optionally, steamID of the user who executed the command - may not be available with value of 0 (e.g. ASF API).</param>
|
||||||
|
/// <returns>Response to the command, or null/empty (as the task value) if the command isn't handled by this plugin.</returns>
|
||||||
|
Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0);
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Composition;
|
using System.Composition;
|
||||||
using System.Composition.Convention;
|
using System.Composition.Convention;
|
||||||
using System.Composition.Hosting;
|
using System.Composition.Hosting;
|
||||||
@@ -39,6 +40,7 @@ using ArchiSteamFarm.Steam;
|
|||||||
using ArchiSteamFarm.Steam.Data;
|
using ArchiSteamFarm.Steam.Data;
|
||||||
using ArchiSteamFarm.Steam.Exchange;
|
using ArchiSteamFarm.Steam.Exchange;
|
||||||
using ArchiSteamFarm.Steam.Integration.Callbacks;
|
using ArchiSteamFarm.Steam.Integration.Callbacks;
|
||||||
|
using ArchiSteamFarm.Storage;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using SteamKit2;
|
using SteamKit2;
|
||||||
|
|
||||||
@@ -266,11 +268,11 @@ internal static class PluginsCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<string?> OnBotCommand(Bot bot, ulong steamID, string message, string[] args) {
|
internal static async Task<string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) {
|
||||||
ArgumentNullException.ThrowIfNull(bot);
|
ArgumentNullException.ThrowIfNull(bot);
|
||||||
|
|
||||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
if (!Enum.IsDefined(typeof(EAccess), access)) {
|
||||||
throw new ArgumentOutOfRangeException(nameof(steamID));
|
throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(message)) {
|
if (string.IsNullOrEmpty(message)) {
|
||||||
@@ -288,13 +290,37 @@ internal static class PluginsCore {
|
|||||||
IList<string?> responses;
|
IList<string?> responses;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
responses = await Utilities.InParallel(ActivePlugins.OfType<IBotCommand>().Select(plugin => plugin.OnBotCommand(bot, steamID, message, args))).ConfigureAwait(false);
|
responses = await Utilities.InParallel(ActivePlugins.OfType<IBotCommand2>().Select(plugin => plugin.OnBotCommand(bot, access, message, args, steamID))).ConfigureAwait(false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ASF.ArchiLogger.LogGenericException(e);
|
ASF.ArchiLogger.LogGenericException(e);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ulong oldSteamID = steamID;
|
||||||
|
|
||||||
|
if (oldSteamID == 0) {
|
||||||
|
oldSteamID = ASF.GlobalConfig?.SteamOwnerID ?? GlobalConfig.DefaultSteamOwnerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((oldSteamID != 0) && new SteamID(oldSteamID).IsIndividualAccount) {
|
||||||
|
IList<string?> oldResponses;
|
||||||
|
|
||||||
|
try {
|
||||||
|
#pragma warning disable CS0618 // We intentionally support deprecated interface for a while longer
|
||||||
|
oldResponses = await Utilities.InParallel(ActivePlugins.OfType<IBotCommand>().Select(plugin => plugin.OnBotCommand(bot, oldSteamID, message, args))).ConfigureAwait(false);
|
||||||
|
#pragma warning restore CS0618 // We intentionally support deprecated interface for a while longer
|
||||||
|
} catch (Exception e) {
|
||||||
|
ASF.ArchiLogger.LogGenericException(e);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string? oldResponse in oldResponses) {
|
||||||
|
responses.Add(oldResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return string.Join(Environment.NewLine, responses.Where(static response => !string.IsNullOrEmpty(response)));
|
return string.Join(Environment.NewLine, responses.Where(static response => !string.IsNullOrEmpty(response)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,6 +409,38 @@ public sealed class Bot : IAsyncDisposable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public EAccess GetAccess(ulong steamID) {
|
||||||
|
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(steamID));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ASF.IsOwner(steamID)) {
|
||||||
|
return EAccess.Owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAccess familySharingAccess = SteamFamilySharingIDs.Contains(steamID) ? EAccess.FamilySharing : EAccess.None;
|
||||||
|
|
||||||
|
if (!BotConfig.SteamUserPermissions.TryGetValue(steamID, out BotConfig.EAccess permission)) {
|
||||||
|
return familySharingAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (permission) {
|
||||||
|
case BotConfig.EAccess.None:
|
||||||
|
return EAccess.None;
|
||||||
|
case BotConfig.EAccess.FamilySharing:
|
||||||
|
return EAccess.FamilySharing;
|
||||||
|
case BotConfig.EAccess.Operator:
|
||||||
|
return EAccess.Operator;
|
||||||
|
case BotConfig.EAccess.Master:
|
||||||
|
return EAccess.Master;
|
||||||
|
default:
|
||||||
|
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(permission), permission));
|
||||||
|
|
||||||
|
return familySharingAccess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static Bot? GetBot(string botName) {
|
public static Bot? GetBot(string botName) {
|
||||||
if (string.IsNullOrEmpty(botName)) {
|
if (string.IsNullOrEmpty(botName)) {
|
||||||
@@ -726,9 +758,10 @@ public sealed class Bot : IAsyncDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
|
[Obsolete($"Use {nameof(GetAccess)} instead (if you still need it), this one will be removed soon.", true)]
|
||||||
public bool HasAccess(ulong steamID, BotConfig.EAccess access) {
|
public bool HasAccess(ulong steamID, BotConfig.EAccess access) {
|
||||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||||
throw new ArgumentNullException(nameof(steamID));
|
throw new ArgumentOutOfRangeException(nameof(steamID));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((access == BotConfig.EAccess.None) || !Enum.IsDefined(typeof(BotConfig.EAccess), access)) {
|
if ((access == BotConfig.EAccess.None) || !Enum.IsDefined(typeof(BotConfig.EAccess), access)) {
|
||||||
@@ -2120,7 +2153,7 @@ public sealed class Bot : IAsyncDisposable {
|
|||||||
|
|
||||||
private bool IsMasterClanID(ulong steamID) {
|
private bool IsMasterClanID(ulong steamID) {
|
||||||
if ((steamID == 0) || !new SteamID(steamID).IsClanAccount) {
|
if ((steamID == 0) || !new SteamID(steamID).IsClanAccount) {
|
||||||
throw new ArgumentNullException(nameof(steamID));
|
throw new ArgumentOutOfRangeException(nameof(steamID));
|
||||||
}
|
}
|
||||||
|
|
||||||
return steamID == BotConfig.SteamMasterClanID;
|
return steamID == BotConfig.SteamMasterClanID;
|
||||||
@@ -2435,7 +2468,7 @@ public sealed class Bot : IAsyncDisposable {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (HasAccess(friend.SteamID, BotConfig.EAccess.FamilySharing)) {
|
if (GetAccess(friend.SteamID) >= EAccess.FamilySharing) {
|
||||||
ArchiLogger.LogInvite(friend.SteamID, true);
|
ArchiLogger.LogInvite(friend.SteamID, true);
|
||||||
|
|
||||||
if (!await ArchiHandler.AddFriend(friend.SteamID).ConfigureAwait(false)) {
|
if (!await ArchiHandler.AddFriend(friend.SteamID).ConfigureAwait(false)) {
|
||||||
|
|||||||
33
ArchiSteamFarm/Steam/EAccess.cs
Normal file
33
ArchiSteamFarm/Steam/EAccess.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// _ _ _ ____ _ _____
|
||||||
|
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
||||||
|
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
||||||
|
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
||||||
|
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
||||||
|
// |
|
||||||
|
// Copyright 2015-2022 Łukasz "JustArchi" Domeradzki
|
||||||
|
// Contact: JustArchi@JustArchi.net
|
||||||
|
// |
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// |
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// |
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ArchiSteamFarm.Steam;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public enum EAccess : byte {
|
||||||
|
None,
|
||||||
|
FamilySharing = 10,
|
||||||
|
Operator = 50,
|
||||||
|
Master = 100,
|
||||||
|
Owner = 255
|
||||||
|
}
|
||||||
@@ -524,7 +524,7 @@ public sealed class Trading : IDisposable {
|
|||||||
|
|
||||||
if (tradeOffer.OtherSteamID64 != 0) {
|
if (tradeOffer.OtherSteamID64 != 0) {
|
||||||
// Always accept trades from SteamMasterID
|
// Always accept trades from SteamMasterID
|
||||||
if (Bot.HasAccess(tradeOffer.OtherSteamID64, BotConfig.EAccess.Master)) {
|
if (Bot.GetAccess(tradeOffer.OtherSteamID64) >= EAccess.Master) {
|
||||||
Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}: {BotConfig.EAccess.Master}"));
|
Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Accepted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}: {BotConfig.EAccess.Master}"));
|
||||||
|
|
||||||
return ParseTradeResult.EResult.Accepted;
|
return ParseTradeResult.EResult.Accepted;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user