mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-10 13:44:22 +00:00
Closes #1114
This commit is contained in:
@@ -122,7 +122,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal void AckMessage(ulong steamID, uint timestamp) {
|
||||
if ((steamID == 0) || (timestamp == 0)) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || (timestamp == 0)) {
|
||||
ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(timestamp));
|
||||
|
||||
return;
|
||||
@@ -140,9 +140,9 @@ namespace ArchiSteamFarm {
|
||||
UnifiedFriendMessagesService.SendMessage(x => x.AckMessage(request), true);
|
||||
}
|
||||
|
||||
internal void AcknowledgeClanInvite(ulong clanID, bool acceptInvite) {
|
||||
if (clanID == 0) {
|
||||
ArchiLogger.LogNullError(nameof(clanID));
|
||||
internal void AcknowledgeClanInvite(ulong steamID, bool acceptInvite) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsClanAccount) {
|
||||
ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
ClientMsg<CMsgClientAcknowledgeClanInvite> request = new ClientMsg<CMsgClientAcknowledgeClanInvite> {
|
||||
Body = {
|
||||
ClanID = clanID,
|
||||
ClanID = steamID,
|
||||
AcceptInvite = acceptInvite
|
||||
}
|
||||
};
|
||||
@@ -162,7 +162,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal async Task<bool> AddFriend(ulong steamID) {
|
||||
if (steamID == 0) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||
ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
return false;
|
||||
@@ -462,7 +462,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal async Task<bool> RemoveFriend(ulong steamID) {
|
||||
if (steamID == 0) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||
ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
return false;
|
||||
@@ -503,7 +503,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal async Task<EResult> SendMessage(ulong steamID, string message) {
|
||||
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || string.IsNullOrEmpty(message)) {
|
||||
ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message));
|
||||
|
||||
return EResult.Fail;
|
||||
@@ -575,6 +575,41 @@ namespace ArchiSteamFarm {
|
||||
return response.Result;
|
||||
}
|
||||
|
||||
internal async Task<EResult> SendTypingStatus(ulong steamID) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||
ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
return EResult.Fail;
|
||||
}
|
||||
|
||||
if (!Client.IsConnected) {
|
||||
return EResult.NoConnection;
|
||||
}
|
||||
|
||||
CFriendMessages_SendMessage_Request request = new CFriendMessages_SendMessage_Request {
|
||||
chat_entry_type = (int) EChatEntryType.Typing,
|
||||
steamid = steamID
|
||||
};
|
||||
|
||||
SteamUnifiedMessages.ServiceMethodResponse response;
|
||||
|
||||
try {
|
||||
response = await UnifiedFriendMessagesService.SendMessage(x => x.SendMessage(request));
|
||||
} catch (Exception e) {
|
||||
ArchiLogger.LogGenericWarningException(e);
|
||||
|
||||
return EResult.Timeout;
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
ArchiLogger.LogNullError(nameof(response));
|
||||
|
||||
return EResult.Fail;
|
||||
}
|
||||
|
||||
return response.Result;
|
||||
}
|
||||
|
||||
internal void SetCurrentMode(uint chatMode) {
|
||||
if (chatMode == 0) {
|
||||
ArchiLogger.LogNullError(nameof(chatMode));
|
||||
|
||||
@@ -1079,13 +1079,13 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal async Task<bool> SendMessage(ulong steamID, string message) {
|
||||
if ((steamID == 0) || string.IsNullOrEmpty(message)) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || string.IsNullOrEmpty(message)) {
|
||||
ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsConnectedAndLoggedOn || !new SteamID(steamID).IsIndividualAccount) {
|
||||
if (!IsConnectedAndLoggedOn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1214,6 +1214,20 @@ namespace ArchiSteamFarm {
|
||||
return true;
|
||||
}
|
||||
|
||||
internal async Task<bool> SendTypingMessage(ulong steamID) {
|
||||
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
|
||||
ArchiLogger.LogNullError(nameof(steamID));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsConnectedAndLoggedOn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return await ArchiHandler.SendTypingStatus(steamID).ConfigureAwait(false) == EResult.OK;
|
||||
}
|
||||
|
||||
internal void SetUserInput(ASF.EUserInputType inputType, string inputValue) {
|
||||
if ((inputType == ASF.EUserInputType.Unknown) || string.IsNullOrEmpty(inputValue)) {
|
||||
ArchiLogger.LogNullError(nameof(inputType) + " || " + nameof(inputValue));
|
||||
|
||||
@@ -33,6 +33,8 @@ using SteamKit2;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
public sealed class Commands {
|
||||
private const ushort SteamTypingStatusDelay = 10000; // Steam client broadcasts typing status each 10 seconds
|
||||
|
||||
private readonly Bot Bot;
|
||||
private readonly Dictionary<uint, string> CachedGamesOwned = new Dictionary<uint, string>();
|
||||
|
||||
@@ -408,13 +410,19 @@ namespace ArchiSteamFarm {
|
||||
message = message.Substring(ASF.GlobalConfig.CommandPrefix.Length);
|
||||
}
|
||||
|
||||
Task<string> responseTask = Response(steamID, message);
|
||||
|
||||
bool feedback = Bot.HasPermission(steamID, BotConfig.EPermission.FamilySharing);
|
||||
|
||||
if (feedback) {
|
||||
await Bot.SendMessage(steamID, FormatBotResponse(Strings.PleaseWait)).ConfigureAwait(false);
|
||||
await Bot.SendTypingMessage(steamID).ConfigureAwait(false);
|
||||
|
||||
while (!responseTask.IsCompleted && (await Task.WhenAny(responseTask, Task.Delay(SteamTypingStatusDelay)).ConfigureAwait(false) != responseTask)) {
|
||||
await Bot.SendTypingMessage(steamID).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
string response = await Response(steamID, message).ConfigureAwait(false);
|
||||
string response = await responseTask.ConfigureAwait(false);
|
||||
|
||||
if (string.IsNullOrEmpty(response)) {
|
||||
if (!feedback) {
|
||||
@@ -449,13 +457,19 @@ namespace ArchiSteamFarm {
|
||||
message = message.Substring(ASF.GlobalConfig.CommandPrefix.Length);
|
||||
}
|
||||
|
||||
Task<string> responseTask = Response(steamID, message);
|
||||
|
||||
bool feedback = Bot.HasPermission(steamID, BotConfig.EPermission.FamilySharing);
|
||||
|
||||
if (feedback) {
|
||||
await Bot.SendMessage(chatGroupID, chatID, FormatBotResponse(Strings.PleaseWait)).ConfigureAwait(false);
|
||||
|
||||
while (!responseTask.IsCompleted && (await Task.WhenAny(responseTask, Task.Delay(SteamTypingStatusDelay)).ConfigureAwait(false) != responseTask)) {
|
||||
await Bot.SendMessage(chatGroupID, chatID, FormatBotResponse(Strings.PleaseWait)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
string response = await Response(steamID, message).ConfigureAwait(false);
|
||||
string response = await responseTask.ConfigureAwait(false);
|
||||
|
||||
if (string.IsNullOrEmpty(response)) {
|
||||
if (!feedback) {
|
||||
|
||||
Reference in New Issue
Block a user