示例#1
0
 private void IRC_Output(MessageInfo messageInfo)
 {
     AppendOutput(messageInfo.Content, Color.Black);
 }
示例#2
0
 private void IRC_Output(MessageInfo messageInfo)
 {
     WriteLine(messageInfo.Content);
 }
示例#3
0
        public static MessageInfo Parse(string content)
        {
            MessageInfo messageInfo = new MessageInfo(content);

            int index;
            string nickname = ParseSection(content, out index);

            // Is it not my message?
            if (nickname.StartsWith(":"))
            {
                nickname = nickname.Substring(1);
                int usernameIndex = nickname.IndexOf("!", StringComparison.Ordinal);

                // Is it not server?
                if (usernameIndex > -1)
                {
                    //nickname!~username@host
                    messageInfo.User.UserType = IRCUserType.User;
                    messageInfo.User.Nickname = nickname.Remove(usernameIndex);

                    nickname = nickname.Substring(usernameIndex + 1);

                    if (nickname[0] == '~') // Remove Ident character
                    {
                        nickname = nickname.Substring(1);
                    }

                    int hostIndex = nickname.IndexOf("@", StringComparison.Ordinal);
                    messageInfo.User.Username = nickname.Remove(hostIndex);
                    messageInfo.User.Host = nickname.Substring(hostIndex + 1);
                }
                else
                {
                    //irc.freenode.net
                    messageInfo.User.UserType = IRCUserType.Server;
                    messageInfo.User.Host = nickname;
                }

                content = content.Substring(index + 1);
                messageInfo.Command = ParseSection(content, out index);
            }
            else
            {
                // It is my command
                messageInfo.User.UserType = IRCUserType.Me;
                messageInfo.Command = nickname;
            }

            while (index > -1)
            {
                content = content.Substring(index + 1);
                string check = ParseSection(content, out index);

                // Is it parameter?
                if (!check.StartsWith(":"))
                {
                    messageInfo.Parameters.Add(check);
                }
                else
                {
                    // It is message
                    messageInfo.Message = content.Substring(1);
                    break;
                }
            }

            return messageInfo;
        }
示例#4
0
文件: IRC.cs 项目: Jaex/IRCLib
        private void ParseWHOIS(MessageInfo messageInfo)
        {
            UserInfo userInfo;

            switch (messageInfo.Command)
            {
                case "311": //:sendak.freenode.net 311 Jaex ShareX ~ShareX unaffiliated/sharex * :realname
                    if (messageInfo.Parameters.Count >= 4)
                    {
                        userInfo = new UserInfo();
                        userInfo.Nickname = messageInfo.Parameters[1];

                        if (messageInfo.Parameters[2][1] == '~')
                        {
                            userInfo.Username = messageInfo.Parameters[2].Substring(1);
                        }
                        else // Ident
                        {
                            userInfo.Username = messageInfo.Parameters[2];
                        }

                        userInfo.Host = messageInfo.Parameters[3];
                        userInfo.Realname = messageInfo.Message;

                        userList.Add(userInfo);
                    }
                    break;
                case "319": //:sendak.freenode.net 319 Jaex ShareX :@#ShareX @#ShareX_Test
                    if (messageInfo.Parameters.Count >= 2)
                    {
                        userInfo = FindUser(messageInfo.Parameters[1]);

                        if (userInfo != null)
                        {
                            userInfo.Channels.Clear();
                            userInfo.Channels.AddRange(messageInfo.Message.Split());
                        }
                    }
                    break;
                case "312": //:sendak.freenode.net 312 Jaex ShareX sendak.freenode.net :Vilnius, Lithuania, EU
                    if (messageInfo.Parameters.Count >= 3)
                    {
                        userInfo = FindUser(messageInfo.Parameters[1]);

                        if (userInfo != null)
                        {
                            userInfo.Server = messageInfo.Parameters[2];
                        }
                    }
                    break;
                case "671": //:sendak.freenode.net 671 Jaex ShareX :is using a secure connection
                    if (messageInfo.Parameters.Count >= 2)
                    {
                        userInfo = FindUser(messageInfo.Parameters[1]);

                        if (userInfo != null)
                        {
                            userInfo.SecureConnection = true;
                        }
                    }
                    break;
                case "317": //:sendak.freenode.net 317 Jaex ShareX 39110 1440201914 :seconds idle, signon time
                    if (messageInfo.Parameters.Count >= 4)
                    {
                        userInfo = FindUser(messageInfo.Parameters[1]);

                        if (userInfo != null)
                        {
                            int idleTime;
                            if (int.TryParse(messageInfo.Parameters[2], out idleTime))
                            {
                                userInfo.IdleTime = TimeSpan.FromSeconds(idleTime);
                            }

                            int signOnTime;
                            if (int.TryParse(messageInfo.Parameters[3], out signOnTime))
                            {
                                userInfo.SignOnDate = Helpers.UnixToDateTime(signOnTime).ToLocalTime();
                            }
                        }
                    }
                    break;
                case "330": //:sendak.freenode.net 330 Jaex ShareX ShareX :is logged in as
                    if (messageInfo.Parameters.Count >= 3)
                    {
                        userInfo = FindUser(messageInfo.Parameters[1]);

                        if (userInfo != null)
                        {
                            userInfo.Identity = messageInfo.Parameters[2];
                        }
                    }
                    break;
                case "318": //:sendak.freenode.net 318 Jaex ShareX :End of /WHOIS list.
                    if (messageInfo.Parameters.Count >= 2)
                    {
                        userInfo = FindUser(messageInfo.Parameters[1]);

                        if (userInfo != null)
                        {
                            userList.Remove(userInfo);
                            OnWhoisResult(userInfo);
                        }
                    }
                    break;
            }
        }
示例#5
0
文件: IRC.cs 项目: Jaex/IRCLib
 protected void OnOutput(MessageInfo messageInfo)
 {
     if (Output != null)
     {
         Output(messageInfo);
     }
 }
示例#6
0
文件: IRC.cs 项目: Jaex/IRCLib
        private void CheckMessage(MessageInfo messageInfo)
        {
            string channel = messageInfo.Parameters[0];

            OnMessage(messageInfo.User, channel, messageInfo.Message);

            if (messageInfo.User.UserType == IRCUserType.User)
            {
                HandleAutoResponse(channel, messageInfo.User.Nickname, messageInfo.Message.ToLowerInvariant());
            }
        }