This commit is contained in:
JustArchi
2017-03-13 01:46:11 +01:00
parent 5b87b605f6
commit d455b3704d
2 changed files with 25 additions and 4 deletions

View File

@@ -313,9 +313,14 @@ namespace ArchiSteamFarm {
return null;
}
internal static string GetAPIStatus() {
internal static string GetAPIStatus(IDictionary<string, Bot> bots) {
if (bots == null) {
ASF.ArchiLogger.LogNullError(nameof(bots));
return null;
}
var response = new {
Bots
Bots = bots
};
try {
@@ -621,6 +626,8 @@ namespace ArchiSteamFarm {
return await Response2FAConfirm(steamID, args[1], false).ConfigureAwait(false);
case "!2FAOK":
return await Response2FAConfirm(steamID, args[1], true).ConfigureAwait(false);
case "!API":
return ResponseAPI(steamID, args[1]);
case "!ADDLICENSE":
if (args.Length > 2) {
return await ResponseAddLicense(steamID, args[1], args[2]).ConfigureAwait(false);
@@ -1988,13 +1995,27 @@ namespace ArchiSteamFarm {
private static string ResponseAPI(ulong steamID) {
if (steamID != 0) {
return IsOwner(steamID) ? FormatStaticResponse(GetAPIStatus()) : null;
return IsOwner(steamID) ? FormatStaticResponse(GetAPIStatus(Bots)) : null;
}
ASF.ArchiLogger.LogNullError(nameof(steamID));
return null;
}
private static string ResponseAPI(ulong steamID, string botNames) {
if ((steamID == 0) || string.IsNullOrEmpty(botNames)) {
ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames));
return null;
}
HashSet<Bot> bots = GetBots(botNames);
if ((bots == null) || (bots.Count == 0)) {
return IsOwner(steamID) ? FormatStaticResponse(string.Format(Strings.BotNotFound, botNames)) : null;
}
return GetAPIStatus(Bots.Where(kv => bots.Contains(kv.Value)).ToDictionary(kv => kv.Key, kv => kv.Value));
}
private static string ResponseExit(ulong steamID) {
if (steamID == 0) {
ASF.ArchiLogger.LogNullError(nameof(steamID));

View File

@@ -50,7 +50,7 @@ namespace ArchiSteamFarm {
StopServer();
}
public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus();
public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus(Bot.Bots);
public string HandleCommand(string input) {
if (string.IsNullOrEmpty(input)) {