public async Task unTrackStreamer(BaseTracker streamerName) { if (await Trackers[BaseTracker.TrackerType.Mixer].TryRemoveTrackerAsync(streamerName.Name, Context.Channel.Id)) { await ReplyAsync("Stopped keeping track of " + streamerName.Name + "'s streams!"); } }
public async Task unTrackYoutube(BaseTracker channelID) { if (await Trackers[BaseTracker.TrackerType.YoutubeLive].TryRemoveTrackerAsync(channelID.Name, Context.Channel.Id)) { await ReplyAsync("Stopped keeping track of " + channelID.Name + "'s streams!"); } }
public async Task SetNotification(BaseTracker streamer, [Remainder] string notification = "") { streamer.ChannelConfig[Context.Channel.Id]["Notification"] = notification; await StaticBase.Trackers[BaseTracker.TrackerType.Mixer].UpdateDBAsync(streamer); await ReplyAsync($"Changed notification for `{streamer.Name}` to `{notification}`"); }
public async void LoopTrackersUpdate(object state) { if (updateTurn < updateQueue.Count) { BaseTracker curTracker = null; try { curTracker = updateQueue[updateTurn]; updateTurn++; curTracker.CheckForChange_Elapsed(null); } catch (Exception e) { await Program.MopsLog(new LogMessage(LogSeverity.Error, "", $"Error on checking for change for {curTracker?.Name ?? "Unknown"}", e)); } } else { updateQueue = trackers.Where(x => (x.Value as BaseUpdatingTracker).ToUpdate.Count > 0).Select(x => x.Value).ToList(); var gap = updateInterval / (updateQueue.Count > 0 ? updateQueue.Count : 1); nextUpdate.Change(gap, gap); updateTurn = 0; } }
public async void LoopTrackers(object state) { if (trackerTurn < loopQueue.Count) { BaseTracker curTracker = null; try { curTracker = loopQueue[trackerTurn]; trackerTurn++; curTracker.CheckForChange_Elapsed(null); } catch (Exception e) { await Program.MopsLog(new LogMessage(LogSeverity.Error, "", $"Error on checking for change for {curTracker?.Name ?? "Unknown"}", e)); } } else { if (trackers.FirstOrDefault().Value is BaseUpdatingTracker) { loopQueue = trackers.Where(x => (x.Value as BaseUpdatingTracker).ToUpdate.Count == 0).Select(x => x.Value).ToList(); } else { loopQueue = trackers.Values.ToList(); } var gap = trackerInterval / (loopQueue.Count > 0 ? loopQueue.Count : 1); nextTracker.Change(gap, gap); trackerTurn = 0; } }
public async Task unTrackYoutube(BaseTracker channelID) { if (await Trackers[BaseTracker.TrackerType.YoutubeLive].TryRemoveTrackerAsync(channelID.Name, channelID.LastCalledChannelPerGuild[Context.Guild.Id])) { await ReplyAsync("Stopped keeping track of " + channelID.Name + "'s streams!"); } }
public async Task SetNotification(BaseTracker channelID, [Remainder] string notification = "") { channelID.ChannelConfig[Context.Channel.Id]["Notification"] = notification; await StaticBase.Trackers[BaseTracker.TrackerType.YoutubeLive].UpdateDBAsync(channelID); await ReplyAsync($"Changed notification for `{channelID.Name}` to `{notification}`"); }
public override async Task RemoveFromDBAsync(BaseTracker tracker) { lock (tracker.ChannelConfig) { try { StaticBase.Database.GetCollection <T>(typeof(T).Name).DeleteOneAsync(x => x.Name.Equals(tracker.Name)).Wait(); } catch (Exception e) { Program.MopsLog(new LogMessage(LogSeverity.Error, "", $"Error on removing for {tracker.Name}, {e.Message}", e)).Wait(); } } }
public async Task WentOffline(BaseTracker sender) { if (!(sender as TwitchTracker).IsHosting) { await ModifyAsync(x => x.Points -= 40); } try { var curGuild = Program.Client.GetGuild(GuildId) as IGuild; var tGuild = StaticBase.TwitchGuilds[GuildId]; await(await curGuild.GetUserAsync(DiscordId)).RemoveRoleAsync(curGuild.GetRole(tGuild.LiveRole)); } catch { } }
public override async Task UpdateDBAsync(BaseTracker tracker) { lock (tracker.ChannelConfig) { try { StaticBase.Database.GetCollection <BaseTracker>(typeof(T).Name).ReplaceOneAsync(x => x.Name.Equals(tracker.Name), tracker, new UpdateOptions { IsUpsert = true }).Wait(); } catch (Exception e) { Program.MopsLog(new LogMessage(LogSeverity.Error, "", $"Error on upsert for {tracker.Name}, {e.Message}", e)).Wait(); } } }
public async Task WentLive(BaseTracker sender = null) { if (sender != null) { LiveCount++; await ModifyAsync(x => x.Points += 20); } try { var curGuild = Program.Client.GetGuild(GuildId) as IGuild; var tGuild = StaticBase.TwitchGuilds[GuildId]; await(await curGuild.GetUserAsync(DiscordId)).AddRoleAsync(curGuild.GetRole(tGuild.LiveRole)); } catch { } }
public override async Task RemoveFromDBAsync(BaseTracker tracker) { await StaticBase.Database.GetCollection <T>(typeof(T).Name).DeleteOneAsync(x => x.Name.Equals(tracker.Name)); }
public abstract Task RemoveFromDBAsync(BaseTracker tracker);
public async Task ChangeConfig(BaseTracker streamerName) { await Tracking.ModifyConfig(this, streamerName, BaseTracker.TrackerType.Mixer); }
public abstract Task UpdateDBAsync(BaseTracker tracker);
public async Task ShowConfig(BaseTracker tracker) { await ReplyAsync($"```yaml\n{string.Join("\n", tracker.ChannelConfig[Context.Channel.Id].Select(x => x.Key + ": " + x.Value))}```"); }
public override async Task InsertToDBAsync(BaseTracker tracker) { await StaticBase.Database.GetCollection <BaseTracker>(typeof(T).Name).InsertOneAsync(tracker); }
public override async Task UpdateDBAsync(BaseTracker tracker) { await StaticBase.Database.GetCollection <BaseTracker>(typeof(T).Name).ReplaceOneAsync(x => x.Name.Equals(tracker.Name), tracker); }
public async Task ChangeConfig(BaseTracker ChannelID) { await Tracking.ModifyConfig(this, ChannelID, BaseTracker.TrackerType.YoutubeLive); }
public abstract Task InsertToDBAsync(BaseTracker tracker);