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

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="chaskisRoot">Where to find the configuration files.</param>
        public Chaskis(string chaskisRoot)
        {
            this.plugins         = null;
            this.defaultHandlers = null;
            this.plugins         = new Dictionary <string, PluginConfig>();
            this.fullyLoaded     = false;
            this.chaskisRoot     = chaskisRoot;
            this.httpClient      = new HttpClient();
            this.httpClient.DefaultRequestHeaders.Add("User-Agent", "Chaskis IRC Bot");
            // Leave the default timeout.  This was set to 10 seconds, but that may not be correct.
            // It takes 15 seconds for DNS to timeout, so a 10 second timeout probably doesn't make a ton of sense.

            this.parsingQueue = new StringParsingQueue();
        }
Exemple #2
0
        /// <summary>
        /// Loads plugins via a plugin list.
        /// </summary>
        /// <param name="pluginList">The list of plugins to load.</param>
        /// <returns>True if load was successful, else false.</returns>
        public bool InitStage2_LoadPlugins(IList <AssemblyConfig> pluginList)
        {
            if (this.ircConfig == null)
            {
                throw new InvalidOperationException(
                          nameof(this.ircConfig) + " is null.  Ensure " + nameof(this.InitState1_LoadIrcConfig) + " was call prior to this function."
                          );
            }

            PluginManager manager = new PluginManager();

            this.defaultHandlers = new DefaultHandlers();
            PluginConfig defaultChaskisPlugin = new PluginConfig(
                Assembly.GetExecutingAssembly().Location,
                DefaultHandlers.DefaultPluginName,
                new List <string>(), // No blacklisted channels
                this.defaultHandlers,
                new GenericLogger()
                );


            if (manager.LoadPlugins(
                    pluginList,
                    new List <PluginConfig>()
            {
                defaultChaskisPlugin
            },
                    this.ircConfig,
                    this.ircBot.Scheduler,
                    this.ircBot.ChaskisEventSender,
                    this.httpClient,
                    this.chaskisRoot
                    )
                )
            {
                this.plugins = manager.Plugins;
                return(true);
            }
            else
            {
                return(false);
            }
        }