Пример #1
0
 private static void PrepareTemplate(ISettingsStore settingsStore, string reason, StringTemplater templater)
 {
     templater.AddParameter("AdminName", settingsStore.AdminName);
     templater.AddParameter("Reason", reason);
     templater.AddParameter("Date", () => DateTime.UtcNow.ToString("dd.MM.yy"));
     templater.AddParameter("Time", () => DateTime.UtcNow.ToString("HH:mm:ss"));
 }
Пример #2
0
        public void TemplateParametersTest()
        {
            var templater = new StringTemplater();

            templater.AddParameter("Param", "value");
            var actual = templater.Template("some text {Param}");

            Assert.AreEqual("some text value", actual);
        }
Пример #3
0
        public string GetBanMessage(ISettingsStore settingsStore, string reason, long minutes)
        {
            // [{AdminName}][{Date} {Time}] {Reason}
            var templater = new StringTemplater();

            PrepareTemplate(settingsStore, reason, templater);

            templater.AddParameter("Minutes", minutes == 0 ? $"perm" : $"{minutes}");

            return(templater.Template(settingsStore.BanMessageTemplate));
        }