private async Task CheckFollower(string chatter, string userTwitchId) { try { TwitchChatter follower = await GetTwitchFollowerInfo(chatter, userTwitchId); if (follower == null) { return; } /* Manage follower experience */ int currentExp = await _follower.CurrentExp(chatter, _broadcasterId); if (TwitchStreamStatus.IsLive) { if (currentExp > -1) { await _follower.UpdateExp(chatter, _broadcasterId, ++currentExp); } else { // add new user to the ranks await _follower.EnlistRecruit(chatter, _broadcasterId); } } // check if follower has a stream currency account int setIncrementFunds = 10; // default to normal follower amount if (_follower.IsRegularFollower(currentExp, _botConfig.RegularFollowerHours)) { setIncrementFunds = 15; if (!_twitchChatterListInstance.TwitchRegularFollowers.Any(c => c.Username == chatter)) { _twitchChatterListInstance.TwitchRegularFollowers.Add(follower); } } /* Manage follower streaming currency */ if (TwitchStreamStatus.IsLive) { int funds = await _bank.CheckBalance(chatter, _broadcasterId); if (funds > -1) { funds += setIncrementFunds; await _bank.UpdateFunds(chatter, _broadcasterId, funds); } else // ToDo: Make currency auto-increment setting { await _bank.CreateAccount(chatter, _broadcasterId, setIncrementFunds); } } } catch (Exception ex) { Console.WriteLine($"Error inside FollowerSubscriberListener.CheckFollower(string, string): {ex.Message}"); if (ex.InnerException != null) { Console.WriteLine($"Inner Exception: {ex.InnerException.Message}"); } } }
private async Task CheckFollower(string chatter, string userTwitchId) { try { TwitchChatter follower = await GetTwitchFollowerInfo(chatter, userTwitchId); if (follower == null) { return; } // check if follower has experience int currentExp = await _follower.CurrentExp(chatter, _broadcasterId); decimal hoursWatched = 0.0m; if (currentExp > -1) { await _follower.UpdateExp(chatter, _broadcasterId, ++currentExp); // check if user has been promoted Rank capRank = _rankList.FirstOrDefault(r => r.ExpCap == currentExp); hoursWatched = _follower.GetHoursWatched(currentExp); if (hoursWatched == _botConfig.RegularFollowerHours) { Rank currentRank = _follower.GetCurrentRank(_rankList, currentExp); _irc.SendPublicChatMessage($"{currentRank.Name} {chatter} has achieved the salty equlibrium " + "needed to become a regular soldier in the salt army"); } else if (capRank != null) { Rank currentRank = _follower.GetCurrentRank(_rankList, currentExp); _irc.SendPublicChatMessage($"@{chatter} has been promoted to \"{currentRank.Name}\" " + $"with {currentExp}/{currentRank.ExpCap} EXP ({hoursWatched} hours watched)"); } } else { // add new user to the ranks await _follower.EnlistRecruit(chatter, _broadcasterId); } // check if follower has a stream currency account int funds = await _bank.CheckBalance(chatter, _broadcasterId); if (funds > -1) { if (hoursWatched >= _botConfig.RegularFollowerHours) { funds += 15; if (!_twitchChatterListInstance.TwitchRegularFollowers.Any(c => c.Username.Equals(chatter))) { _twitchChatterListInstance.TwitchRegularFollowers.Add(follower); } } else { funds += 10; } await _bank.UpdateFunds(chatter, _broadcasterId, funds); } else // ToDo: Make currency auto-increment setting { await _bank.CreateAccount(chatter, _broadcasterId, 10); } } catch (Exception ex) { Console.WriteLine($"Error inside FollowerSubscriberListener.CheckFollower(string, string): {ex.Message}"); if (ex.InnerException != null) { Console.WriteLine($"Inner Exception: {ex.InnerException.Message}"); } } }
private async Task CheckFollower(string chatter, string userTwitchId) { try { TwitchChatter follower = await GetTwitchFollowerInfo(chatter, userTwitchId); if (follower == null) { return; } // check if follower has experience int currentExp = await _follower.CurrentExp(chatter, _broadcasterId); decimal hoursWatched = 0.0m; if (currentExp > -1) { await _follower.UpdateExp(chatter, _broadcasterId, ++currentExp); } else { // add new user to the ranks await _follower.EnlistRecruit(chatter, _broadcasterId); } // check if follower has a stream currency account int funds = await _bank.CheckBalance(chatter, _broadcasterId); if (funds > -1) { if (hoursWatched >= _botConfig.RegularFollowerHours) { funds += 15; if (!_twitchChatterListInstance.TwitchRegularFollowers.Any(c => c.Username == chatter)) { _twitchChatterListInstance.TwitchRegularFollowers.Add(follower); } } else { funds += 10; } await _bank.UpdateFunds(chatter, _broadcasterId, funds); } else // ToDo: Make currency auto-increment setting { await _bank.CreateAccount(chatter, _broadcasterId, 10); } } catch (Exception ex) { Console.WriteLine($"Error inside FollowerSubscriberListener.CheckFollower(string, string): {ex.Message}"); if (ex.InnerException != null) { Console.WriteLine($"Inner Exception: {ex.InnerException.Message}"); } } }