Holds host informations about a user.
Inheritance: IIrcObject
コード例 #1
0
ファイル: WhoLine.cs プロジェクト: hapm/IrcShark
        public WhoLine(IrcLine baseLine)
            : base(baseLine)
        {
            if(baseLine.Numeric != 352)
                throw new ArgumentOutOfRangeException("baseLine", "RPL_WHOREPLY 352 expected");
            if(Parameters.Length < 8)
                throw new ArgumentOutOfRangeException("baseLine", "Need a minimum of 8 parameters");

            UserValue = new UserInfo(Parameters[5], Parameters[2], Parameters[3], Client);
            List<Mode> modes = new List<Mode>();
            int i = 1;

            IsAwayValue = Parameters[6][0] == 'G';
            IsOperValue = Parameters[6][i] == '*';

            if(IsOper)
                i++;

            for(; i < Parameters[6].Length; i++)
            {
                if(Client.Standard.UserPrefixFlags.ContainsKey(Parameters[6][i]))
                {
                    modes.Add(new Mode(Client.Standard.UserPrefixFlags[Parameters[6][i]], FlagArt.Set, User.NickName));
                }
            }

            ModesValue = modes.ToArray();

            RealNameValue = Parameters[7];

            if(!int.TryParse(RealNameValue.Substring(1, RealNameValue.IndexOf(" ")), out HopCountValue))
                throw new ArgumentOutOfRangeException("baseLine", "Invalid hop count, integer expected");

            RealNameValue = RealNameValue.Substring(RealNameValue.IndexOf(" ") + 1);
        }
コード例 #2
0
        public PartReceivedEventArgs(IrcLine BaseLine)
            : base(BaseLine)
        {
            user = new UserInfo(BaseLine);
            channelName = BaseLine.Parameters[0];

            if (BaseLine.Parameters.Length > 1)
                partMessage = BaseLine.Parameters[1];
        }
コード例 #3
0
        public QuitReceivedEventArgs(IrcLine BaseLine)
            : base(BaseLine)
        {
            user = new UserInfo(BaseLine);

            if (BaseLine.Parameters.Length > 0)
                quitMessage = BaseLine.Parameters[0];
            else
                quitMessage = "";
        }
コード例 #4
0
ファイル: QueryWindow.cs プロジェクト: hapm/IrcShark
 void Client_NickChangeReceived(Object sender, NickChangeReceivedEventArgs e)
 {
     if (InvokeRequired)
     {
         Invoke(new NickChangeReceivedEventHandler(Client_NickChangeReceived), sender, e);
         return;
     }
     if (!e.User.Equals(BoundedUser)) return;
     BoundedUserValue = new UserInfo(e.NewNick, e.User.Ident, e.User.Host, e.Client);
     AddLine(String.Format("{0} changed his nick to {1}", e.User.NickName, e.NewNick));
     Text = e.NewNick;
 }
コード例 #5
0
ファイル: QueryWindow.cs プロジェクト: hapm/IrcShark
 public QueryWindow(GUIIrcConnection baseCon, UserInfo user)
     : base(baseCon)
 {
     BoundedUserValue = user;
     IrcConnection con = baseCon.BaseConnection;
     con.PrivateMessageReceived += new PrivateMessageReceivedEventHandler(Client_PrivateMessageReceived);
     con.NickChangeReceived += new NickChangeReceivedEventHandler(Client_NickChangeReceived);
     con.QuitReceived += new QuitReceivedEventHandler(Client_QuitReceived);
     InitializeComponent();
     Text = user.NickName;
     MdiParent = baseCon.Status.MdiParent;
 }
コード例 #6
0
ファイル: QueryWindow.cs プロジェクト: hapm/IrcShark
 public QueryWindow(GUIIrcConnection baseCon, PrivateMessageReceivedEventArgs args)
     : base(baseCon)
 {
     if (args.Destination != args.Client.CurrentNick) throw new ArgumentOutOfRangeException("msg", "Received private message is no direct message");
     BoundedUserValue = args.Sender;
     IrcConnection con = baseCon.BaseConnection;
     con.PrivateMessageReceived += new PrivateMessageReceivedEventHandler(Client_PrivateMessageReceived);
     con.NickChangeReceived += new NickChangeReceivedEventHandler(Client_NickChangeReceived);
     con.QuitReceived += new QuitReceivedEventHandler(Client_QuitReceived);
     InitializeComponent();
     Text = args.Sender.NickName;
     MdiParent = baseCon.Status.MdiParent;
     Client_PrivateMessageReceived(args.Client, args);
 }
コード例 #7
0
        public PrivateMessageReceivedEventArgs(IrcLine baseLine)
            : base(baseLine)
        {
            sender = new UserInfo(baseLine);
            String line;
            line = Message;

            if (line[0] == '\x01' && line[line.Length - 1] == '\x01')
            {
                line = line.Substring(1, line.Length - 2);
                cTCPCommandString = line;
                int firstSpace = line.IndexOf(' ');

                if (firstSpace > 0)
                {
                    cTCPCommandString = line.Substring(0, firstSpace);
                    cTCPParameters = line.Substring(firstSpace + 1);
                }

                switch (cTCPCommandString)
                {
                    case "ACTION":
                        cTCPCommand = CTCPCommands.Action;
                        break;

                    case "VERSION":
                        cTCPCommand = CTCPCommands.Version;
                        break;

                    default:
                        cTCPCommand = CTCPCommands.Unkown;
                        break;
                }
            }
            else
            {
                cTCPCommand = CTCPCommands.None;
            }
        }
