Exemple #1
0
 public bool EventMatches(DIEvent evt)
 {
     return
         ((TagPrimary == null || evt.TagPrimary.ToLowerInvariant() == TagPrimary.ToLowerInvariant()) &&
          (TagSecondary == null || evt.TagSecondary.ToLowerInvariant() == TagSecondary.ToLowerInvariant()) &&
          (Host == null || evt.Hosts.Contains(Host)));
 }
Exemple #2
0
 private void ProcessTriggers(DIEvent evt, DiscordSocketClient discord, MasterDivisionRegistry mdr, bool isEdit = false)
 {
     foreach (DICalendarTrigger trigger in Triggers)
     {
         if (trigger.EventMatches(evt))
         {
             evt.PostToChannel(trigger.GuildID, trigger.ChannelID, trigger, isEdit);
         }
     }
 }
Exemple #3
0
        public void ProcessEvents(Calendar vCal, DiscordSocketClient discord, MasterDivisionRegistry mdr)
        {
            foreach (var calEvt in vCal.Events.OrderBy(x => x.Start.Ticks))
            {
                DIEvent evt = null;

                if (Events.Any(x => x.UID == calEvt.Uid))
                {
                    evt = Events.First(x => x.UID == calEvt.Uid);

                    var description = DIEvent.DetailsRegex.Match(calEvt.Description).Groups[1].Value.Replace("\n\n", "\n").Trim();
                    if (description == string.Empty)
                    {
                        description = calEvt.Description.Replace("\n\n", "\n").Trim();
                    }

                    if (evt.Start != calEvt.DtStart.AsUtc ||
                        evt.End != (calEvt.DtEnd?.AsUtc ?? DateTime.MinValue.ToUniversalTime()) ||
                        evt.RawTitle != calEvt.Summary ||
                        evt.Description != description)
                    {
                        evt.CopyFrom(calEvt);

                        ProcessTriggers(evt, discord, mdr, true);
                    }

                    continue;
                }

                evt = new DIEvent();

                evt.CopyFrom(calEvt);

                Events.Add(evt);

                if (evt.End > DateTime.UtcNow)
                {
                    ProcessTriggers(evt, discord, mdr);
                }
            }
        }