CLre/CLre_server/Tweaks/Chat/UserCommands.cs

49 lines
2.3 KiB
C#
Raw Normal View History

2021-08-16 21:59:48 +01:00
using System.Text;
using System.Text.RegularExpressions;
using ExitGames.Client.Photon.Chat;
namespace CLre_server.Tweaks.Chat
{
public static class UserCommands
{
private const string HELP_STRING = "CLre chat commands:\n" +
"/echo <msg> - say <msg>\n" +
"/help - show this message\n" +
"/list - display online users\n" +
"/version - display version information\n\n" +
"CLre moderation commands:\n" +
"/ban <user> - permanently remove <user> from this server\n" +
"/deop <user> - revoke <user> moderator permissions\n" +
"/kick <user> - disconnect <user> from this server\n" +
"/op <user> - grant <user> moderator permissions";
[ChatCommand("ONLINE", "(list|online)")]
public static void WhoIsOnline(Match messageMatch, ChatClient connection, string sender)
{
var players = API.MainServer.Server.Instance.Players;
StringBuilder sb = new StringBuilder($"Online Users ({players.Length}):\n");
foreach (var p in players)
{
sb.AppendFormat("{0} ({1})\n", p.accountId.displayName, p.accountId.publicId);
}
connection.PublishMessage(ChatListener.ChatName, sb.ToString().TrimEnd());
}
[ChatCommand("VERSION", "version")]
public static void CeleryVersion(Match messageMatch, ChatClient connection, string sender)
{
string versionStr = $"CLre {CLre.Instance.Version}\nCardLife {Game.Utilities.VersionReader.GetVersion()}\nUnity {UnityEngine.Application.version}";
connection.PublishMessage(ChatListener.ChatName, versionStr);
}
[ChatCommand("HELP", "help")]
public static void Halp(Match messageMatch, ChatClient connection, string sender)
{
connection.PublishMessage(ChatListener.ChatName, HELP_STRING);
}
}
}