public Bot(string channel, string token, BotSettings botSettings) { commandManager = new(); pointsManager = new(); userManager = new(); settings = botSettings; ConnectionCredentials credentials = new ConnectionCredentials(channel, token); var clientOptions = new ClientOptions { MessagesAllowedInPeriod = 750, ThrottlingPeriod = TimeSpan.FromSeconds(1) }; WebSocketClient customClient = new WebSocketClient(clientOptions); client = new TwitchClient(customClient); client.Initialize(credentials, channel); client.OnLog += Client_OnLog; client.OnJoinedChannel += Client_OnJoinedChannel; client.OnMessageReceived += Client_OnMessageReceived; client.OnWhisperReceived += Client_OnWhisperReceived; client.OnNewSubscriber += Client_OnNewSubscriber; client.OnConnected += Client_OnConnected; client.Connect(); }
public static string PlayGame(bool betEven, string userName, int wager, UserPointsRepo mgr) { var rand = new Random(); var number = rand.Next(0, 1000); var didWin = false; Console.WriteLine($"The random number for this round is {number}"); var isEven = number % 2 == 0 ? true : false; string result = $"The number was {number}. "; if (betEven && isEven || !betEven && !isEven) { result += "YOU WIN!!!!"; didWin = true; mgr.ChangePoints(userName, "", wager, "Won OddOrEven"); } else { result += "Oh no, you lose! :("; didWin = false; mgr.ChangePoints(userName, "", wager * -1, "Lost OddOrEven"); } using (var context = new mashDbContext()) { context.WinLoss.Add(new WinLoss { UserName = userName, DidWin = didWin, Date = DateTime.Now, Game = "OddOrEven" }); context.SaveChanges(); } return(result); }