Inheritance: IrcEventArgs
コード例 #1
1
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpDccDelegate(CtcpEventArgs e)
 {
     if (e.Data.MessageArray.Length < 2) {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC missing parameters");
     } else {
         switch(e.Data.MessageArray[1]) {
             case "CHAT":
                 DccChat chat = new DccChat(this, _ExternalIpAdress, e);
                 _DccConnections.Add(chat);
                 ThreadPool.QueueUserWorkItem(new WaitCallback(chat.InitWork));
                 break;
             case "SEND":
                 if (e.Data.MessageArray.Length > 6 &&  (FilterMarker(e.Data.MessageArray[6]) != "T")) {
                     long session = -1;
                     long.TryParse(FilterMarker(e.Data.MessageArray[6]), out session);
                     foreach(DccConnection dc in _DccConnections) {
                         if(dc.isSession(session)) {
                             ((DccSend)dc).SetRemote(e);
                             ((DccSend)dc).AcceptRequest(null, 0);
                                return;
                         }
                     }
                     SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid passive DCC");
                 } else {
                     DccSend send = new DccSend(this, _ExternalIpAdress, e);
                     _DccConnections.Add(send);
                     ThreadPool.QueueUserWorkItem(new WaitCallback(send.InitWork));
                 }
                 break;
             case "RESUME":
                 foreach(DccConnection dc in _DccConnections) {
                     if((dc is DccSend) && (((DccSend)dc).TryResume(e))) {
                         return;
                     }
                 }
                 SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME");
                 break;
             case "ACCEPT":
                 foreach(DccConnection dc in _DccConnections) {
                     if((dc is DccSend) && (((DccSend)dc).TryAccept(e))) {
                         return;
                     }
                 }
                 SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC ACCEPT");
                 break;
             case "XMIT":
                 SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC XMIT not implemented");
                 break;
             default:
                 SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC "+e.CtcpParameter+" unavailable");
                 break;
         }
     }
 }
コード例 #2
0
ファイル: DccSend.cs プロジェクト: hnjm/IrcBots
        internal bool TryResume(CtcpEventArgs e)
        {
            if (User == e.Data.Nick)
            {
                if ((e.Data.MessageArray.Length > 4) && (_Filename == e.Data.MessageArray[2].Trim(new char[] { '\"' })))
                {
                    long offset = 0;
                    long.TryParse(FilterMarker(e.Data.MessageArray[4]), out offset);
                    if (_File.CanSeek)
                    {
                        if (e.Data.MessageArray.Length > 5)
                        {
                            Irc.SendMessage(SendType.CtcpRequest, e.Data.Nick, "DCC ACCEPT " + e.Data.MessageArray[2] + " " + e.Data.MessageArray[3] + " " + e.Data.MessageArray[4] + " " + FilterMarker(e.Data.MessageArray[5]));
                        }
                        else
                        {
                            Irc.SendMessage(SendType.CtcpRequest, e.Data.Nick, "DCC ACCEPT " + e.Data.MessageArray[2] + " " + e.Data.MessageArray[3] + " " + FilterMarker(e.Data.MessageArray[4]));
                        }

                        _File.Seek(offset, SeekOrigin.Begin);
                        _SentBytes = offset;
                        return(true);
                    }
                    else
                    {
                        Irc.SendMessage(SendType.CtcpRequest, e.Data.Nick, "ERRMSG DCC File not seekable");
                    }
                }
            }
            return(false);
        }
コード例 #3
0
 /// <summary>
 /// Constructor of a DCC Chat for a Incoming DCC Chat Request
 /// </summary>
 /// <param name="irc">IrcFeature Class</param>
 /// <param name="externalIpAdress">Our externally reachable IP Adress</param>
 /// <param name="e">The Ctcp Event which initiated this constructor</param>
 internal DccChat(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e)
 {
     Irc = irc;
     ExternalIPAdress = externalIpAdress;
     User             = e.Data.Nick;
     if (e.Data.MessageArray.Length > 4)
     {
         bool okIP = Int64.TryParse(e.Data.MessageArray[3], out long ip);
         bool okPo = Int32.TryParse(FilterMarker(e.Data.MessageArray[4]), out int port);  // port 0 = passive
         if ((e.Data.MessageArray[2] == "chat") && okIP && okPo)
         {
             RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
             if (e.Data.MessageArray.Length > 5 && e.Data.MessageArray[5] != "T")
             {
                 AcceptRequest();    // Since we initated the Request, we accept DCC
                 return;             // No OnDccChatRequestEvent Event! (we know that we want a connection)
             }
             DccChatRequestEvent(new DccEventArgs(this));
             return;
         }
         else
         {
             irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Chat Parameter Error");
         }
     }
     else
     {
         irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Chat not enough parameters");
     }
     isValid = false;
 }
