private Task SaveConfigAsync(ITargetConfig config, CancellationToken cancellationToken = default)
 {
     if (config is GroupConfig groupConfig)
     {
         return(_groupConfigStore.SetGroupConfigAsync(groupConfig, cancellationToken));
     }
     else if (config is UserData userData)
     {
         return(_userDataStore.SetUserDataAsync(userData, cancellationToken));
     }
     return(Task.CompletedTask);
 }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public static Task SetGroupConfigAsync(this IGroupConfigStore store, GroupConfig config, CancellationToken cancellationToken = default)
 => store.SetGroupConfigAsync(config, true, cancellationToken);