示例#1
0
 public BroadcastMeep()
 {
     BroadcastType = MeetUpBroadCastTypeEnum.Reoccuring;
     CreationDate  = DateTime.Now;
     LastUpdate    = CreationDate;
 }
示例#2
0
        public void SetBroadcast(KnownMeetUp meeup, ISocketMessageChannel channel, TimeSpan frequency, MeetUpBroadCastTypeEnum type, out string msg)
        {
            msg = string.Empty;

            BroadcastMeep mub = broadcasts.SingleOrDefault(b => b.MeetUp.Name == meeup.Name && b.Channel == channel);

            if (mub == null)
            {
                broadcasts.Add(new BroadcastMeep()
                {
                    Channel = channel, MeetUp = meeup, Duration = frequency, BroadcastType = type
                });

                (new Thread(new ThreadStart(broadcasts[broadcasts.Count - 1].Broadcast))).Start();
            }
            else
            {
                msg = $"A broadcast for {meeup.Name} on {channel.Name} has already been set.";
            }
        }
示例#3
0
        public async Task BroadcastMUP(string meetup, string duration)
        {
            EmbedBuilder b          = null;
            KnownMeetUp  thisMeetup = GetThisMeetUp(meetup);

            if (thisMeetup != null)
            {
                if (!string.IsNullOrEmpty(thisMeetup.URL))
                {
                    MeetUpBroadcastService broadcastService = (MeetUpBroadcastService)Services.GetService(typeof(MeetUpBroadcastService));
                    string   state;
                    TimeSpan ts;
                    MeetUpBroadCastTypeEnum type = MeetUpBroadCastTypeEnum.Reoccuring;

                    if (duration.ToLower().Substring(0, 6) == "before") // !mub name before02:00:00:00.000 in dd:hh:mm:ss.fff
                    {
                        type = MeetUpBroadCastTypeEnum.TimeSpanBefore;
                        ts   = TimeSpan.Parse(duration.Substring(6));         // How long before.
                    }
                    else if (duration.ToLower().Substring(0, 7) == "weekly:") // !mub name weekly:Monday
                    {
                        type = MeetUpBroadCastTypeEnum.Weekly;
                        // 0 = sun - 6 sat
                        int td       = (int)DateTime.Now.DayOfWeek;
                        int target   = (int)(DayOfWeek)Enum.Parse(typeof(DayOfWeek), duration.Substring(7));
                        int dayDelta = Math.Abs(target - td);
                        ts = DateTime.Now.AddDays(dayDelta) - DateTime.Now;   // Next Day to broadcast on from now
                    }
                    else if (duration.ToLower().Substring(0, 7) == "monthly") // !mub name monthly always first of the month.
                    {
                        type = MeetUpBroadCastTypeEnum.Monthly;
                        ts   = TimeSpan.Zero; // It's the 1st of every month
                    }
                    else
                    {
                        ts = TimeSpan.Parse(duration);
                    }

                    broadcastService.SetBroadcast(thisMeetup, Context.Channel, ts, type, out state);

                    if (!string.IsNullOrEmpty(state))
                    {
                        b = GetErrorMsg(state);
                    }
                    else
                    {
                        b = GetMsg("Broadcast Set", $"{type} Meet Up Broadcast set.");
                    }
                }
                else
                {
                    b = GetWarningMsg($"{thisMeetup.Name} meetup does not use MeetUp, so a broadcast can't be set.");
                }
            }
            else
            {
                b = GetErrorMsg($"{meetup} is not a known meet up.");
            }

            await Context.Channel.SendMessageAsync("", false, b);
        }