void LoginTimerElapsed(object sender, ElapsedEventArgs e) { if (!Loading) { loginTimer.Stop(); if (File.Exists("text/welcome.txt")) { try { List <string> welcome = CP437Reader.ReadAllLines("text/welcome.txt"); foreach (string w in welcome) { SendMessage(w); } } catch { } } else { Server.s.Log("Could not find Welcome.txt. Using default."); CP437Writer.WriteAllText("text/welcome.txt", "Welcome to my server!"); SendMessage("Welcome to my server!"); } loginTimer.Dispose(); extraTimer.Start(); } }
static void LoadBadWords() { if (!File.Exists("text/badwords.txt")) { // No file exists yet, so let's create one StringBuilder sb = new StringBuilder(); sb.AppendLine("# This file contains a list of bad words to remove via the profanity filter"); sb.AppendLine("# Each bad word should be on a new line all by itself"); File.WriteAllText("text/badwords.txt", sb.ToString()); } List <string> lines = CP437Reader.ReadAllLines("text/badwords.txt"); // Run the badwords through the reducer to ensure things like Ls become Is and everything is lowercase filters = new List <string>(); foreach (string line in lines) { if (line.StartsWith("#") || line.Trim().Length == 0) { continue; } string word = Reduce(line.ToLower()); filters.Add(word); } }
public static List <string> GetInfectMessages(Player p) { if (p.name == null || !Directory.Exists("text/infect")) { return(null); } string path = InfectPath(p.name); return(File.Exists(path) ? CP437Reader.ReadAllLines(path) : null); }
public static void InitAll() { List <string> lines = CP437Reader.ReadAllLines(filename); Group grp = null; PropertiesFile.Read(filename, ref grp, ParseProperty, '=', false); if (grp != null) { AddGroup(ref grp); } }
void InitTimers() { updateTimer.Elapsed += delegate { Entities.GlobalUpdate(); PlayerBot.GlobalUpdatePosition(); }; updateTimer.Start(); if (File.Exists("text/messages.txt")) { messages = CP437Reader.ReadAllLines("text/messages.txt"); } else { using (File.Create("text/messages.txt")) {} } Server.MainScheduler.QueueRepeat(RandomMessage, null, TimeSpan.FromMinutes(5)); }