private async Task <bool> SaveGroupConfigAsync(IWolfClient client, uint groupID, uint currentID, CancellationToken cancellationToken = default) { try { GroupConfig groupConfig = await _groupConfigStore.GetGroupConfigAsync(groupID, cancellationToken).ConfigureAwait(false); groupConfig.CurrentGuesswhatGameID = currentID; await _groupConfigStore.SetGroupConfigAsync(groupConfig, false, cancellationToken).ConfigureAwait(false); return(true); } catch (Exception ex) when(ex.LogAsError(_log, "Failed saving group config for group {GroupID} in the database", groupID)) { await client.SendGroupTextMessageAsync(groupID, "/alert Failed saving group config in the database.", cancellationToken).ConfigureAwait(false); return(false); } }
private async Task <T> GetConfigAsync <T>(ChatMessage message, CancellationToken cancellationToken = default) where T : class, ITargetConfig { if (message.IsGroupMessage) { return(await _groupConfigStore.GetGroupConfigAsync(message.RecipientID, cancellationToken).ConfigureAwait(false) as T); } else { return(await _userDataStore.GetUserDataAsync(message.SenderID.Value, cancellationToken).ConfigureAwait(false) as T); } }