Browse Source

Add chat commands for regular users

tags/v0.0.3
NGnius (Graham) 3 years ago
parent
commit
f82eac3ffc
2 changed files with 52 additions and 0 deletions
  1. +3
    -0
      CLre_server/CLre_server.cs
  2. +49
    -0
      CLre_server/Tweaks/Chat/UserCommands.cs

+ 3
- 0
CLre_server/CLre_server.cs View File

@@ -26,6 +26,8 @@ namespace CLre_server
public static CLreConfig Config = CLreConfig.Default();

public static CLre Instance = null;

// called when Cardlife shuts down
public override void OnApplicationQuit()
{
@@ -37,6 +39,7 @@ namespace CLre_server
// called when Cardlife starts up
public override void OnApplicationStart()
{
Instance = this;
#if DEBUG
FileLog.Reset();
Harmony.DEBUG = true;


+ 49
- 0
CLre_server/Tweaks/Chat/UserCommands.cs View File

@@ -0,0 +1,49 @@
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);
}
}
}

Loading…
Cancel
Save