コード例 #8
0
ファイル: UserInfo.cs プロジェクト: hapm/IrcShark
 public UserInfo(UserInfo baseInfo)
 {
     baseLine = baseInfo.BaseLine;
     nickName = baseInfo.NickName;
     ident = baseInfo.Ident;
     host = baseInfo.Host;
     client = baseInfo.Client;
 }
コード例 #9
0
 public PartReceivedEventArgs(String ChannelName, UserInfo PartedUser)
     : base(PartedUser.Client)
 {
     channelName = ChannelName;
     user = PartedUser;
 }
コード例 #10
0
ファイル: IrcClient.cs プロジェクト: hapm/IrcShark
        /// <summary>
        /// Handles a line received from server.
        /// </summary>
        private void HandleLine(LineReceivedEventArgs e)
        {
            if (e.Line.IsNumeric)
            {
                if (NumericReceived != null) NumericReceived(this, new NumericReceivedEventArgs(e.Line));
                switch (e.Line.Numeric)
                {
                    case 1: // Parse the Server Info
                        currentNick = e.Line.Parameters[0];
                        networkName = e.Line.Parameters[1].Split(' ')[3];
                        myUserInfo = new UserInfo(e.Line.Parameters[1].Split(' ')[6], this);
                        break;

                    case 3: // Parse Welcome-Message
                        loggedIn = true;
                        if (Login != null)
                            Login(this, new LoginEventArgs(NetworkName, CurrentNick, this));
                        break;

                    case 376: // End of MOTD message
                        loggedIn = true;
                        if (Login != null)
                            Login(this, new LoginEventArgs(NetworkName, CurrentNick, this));
                        break;
                }
            }
            else
            {
                e.Handled = true;
                switch (e.Line.Command)
                {
                    case "PING": // Handle the Ping here
                        PingReceivedEventArgs pingArgs = new PingReceivedEventArgs(e.Line);
                        if (PingReceived != null)
                            PingReceived(this, pingArgs);
                        if (!pingArgs.Handled)
                            if (e.Line.Parameters.Length > 0)
                                SendLine("PONG :" + e.Line.Parameters[0]);
                            else
                                SendLine("PONG");
                        break;

                    case "JOIN": //Parse Join-Message
                        JoinReceivedEventArgs joinArgs = new JoinReceivedEventArgs(e.Line);
                        if (JoinReceived != null)
                            JoinReceived(this, joinArgs);
                        break;

                    case "PART": //Parse Part-Message
                        PartReceivedEventArgs partArgs = new PartReceivedEventArgs(e.Line);
                        if (PartReceived != null)
                            PartReceived(this, partArgs);
                        break;

                    case "QUIT": //Parse Quit-Message
                        QuitReceivedEventArgs quitArgs = new QuitReceivedEventArgs(e.Line);
                        if (QuitReceived != null)
                            QuitReceived(this, quitArgs);
                        break;

                    case "NICK": //Parse Nick-Message
                        if(e.Line.Client.ToString() == this.ToString())
                            this.currentNick = e.Line.Parameters[0];

                        NickChangeReceivedEventArgs nickChangeArgs = new NickChangeReceivedEventArgs(e.Line);
                        if (NickChangeReceived != null)
                            NickChangeReceived(this, nickChangeArgs);
                        break;

                    case "MODE": //Parse Mode-Message
                        ModeReceivedEventArgs modeArgs = new ModeReceivedEventArgs(e.Line);
                        if (ModeReceived != null)
                            ModeReceived(this, modeArgs);
                        break;

                    case "NOTICE": //Parse Notice-Message
                        NoticeReceivedEventArgs noticeArgs = new NoticeReceivedEventArgs(e.Line);
                        if (NoticeReceived != null)
                            NoticeReceived(this, noticeArgs);
                        break;

                    case "PRIVMSG": //Parse Private-Message
                        PrivateMessageReceivedEventArgs privmsgArgs = new PrivateMessageReceivedEventArgs(e.Line);
                        if (PrivateMessageReceived != null)
                            PrivateMessageReceived(this, privmsgArgs);
                        break;

                    case "KICK": //Parse Kick-Message
                        KickReceivedEventArgs kickArgs = new KickReceivedEventArgs(e.Line);
                        if (KickReceived != null)
                            KickReceived(this, kickArgs);
                        break;

                    default:
                        e.Handled = false;
                        break;
                }
            }
        }
コード例 #11
0
 public QuitReceivedEventArgs(UserInfo QuittedUser, String QuitMessage)
     : base(QuittedUser.Client)
 {
     user = QuittedUser;
 }