コード例 #4
0
ファイル: DccSend.cs プロジェクト: Suchiman/Irc4netButSmarter
        internal DccSend(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e)
        {
            /* Remote Request */
            Irc          = irc;
            _DirectionUp = false;
            User         = e.Data.Nick;

            if (e.Data.MessageArray.Length > 4)
            {
                long filesize = 0;
                if (e.Data.MessageArray.Length > 5)
                {
                    bool okFs = Int64.TryParse(FilterMarker(e.Data.MessageArray[5]), out filesize);
                    _Filesize = filesize;
                    _Filename = e.Data.MessageArray[2].Trim('"');
                }

                if (Int64.TryParse(e.Data.MessageArray[3], out long ip) && Int32.TryParse(e.Data.MessageArray[4], out int port)) // port 0 = passive
                {
                    RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
                    DccSendRequestEvent(new DccSendRequestEventArgs(this, e.Data.MessageArray[2], filesize));
                    return;
                }
                irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send Parameter Error");
            }
            else
            {
                irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send not enough parameters");
            }
        }
コード例 #5
0
ファイル: DccChat.cs プロジェクト: ByteCat/RedChat
 /// <summary>
 /// Constructor of a DCC Chat for a Incoming DCC Chat Request
 /// </summary>
 /// <param name="irc">IrcFeature Class</param>
 /// <param name="externalIpAdress">Our externally reachable IP Adress</param>
 /// <param name="e">The Ctcp Event which initiated this constructor</param>
 internal DccChat(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e) : base ()
 {
     this.Irc = irc;
     this.ExternalIPAdress = externalIpAdress;
     this.User = e.Data.Nick;
     
     long ip; int port;
     if (e.Data.MessageArray.Length > 4) {
         bool okIP = long.TryParse(e.Data.MessageArray[3], out ip);
         bool okPo = int.TryParse(FilterMarker(e.Data.MessageArray[4]), out port);  // port 0 = passive
         if((e.Data.MessageArray[2]=="chat") && okIP && okPo) {
             RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
             if (e.Data.MessageArray.Length > 5 && e.Data.MessageArray[5] != "T") {
                this.AcceptRequest();    // Since we initated the Request, we accept DCC
                return;                    // No OnDccChatRequestEvent Event! (we know that we want a connection)
             }
             DccChatRequestEvent(new DccEventArgs(this));
             return;
         } else {
             irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Chat Parameter Error");
         }
     } else {
         irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Chat not enough parameters");
     }
     this.isValid = false;
 }
コード例 #6
0
ファイル: DccSend.cs プロジェクト: groma84/IrcBots
        internal DccSend(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e)
            : base()
        {
            /* Remote Request */
            this.Irc = irc;
            _DirectionUp = false;
            User = e.Data.Nick;

            if (e.Data.MessageArray.Length > 4) {
                long ip, filesize = 0; int port = 0;
                bool okIP = long.TryParse(e.Data.MessageArray[3], out ip);
                bool okPo = int.TryParse(e.Data.MessageArray[4], out port);  // port 0 = passive
                if (e.Data.MessageArray.Length > 5) {
                    bool okFs = long.TryParse(FilterMarker(e.Data.MessageArray[5]), out filesize);
                    _Filesize = filesize;
                    _Filename = e.Data.MessageArray[2].Trim(new char[] {'\"'});
                }
                if (okIP && okPo) {
                    RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
                    DccSendRequestEvent(new DccSendRequestEventArgs(this, e.Data.MessageArray[2], filesize));
                    return;
                } else {
                    irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send Parameter Error");
                }
            } else {
                irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send not enough parameters");
            }
        }
