Exemplo n.º 1
0
        private void Session_CtcpCommandReceived(object sender, CtcpEventArgs e)
        {
            var session = sender as IrcSession;

            if (!e.IsResponse)
            {
                switch (e.Command.Command)
                {
                    case "VERSION":
                        session.SendCtcp(new IrcTarget(e.From), new CtcpCommand(
                            "VERSION",
                            App.Product,
                            App.Version), true);
                        break;
                    case "PING":
                        session.SendCtcp(new IrcTarget(e.From), new CtcpCommand(
                            "PONG",
                            e.Command.Arguments.Length > 0 ? e.Command.Arguments[0] : null), true);
                        break;
                    case "CLIENTINFO":
                        session.SendCtcp(new IrcTarget(e.From), new CtcpCommand(
                            "CLIENTINFO",
                            "VERSION", "PING", "CLIENTINFO", "ACTION"), true);
                        break;
                }
            }
        }
Exemplo n.º 2
0
        private void session_CtcpCommandReceived(object sender, CtcpEventArgs e)
        {
            VoiceCodec codec;
            int quality;
            IPAddress pubAddress, prvAddress;
            int pubPort, prvPort;

            if (!this.IsChatting)
            {
                return;
            }

            if (string.Compare(e.Command.Command, "VCHAT", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (e.Command.Arguments.Length == 7 &&
                string.Compare(e.Command.Arguments[0], "START", StringComparison.OrdinalIgnoreCase) == 0 &&
                (!e.To.IsChannel || e.To.Equals(_target)) &&
                Enum.TryParse(e.Command.Arguments[1], out codec) &&
                int.TryParse(e.Command.Arguments[2], out quality) &&
                IPAddress.TryParse(e.Command.Arguments[3], out pubAddress) &&
                int.TryParse(e.Command.Arguments[4], out pubPort) &&
                IPAddress.TryParse(e.Command.Arguments[5], out prvAddress) &&
                int.TryParse(e.Command.Arguments[6], out prvPort) &&
                pubPort > 0 && pubPort <= ushort.MaxValue &&
                prvPort > 0 && prvPort <= ushort.MaxValue)
                {
                    // if they're behind the same NAT, use the local address
                    if (pubAddress.Equals(_publicEndPoint.Address))
                    {
                        pubAddress = prvAddress;
                        pubPort = prvPort;
                    }
                    this.AddPeer(e.From.Nickname, codec, quality, new IPEndPoint(pubAddress, pubPort));
                    if (!e.IsResponse && e.To.IsChannel)
                    {
                        _session.SendCtcp(new IrcTarget(e.From), new CtcpCommand("VCHAT", "START",
                            VoiceCodec.Gsm610.ToString(),
                            App.Settings.Current.Voice.Quality.ToString(),
                            _publicEndPoint.Address.ToString(),
                            _publicEndPoint.Port.ToString(),
                            _session.InternalAddress.ToString(),
                            _voice.LocalEndPoint.Port.ToString()), true);
                    }
                }
                else if (e.Command.Arguments.Length == 1 &&
                    string.Compare(e.Command.Arguments[0], "STOP", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    this.RemovePeer(e.From.Nickname);
                }
            }
        }
Exemplo n.º 3
0
		private void Session_CtcpCommandReceived(object sender, CtcpEventArgs e)
		{
			if (App.IsIgnoreMatch(e.From, IgnoreActions.Ctcp))
			{
				return;
			}

			var session = sender as IrcSession;

			if (!e.IsResponse)
			{
				switch (e.Command.Command)
				{
					case "VERSION":
						session.SendCtcp(new IrcTarget(e.From), new CtcpCommand(
							"VERSION",
							App.Product,
							App.Version), true);
						break;
					case "PING":
						session.SendCtcp(new IrcTarget(e.From), new CtcpCommand(
							"PONG",
							e.Command.Arguments.Length > 0 ? new string[] { e.Command.Arguments[0] } : new string[0]), true);
						break;
					case "CLIENTINFO":
						session.SendCtcp(new IrcTarget(e.From), new CtcpCommand(
							"CLIENTINFO",
							"VERSION", "PING", "CLIENTINFO", "ACTION"), true);
						break;
					case "DCC":
						var args = e.Command.Arguments;
						e.Handled = this.HandleDcc(session, new IrcTarget(e.From), args);
						break;
				}
			}
		}
Exemplo n.º 4
0
        private void Session_CtcpCommandReceived(object sender, CtcpEventArgs e)
        {
            if (App.IsIgnoreMatch(e.From, IgnoreActions.Ctcp))
            {
                return;
            }

            if (((this.IsChannel && this.Target.Equals(e.To)) ||
                (this.IsNickname && this.Target.Equals(new IrcTarget(e.From)) && !e.To.IsChannel))
                && e.Command.Command == "ACTION")
            {
                string text = string.Join(" ", e.Command.Arguments);
                bool attn = false;
                if (App.IsAttentionMatch(this.Session.Nickname, text))
                {
                    attn = true;
                    if (_window != null)
                    {
                        Interop.WindowHelper.FlashWindow(_window);
                    }
                }

                this.Write("Action", e.Message.Time, string.Format("{0} {1}", e.From.Nickname, text, attn));
            }
            else if (this.IsServer && e.Command.Command != "ACTION" && e.From != null)
            {
                this.Write("Ctcp", e.Message.Time, e.From, string.Format("[CTCP {1}] {2}",
                    e.From.Nickname, e.Command.Command,
                    e.Command.Arguments.Length > 0 ? string.Join(" ", e.Command.Arguments) : ""), false);
            }
        }