Add chat commands for regular users
This commit is contained in:
parent
b8a8a535f1
commit
f82eac3ffc
2 changed files with 52 additions and 0 deletions
|
@ -26,6 +26,8 @@ namespace CLre_server
|
||||||
|
|
||||||
public static CLreConfig Config = CLreConfig.Default();
|
public static CLreConfig Config = CLreConfig.Default();
|
||||||
|
|
||||||
|
public static CLre Instance = null;
|
||||||
|
|
||||||
// called when Cardlife shuts down
|
// called when Cardlife shuts down
|
||||||
public override void OnApplicationQuit()
|
public override void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
|
@ -37,6 +39,7 @@ namespace CLre_server
|
||||||
// called when Cardlife starts up
|
// called when Cardlife starts up
|
||||||
public override void OnApplicationStart()
|
public override void OnApplicationStart()
|
||||||
{
|
{
|
||||||
|
Instance = this;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
FileLog.Reset();
|
FileLog.Reset();
|
||||||
Harmony.DEBUG = true;
|
Harmony.DEBUG = true;
|
||||||
|
|
49
CLre_server/Tweaks/Chat/UserCommands.cs
Normal file
49
CLre_server/Tweaks/Chat/UserCommands.cs
Normal 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…
Reference in a new issue