Beispiel #1
0
        public void SendMessage(string text)
        {
            if (Name == null)
            {
                if (text.StartsWith("/w "))
                {
                    var channel = AllChannels.FirstOrDefault();

                    if (channel != null)
                    {
                        //IrcManager.Client.Say(text, "fivetf", true);
                        IrcManager.SendMessage(channel, text, IsModOrBroadcaster);
                    }
                }

                return;
            }

            IrcManager.SendMessage(this, text, IsModOrBroadcaster);

            if (AppSettings.Rainbow)
            {
                usernameHue += 0.1f;

                float r, g, b;
                (new HSLColor(usernameHue % 1, 0.5f, 0.5f)).ToRGB(out r, out g, out b);

                IrcManager.SendMessage(this, $".color #{(int)(r * 255):X}{(int)(g * 255):X}{(int)(b * 255):X}", IsModOrBroadcaster);
            }
        }
Beispiel #2
0
 public Recording(
     XElement xRecording)
 {
     try
     {
         Id          = xRecording.Attribute("id").Value;
         Title       = xRecording.Element("title").Value;
         Description = xRecording.Element("info").Value;
         Channel     = AllChannels.FirstOrDefault(c => c.Name.Equals(xRecording.Element("channel").Value, StringComparison.CurrentCultureIgnoreCase));
         StartTime   = DateTime.ParseExact(
             xRecording.Attribute("start").Value,
             new[] { "yyyyMMddHHmmss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
         Duration = TimeSpan.ParseExact(xRecording.Attribute("duration").Value,
                                        "hhmmss",
                                        CultureInfo.InvariantCulture);
         Filename = xRecording.Element("file").Value;
         InError  = false;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex, "Error parsing Recording XML");
         InError = true;
     }
 }
Beispiel #3
0
 public Timer(
     XElement xTimer)
 {
     try
     {
         Id        = xTimer.Element("ID").Value;
         Name      = xTimer.Element("Descr").Value;
         PrePad    = xTimer.Attribute("PreEPG") == null ? TimeSpan.Zero : TimeSpan.FromMinutes(int.Parse(xTimer.Attribute("PreEPG").Value));
         PostPad   = xTimer.Attribute("PostEPG") == null ? TimeSpan.Zero : TimeSpan.FromMinutes(int.Parse(xTimer.Attribute("PostEPG").Value));
         Channel   = AllChannels.FirstOrDefault(c => c.Name == xTimer.Element("Channel").Attribute("ID").Value.Split('|')[1]);
         StartTime = DateTime.ParseExact(
             xTimer.Attribute("Date").Value + " " + xTimer.Attribute("Start").Value,
             new[] { "dd.MM.yyyy HH:mm:ss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal) + PrePad;
         StopTime    = StartTime.AddMinutes(int.Parse(xTimer.Attribute("Dur").Value)) - PrePad - PostPad;
         EventId     = xTimer.Attribute("EPGEventID") == null ? "" : xTimer.Attribute("EPGEventID").Value;
         IsRecording = xTimer.Element("Recording").Value != "0";
         InError     = false;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex, "Error parsing Timer XML");
         InError = true;
     }
 }
Beispiel #4
0
 public Programme(
     XElement xProg)
 {
     try
     {
         Id          = xProg.Element("eventid").Value;
         Title       = xProg.Element("titles").Element("title").Value;
         Description = xProg.Element("events")?.Element("event")?.Value ?? "";
         Channel     = AllChannels.FirstOrDefault(c => c.EpgId == xProg.Attribute("channel").Value);
         StartTime   = DateTime.ParseExact(
             xProg.Attribute("start").Value,
             new[] { "yyyyMMddHHmmss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
         StopTime = DateTime.ParseExact(
             xProg.Attribute("stop").Value,
             new[] { "yyyyMMddHHmmss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
         InError = false;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex, "Error parsing Programme XML");
         InError = true;
     }
 }
Beispiel #5
0
        public override async void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(e, viewModelState);

            this.PropertyChanged += PropChanged;
            AllChannels           = await OperateAsyncOperation(_channelRepository.GetChannels(ChannelCategory.Hepsi));

            CurrentChannel = AllChannels.FirstOrDefault(a => a.Channel.Id == (JsonConvert.DeserializeObject <ChannelModelView>(e.Parameter.ToString())).Channel.Id);
        }
Beispiel #6
0
        private static void OnSpeech(SpeechEventArgs e)
        {
            if (e.Handled || e.Blocked || !(e.Mobile is PlayerMobile) || String.IsNullOrWhiteSpace(e.Speech) ||
                e.Speech.Length < 3 || e.Speech[0] != CMOptions.ChatPrefix)
            {
                return;
            }

            var pm   = (PlayerMobile)e.Mobile;
            var args = e.Speech.Substring(1).Split(' ');

            if (args.Length < 2)
            {
                return;
            }

            string token = args[0];

            var channel = AllChannels.FirstOrDefault(c => c.Available && c.Token == token && c.Access <= e.Mobile.AccessLevel);

            if (channel == null)
            {
                return;
            }

            e.Handled = true;
            e.Blocked = true;

            if (Insensitive.Equals(args[1], "join"))
            {
                if (channel.Join(pm))
                {
                }

                return;
            }

            if (Insensitive.Equals(args[1], "leave"))
            {
                if (channel.Leave(pm))
                {
                }

                return;
            }

            if (pm.AccessLevel > AccessLevel.Counselor)
            {
                if (Insensitive.Equals(args[1], "kick"))
                {
                    if (args.Length > 2)
                    {
                        PlayerMobile toKick = channel.Users.Keys.FirstOrDefault(u => Insensitive.Equals(u.RawName, args[2]));

                        if (toKick != null && pm.AccessLevel > toKick.AccessLevel && channel.Kick(toKick))
                        {
                        }
                    }

                    return;
                }

                if (Insensitive.Equals(args[1], "ban"))
                {
                    if (args.Length > 2)
                    {
                        PlayerMobile toBan = channel.Users.Keys.FirstOrDefault(u => Insensitive.Equals(u.RawName, args[2]));

                        TimeSpan duration = TimeSpan.Zero;

                        if (args.Length > 3)
                        {
                            double mins;

                            if (Double.TryParse(args[3], out mins))
                            {
                                duration = TimeSpan.FromMinutes(mins);
                            }
                        }

                        if (toBan != null && pm.AccessLevel > toBan.AccessLevel && channel.Ban(toBan, duration))
                        {
                        }
                    }

                    return;
                }
            }

            var tmp = args.ToList();

            tmp.RemoveAt(0);
            args = tmp.ToArray();
            tmp.Clear();

            if (channel.Message(pm, String.Join(" ", args)))
            {
            }
        }