Ejemplo n.º 1
0
        protected override void LoadConfig(XElement moduleEl)
        {
            base.LoadConfig(moduleEl);

            foreach (var feedEl in moduleEl.Elements("feed"))
            {
                var feed = new RssFeed();
                BotModule.LoadProperties(feed, feedEl);
                if (_feeds.ContainsKey(feed.Name))
                {
                    throw new BotConfigException(string.Format(
                                                     "An RSS feed with the name {0} already exists.", feed.Name));
                }
                try
                {
                    feed.CatchUp();
                    _feeds.Add(feed.Name, feed);
                }
                catch (Exception ex)
                {
                    throw new BotConfigException(string.Format(
                                                     "An RSS feed with the name {0} could not be loaded: {1}", feed.Name, ex.Message));
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadConfig()
        {
            if (string.IsNullOrEmpty(_configPath))
            {
                throw new BotConfigException("No configuration path was provided.");
            }

            XDocument doc;

            try
            {
                doc = XDocument.Load(_configPath);
            }
            catch (Exception ex)
            {
                throw new BotConfigException(ex);
            }

            var root = doc.Root;

            if (root.Name != "bot")
            {
                throw new BotConfigException("Missing 'bot' element.");
            }

            BotModule.LoadProperties(this, root);

            foreach (var startupEl in root.Elements("startup"))
            {
                _startup.Add(startupEl.Value);
            }

            foreach (var moduleEl in root.Elements("module"))
            {
                this.LoadModule(moduleEl);
            }

            this.Irc = new IrcSession();
            BotModule.LoadProperties(this.Irc, root);

            this.Security = this.GetModule(typeof(Security)) as Security;
            if (this.Security == null)
            {
                throw new InvalidOperationException("There must be a configured Security module.");
            }
            this.Aliases = this.GetModule(typeof(Aliases)) as Aliases;
            if (this.Aliases == null)
            {
                throw new InvalidOperationException("There must be a configured Aliases module.");
            }
            this.Channels = this.GetModule(typeof(Channels)) as Channels;
            if (this.Channels == null)
            {
                throw new InvalidOperationException("There must be a configured Channels module.");
            }
        }
Ejemplo n.º 3
0
        protected override void LoadConfig(System.Xml.Linq.XElement moduleEl)
        {
            base.LoadConfig(moduleEl);

            foreach (var userEl in moduleEl.Elements("user"))
            {
                var user = new User();
                BotModule.LoadProperties(user, userEl);
                if (_userIndex.ContainsKey(user.Name))
                {
                    throw new BotConfigException(string.Format(
                                                     "There are multiple users with the name {0}.", user.Name));
                }
                _users.Add(user);
                _userIndex.Add(user.Name, user);
            }
        }
Ejemplo n.º 4
0
 protected virtual void LoadConfig(XElement moduleEl)
 {
     BotModule.LoadProperties(this, moduleEl);
 }