コード例 #7
0
ファイル: DccSend.cs プロジェクト: hnjm/IrcBots
        internal DccSend(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e) : base()
        {
            /* Remote Request */
            this.Irc     = irc;
            _DirectionUp = false;
            User         = e.Data.Nick;

            if (e.Data.MessageArray.Length > 4)
            {
                long ip, filesize = 0; int port = 0;
                bool okIP = long.TryParse(e.Data.MessageArray[3], out ip);
                bool okPo = int.TryParse(e.Data.MessageArray[4], out port);  // port 0 = passive
                if (e.Data.MessageArray.Length > 5)
                {
                    bool okFs = long.TryParse(FilterMarker(e.Data.MessageArray[5]), out filesize);
                    _Filesize = filesize;
                    _Filename = e.Data.MessageArray[2].Trim(new char[] { '\"' });
                }
                if (okIP && okPo)
                {
                    RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
                    DccSendRequestEvent(new DccSendRequestEventArgs(this, e.Data.MessageArray[2], filesize));
                    return;
                }
                else
                {
                    irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send Parameter Error");
                }
            }
            else
            {
                irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send not enough parameters");
            }
        }
コード例 #8
0
        private void CtcpClientInfoDelegate(CtcpEventArgs e)
        {
            string clientInfo = "CLIENTINFO";

            foreach (KeyValuePair <string, CtcpDelegate> kvp in _CtcpDelegates)
            {
                clientInfo = clientInfo + " " + kvp.Key.ToUpper();
            }
            SendMessage(SendType.CtcpReply, e.Data.Nick, clientInfo);
        }
コード例 #9
0
ファイル: DccSend.cs プロジェクト: Suchiman/Irc4netButSmarter
 internal bool SetRemote(CtcpEventArgs e)
 {
     // port 0 = passive
     if (Int64.TryParse(e.Data.MessageArray[3], out long ip) && Int32.TryParse(e.Data.MessageArray[4], out int port))
     {
         RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
         return(true);
     }
     return(false);
 }
コード例 #10
0
 private void CtcpPingDelegate(CtcpEventArgs e)
 {
     if (e.Data.Message.Length > 7)
     {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PING " + e.Data.Message.Substring(6, (e.Data.Message.Length - 7)));
     }
     else
     {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PING");    //according to RFC, it should be PONG!
     }
 }
コード例 #11
0
 /// <summary>
 ///  This is the correct Rfc Ping Delegate, which is not used because all other clients do not use the PING According to RfC
 /// </summary>
 /// <param name="e"></param>
 private void CtcpRfcPingDelegate(CtcpEventArgs e)
 {
     if (e.Data.Message.Length > 7)
     {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PONG " + e.Data.Message.Substring(6, (e.Data.Message.Length - 7)));
     }
     else
     {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PONG");
     }
 }
コード例 #12
0
ファイル: DccSend.cs プロジェクト: hnjm/IrcBots
 internal bool TryAccept(CtcpEventArgs e)
 {
     if (User == e.Data.Nick)
     {
         if ((e.Data.MessageArray.Length > 4) && (_Filename == e.Data.MessageArray[2].Trim(new char[] { '\"' })))
         {
             return(this.AcceptRequest(null, 0));
         }
     }
     return(false);
 }
コード例 #13
0
 private void CtcpRequestsHandler(object sender, CtcpEventArgs e)
 {
     if (_CtcpDelegates.ContainsKey(e.CtcpCommand))
     {
         _CtcpDelegates[e.CtcpCommand].Invoke(e);
     }
     else
     {
         /* No CTCP Handler for this Command */
     }
     RemoveInvalidDccConnections();
 }
コード例 #14
0
ファイル: DccSend.cs プロジェクト: hnjm/IrcBots
        internal bool SetRemote(CtcpEventArgs e)
        {
            long ip;
            int  port = 0;
            bool okIP = long.TryParse(e.Data.MessageArray[3], out ip);
            bool okPo = int.TryParse(e.Data.MessageArray[4], out port);  // port 0 = passive

            if (okIP && okPo)
            {
                RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
                return(true);
            }
            return(false);
        }
コード例 #15
0
        public static void irc_OnCtcpRequest(object sender, CtcpEventArgs e)
        {
            switch (e.CtcpCommand)
            {
                case "VERSION":
                    irc.SendMessage(SendType.CtcpReply, e.Data.Nick,
                                    "\rVERSION" + " Bot version: r" + Revision.bot_revision + "-trunk");

                    break;

                case "TIME":
                    irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "\rtime \r" + DateTime.Now);
                    break;
            }
        }
