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(); }
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); }
public WelcomeSchedulerSingleUserConfig(string userid, WelcomeSchedulerConfig config) { this.UserId = userid; this.Welcome = "${default}"; this.Bye = "${default}"; this.NameWelcome = "${default}"; this.NameBye = "${default}"; this.Init(config); }
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); }
public WelcomeTask(WelcomeSchedulerConfig config) : base(NAME) { this.Config = config; this.Builder = new MessageBuilder(this.Config); }
public void Initialize(IPluginManager loader, IPlugin[] plugins) { WelcomeSchedulerConfig config = LoadCofig(loader); loader.AddSchedule(new WelcomeTask(config)); }
public MessageBuilder(WelcomeSchedulerConfig config) { this.Config = config; }
public void Init(WelcomeSchedulerConfig config) { SetText(config); }