示例#1
0
 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!");
     }
 }
示例#2
0
 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!");
     }
 }
示例#3
0
            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}`");
            }
示例#4
0
        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;
            }
        }
示例#5
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;
            }
        }
示例#6
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!");
     }
 }
示例#7
0
            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}`");
            }
示例#8
0
 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 { }
        }
示例#10
0
 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();
         }
     }
 }
示例#11
0
        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 { }
        }
示例#12
0
 public override async Task RemoveFromDBAsync(BaseTracker tracker)
 {
     await StaticBase.Database.GetCollection <T>(typeof(T).Name).DeleteOneAsync(x => x.Name.Equals(tracker.Name));
 }
示例#13
0
 public abstract Task RemoveFromDBAsync(BaseTracker tracker);
示例#14
0
 public async Task ChangeConfig(BaseTracker streamerName)
 {
     await Tracking.ModifyConfig(this, streamerName, BaseTracker.TrackerType.Mixer);
 }
示例#15
0
 public abstract Task UpdateDBAsync(BaseTracker tracker);
示例#16
0
 public async Task ShowConfig(BaseTracker tracker)
 {
     await ReplyAsync($"```yaml\n{string.Join("\n", tracker.ChannelConfig[Context.Channel.Id].Select(x => x.Key + ": " + x.Value))}```");
 }
示例#17
0
 public override async Task InsertToDBAsync(BaseTracker tracker)
 {
     await StaticBase.Database.GetCollection <BaseTracker>(typeof(T).Name).InsertOneAsync(tracker);
 }
示例#18
0
 public override async Task UpdateDBAsync(BaseTracker tracker)
 {
     await StaticBase.Database.GetCollection <BaseTracker>(typeof(T).Name).ReplaceOneAsync(x => x.Name.Equals(tracker.Name), tracker);
 }
示例#19
0
 public async Task ChangeConfig(BaseTracker ChannelID)
 {
     await Tracking.ModifyConfig(this, ChannelID, BaseTracker.TrackerType.YoutubeLive);
 }
示例#20
0
 public abstract Task InsertToDBAsync(BaseTracker tracker);