コード例 #16
0
ファイル: HappyNewYear.cs プロジェクト: bsamuels453/Pikatwo
        void ClientOnOnCtcpReply(object sender, CtcpEventArgs ctcpEventArgs)
        {
            try{
                var strTime = ctcpEventArgs.CtcpParameter;
                var semicolonIdx = strTime.IndexOf(':');
                var timeStr = strTime.Substring(semicolonIdx - 2, 5);

                var hourStr = timeStr.Substring(0, 2);
                var hour = int.Parse(hourStr);
                var diff = hour - DateTime.Now.Hour;
                var userNick = ctcpEventArgs.Data.Nick;
                var userChannel = _activeCtcp.Where(usr => usr.Nick.Equals(userNick)).ToList()[0].Channel;
                _usersToGreet.Add(new User(userNick, userChannel, diff));
            }
            catch (Exception e){
                int g = 5;
            }
        }
コード例 #17
0
 private void CtcpUrlDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "URL " + ((CtcpUrl == null)?"http://www.google.com":CtcpUrl));
 }
コード例 #18
0
 private void CtcpUserInfoDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "USERINFO " + ((CtcpUserInfo == null)?"No user info given.":CtcpUserInfo));
 }
コード例 #19
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpPingDelegate(CtcpEventArgs e)
 {
     if (e.Data.Message.Length > 7) {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PING "+e.Data.Message.Substring(6, (e.Data.Message.Length-7)));
     } else {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PING");    //according to RFC, it should be PONG!
     }
 }
コード例 #20
0
 private void CtcpVersionDelegate(CtcpEventArgs e) => SendMessage(SendType.CtcpReply, e.Data.Nick, "VERSION " + (CtcpVersion ?? VersionString));
コード例 #21
0
ファイル: DccSend.cs プロジェクト: groma84/IrcBots
 internal bool TryAccept(CtcpEventArgs e)
 {
     if (User == e.Data.Nick) {
         if ((e.Data.MessageArray.Length > 4) && (_Filename == e.Data.MessageArray[2].Trim(new char[] {'\"'}))) {
             return this.AcceptRequest(null, 0);
         }
     }
     return false;
 }
コード例 #22
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 /// <summary>
 ///  This is the correct Rfc Ping Delegate, which is not used because all other clients do not use the PING According to RfC
 /// </summary>
 /// <param name="e"></param>
 private void CtcpRfcPingDelegate(CtcpEventArgs e)
 {
     if (e.Data.Message.Length > 7) {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PONG "+e.Data.Message.Substring(6, (e.Data.Message.Length-7)));
     } else {
         SendMessage(SendType.CtcpReply, e.Data.Nick, "PONG");
     }
 }
コード例 #23
0
        private void CtcpDccDelegate(CtcpEventArgs e)
        {
            if (e.Data.MessageArray.Length < 2)
            {
                SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC missing parameters");
            }
            else
            {
                switch (e.Data.MessageArray[1])
                {
                case "CHAT":
                    DccChat chat = new DccChat(this, _ExternalIpAdress, e);
                    _DccConnections.Add(chat);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(chat.InitWork));
                    break;

                case "SEND":
                    if (e.Data.MessageArray.Length > 6 && (FilterMarker(e.Data.MessageArray[6]) != "T"))
                    {
                        long session = -1;
                        long.TryParse(FilterMarker(e.Data.MessageArray[6]), out session);
                        foreach (DccConnection dc in _DccConnections)
                        {
                            if (dc.isSession(session))
                            {
                                ((DccSend)dc).SetRemote(e);
                                ((DccSend)dc).AcceptRequest(null, 0);
                                return;
                            }
                        }
                        SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid passive DCC");
                    }
                    else
                    {
                        DccSend send = new DccSend(this, _ExternalIpAdress, e);
                        _DccConnections.Add(send);
                        ThreadPool.QueueUserWorkItem(new WaitCallback(send.InitWork));
                    }
                    break;

                case "RESUME":
                    foreach (DccConnection dc in _DccConnections)
                    {
                        if ((dc is DccSend) && (((DccSend)dc).TryResume(e)))
                        {
                            return;
                        }
                    }
                    SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME");
                    break;

                case "ACCEPT":
                    foreach (DccConnection dc in _DccConnections)
                    {
                        if ((dc is DccSend) && (((DccSend)dc).TryAccept(e)))
                        {
                            return;
                        }
                    }
                    SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC ACCEPT");
                    break;

                case "XMIT":
                    SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC XMIT not implemented");
                    break;

                default:
                    SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC " + e.CtcpParameter + " unavailable");
                    break;
                }
            }
        }
