Exemplo n.º 1
0
        public void Load()
        {
            string[] code = Main.Properties.Settings.Default.ChatSave.Split(new string[] { ";" },
                                                                            StringSplitOptions.RemoveEmptyEntries);

            foreach (var x in code)
            {
                string[] pp = x.Split(',');
                int      id = int.Parse(pp[0]);


                foreach (var s in TwoRatChat.Main.Sources.SourceManager.Sources)
                {
                    if (s.Id == id)
                    {
                        AddSource(s, pp[1], pp[2]);
                        break;
                    }
                }
            }

            //code = Main.Properties.Settings.Default.voice_Personals.Split( new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries );
            //foreach( var x in code ) {
            //    string[] pp = x.Trim( ' ', '\r', '\n', '\t' ).Split( ',' );

            //    PersonalData pd = new Main.Model.PersonalData();
            //    pd.VoiceHello = pp[1];
            //    if( pp.Length > 2 )
            //        pd.CustomIcon = pp[2];

            //    PersonalData[pp[0]] = pd;
            //}

            //PersonalData["TwoRatChat"] = new Main.Model.PersonalData() { VoiceHello = "", CustomIcon = "" };

            BlackList.Load(Main.Properties.Settings.Default.Chat_Blacklist);
            ImageBlackList.Load(Main.Properties.Settings.Default.imageBlackList);
            ImageWhiteList.Load(Main.Properties.Settings.Default.imageWhiteList);
            //  this._LevelManager.Load();
        }
Exemplo n.º 2
0
        public void Save()
        {
            //  this._LevelManager.Save();
            StringBuilder sb = new StringBuilder();

            foreach (var s in _sources)
            {
                sb.AppendFormat("{0},{1},{2};", s.SystemId, s.Uri, s.Label);
            }

            Main.Properties.Settings.Default.ChatSave       = sb.ToString();
            Main.Properties.Settings.Default.Chat_Blacklist = BlackList.Save();

            Main.Properties.Settings.Default.imageBlackList = ImageBlackList.Save();
            Main.Properties.Settings.Default.imageWhiteList = ImageWhiteList.Save();

            this.CustomUsers.Save();
            //sb.Clear();

            //foreach ( var pd in PersonalData )
            //    sb.AppendFormat( "{0},{1},{2};", pd.Key, pd.Value.VoiceHello, pd.Value.CustomIcon );

            //Main.Properties.Settings.Default.voice_Personals = sb.ToString();
        }
Exemplo n.º 3
0
        private void onMessage(ChatMessage m)
        {
            if (Main.Properties.Settings.Default.showImageMode > 0)
            {
                bool allow = false;
                switch (Main.Properties.Settings.Default.showImageMode)
                {
                case 5:
                    allow = true;
                    break;

                case 4:
                    if (!ImageBlackList.IsInList(m.Source, m.Name))
                    {
                        allow = true;
                    }
                    break;

                case 3:
                    if (ImageWhiteList.IsInList(m.Source, m.Name))
                    {
                        allow = true;
                    }
                    break;
                }

                if (allow)
                {
                    m.Text = r.Replace(m.Text, (match) => {
                        return(string.Format("[img{1}]{0}[/img]", match.Groups[1].Value,
                                             string.Format("max-width:{0};max-height:{1};",
                                                           Main.Properties.Settings.Default.maxImageWidth,
                                                           Main.Properties.Settings.Default.maxImageHeight)));
                    });
                }
            }

            if (Polling != null && Polling.Started == PollStatusEnum.Started)
            {
                if (_dispatcher.CheckAccess())
                {
                    Polling.OnMessage(m);
                }
                else
                {
                    _dispatcher.Invoke(() => {
                        Polling.OnMessage(m);
                    });
                }
            }


            if (FortuneList != null && FortuneList.Status == FortuneStatusEnum.Started)
            {
                if (_dispatcher.CheckAccess())
                {
                    FortuneList.OnMessage(m);
                }
                else
                {
                    _dispatcher.Invoke(() => {
                        FortuneList.OnMessage(m);
                    });
                }
            }


            foreach (var bot in _bots)
            {
                bot.OnMessage(m);
            }
        }