Ejemplo n.º 1
0
        private IMBotMessage DoShowUpcomingCommand(IMBotConversation conversation, ScheduleType type)
        {
            if (type == ScheduleType.Recording)
            {
                var upcomingRecordings = Proxies.ControlService.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings, false).Result;

                StringBuilder replyText = new StringBuilder();

                if (upcomingRecordings.Count > 0)
                {
                    int index = 0;
                    foreach (UpcomingRecording upcomingRecording in upcomingRecordings)
                    {
                        if (replyText.Length > 0)
                        {
                            replyText.AppendLine();
                        }

                        PluginService pluginService = null;
                        if (upcomingRecording.CardChannelAllocation != null)
                        {
                            pluginService =
                                RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId);
                        }

                        replyText.AppendFormat("{0,3}» ", ++index);
                        Utility.AppendProgramDetails(replyText, upcomingRecording.Program.Channel, upcomingRecording.Program);
                        replyText.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name);
                    }

                    conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingRecordings);

                    return(new IMBotMessage(replyText.ToString(), true)
                    {
                        Footer = "Use 'cancel', 'uncancel' or 'delete schedule' with <number>."
                    });
                }
            }
            else
            {
                var upcomingPrograms = Proxies.SchedulerService.GetAllUpcomingPrograms(type, false).Result;

                StringBuilder replyText = new StringBuilder();

                if (upcomingPrograms.Count > 0)
                {
                    int index = 0;
                    foreach (UpcomingProgram upcomingProgram in upcomingPrograms)
                    {
                        if (replyText.Length > 0)
                        {
                            replyText.AppendLine();
                        }
                        replyText.AppendFormat("{0,3}» ", ++index);
                        Utility.AppendProgramDetails(replyText, upcomingProgram.Channel, upcomingProgram);
                    }

                    conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingPrograms);

                    return(new IMBotMessage(replyText.ToString(), true)
                    {
                        Footer = "Use 'record', 'cancel', 'uncancel' or 'delete schedule' with <number>."
                    });
                }
            }
            return(new IMBotMessage("There are no upcoming " + type.ToString().ToLowerInvariant() + "s."));
        }
Ejemplo n.º 2
0
        private IMBotMessage DoStatusCommand(IMBotConversation conversation, IList <string> arguments)
        {
            bool fixedWidth = false;

            // Check if currently recording :
            var activeRecordings  = Proxies.ControlService.GetActiveRecordings().Result;
            var liveStreams       = Proxies.ControlService.GetLiveStreams().Result;
            var upcomingRecording = Proxies.ControlService.GetNextUpcomingRecording(false).Result;

            StringBuilder reply = new StringBuilder();

            if (activeRecordings.Count > 0)
            {
                reply.Append("Currently recording:");
                foreach (ActiveRecording activeRecording in activeRecordings)
                {
                    PluginService pluginService = null;
                    if (activeRecording.CardChannelAllocation != null)
                    {
                        pluginService =
                            RecorderTunersCache.GetRecorderTunerById(activeRecording.CardChannelAllocation.RecorderTunerId);
                    }

                    reply.AppendLine();
                    Utility.AppendProgramDetails(reply, activeRecording.Program.Channel, activeRecording.Program);
                    reply.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name);
                }
                fixedWidth = true;

                if (liveStreams.Count > 0 ||
                    upcomingRecording != null)
                {
                    reply.AppendLine();
                }
            }
            if (liveStreams.Count > 0)
            {
                reply.Append("Currently streaming:");
                foreach (LiveStream liveStream in liveStreams)
                {
                    reply.AppendLine();
                    reply.AppendFormat("[{0}]", liveStream.Channel.DisplayName);
                }
                fixedWidth = true;

                if (upcomingRecording != null)
                {
                    reply.AppendLine();
                }
            }
            if (upcomingRecording != null)
            {
                if (reply.Length == 0)
                {
                    reply.AppendLine("Idle, next scheduled recording:");
                }
                else
                {
                    reply.AppendLine("Next scheduled recording:");
                }

                PluginService pluginService = null;
                if (upcomingRecording.CardChannelAllocation != null)
                {
                    pluginService = RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId);
                }

                Utility.AppendProgramDetails(reply, upcomingRecording.Program.Channel, upcomingRecording.Program);
                reply.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name);

                fixedWidth = true;
            }
            if (reply.Length == 0)
            {
                reply.Append("Idle");
            }
            reply.AppendLine().AppendLine();
            reply.Append("ARGUS TV Messenger " + Constants.ProductVersion + @", running on server \\").AppendLine(Dns.GetHostName());
            reply.Append("http://www.argus-tv.com");
            return(new IMBotMessage(reply.ToString(), fixedWidth));
        }