コード例 #24
0
ファイル: IrcProtocolManager.cs プロジェクト: RoninBG/smuxi
 private void _OnCtcpRequest(object sender, CtcpEventArgs e)
 {
     Session.AddTextToChat(_NetworkChat, String.Format(
                                     _("{0} [{1}] requested CTCP {2} from {3}: {4}"),
                                     e.Data.Nick, e.Data.Ident+"@"+e.Data.Host,
                                     e.CtcpCommand, _IrcClient.Nickname,
                                     e.CtcpParameter));
 }
コード例 #25
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpUserInfoDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "USERINFO " + ((CtcpUserInfo==null)?"No user info given.":CtcpUserInfo));
 }
コード例 #26
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpVersionDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "VERSION " + ((CtcpVersion==null)?VersionString:CtcpVersion));
 }
コード例 #27
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpUrlDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "URL " + ((CtcpUrl==null)?"http://www.google.com":CtcpUrl));
 }
コード例 #28
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpTimeDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "TIME " + DateTime.Now.ToString("r"));
 }
コード例 #29
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpSourceDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "SOURCE " + ((CtcpSource==null)?"http://smartirc4net.meebey.net":CtcpSource));
 }
コード例 #30
0
 private void CtcpSourceDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "SOURCE " + ((CtcpSource == null)?"http://smartirc4net.meebey.net":CtcpSource));
 }
コード例 #31
0
 private void CtcpUserInfoDelegate(CtcpEventArgs e) => SendMessage(SendType.CtcpReply, e.Data.Nick, "USERINFO " + (CtcpUserInfo ?? "No user info given."));
コード例 #32
0
 private void CtcpFingerDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "FINGER Don't touch little Helga there! ");
     //SendMessage(SendType.CtcpReply, e.Data.Nick, "FINGER " + this.Realname + " (" + this.Email + ") Idle " + this.Idle + " seconds (" + ((string.IsNullOrEmpty(this.Reason))?this.Reason:"-") + ") " );
 }
コード例 #33
0
ファイル: IrcProtocolManager.cs プロジェクト: txdv/smuxi
 private void _OnCtcpRequest(object sender, CtcpEventArgs e)
 {
     Session.AddTextToChat(_NetworkChat,
         String.Format(
             // TRANSLATOR: {0}: nickname, {1}: ident@host,
             // {2}: CTCP command, {3}: own nickname, {4}: CTCP parameter
             // example:
             // meebey [[email protected]] requested CTCP VERSION from meebey:
             _("{0} [{1}] requested CTCP {2} from {3}: {4}"),
             e.Data.Nick, e.Data.Ident+"@"+e.Data.Host,
             e.CtcpCommand, _IrcClient.Nickname,
             e.CtcpParameter
         )
     );
 }
コード例 #34
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpClientInfoDelegate(CtcpEventArgs e)
 {
     string clientInfo = "CLIENTINFO";
     foreach(KeyValuePair<string, CtcpDelegate> kvp in _CtcpDelegates) {
         clientInfo = clientInfo+" "+kvp.Key.ToUpper();
     }
     SendMessage(SendType.CtcpReply, e.Data.Nick, clientInfo);
 }
コード例 #35
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpRequestsHandler(object sender, CtcpEventArgs e)
 {
     if (_CtcpDelegates.ContainsKey(e.CtcpCommand)) {
         _CtcpDelegates[e.CtcpCommand].Invoke(e);
     } else {
         /* No CTCP Handler for this Command */
     }
     RemoveInvalidDccConnections();
 }
