Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.3KB

  1. using System.Text;
  2. using System.Text.RegularExpressions;
  3. using ExitGames.Client.Photon.Chat;
  4. namespace CLre_server.Tweaks.Chat
  5. {
  6. public static class UserCommands
  7. {
  8. private const string HELP_STRING = "CLre chat commands:\n" +
  9. "/echo <msg> - say <msg>\n" +
  10. "/help - show this message\n" +
  11. "/list - display online users\n" +
  12. "/version - display version information\n\n" +
  13. "CLre moderation commands:\n" +
  14. "/ban <user> - permanently remove <user> from this server\n" +
  15. "/deop <user> - revoke <user> moderator permissions\n" +
  16. "/kick <user> - disconnect <user> from this server\n" +
  17. "/op <user> - grant <user> moderator permissions";
  18. [ChatCommand("ONLINE", "(list|online)")]
  19. public static void WhoIsOnline(Match messageMatch, ChatClient connection, string sender)
  20. {
  21. var players = API.MainServer.Server.Instance.Players;
  22. StringBuilder sb = new StringBuilder($"Online Users ({players.Length}):\n");
  23. foreach (var p in players)
  24. {
  25. sb.AppendFormat("{0} ({1})\n", p.accountId.displayName, p.accountId.publicId);
  26. }
  27. connection.PublishMessage(ChatListener.ChatName, sb.ToString().TrimEnd());
  28. }
  29. [ChatCommand("VERSION", "version")]
  30. public static void CeleryVersion(Match messageMatch, ChatClient connection, string sender)
  31. {
  32. string versionStr = $"CLre {CLre.Instance.Version}\nCardLife {Game.Utilities.VersionReader.GetVersion()}\nUnity {UnityEngine.Application.version}";
  33. connection.PublishMessage(ChatListener.ChatName, versionStr);
  34. }
  35. [ChatCommand("HELP", "help")]
  36. public static void Halp(Match messageMatch, ChatClient connection, string sender)
  37. {
  38. connection.PublishMessage(ChatListener.ChatName, HELP_STRING);
  39. }
  40. }
  41. }