Compare commits

...

2 Commits

Author SHA1 Message Date
JustArchi
2347925b1c Closes #951 2019-02-10 06:35:20 +01:00
JustArchi
c400f05ed6 Bump 2019-02-10 04:57:16 +01:00
6 changed files with 115 additions and 19 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<ApplicationIcon>ASF.ico</ApplicationIcon>
<AssemblyVersion>4.0.0.6</AssemblyVersion>
<AssemblyVersion>4.0.0.7</AssemblyVersion>
<Authors>JustArchi</Authors>
<Company>JustArchi</Company>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
@@ -11,7 +11,7 @@
<DefaultItemExcludes>$(DefaultItemExcludes);config/**;debug/**;out/**;overlay/**</DefaultItemExcludes>
<Description>ASF is an application that allows you to farm steam cards using multiple steam accounts simultaneously.</Description>
<ErrorReport>none</ErrorReport>
<FileVersion>4.0.0.6</FileVersion>
<FileVersion>4.0.0.7</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>latest</LangVersion>
<NoWarn>1591</NoWarn>

View File

@@ -1411,14 +1411,7 @@ namespace ArchiSteamFarm {
return;
}
string response = await Commands.Response(steamID, message).ConfigureAwait(false);
// We respond with null when user is not authorized (and similar)
if (string.IsNullOrEmpty(response)) {
return;
}
await SendMessage(chatGroupID, chatID, response).ConfigureAwait(false);
await Commands.HandleMessage(chatGroupID, chatID, steamID, message).ConfigureAwait(false);
}
private async Task HandleMessage(ulong steamID, string message) {
@@ -1428,14 +1421,7 @@ namespace ArchiSteamFarm {
return;
}
string response = await Commands.Response(steamID, message).ConfigureAwait(false);
// We respond with null when user is not authorized (and similar)
if (string.IsNullOrEmpty(response)) {
return;
}
await SendMessage(steamID, response).ConfigureAwait(false);
await Commands.HandleMessage(steamID, message).ConfigureAwait(false);
}
private async Task HeartBeat() {

View File

@@ -71,8 +71,13 @@ namespace ArchiSteamFarm {
return "<" + SharedInfo.ASF + "> " + response;
}
[Obsolete("Use Response(steamID, message) instead, useCommandPrefix is obsolete and no longer used (same as false), this method will be removed in the next ASF version.", true)]
[PublicAPI]
[SuppressMessage("ReSharper", "MethodOverloadWithOptionalParameter")]
public async Task<string> Response(ulong steamID, string message, bool useCommandPrefix = true) {
// TODO: Delete the method entirely in the next ASF version
ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningDeprecated, "[API] Response(steamID, message, useCommandPrefix)", "[API] Response(steamID, message)"));
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message));
@@ -89,6 +94,17 @@ namespace ArchiSteamFarm {
message = message.Substring(ASF.GlobalConfig.CommandPrefix.Length);
}
return await Response(steamID, message).ConfigureAwait(false);
}
[PublicAPI]
public async Task<string> Response(ulong steamID, string message) {
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message));
return null;
}
string[] args = message.Split((char[]) null, StringSplitOptions.RemoveEmptyEntries);
switch (args.Length) {
@@ -371,6 +387,88 @@ namespace ArchiSteamFarm {
}
}
internal async Task HandleMessage(ulong steamID, string message) {
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message));
return;
}
if (!string.IsNullOrEmpty(ASF.GlobalConfig.CommandPrefix)) {
if (!message.StartsWith(ASF.GlobalConfig.CommandPrefix, StringComparison.OrdinalIgnoreCase)) {
string pluginsResponse = await Core.OnBotMessage(Bot, steamID, message).ConfigureAwait(false);
if (!string.IsNullOrEmpty(pluginsResponse)) {
await Bot.SendMessage(steamID, pluginsResponse).ConfigureAwait(false);
}
return;
}
message = message.Substring(ASF.GlobalConfig.CommandPrefix.Length);
}
bool feedback = Bot.HasPermission(steamID, BotConfig.EPermission.FamilySharing);
if (feedback) {
await Bot.SendMessage(steamID, FormatBotResponse(Strings.PleaseWait)).ConfigureAwait(false);
}
string response = await Response(steamID, message).ConfigureAwait(false);
if (string.IsNullOrEmpty(response)) {
if (!feedback) {
return;
}
Bot.ArchiLogger.LogNullError(nameof(response));
response = FormatBotResponse(Strings.UnknownCommand);
}
await Bot.SendMessage(steamID, response).ConfigureAwait(false);
}
internal async Task HandleMessage(ulong chatGroupID, ulong chatID, ulong steamID, string message) {
if ((chatGroupID == 0) || (chatID == 0) || (steamID == 0) || string.IsNullOrEmpty(message)) {
Bot.ArchiLogger.LogNullError(nameof(chatGroupID) + " || " + nameof(chatID) + " || " + nameof(steamID) + " || " + nameof(message));
return;
}
if (!string.IsNullOrEmpty(ASF.GlobalConfig.CommandPrefix)) {
if (!message.StartsWith(ASF.GlobalConfig.CommandPrefix, StringComparison.OrdinalIgnoreCase)) {
string pluginsResponse = await Core.OnBotMessage(Bot, steamID, message).ConfigureAwait(false);
if (!string.IsNullOrEmpty(pluginsResponse)) {
await Bot.SendMessage(chatGroupID, chatID, pluginsResponse).ConfigureAwait(false);
}
return;
}
message = message.Substring(ASF.GlobalConfig.CommandPrefix.Length);
}
bool feedback = Bot.HasPermission(steamID, BotConfig.EPermission.FamilySharing);
if (feedback) {
await Bot.SendMessage(chatGroupID, chatID, FormatBotResponse(Strings.PleaseWait)).ConfigureAwait(false);
}
string response = await Response(steamID, message).ConfigureAwait(false);
if (string.IsNullOrEmpty(response)) {
if (!feedback) {
return;
}
Bot.ArchiLogger.LogNullError(nameof(response));
response = FormatBotResponse(Strings.UnknownCommand);
}
await Bot.SendMessage(chatGroupID, chatID, response).ConfigureAwait(false);
}
internal void OnNewLicenseList() {
lock (CachedGamesOwned) {
CachedGamesOwned.Clear();

View File

@@ -59,7 +59,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
command = command.Substring(ASF.GlobalConfig.CommandPrefix.Length);
}
string response = await targetBot.Commands.Response(ASF.GlobalConfig.SteamOwnerID, command, false).ConfigureAwait(false);
string response = await targetBot.Commands.Response(ASF.GlobalConfig.SteamOwnerID, command).ConfigureAwait(false);
return Ok(new GenericResponse<string>(response));
}

View File

@@ -1170,6 +1170,15 @@ namespace ArchiSteamFarm.Localization {
}
}
/// <summary>
/// Wyszukuje zlokalizowany ciąg podobny do ciągu Please wait....
/// </summary>
public static string PleaseWait {
get {
return ResourceManager.GetString("PleaseWait", resourceCulture);
}
}
/// <summary>
/// Wyszukuje zlokalizowany ciąg podobny do ciągu {0} has been loaded successfully!.
/// </summary>

View File

@@ -693,4 +693,7 @@ StackTrace:
<data name="PluginsWarning" xml:space="preserve">
<value>You've loaded one or more of custom plugins into the ASF. Since we're unable to offer a support for modded setups, please reach the appropriate developers of the plugins that you decided to use in case of any issues.</value>
</data>
<data name="PleaseWait" xml:space="preserve">
<value>Please wait...</value>
</data>
</root>