示例#1
0
        //IrcalBot ibot;
        private void icore_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            place = -1;
            if (e.UserState is List <Message> )
            {
                mList = (List <Message>)e.UserState;
            }
            else
            {
                return;
            }
            place = -2;
            try
            {
                int icnt = mList.Count;
                if (sbmc == null)
                {
                    sbmc = new SBMessage();
                }
                //if (ibot == null)
                //    ibot = new IrcalBot(ircCore1);

                //ibot.pushmessage(mList);

                for (int i = 0; i < icnt; i++)
                {
                    place = 49;
                    m     = (Message)mList[i];
                    place = 52;
                    //
                    //:[email protected] PRIVMSG #HamRadio :test
                    //sbmc.SendSBM(m.message);

                    if (m.message.Contains("PRIVMSG"))
                    {
                        place = 53;
                        iparse.MainParser(m.message);
                        PrivMsgEventArgs pme  = iparse.pmargs;
                        PrivMsgEventArgs nPME = new PrivMsgEventArgs();
                        pme.Copy(ref nPME);
                        ChanMessageList cml;
                        place = 54;
                        string scChannel = StripPND(nPME.From);
                        sbmc.SendSBM(m.message, scChannel);
                        MessageQueue.Add(m.message);
                        if (!ChannelList.TryGetValue(scChannel, out cml))
                        {
                            cml = new ChanMessageList();
                            ChannelList.Add(nPME.From, cml);
                        }
                        if (ChannelList.TryGetValue(scChannel, out cml))
                        {
                            cml.AddPrivMsg(nPME);

                            if (!cml.nicks.Contains(nPME.User.Nick))
                            {
                                cml.nicks.Add(nPME.User.Nick);
                            }
                            //Only add text to window if channel is selected.
                            if (selectedChannel == scChannel.ToLower())
                            {
                                AppendText(nPME, true);
                                rtbTopic.SelectAll();
                                rtbTopic.SelectionAlignment = HorizontalAlignment.Right;
                                ScrollToBottom(rtbBox);
                            }
                            oNotify.CheckName(nPME.User.Nick);
                            oNotify.CheckChannel(ircCore1.ServerName, scChannel, nPME);
                            cml.LastUpdate = DateTime.Now;
                        }
                        place = 88;
                    }
                    else
                    {
                        iparse.MainParser(m.message);
                        if (!iparse.parsed)
                        {
                            string msg = m.message.Trim();
                            if (msg.Length > 0)
                            {
                                if (msg.StartsWith("PING"))
                                {
                                    break;
                                }
                                rtbGeneral.AppendText(msg + retval);
                                rtbGeneral.Select(rtbGeneral.Text.Length, 0);
                            }
                        }
                    }
                    //if (m.Direction == "parse")
                    //{
                    //    place = 71;
                    //    iparse.MainParser(m.message.Split(new char[] { ' ' }));

                    //}
                }
                place = 72;

                mList.RemoveRange(0, mList.Count);
                place = 73;
            }
            catch (Exception ex)
            {
                rtbGeneral.AppendText("ERROR:place" + place.ToString() + ex.Message);

                //  MessageBox.Show(ex.Message + " err: place = "+ place.ToString());
            }
        }
示例#2
0
文件: MainForm.cs 项目: foxjazz/IRCAL
        //IrcalBot ibot;
        private void icore_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            place = -1;
            if (e.UserState is List<Message>)
                mList = (List<Message>)e.UserState;
            else
                return;
            place = -2;
            try
            {
                int icnt = mList.Count;
                if (sbmc == null)
                    sbmc = new SBMessage();
                //if (ibot == null)
                //    ibot = new IrcalBot(ircCore1);

                //ibot.pushmessage(mList);

                for (int i = 0; i < icnt; i++)
                {
                    place = 49;
                    m = (Message) mList[i];
                    place = 52;
                    //
                    //:[email protected] PRIVMSG #HamRadio :test
                    //sbmc.SendSBM(m.message);

                    if (m.message.Contains("PRIVMSG"))
                    {
                        place = 53;
                        iparse.MainParser(m.message);
                        PrivMsgEventArgs pme = iparse.pmargs;
                        PrivMsgEventArgs nPME = new PrivMsgEventArgs();
                        pme.Copy(ref nPME);
                         ChanMessageList cml;
                         place = 54;
                        string scChannel = StripPND(nPME.From);
                        sbmc.SendSBM(m.message,scChannel);
                        MessageQueue.Add(m.message);
                         if (!ChannelList.TryGetValue(scChannel, out cml))
                         {
                             cml = new ChanMessageList();
                             ChannelList.Add(nPME.From, cml);
                         }
                         if (ChannelList.TryGetValue(scChannel, out cml))
                         {
                             cml.AddPrivMsg(nPME);
                             
                             if (!cml.nicks.Contains(nPME.User.Nick))
                                 cml.nicks.Add(nPME.User.Nick);
                             //Only add text to window if channel is selected.
                             if (selectedChannel == scChannel.ToLower())
                             {
                                 AppendText(nPME, true);
                                 rtbTopic.SelectAll();
                                 rtbTopic.SelectionAlignment = HorizontalAlignment.Right;
                                 ScrollToBottom(rtbBox);
                             }
                             oNotify.CheckName(nPME.User.Nick);
                             oNotify.CheckChannel(ircCore1.ServerName, scChannel, nPME);
                             cml.LastUpdate = DateTime.Now;
                         }
                        place = 88;
                    }
                    else
                    {
                        iparse.MainParser(m.message);
                        if (!iparse.parsed)
                        {
                            string msg = m.message.Trim();
                            if (msg.Length > 0 )
                            {
                                if (msg.StartsWith("PING"))
                                    break;
                                rtbGeneral.AppendText(msg + retval);
                                rtbGeneral.Select(rtbGeneral.Text.Length, 0);
                            }
                        }
                        
                    }
                    //if (m.Direction == "parse")
                    //{
                    //    place = 71;
                    //    iparse.MainParser(m.message.Split(new char[] { ' ' }));

                    //}
                  
                        

                }
                place = 72;

                mList.RemoveRange(0, mList.Count);
                place = 73;
            }
            catch (Exception ex)
            {
                rtbGeneral.AppendText("ERROR:place" + place.ToString() +  ex.Message);
                    
              //  MessageBox.Show(ex.Message + " err: place = "+ place.ToString());
            }
           
            
        }