Beispiel #1
0
        private static void LoadAdditionalConfig(IPluginManager loader, WelcomeSchedulerConfig config)
        {
            var files = GetAdditionalConfigFiles(loader);

            if (files.Length == 0)
            {
                return;
            }
            var pairs = new List <WelcomeSchedulerSingleUserConfig>();

            pairs.AddRange(config.IdTextPairs);
            foreach (var f in files)
            {
                try {
                    var c = loader.LoadConfig <WelcomeSchedulerSingleUserConfig>(f);
                    if (c != null)
                    {
                        pairs.Add(c);
                    }
                } catch (Exception e) {
                    Logger.DebugLog(e.ToString());
                }
            }
            var checkedPairs = new List <WelcomeSchedulerSingleUserConfig>();

            foreach (var pair in pairs)
            {
                checkedPairs.RemoveAll(p => p.UserId == pair.UserId);
                checkedPairs.Add(pair);
            }
            config.IdTextPairs = checkedPairs.ToArray();
        }
Beispiel #2
0
 private void SetText(WelcomeSchedulerConfig config)
 {
     this.Welcome     = this.Welcome.Replace("${default}", config.DefaultWelcome);
     this.Bye         = this.Bye.Replace("${default}", config.DefaultBye);
     this.NameWelcome = this.NameWelcome.Replace("${default}", config.DefaultNameWelcome);
     this.NameBye     = this.NameBye.Replace("${default}", config.DefaultNameBye);
 }
Beispiel #3
0
 public WelcomeSchedulerSingleUserConfig(string userid, WelcomeSchedulerConfig config)
 {
     this.UserId      = userid;
     this.Welcome     = "${default}";
     this.Bye         = "${default}";
     this.NameWelcome = "${default}";
     this.NameBye     = "${default}";
     this.Init(config);
 }
Beispiel #4
0
        private static WelcomeSchedulerConfig LoadCofig(IPluginManager loader)
        {
            WelcomeSchedulerConfig config;

            try {
                config = loader.GetPluginSetting <WelcomeSchedulerConfig>(NAME);
            } catch (System.IO.FileNotFoundException) {
                config = null;
            } catch (System.Exception e) {
                Logger.DebugLog(e.ToString());
                config = null;
            }
            if (config == null)
            {
                config = new WelcomeSchedulerConfig();
            }
            LoadAdditionalConfig(loader, config);
            config.Init();
            return(config);
        }
Beispiel #5
0
 public WelcomeTask(WelcomeSchedulerConfig config) : base(NAME)
 {
     this.Config  = config;
     this.Builder = new MessageBuilder(this.Config);
 }
Beispiel #6
0
        public void Initialize(IPluginManager loader, IPlugin[] plugins)
        {
            WelcomeSchedulerConfig config = LoadCofig(loader);

            loader.AddSchedule(new WelcomeTask(config));
        }
Beispiel #7
0
 public MessageBuilder(WelcomeSchedulerConfig config)
 {
     this.Config = config;
 }
Beispiel #8
0
 public void Init(WelcomeSchedulerConfig config)
 {
     SetText(config);
 }