Пример #1
0
 /// <summary>
 /// Raises the NewMessage event.
 /// </summary>
 /// <param name="e">The event data.</param>
 protected void OnNewMessage(PrivateMessageEventArgs e)
 {
     if (e != null)
     {
         NewMessage?.Invoke(this, e);
     }
 }
Пример #2
0
        /// <summary>
        /// Event handling method for <see cref="Irc.IrcClient.PrivateMessageReceived"/>event.
        /// </summary>
        /// <param name="sender">The <see cref="Irc.IRfc2812"/> object raising the event.</param>
        /// <param name="e">The event data for the event.</param>
        protected override void OnPrivateMessageReceived(object sender, PrivateMessageEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            if (e.MessageTarget is IrcNickname)
            {
                if ((IrcNickname)e.MessageTarget == Client.Nickname && RemoteUser.Nickname == e.Nickname)
                {
                    OnNewMessage(e);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Sends a message to the remote user.
        /// </summary>
        /// <param name="message">The message to send.</param>
        /// <exception cref="System.InvalidOperationException">Throw if ConnectionState is not Registered.</exception>
        /// <exception cref="System.IO.IOException">Thrown if there is a problem communicating with the server.</exception>
        /// <exception cref="System.ArgumentNullException">Thrown if message is null.</exception>
        /// <exception cref="System.ObjectDisposedException">Thrown if the object has been disposed of.</exception>
        public virtual void SendMessage(string message)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(this.GetType().ToString());
            }
            if (string.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException(nameof(message));
            }

            Client.SendMessage(TargetName, message);

            PrivateMessageEventArgs pmea = new PrivateMessageEventArgs(Client.Nickname, TargetName)
            {
                UserName    = Client.Username,
                RealName    = Client.RealName,
                Message     = message,
                IsLocalEcho = true
            };

            OnNewMessage(pmea);
        }
Пример #4
0
 /// <summary>
 /// Event handling method for <see cref="Irc.IRfc2812.PrivateMessageReceived"/> event to be
 /// overridden in derived classes.
 /// </summary>
 /// <param name="sender">The <see cref="Irc.IRfc2812"/> object raising the event.</param>
 /// <param name="e">The event data for the event.</param>
 protected abstract void OnPrivateMessageReceived(object sender, PrivateMessageEventArgs e);
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Irc.PrivateMessage"/> class.
 /// </summary>
 /// <param name="user">The remote user the message is open with.</param>
 /// <param name="connection">The server connection the message belongs to.</param>
 /// <param name="incomingMessage">The incoming message that initiated the private message conversation.</param>
 /// <exception cref="System.ArgumentNullException">Thrown if user or connection are null.</exception>
 public PrivateMessage(User user, IIrcxProtocol connection, PrivateMessageEventArgs incomingMessage)
     : this(user, connection)
 {
     OpeningMessage = incomingMessage;
 }