public override void Use(Player p, string message)
{
if (!Directory.Exists("extra/text/"))
{
Directory.CreateDirectory("extra/text");
}
if (message.IndexOf(' ') == -1)
{
Help(p); return;
}
try
{
if (message.Split(' ')[0].ToLower() == "delete")
{
if (File.Exists("extra/text/" + message.Split(' ')[1] + ".txt"))
{
File.Delete("extra/text/" + message.Split(' ')[1] + ".txt");
Player.SendMessage(p, "Deleted file");
}
else
{
Player.SendMessage(p, "Could not find file specified");
}
}
else
{
bool again = false;
string fileName = "extra/text/" + message.Split(' ')[0] + ".txt";
string group = Group.findPerm(LevelPermission.Guest).name;
if (Group.Find(message.Split(' ')[1]) != null)
{
group = Group.Find(message.Split(' ')[1]).name;
again = true;
}
message = message.Substring(message.IndexOf(' ') + 1);
if (again)
{
message = message.Substring(message.IndexOf(' ') + 1);
}
string contents = message;
if (contents == "")
{
Help(p); return;
}
if (!File.Exists(fileName))
{
contents = "#" + group + System.Environment.NewLine + contents;
}
else
{
contents = " " + contents;
}
File.AppendAllText(fileName, contents);
Player.SendMessage(p, "Added text");
}
} catch { Help(p); }
}