Last few misc fixes for !input

- Make it master-only, because of improvements we don't need owner permission anymore
- Add case-insensitivty to Enum.TryParse()
- Add missing strings
This commit is contained in:
JustArchi
2017-02-25 19:05:37 +01:00
parent 0b301d904b
commit bb7924f184
3 changed files with 18 additions and 7 deletions

View File

@@ -2052,19 +2052,17 @@ namespace ArchiSteamFarm {
return null;
}
if (!IsOwner(steamID)) {
if (!IsMaster(steamID)) {
return null;
}
if (!Program.GlobalConfig.Headless) {
//TODO: l10n
return "Avaliable only in headless mode!";
return FormatBotResponse(Strings.ErrorFunctionOnlyInHeadlessMode);
}
ASF.EUserInputType inputType;
if (!Enum.TryParse(propertyName, out inputType) || (inputType == ASF.EUserInputType.Unknown)) {
// TODO: Proper response
return ResponseUnknown(steamID);
if (!Enum.TryParse(propertyName, true, out inputType) || (inputType == ASF.EUserInputType.Unknown)) {
return FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(inputType)));
}
SetUserInput(inputType, inputValue);
@@ -3036,6 +3034,7 @@ namespace ArchiSteamFarm {
ArchiLogger.LogNullError(nameof(inputValue) + " || " + nameof(inputValue));
}
// This switch should cover ONLY bot properties
switch (inputType) {
case ASF.EUserInputType.DeviceID:
DeviceID = inputValue;
@@ -3065,7 +3064,7 @@ namespace ArchiSteamFarm {
TwoFactorCode = inputValue;
break;
case ASF.EUserInputType.WCFHostname:
// We don't handle ASF properties here
// We don't handle global ASF properties here
break;
default:
ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(inputType), inputType));

View File

@@ -774,6 +774,15 @@ namespace ArchiSteamFarm.Localization {
}
}
/// <summary>
/// Looks up a localized string similar to This function is available only in headless mode!.
/// </summary>
internal static string ErrorFunctionOnlyInHeadlessMode {
get {
return ResourceManager.GetString("ErrorFunctionOnlyInHeadlessMode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Global config could not be loaded, please make sure that {0} exists and is valid! Follow setting up guide on the wiki if you&apos;re confused..
/// </summary>

View File

@@ -707,4 +707,7 @@ StackTrace:
<data name="BotStatusLocked" xml:space="preserve">
<value>Bot is locked and can't drop any cards through idling.</value>
</data>
<data name="ErrorFunctionOnlyInHeadlessMode" xml:space="preserve">
<value>This function is available only in headless mode!</value>
</data>
</root>