Example #1
0
 private void GetChannelFromHashtable(string key, string line)
 {
     chTemp = (IrcChannel)htChannel[key];
     chTemp.Message = line;
 }
Example #2
0
 public void AddChannel(string channelname, int users)
 {
     if(htChannel[channelname] == null)
     {
         chTemp = new IrcChannel(channelname);
         chTemp.Message = "You have joined " + channelname;
         htChannel[channelname] = chTemp;
         ListViewItem items = new ListViewItem(channelname);
         items.SubItems.Add(users.ToString());
         _form.lvwChannel.Items.Add(items);
     }
 }
Example #3
0
        public void ConnectionStart(string server, int port, string nick, string name)
        {
            _form.TurnOffButtonEnabled();
            ircTokenizer = new IrcTokenizer(_form, this);

            AddChannel(server, 0);

            try
            {
                tcpClient = new TcpClient(server, port);
                netStream = tcpClient.GetStream();
                isConnect = true;
            }
            catch
            {
            }

            htServer[server] = new IrcServer(server, port, nick, name);
            htChannel[server] = new IrcChannel(server);

            ircCommander = new IrcCommander(netStream);

            ircCommander.Nick(nick);
            Get();

            if(isConnect)
            {
                ircCommander.User(name, 0);
                Get();

                tGet = new Thread(new ThreadStart(GetLoop));
                tGet.IsBackground = true;
                tGet.Start();

                foreach(string channel in _form.tboxAutoJoin.Lines)
                {
                    ircCommander.Join(channel);
                }
            }
        }
Example #4
0
        public void Analyze(string message)
        {
            message = message.Replace("\0", string.Empty);
            string[] line = message.Split(new char[] { '\n' });

            foreach(string s in line)
            {
                //s = s.Replace("\r", string.Empty);
                if(s == string.Empty) continue;
                string[] token = s.Split(new char[] { ' ' });
                _manager.Message = _form.ApdBackMessage(s);

                if(s.StartsWith(":" + _manager.htChannel["irc.huie.hokudai.ac.jp"]))
                {
                    // �T�[�o�[����̃��b�Z�[�W
                    //IrcChannel chTemp = _manager.htChannel[ircConnection.Server] as IrcChannel;
                    chTemp = _manager.htChannel["irc.huie.hokudai.ac.jp"] as IrcChannel;
                    chTemp.Message = s;

                    /* :SERVERNAME CODE NAME :MESSAGE */
                    /* [0]         [1]  [2]  [3]      */

                    switch(token[1])
                    {
                        case "001":
                        {
                            /* �T�[�o���O�C�� */
                            /* :irc.huie.hokudai.ac.jp 001 NullIRC :Welcome to the Internet Relay Network [email protected] */
                            // AddRoom(ircConnection.Server, 0);
                            break;
                        }
                        case "332":
                            /* �g�s�b�N */
                            /* :irc.huie.hokudai.ac.jp 332 NullIRC #japan :Welcome to #japan / English or Japanese only, please | 'asl' xiuxing for a chat */
                            _manager.AddChannel(token[3], 0);
                            chTemp = _manager.htChannel[token[3]] as IrcChannel;
                            chTemp.Topic = s.Substring(s.IndexOf(":", 1));
                            chTemp.Message = token[3] + " topic:" + chTemp.Topic; // System Message
                            break;
                        case "353":
                        {
                            /* �����o���X�g */
                            /* :irc.huie.hokudai.ac.jp 353 NullIRC @ #IRC�k�b�� :dirby works siba Gon-zeeN_ Last__ kanara_ yaguti cruiser65 ikuta_aoc Recie_Die Veguna sibikku */
                            string chname = string.Empty;
                            foreach(string str in token)
                            {
                                if(str.StartsWith("#") || str.StartsWith("&"))
                                {
                                    chname = str.Trim();
                                    break;
                                }
                            }
                            _manager.AddChannel(chname, 0);
                            chTemp = _manager.htChannel[token[4]] as IrcChannel;
                            for(int i = 5; i < token.Length; i++)
                            {
                                chTemp.AddChannelMember(token[i]);
                            }
                            break;
                        }
                    }
                }
                else if(s.StartsWith("PING"))
                {
                    /* PING-PONG! */

                }
                else if(s.StartsWith("ERROR"))
                {
                    /* �G���[�̂΂₢ */
                    _manager.ConnectionClose();
                    return;
                }
                else
                {
                    /* ���̂� */
                    /* :[email protected] PRIVMSG #maxXx65535 :test */
                    /* :NICKNAME!~HOSTNAME COMMAND CHHANNEL :MESSAGE */
                    /* [0]                 [1]     [2]      [3]      */

                    Regex regex = new Regex(@"");
                    Match m = regex.Match(s);

                    string print = string.Empty;

                    switch(token[1])
                    {
                        case "PRIVMSG":
                            chTemp = _manager.htChannel[token[2]] as IrcChannel;
                            print = chTemp.Message
                                = "(" + token[0] + ") " + s.Substring(s.LastIndexOf(":"));
                            goto default;
                        case "NOTICE":
                            chTemp = _manager.htChannel[token[2]] as IrcChannel;
                            print = chTemp.Message
                                = "(" + token[0] + ":Notice) " + s.Substring(s.LastIndexOf(":"));
                            goto default;
                        default:
                            /*if(token[2] == GetActiveChannel())
                                //AppendTextMessage(print);*/
                            break;
                    }
                }
            }
        }