Example #1
0
        public void AdminLog(string message, bool systemMsg = false)
        {
            message = CP437Writer.ConvertToUnicode(message);
            if (ServerAdminLog != null)
            {
                ServerAdminLog(message);
                if (canceladmin)
                {
                    canceladmin = false; return;
                }
            }

            string now = DateTime.Now.ToString("(HH:mm:ss) ");

            if (OnAdmin != null)
            {
                if (!systemMsg)
                {
                    OnAdmin(now + message);
                }
                else
                {
                    OnSystem(now + message);
                }
            }
            Logger.Write(now + message + Environment.NewLine);
        }
Example #2
0
        public void Log(string message, bool systemMsg = false)
        {
            message = CP437Writer.ConvertToUnicode(message);
            if (ServerLog != null)
            {
                ServerLog(message);
                if (cancellog)
                {
                    cancellog = false; return;
                }
            }
            if (!systemMsg)
            {
                OnServerLogEvent.Call(message);
            }

            string now = DateTime.Now.ToString("(HH:mm:ss) ");

            if (!systemMsg && OnLog != null)
            {
                OnLog(now + message);
            }
            if (systemMsg && OnSystem != null)
            {
                OnSystem(now + message);
            }
            Logger.Write(now + message + Environment.NewLine);
        }
Example #3
0
        /// <summary> Change the ban reason for the given user. </summary>
        public static string EditReason(string who, string reason)
        {
            who    = who.ToLower();
            reason = reason.Replace(" ", "%20");
            bool          found = false;
            StringBuilder sb    = new StringBuilder();

            foreach (string line in File.ReadAllLines("text/bans.txt"))
            {
                string[] parts = line.Split(' ');
                if (parts.Length > 2 && parts[1] == who)
                {
                    parts[2] = CP437Writer.ConvertToUnicode(reason);
                    found    = true;
                    sb.Append(String.Join(" ", parts) + "\r\n");
                }
                else
                {
                    sb.Append(line + "\r\n");
                }
            }

            if (found)
            {
                File.WriteAllText("text/bans.txt", sb.ToString());
                return("");
            }
            return("This player isn't banned!");
        }
Example #4
0
        public void OpLog(string message, bool systemMsg = false)
        {
            message = CP437Writer.ConvertToUnicode(message);
            if (ServerOpLog != null)
            {
                OpLog(message);
                if (canceloplog)
                {
                    canceloplog = false;
                    return;
                }
            }
            if (OnOp != null)
            {
                if (!systemMsg)
                {
                    OnOp(DateTime.Now.ToString("(HH:mm:ss) ") + message);
                }
                else
                {
                    OnSystem(DateTime.Now.ToString("(HH:mm:ss) ") + message);
                }
            }

            Logger.Write(DateTime.Now.ToString("(HH:mm:ss) ") + message + Environment.NewLine);
        }
Example #5
0
        static bool ChangeReason(string who, string reason, PlayerMetaList list)
        {
            who    = who.ToLower();
            reason = reason.Replace(" ", "%20");
            bool          success = false;
            StringBuilder sb      = new StringBuilder();

            foreach (string line in File.ReadAllLines(list.file))
            {
                string[] parts = line.Split(' ');
                if (parts.Length > 2 && parts[1] == who)
                {
                    parts[2] = CP437Writer.ConvertToUnicode(reason);
                    success  = true;
                    sb.AppendLine(String.Join(" ", parts));
                }
                else
                {
                    sb.AppendLine(line);
                }
            }

            if (success)
            {
                File.WriteAllText(list.file, sb.ToString());
            }
            return(success);
        }
Example #6
0
        /// <summary> Adds the given line to the end of the file. </summary>
        public void Append(string data)
        {
            string line = CP437Writer.ConvertToUnicode(data);

            lock (locker) {
                using (StreamWriter w = new StreamWriter(file, true))
                    w.WriteLine(line);
            }
        }
Example #7
0
 public void CommandUsed(string message)
 {
     message = CP437Writer.ConvertToUnicode(message);
     if (OnCommand != null)
     {
         OnCommand(DateTime.Now.ToString("(HH:mm:ss) ") + message);
     }
     Logger.Write(DateTime.Now.ToString("(HH:mm:ss) ") + message + Environment.NewLine);
 }
Example #8
0
 static string ConvertMessage(string message, bool color)
 {
     if (String.IsNullOrEmpty(message.Trim()))
     {
         message = ".";
     }
     message = CP437Writer.ConvertToUnicode(message);
     if (color)
     {
         message = Colors.MinecraftToIrcColors(message.Replace("%r", ResetSignal));
     }
     return(message);
 }
Example #9
0
        static string ConvertMessage(string message, bool color)
        {
            if (String.IsNullOrEmpty(message.Trim()))
            {
                message = ".";
            }
            message = EmotesHandler.Replace(message);
            message = FullCP437Handler.Replace(message);
            message = ChatTokens.ApplyCustom(message);
            message = CP437Writer.ConvertToUnicode(message);

            if (color)
            {
                message = Colors.MinecraftToIrcColors(message.Replace("%S", ResetSignal));
            }
            return(message);
        }