public static async Task HandleViewerExperience(object sender, OnMessageReceivedArgs e) { if (e.ChatMessage.IsBroadcaster) { return; } var dbViewer = await HandleNewViewer(sender, e); dbViewer.IsSubscriber = e.ChatMessage.IsSubscriber; dbViewer.Points += _account.TwitchBotSettings.DefaultExperienceAmount; await _viewerCollection.AddOrUpdateAsync(dbViewer); }
public void MigrateTwitchVODMetadata() { var channelId = _twitchService.GetChannelIdFromChannelName("dasmehdi").GetAwaiter().GetResult(); ChannelVideos videos = null; var offset = 0; do { videos = _twitchService.GetVideosFromChannelId(channelId, offset).GetAwaiter().GetResult(); videos.Videos.ForEach(video => { var vod = new Vod() { ImportedAt = DateTime.UtcNow, Video = video }; var dbVod = _vodCollection.AddOrUpdateAsync(vod).GetAwaiter().GetResult(); Assert.IsInstanceOfType(dbVod, typeof(Vod)); }); offset += 100; } while (offset <= videos.Total); }
public async Task <ActionResult> Register(Account account) { if (string.IsNullOrEmpty(account.Email) || string.IsNullOrEmpty(account.Password)) { return(StatusCode((int)HttpStatusCode.BadRequest, Json(new { error = "Email or Password are required" }))); } var dbAccount = await _accountCollection.FindAsync(account.Email, "account-email"); if (dbAccount != null) { return(StatusCode((int)HttpStatusCode.BadRequest, Json(new { error = "Account already exists" }))); } var salt = BCrypt.Net.BCrypt.GenerateSalt(); var hashedPassword = _cryptoService.PasswordCrypt(account.Password, salt); account = new Account { Email = account.Email, Password = hashedPassword, PasswordSalt = salt }; dbAccount = await _accountCollection.AddOrUpdateAsync(account); dbAccount.Password = string.Empty; dbAccount.PasswordSalt = string.Empty; return(StatusCode((int)HttpStatusCode.OK, Json(dbAccount))); }
public void GetChatStats_ReturnsChatStats() { var chatstats = _seClient.GetChatStats("KungRaseri").GetAwaiter().GetResult(); chatstats.Chatters.ForEach(chatter => { var viewer = new Viewer() { Username = chatter.Name, Points = chatter.Amount }; _viewerCollection.AddOrUpdateAsync(viewer).GetAwaiter().GetResult(); }); }