internal async Task ProcessQueueAsync() { Console.Write("\u2588"); if (queue.Count == 0) { return; } Effect br = queue.First.Value; switch (br.EffectType) { case EffectType.BITS: BitEffect be = (BitEffect)br; Log.Information($"BIT EFFECT SET: {be.Username}, {br.EffectName}, {br.Milliseconds / 1000} seconds"); if (!be.Continued) { string msgBit = settings.msgEffectSet.Replace("{username}", be.Username) .Replace("{effect}", br.EffectName).Replace("{seconds}", br.Milliseconds / 1000 + ""); twitchClient.SendMessage(settings.botJoinChannel, msgBit); } await ProcessEffect(br); break; case EffectType.SUB: SubEffect se = (SubEffect)br; Log.Information($"SUB EFFECT SET: Tier {se.Tier}, {se.Months} months," + $" {br.EffectName}, {br.Milliseconds / 1000} seconds"); await ProcessEffect(br); break; } }
internal async Task TryAddBitRequestToEffectQueueAsync(OnBitsReceivedArgs e) { if (e.BitsUsed < settings.minimumBitAmount) { string msgUnderMinimumBitAmount = settings.msgUnderMinimumBitAmount.Replace("{username}", e.Username); twitchClient.SendMessage(settings.botJoinChannel, msgUnderMinimumBitAmount); Log.Information("Bit donation to small"); } string effect = await GetEffectFromMessageAsync(e.ChatMessage); if (effect == null) { string msgEffectNotFound = settings.msgEffectNotFound.Replace("{username}", e.Username); twitchClient.SendMessage(settings.botJoinChannel, msgEffectNotFound); Log.Information("Effect not found"); return; } BitEffect be = new BitEffect(effect, e.Username, e.BitsUsed); queue.EnqueueBitEffect(be); if (queue.Count > 1) { Log.Information($"EFFECT ADDED TO QUEUE: {e.Username}, {e.BitsUsed} bits, {effect}," + $" {be.Milliseconds / 1000} seconds, position {queue.Count}"); string msgBitQueue = settings.msgAddedToQueue.Replace("{username}", e.Username).Replace("{position}", queue.Count + ""); twitchClient.SendMessage(settings.botJoinChannel, msgBitQueue); } }