Inheritance: StringPacket
        protected override string ResolveAuth(IrcUser user, IrcPacket packet)
        {
            packet.Content.SkipWord();

            var nick = packet.Content.NextWord();
            if (nick == user.Nick)
            {
                user.AuthName = nick;
                return nick;
            }
            return null;
        }
        protected override string OnAuthPacketReceived(IrcUser user, IrcPacket packet)
        {
            packet.Content.SkipWord();

            var nick = packet.Content.NextWord();
            if (nick == user.Nick)
            {
                var userName = packet.Content.NextWord();
                return userName;
            }
            return null;
        }
Esempio n. 3
0
        /// <summary>
        /// Build a packet from a new line of content from the server.
        /// Do as much parsing as possible here before the packet-handler
        /// will then work with the gathered information.
        /// </summary>
        public IrcPacket CreatePacket(string content)
        {
            var line = new StringStream(content.Trim());

            string prefix;

            if (content[0] == ':')
            {
                prefix = line.NextWord().Substring(1);
            }
            else
            {
                prefix = line.NextWord();
            }

            var action = line.NextWord();
            var packet = new IrcPacket(irc, prefix, action, new StringStream(line.Remainder.Trim()), line.String)
            {
                protHandler = this
            };

            return(packet);
        }
 /// <summary>
 /// Returns the auth name of the given user or null if not the right one
 /// </summary>
 /// <param name="packet"></param>
 /// <returns></returns>
 protected abstract string OnAuthPacketReceived(IrcUser user, IrcPacket packet);
Esempio n. 5
0
 /// <summary>
 /// Fires when an Error reply has been sent by the network (raw is greater than 399).
 /// </summary>
 /// <param name="from">Usually the name of the current server</param>
 /// <param name="error">The raw numeric</param>
 /// <param name="preArgs">All command arguments (before a ":")</param>
 /// <param name="postArgs">All further arguments, probably describing the problem</param>
 protected virtual void OnError(IrcPacket packet)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Fires when network-specific Informations are sent (raw 005).
 /// </summary>
 /// <param name="pairs">A Dictionary, containing all information, indexed case-insensitively. Value is "" if the information isnt a pair.</param>
 protected virtual void OnConnectionInfo(IrcPacket packet, Dictionary<string, string> pairs)
 {
     // TODO: Improve authenticator detection
     if ("QuakeNet".Equals(Network.Name, StringComparison.InvariantCultureIgnoreCase))
     {
         // found Quakenet
         AuthMgr.Authenticator = new QuakenetAuthenticator();
     }
     else if ("freenode".Equals(Network.Name, StringComparison.InvariantCultureIgnoreCase))
     {
         AuthMgr.Authenticator = new NickServAuthenticator("320");
     }
 }
Esempio n. 7
0
 internal void UnspecifiedInfoNotify(IrcPacket packet)
 {
     OnUnspecifiedInfo(packet);
 }
Esempio n. 8
0
 internal void ErrorNotify(IrcPacket packet)
 {
     OnError(packet);
 }
Esempio n. 9
0
        internal void ConnectionInfoNotify(IrcPacket packet)
        {
            var args = packet.Content.Remainder;
            var index = args.IndexOf(':');
            if (index > -1)
            {
                args = args.Substring(0, index);
            }

            var words = args.Split(' ');
            m_server = packet.Prefix;
            var pairs = new Dictionary<string, string>(words.Length, StringComparer.InvariantCultureIgnoreCase);

            for (var i = 1; i < words.Length; i++)
            {
                string key, value;
                if (words[i].IndexOf('=') < 0)
                {
                    key = words[i];
                    value = "";
                }
                else
                {
                    var pair = words[i].Split('=');
                    key = pair[0];
                    value = pair[1];
                }
                pairs[key] = value;
                switch (key.ToUpper())
                {
                    case "CHANTYPES":
                        m_CTypes = value;
                        break;
                    case "MAXNICKLEN":
                        if (!int.TryParse(value, out m_MaxNickLen))
                        {
                            m_MaxNickLen = 30;
                        }
                        break;
                    case "PREFIX":
                        var pair = value.Substring(1).Split(')');
                        m_CPrefixes = pair[0];
                        m_CSymbols = pair[1];
                        break;
                    case "CHANMODES":
                        m_CModes = value;
                        break;
                    case "NETWORK":
                        Network.Name = value;
                        break;
                }
            }
            if (Network.Name != null)
            {
                OnConnectionInfo(packet, pairs);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Fires when an information is sent that is not captured by the intern protocol handler.
 /// </summary>
 protected virtual void OnUnspecifiedInfo(IrcPacket packet)
 {
 }
Esempio n. 11
0
        /// <summary>
        /// Build a packet from a new line of content from the server.
        /// Do as much parsing as possible here before the packet-handler
        /// will then work with the gathered information.
        /// </summary>
        public IrcPacket CreatePacket(string content)
        {
            var line = new StringStream(content.Trim());

            string prefix;
            if (content[0] == ':')
            {
                prefix = line.NextWord().Substring(1);
            }
            else
            {
                prefix = line.NextWord();
            }

            var action = line.NextWord();
            var packet = new IrcPacket(irc, prefix, action, new StringStream(line.Remainder.Trim()), line.String)
            {
                protHandler = this
            };

            return packet;
        }
 /// <summary>
 /// Returns null if not the right one
 /// </summary>
 /// <param name="packet"></param>
 /// <returns></returns>
 protected abstract string ResolveAuth(IrcUser user, IrcPacket packet);
Esempio n. 13
0
 protected static void OnReceive(IrcPacket packet)
 {
     if(DisplayIrcPackets)
         Console.WriteLine("<-- " + packet);
 }
Esempio n. 14
0
 protected override void OnError(IrcPacket packet)
 {
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine("({0}) <IRC Interface> ERROR: {1}", DateTime.Now.ToString("hh:mm"), packet.ToString());
 }
Esempio n. 15
0
 protected void OnReceive(IrcPacket packet)
 {
     if (HideIncomingIrcPackets != true)
     {
         Console.ForegroundColor = ConsoleColor.Green;
         Console.WriteLine("({0}) <IRC Interface> <-- {1}", DateTime.Now.ToString("hh:mm"), packet);
     }
 }