Пример #1
0
        /// <summary>
        /// Init a DCC Chat Session
        /// </summary>
        /// <param name="user">User to DCC</param>
        /// <param name="passive">Passive DCC</param>
        /// <param name="priority">Non Dcc Message Priority for Negotiation</param>
        public void InitDccChat(string user, bool passive, Priority priority)
        {
            var chat = new DccChat(this, user, ExternalIpAdress, passive, priority);

            _DccConnections.Add(chat);
            ThreadPool.QueueUserWorkItem(chat.InitWork);
            RemoveInvalidDccConnections();
        }
Пример #2
0
        private async Task CtcpFingerDelegate(CtcpEventArgs e) => await 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:"-") + ") " );

        private async Task CtcpDccDelegate(CtcpEventArgs e)
        {
            if (e.Data.MessageArray.Length < 2)
            {
                await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC missing parameters");
            }
            else
            {
                switch (e.Data.MessageArray[1])
                {
                case "CHAT":
                    var 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"))
                    {
                        if (!Int64.TryParse(FilterMarker(e.Data.MessageArray[6]), out long session))
                        {
                            break;
                        }

                        foreach (DccConnection dc in _DccConnections)
                        {
                            if (dc.SessionId == session)
                            {
                                ((DccSend)dc).SetRemote(e);
                                ((DccSend)dc).AcceptRequest(null, 0);
                                return;
                            }
                        }
                        await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid passive DCC");
                    }
                    else
                    {
                        var 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 dcs && dcs.TryResume(e))
                        {
                            return;
                        }
                    }
                    await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME");

                    break;

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

                    break;

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

                    break;

                default:
                    await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC " + e.CtcpParameter + " unavailable");

                    break;
                }
            }
        }