コード例 #1
0
        private void Sender_OnNewFollower(ChatSource sender, string userName)
        {
            if (Main.Properties.Settings.Default.newFollowerShowInChat)
            {
                cs_OnNewMessages(new ChatMessage[] { new ChatMessage()
                                                     {
                                                         Text   = string.Format(Main.Properties.Resources.NewFollowerMessage, userName),
                                                         Date   = DateTime.Now,
                                                         Source = sender,
                                                         ToMe   = true,
                                                         Name   = "TwoRatChat"
                                                     } });
            }


            if (sender != null)
            {
                if (!string.IsNullOrEmpty(Main.Properties.Settings.Default.voice_Followers))
                {
                    TwoRatChat.Commands.CommandFactory.Talk(
                        string.Format(Main.Properties.Settings.Default.voice_Followers, userName, sender.Id));
                }

                lock ( _cmdLocker ) {
                    _commands.Add(new Command("shownotify",
                                              string.Format("{0}/{1}<br/>новый подписчик!",
                                                            sender.Id, userName)));
                }
            }
        }
コード例 #2
0
ファイル: BlackList.cs プロジェクト: JustOxlamon/TwoRatChat
        public bool IsInList(ChatSource source, string nick)
        {
            if (source == null)
            {
                return(false);
            }
            BlackItem bi = Find(source.SystemId, nick);

            return(bi != null);
        }
コード例 #3
0
        private bool onSort(int j, ChatSource temp)
        {
            if (Sources[j - 1].ViewersCount.HasValue)
            {
                return(Sources[j - 1].ViewersCount < temp.ViewersCount);
            }
            else
            {
                int x = string.Compare(Sources[j - 1].Id, temp.Id);

                return(x < 0);
            }
        }
コード例 #4
0
ファイル: BlackList.cs プロジェクト: JustOxlamon/TwoRatChat
        public string GetReplaceText(ChatSource source, string nick, string originalText)
        {
            if (source == null)
            {
                return(originalText);
            }

            BlackItem bi = Find(source.SystemId, nick);

            if (bi == null)
            {
                return(originalText);
            }

            return(bi.ReplaceText);
        }
コード例 #5
0
        private void Cs_OnFatalError(ChatSource sender, ChatSource.FatalErrorCodeEnum code)
        {
            Action a = new Action(() => {
                _systemMessages.Add(new ChatMessage()
                {
                    Text   = Main.Helpers.Errors.GetLocalizedError((int)code),
                    Date   = DateTime.Now,
                    Source = sender
                });
            });

            if (_dispatcher.CheckAccess())
            {
                a();
            }
            else
            {
                _dispatcher.Invoke(a);
            }
            // Add message
            removeChatSource(sender);
        }
コード例 #6
0
        public void AddSource(TwoRatChat.Main.Sources.Source source, string param1, string param2)
        {
            if (source == null)
            {
                return;
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(b => {
                Thread.CurrentThread.Name = "create thread";
                ChatSource cs             = Activator.CreateInstance(source.Type, this._dispatcher) as ChatSource;
                cs.Status                = false;
                cs.OnFatalError         += Cs_OnFatalError;
                cs.OnNewMessages        += cs_OnNewMessages;
                cs.OnRemoveUserMessages += Sender_OnRemoveUserMessages;
                cs.OnNewFollower        += Sender_OnNewFollower;

                _dispatcher.Invoke(() => { _sources.Add(cs); });

                cs.SystemId = source.Id;
                cs.Create(param1, param2);
            }), null);
        }
コード例 #7
0
        private void removeChatSource(ChatSource sender)
        {
            lock ( _locker ) {
                List <ChatMessage> delMe = new List <ChatMessage>();
                foreach (var m in _messages)
                {
                    if (m.Source == sender)
                    {
                        delMe.Add(m);
                    }
                }
                foreach (var m in delMe)
                {
                    _messageGIDs.Remove(m.GID);
                    _messages.Remove(m);
                }
            }


            sender.Status                = false;
            sender.OnNewMessages        -= cs_OnNewMessages;
            sender.OnFatalError         -= Cs_OnFatalError;
            sender.OnRemoveUserMessages -= Sender_OnRemoveUserMessages;
            sender.OnNewFollower        -= Sender_OnNewFollower;

            if (_dispatcher.CheckAccess())
            {
                _sources.Remove(sender);
                sender.Destroy();
            }
            else
            {
                _dispatcher.Invoke(() => {
                    _sources.Remove(sender);
                    sender.Destroy();
                });
            }
        }
コード例 #8
0
        private void Sender_OnRemoveUserMessages(ChatSource sender, string userName)
        {
            Action a = new Action(() => {
                foreach (var m in _messages.ToArray())
                {
                    if (string.Compare(m.Name, userName, true) == 0)
                    {
                        m.Text = Main.Properties.Resources.MES_Deleted;
                    }
                }
            });

            if (_dispatcher.CheckAccess())
            {
                a();
            }
            else
            {
                _dispatcher.Invoke(a);
            }

            //Console.WriteLine( "CLEAR!" );
        }
コード例 #9
0
 internal void CloseChat(ChatSource cs)
 {
     removeChatSource(cs);
 }
コード例 #10
0
 internal void ReloadChat(ChatSource cs)
 {
     cs.Status = false;
     cs.ReloadChatCommand();
 }