コード例 #36
0
ファイル: IrcProtocolManager.cs プロジェクト: txdv/smuxi
        private void _OnCtcpReply(object sender, CtcpEventArgs e)
        {
            ChatModel chat = GetChat(e.Data);
            if (chat == null) {
                chat = _NetworkChat;
            }

            if (e.CtcpCommand == "PING") {
                try {
                    long timestamp = Int64.Parse(e.CtcpParameter);
                    if (!(timestamp >= 0)) {
                        return;
                    }
                    DateTime sent = DateTime.FromFileTime(timestamp);
                    string duration = DateTime.Now.Subtract(sent).TotalSeconds.ToString();

                    Session.AddTextToChat(chat, String.Format(
                                                    _("CTCP PING reply from {0}: {1} seconds"),
                                                    e.Data.Nick, duration));

                } catch (FormatException) {
                }
            } else {
                Session.AddTextToChat(chat, String.Format(
                                            _("CTCP {0} reply from {1}: {2}"),
                                            e.CtcpCommand, e.Data.Nick, e.CtcpParameter));
            }
        }
コード例 #37
0
 private void CtcpSourceDelegate(CtcpEventArgs e) => SendMessage(SendType.CtcpReply, e.Data.Nick, "SOURCE " + (CtcpSource ?? "http://smartirc4net.meebey.net"));
コード例 #38
0
ファイル: DccSend.cs プロジェクト: groma84/IrcBots
 internal bool SetRemote(CtcpEventArgs e)
 {
     long ip;
     int port = 0;
     bool okIP = long.TryParse(e.Data.MessageArray[3], out ip);
     bool okPo = int.TryParse(e.Data.MessageArray[4], out port);  // port 0 = passive
     if (okIP && okPo) {
         RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
         return true;
     }
     return false;
 }
コード例 #39
0
 private void CtcpUrlDelegate(CtcpEventArgs e) => SendMessage(SendType.CtcpReply, e.Data.Nick, "URL " + (CtcpUrl ?? "http://www.google.com"));
コード例 #40
0
ファイル: DccSend.cs プロジェクト: groma84/IrcBots
        internal bool TryResume(CtcpEventArgs e)
        {
            if (User == e.Data.Nick) {
                if ((e.Data.MessageArray.Length > 4) && (_Filename == e.Data.MessageArray[2].Trim(new char[] {'\"'}))) {
                    long offset = 0;
                    long.TryParse(FilterMarker(e.Data.MessageArray[4]), out offset);
                    if (_File.CanSeek) {
                        if (e.Data.MessageArray.Length > 5) {
                            Irc.SendMessage(SendType.CtcpRequest, e.Data.Nick, "DCC ACCEPT " + e.Data.MessageArray[2] + " " + e.Data.MessageArray[3] + " " + e.Data.MessageArray[4] + " " + FilterMarker(e.Data.MessageArray[5]));
                        } else {
                            Irc.SendMessage(SendType.CtcpRequest, e.Data.Nick, "DCC ACCEPT " + e.Data.MessageArray[2] + " " + e.Data.MessageArray[3] + " " + FilterMarker(e.Data.MessageArray[4]));
                        }

                        _File.Seek(offset, SeekOrigin.Begin);
                        _SentBytes = offset;
                        return true;
                    } else {
                        Irc.SendMessage(SendType.CtcpRequest, e.Data.Nick, "ERRMSG DCC File not seekable");
                    }
                }
            }
            return false;
        }
コード例 #41
0
 private void CtcpTimeDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "TIME " + DateTime.Now.ToString("r"));
 }
コード例 #42
0
ファイル: DccSend.cs プロジェクト: Suchiman/Irc4netButSmarter
 internal bool TryAccept(CtcpEventArgs e) => User == e.Data.Nick && e.Data.MessageArray.Length > 4 && _Filename == e.Data.MessageArray[2].Trim('"') && AcceptRequest(null, 0);
コード例 #43
0
ファイル: IrcFeatures.cs プロジェクト: groma84/IrcBots
 private void CtcpFingerDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "FINGER Don't touch little Helga there! " );
     //SendMessage(SendType.CtcpReply, e.Data.Nick, "FINGER " + this.Realname + " (" + this.Email + ") Idle " + this.Idle + " seconds (" + ((string.IsNullOrEmpty(this.Reason))?this.Reason:"-") + ") " );
 }
コード例 #44
0
		void ClientOnCtcpRequest(object sender, CtcpEventArgs e)
		{
			_events.Enqueue(new IrcEvent { Type = IrcEvent.EventType.CtcpRequest, Event = e });
			_waitHandle.Set();
		}
コード例 #45
0
 private void CtcpVersionDelegate(CtcpEventArgs e)
 {
     SendMessage(SendType.CtcpReply, e.Data.Nick, "VERSION " + ((CtcpVersion == null)?VersionString:CtcpVersion));
 }