Exemple #1
0
        // -------- Constructor --------

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ircConfig">The irc config object to use.  This will be cloned after being passed in.</param>
        /// <param name="parsingQueue">The global parsing queue we are using.</param>
        public IrcBot(IIrcConfig ircConfig, INonDisposableStringParsingQueue parsingQueue)
        {
            ArgumentChecker.IsNotNull(ircConfig, nameof(ircConfig));
            ArgumentChecker.IsNotNull(parsingQueue, nameof(parsingQueue));

            this.ircConfig = ircConfig.Clone();
            this.IrcConfig = new ReadOnlyIrcConfig(this.ircConfig);

            IrcConnection connection = new IrcConnection(ircConfig, parsingQueue);

            this.ircConnection = connection;

            this.parsingQueue = parsingQueue;
        }
Exemple #2
0
        // -------- Constructor --------

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ircConfig">The irc config object to use.  This will be cloned after being passed in.</param>
        /// <param name="ircHandlers">The line configs to be used in this bot.</param>
        /// <param name="infoLogEvent">The event to do if we want to log information.</param>
        /// <param name="errorLogEvent">The event to do if an error occurrs.</param>
        public IrcBot(IIrcConfig ircConfig, IList <IIrcHandler> ircHandlers, Action <string> infoLogEvent, Action <string> errorLogEvent)
        {
            ArgumentChecker.IsNotNull(ircConfig, nameof(ircConfig));
            ArgumentChecker.IsNotNull(ircHandlers, nameof(ircHandlers));

            this.ircConfig = ircConfig.Clone();
            this.IrcConfig = new ReadOnlyIrcConfig(this.ircConfig);

            this.ircHandlers = ircHandlers;

            IrcConnection connection = new IrcConnection(ircConfig);

            connection.ReadEvent = delegate(string line)
            {
                foreach (IIrcHandler config in this.ircHandlers)
                {
                    config.HandleEvent(line, this.ircConfig, connection);
                }
            };
            connection.InfoLogEvent  = infoLogEvent;
            connection.ErrorLogEvent = errorLogEvent;

            this.ircConnection = connection;
        }