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; }
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); }
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); }
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"); } }
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; }
private void Write(string styleKey, IrcPeer peer, string text, bool attn) { this.Write(styleKey, DateTime.Now, peer, text, attn); }
public IrcTarget(IrcPeer peer) { this.Type = IrcTargetType.Nickname; this.Name = peer.Nickname; }
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"); } } } } } }
/// <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; }