diff --git a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs index 7430a7b40..4248ac6fc 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiHandler.cs @@ -93,6 +93,42 @@ public sealed class ArchiHandler : ClientMsgHandler { return response.Result == EResult.OK; } + [PublicAPI] + public async Task GetClanChatRoomInfo(ulong steamID) { + if ((steamID == 0) || !new SteamID(steamID).IsClanAccount) { + throw new ArgumentOutOfRangeException(nameof(steamID)); + } + + if (Client == null) { + throw new InvalidOperationException(nameof(Client)); + } + + if (!Client.IsConnected) { + return null; + } + + CClanChatRooms_GetClanChatRoomInfo_Request request = new() { + autocreate = true, + steamid = steamID + }; + + SteamUnifiedMessages.ServiceMethodResponse response; + + try { + response = await UnifiedClanChatRoomsService.SendMessage(x => x.GetClanChatRoomInfo(request)).ToLongRunningTask().ConfigureAwait(false); + } catch (Exception e) { + ArchiLogger.LogGenericWarningException(e); + + return null; + } + + if (response.Result != EResult.OK) { + return null; + } + + return response.GetDeserializedResponse(); + } + [PublicAPI] public async Task GetCredentialChangeTimeDetails() { if (Client == null) { @@ -248,6 +284,64 @@ public sealed class ArchiHandler : ClientMsgHandler { } } + [PublicAPI] + public async Task JoinChatRoomGroup(ulong chatGroupID) { + if (chatGroupID == 0) { + throw new ArgumentOutOfRangeException(nameof(chatGroupID)); + } + + if (Client == null) { + throw new InvalidOperationException(nameof(Client)); + } + + if (!Client.IsConnected) { + return false; + } + + CChatRoom_JoinChatRoomGroup_Request request = new() { chat_group_id = chatGroupID }; + + SteamUnifiedMessages.ServiceMethodResponse response; + + try { + response = await UnifiedChatRoomService.SendMessage(x => x.JoinChatRoomGroup(request)).ToLongRunningTask().ConfigureAwait(false); + } catch (Exception e) { + ArchiLogger.LogGenericWarningException(e); + + return false; + } + + return response.Result == EResult.OK; + } + + [PublicAPI] + public async Task LeaveChatRoomGroup(ulong chatGroupID) { + if (chatGroupID == 0) { + throw new ArgumentOutOfRangeException(nameof(chatGroupID)); + } + + if (Client == null) { + throw new InvalidOperationException(nameof(Client)); + } + + if (!Client.IsConnected) { + return false; + } + + CChatRoom_LeaveChatRoomGroup_Request request = new() { chat_group_id = chatGroupID }; + + SteamUnifiedMessages.ServiceMethodResponse response; + + try { + response = await UnifiedChatRoomService.SendMessage(x => x.LeaveChatRoomGroup(request)).ToLongRunningTask().ConfigureAwait(false); + } catch (Exception e) { + ArchiLogger.LogGenericWarningException(e); + + return false; + } + + return response.Result == EResult.OK; + } + [PublicAPI] public async Task RemoveFriend(ulong steamID) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) { @@ -277,42 +371,6 @@ public sealed class ArchiHandler : ClientMsgHandler { return response.Result == EResult.OK; } - [PublicAPI] - public async Task GetClanChatRoomInfo(ulong steamID) { - if ((steamID == 0) || !new SteamID(steamID).IsClanAccount) { - throw new ArgumentOutOfRangeException(nameof(steamID)); - } - - if (Client == null) { - throw new InvalidOperationException(nameof(Client)); - } - - if (!Client.IsConnected) { - return null; - } - - CClanChatRooms_GetClanChatRoomInfo_Request request = new() { - autocreate = true, - steamid = steamID - }; - - SteamUnifiedMessages.ServiceMethodResponse response; - - try { - response = await UnifiedClanChatRoomsService.SendMessage(x => x.GetClanChatRoomInfo(request)).ToLongRunningTask().ConfigureAwait(false); - } catch (Exception e) { - ArchiLogger.LogGenericWarningException(e); - - return null; - } - - if (response.Result != EResult.OK) { - return null; - } - - return response.GetDeserializedResponse(); - } - internal void AckChatMessage(ulong chatGroupID, ulong chatID, uint timestamp) { if (chatGroupID == 0) { throw new ArgumentOutOfRangeException(nameof(chatGroupID)); @@ -516,64 +574,6 @@ public sealed class ArchiHandler : ClientMsgHandler { return body.device_identifier; } - [PublicAPI] - public async Task JoinChatRoomGroup(ulong chatGroupID) { - if (chatGroupID == 0) { - throw new ArgumentOutOfRangeException(nameof(chatGroupID)); - } - - if (Client == null) { - throw new InvalidOperationException(nameof(Client)); - } - - if (!Client.IsConnected) { - return false; - } - - CChatRoom_JoinChatRoomGroup_Request request = new() { chat_group_id = chatGroupID }; - - SteamUnifiedMessages.ServiceMethodResponse response; - - try { - response = await UnifiedChatRoomService.SendMessage(x => x.JoinChatRoomGroup(request)).ToLongRunningTask().ConfigureAwait(false); - } catch (Exception e) { - ArchiLogger.LogGenericWarningException(e); - - return false; - } - - return response.Result == EResult.OK; - } - - [PublicAPI] - public async Task LeaveChatRoomGroup(ulong chatGroupID) { - if (chatGroupID == 0) { - throw new ArgumentOutOfRangeException(nameof(chatGroupID)); - } - - if (Client == null) { - throw new InvalidOperationException(nameof(Client)); - } - - if (!Client.IsConnected) { - return false; - } - - CChatRoom_LeaveChatRoomGroup_Request request = new() { chat_group_id = chatGroupID }; - - SteamUnifiedMessages.ServiceMethodResponse response; - - try { - response = await UnifiedChatRoomService.SendMessage(x => x.LeaveChatRoomGroup(request)).ToLongRunningTask().ConfigureAwait(false); - } catch (Exception e) { - ArchiLogger.LogGenericWarningException(e); - - return false; - } - - return response.Result == EResult.OK; - } - internal async Task PlayGames(IReadOnlyCollection gameIDs, string? gameName = null) { ArgumentNullException.ThrowIfNull(gameIDs);