Пример #1
0
 internal AliasEventArgs(string name, string[] arguments, IrcPeer from, IrcTarget to, IrcTarget replyTo)
 {
     this.Name = name;
     this.Arguments = new List<string>(arguments).AsReadOnly();
     this.From = from;
     this.To = to;
     this.ReplyTo = replyTo;
 }
Пример #2
0
        public void Demand(IrcPeer peer, params string[] permissions)
        {
            if (permissions == null || permissions.Length == 0)
            {
                throw new ArgumentException("At least one permission must be specified.");
            }

            if (permissions.Length == 1 && permissions[0] == "?")
            {
                return;
            }

            User user = this.Recognize(peer);
            if (user == null)
            {
                throw new SecurityException(string.Format(CultureInfo.InvariantCulture,
                    "Permission denied for {0} to {1}", string.Join(",", permissions), peer.Prefix));
            }

            Demand(user, permissions);
        }
Пример #3
0
 private void Write(string styleKey, IrcPeer peer, string text, bool attn)
 {
     this.Write(styleKey, string.Format("{0}@{1}", peer.Username, peer.Hostname).GetHashCode(),
         this.GetNickWithLevel(peer.Nickname), text, attn);
 }
Пример #4
0
 private void Write(string styleKey, IrcPeer peer, string text, bool attn)
 {
     this.Write(styleKey, string.Format("{0}@{1}", peer.Username, peer.Hostname).GetHashCode(),
         this.GetNickWithLevel(peer.Nickname), text, attn);
     if (!boxOutput.IsAutoScrolling)
     {
         App.DoEvent("beep");
     }
 }
Пример #5
0
        public User Recognize(IrcPeer peer)
        {
            if (string.IsNullOrEmpty(peer.Prefix))
            {
                return null;
            }

            foreach (User user in _users)
            {
                if (Regex.IsMatch(peer.Prefix, "^" + user.Mask + "$"))
                {
                    return user;
                }
            }
            return null;
        }
Пример #6
0
 private void Write(string styleKey, IrcPeer peer, string text, bool attn)
 {
     this.Write(styleKey, DateTime.Now, peer, text, attn);
 }
Пример #7
0
 public IrcTarget(IrcPeer peer)
 {
     this.Type = IrcTargetType.Nickname;
     this.Name = peer.Nickname;
 }
Пример #8
0
        private void Session_PrivateMessaged(object sender, IrcMessageEventArgs e)
        {
            if (App.IsIgnoreMatch(e.From, e.To.IsChannel ? IgnoreActions.Channel : IgnoreActions.Private))
            {
                return;
            }

            if (!this.IsServer)
            {
                if ((this.Target.IsChannel && this.Target.Equals(e.To)) ||
                    (!this.Target.IsChannel && this.Target.Equals(new IrcTarget(e.From)) && !e.To.IsChannel))
                {
                    bool attn = false;
                    if (App.IsAttentionMatch(this.Session.Nickname, e.Text))
                    {
                        attn = true;
                        if (_window != null)
                        {
                            App.Alert(_window, string.Format("You received an alert from {0}", this.Target.Name));
                        }
                        if (this.VisualParent == null)
                        {
                            this.NotifyState = NotifyState.Alert;
                            App.DoEvent("inactiveAlert");
                        }
                        else if (_window != null && !_window.IsActive)
                        {
                            App.DoEvent("inactiveAlert");
                        }
                        else
                        {
                            App.DoEvent("activeAlert");
                        }
                    }

                    if (e.From.Prefix.Equals("*[email protected]"))
                    {
                        int space = e.Text.IndexOf(' ');
                        String subject = e.Text.Substring(0, space);
                        String text = e.Text.Substring(space + 1);

                        IrcPeer peer = new IrcPeer(subject);
                        String styleKey = "Default";

                        // TODO: Rewrite text if it doesn't match how Floe writes it.
                        if (text.StartsWith("set mode")) // sNickMask + " set mode: " + sModes + " " + sArgs
                        {
                            styleKey = "Mode";
                        }
                        else if (text.StartsWith("kicked")) // OpNick.GetNickMask() + " kicked " + sKickedNick + " Reason: [" + sMessage + "]"
                        {
                            styleKey = "Kick";
                        }
                        else if (text.StartsWith("quit")) // Nick.GetNickMask() + " quit with message: [" + sMessage + "]"
                        {
                            styleKey = "Quit";
                        }
                        else if (text.StartsWith("joined")) // Nick.GetNickMask() + " joined"
                        {
                            styleKey = "Join";
                        }
                        else if (text.StartsWith("parted")) // Nick.GetNickMask() + " parted with message: [" + sMessage + "]"
                        {
                            styleKey = "Part";
                        }
                        else if (text.StartsWith("is now known as")) // OldNick.GetNickMask() + " is now known as " + sNewNick
                        {
                            styleKey = "Nick";
                        }
                        else if (text.StartsWith("changed the topic")) // Nick.GetNickMask() + " changed the topic to: " + sTopic
                        {
                            styleKey = "Topic";
                        }
                        this.Write(styleKey, e.Message.Time, string.Format("{0} {1}", peer.Nickname, text));
                    }
                    else
                    {
                        this.Write("Default", e.Message.Time, e.From, e.Text, attn);

                        if (!this.Target.IsChannel)
                        {
                            if (e.From.Prefix != _prefix)
                            {
                                _prefix = e.From.Prefix;
                                this.SetTitle();
                            }
                            Interop.WindowHelper.FlashWindow(_window);
                            if (this.VisualParent == null)
                            {
                                App.DoEvent("privateMessage");
                            }
                        }
                    }
                }
            }
        }
Пример #9
0
		/// <summary>
		/// Construct an IrcTarget from an IrcPeer. This is useful when replying to a received message.
		/// </summary>
		/// <param name="peer"></param>
		public IrcTarget(IrcPeer peer)
		{
			this.IsChannel = false;
			this.Name = peer.Nickname;
		}
Пример #10
0
 /// <summary>
 /// Construct an IrcTarget from an IrcPeer. This is useful when replying to a received message.
 /// </summary>
 /// <param name="peer"></param>
 public IrcTarget(IrcPeer peer)
 {
     this.IsChannel = false;
     this.Name      = peer.Nickname;
 }