using System; using System.Collections.Generic; using System.Text.RegularExpressions; using ExitGames.Client.Photon.Chat; namespace CLre_server.Tweaks.Chat { public static class ModeratorCommands { [ChatCommand("KICK", "kick ([\\w\\d\\-_]+)")] public static void KickInButt(Match messageMatch, ChatClient connection, string sender) { if (!API.MainServer.Moderator.Instance.IsModerator(sender)) { connection.PublishMessage(ChatListener.ChatName, "Ban failure: You're not a mod :("); return; } string target = messageMatch.Groups[1].Value; #if DEBUG API.Utility.Logging.MetaLog($"/kick {target}"); #endif if (API.MainServer.Moderator.Instance.DisconnectPlayerById(target)) { connection.PublishMessage(ChatListener.ChatName, $"Adios {target}"); } else if (API.MainServer.Moderator.Instance.DisconnectPlayerByName(target)) { connection.PublishMessage(ChatListener.ChatName, $"Bye bye {target}"); } else { connection.PublishMessage(ChatListener.ChatName, "Kick failure: User not found :("); } } [ChatCommand("BAN", "ban ([\\w\\d\\-_]+)")] public static void BanishIdiot(Match messageMatch, ChatClient connection, string sender) { if (!API.MainServer.Moderator.Instance.IsModerator(sender)) { connection.PublishMessage(ChatListener.ChatName, "Ban failure: You're not a mod :("); return; } string target = messageMatch.Groups[1].Value; #if DEBUG API.Utility.Logging.MetaLog($"/ban {target}"); #endif if (API.MainServer.Moderator.Instance.BanPlayerById(target)) { connection.PublishMessage(ChatListener.ChatName, $"And {target} is no more!"); } else if (API.MainServer.Moderator.Instance.BanPlayerByName(target)) { connection.PublishMessage(ChatListener.ChatName, $"And {target} was never seen again..."); } else { connection.PublishMessage(ChatListener.ChatName, "Ban failure: User not found :("); } } [ChatCommand("(SH)OPIFY", "(mod|op) ([\\w\\d\\-_]+)")] public static void GoPro(Match messageMatch, ChatClient connection, string sender) { if (!API.MainServer.Moderator.Instance.IsModerator(sender)) { connection.PublishMessage(ChatListener.ChatName, "Op failure: You're not a mod :("); return; } string target = messageMatch.Groups[2].Value; #if DEBUG API.Utility.Logging.MetaLog($"/op {target}"); #endif List moderators = new List(CLre.Config.moderators); moderators.Add(target); CLre.Config.moderators = moderators.ToArray(); connection.PublishMessage(ChatListener.ChatName, $"Promoted {target} to moderator"); } [ChatCommand("De(SH)OPIFY", "(demod|deop) ([\\w\\d\\-_]+)")] public static void AntiProton(Match messageMatch, ChatClient connection, string sender) { if (!API.MainServer.Moderator.Instance.IsModerator(sender)) { connection.PublishMessage(ChatListener.ChatName, "DeOp failure: You're not a mod :("); return; } string target = messageMatch.Groups[2].Value; #if DEBUG API.Utility.Logging.MetaLog($"/deop {target}"); #endif List moderators = new List(CLre.Config.moderators); if (moderators.Remove(target)) { CLre.Config.moderators = moderators.ToArray(); connection.PublishMessage(ChatListener.ChatName, $"Demoted {target} to regular user"); } connection.PublishMessage(ChatListener.ChatName, "DeOp failure: User not found :("); } [ChatCommand("ECHO", "echo (.+)$")] public static void EchoEchoEcho(Match messageMatch, ChatClient connection, string sender) { string target = messageMatch.Groups[1].Value; #if DEBUG API.Utility.Logging.MetaLog($"/echo {target}"); #endif connection.PublishMessage(ChatListener.ChatName, target); } } }