namespace StreamBuddy.PluginInterface.IRC
{
    /// <summary>
    /// A delegate used for events dealing with user changes, joins/parts etc.
    /// </summary>
    /// <param name="User">The users in question.</param>
    public delegate void UserDelegate(params Users.IUser[] User);
    /// <summary>
    /// A delegate used for events dealing with unhandled messages.
    /// </summary>
    /// <param name="Sender">The sender of the message.</param>
    /// <param name="Message">The message itself.</param>
    /// <returns>true if the message was successfully handled by this delegate.</returns>
    public delegate bool? MessageHandlingDelegate(Users.IUser Sender, string Message);
    /// <summary>
    /// A delegate used for events dealing with already handled messages.
    /// </summary>
    /// <param name="Sender">The sender of the message.</param>
    /// <param name="Message">The message itself.</param>
    public delegate void MessageDelegate(Users.IUser Sender, string Message);

    public interface IIRCConnection
    {
        /// <summary>
        /// Called as a message arrives in the channel, before processing
        /// </summary>
        event MessageHandlingDelegate PreMessage;
		/// <summary>
		/// Called afer a message has been processed and executed as a commadn.
		/// </summary>
		event MessageDelegate OnCommand;
        /// <summary>
        /// Called after a message has been processed, as long as it's not a command
        /// </summary>
        event MessageDelegate OnMessage;
        /// <summary>
        /// Called after a message has been processed, regardless of it's a command or not
        /// </summary>
        event MessageDelegate OnMessageOrCommand;
		/// <summary>
		/// Called when a twitch notification is sent.
		/// </summary>
		event MessageDelegate OnTwitchNotify;
        /// <summary>
        /// Called when a user joins the stream.
        /// </summary>
        event UserDelegate UserJoin;
        /// <summary>
        /// Called when a user leaves the stream.
        /// </summary>
        event UserDelegate UserLeave;

        /// <summary>
        /// Sends a messge to the stream.
        /// </summary>
        /// <param name="Message">The text of the message</param>
        /// <param name="Priority">The priority of the message, defaults to <seealso cref="MessagePriority.Text"/></param>
        void SendPrivmsg(string Message, MessagePriority Priority = MessagePriority.Text);
        /// <summary>
        /// Sends a message to the stream.
        /// </summary>
        /// <param name="Message">The text of the message.</param>
        /// <param name="Objects">The objects to format the message with.</param>
        void SendMessage(string Message, params object[] Objects);

        /// <summary>
        /// Convenience functions for sending a reply to a specified user.
        /// </summary>
        /// <param name="User">The user to reply to.</param>
        /// <param name="Message">The message in the reply.</param>
        /// <param name="Objects">Objects for formatting the input string.</param>
        void Reply(Users.IUser User, string Message, params object[] Objects);
        /// <summary>
        /// Times a user out of the stream.
        /// </summary>
        /// <param name="User">The user to time out.</param>
        /// <param name="Seconds">The time they're to be timed out for, in seconds.</param>
        void Timeout(Users.IUser User, int Seconds = 600);
        /// <summary>
        /// Bans a user from the stream.
        /// </summary>
        /// <param name="User">The user to ban.</param>
        void Ban(Users.IUser User);

		void Unban(Users.IUser User);
    }
}
