public static void AddMessage(string input, bool IsUser = false, bool AddTime = true) { string message = input; if (AddTime) { message = $"[{DateTime.Now.Hour}:{DateTime.Now.Minute}:{DateTime.Now.Second}] {input}"; } messages.Add(message); OnNewMessage?.Invoke(message); if (IsUser) { for (int i = 0; i < UserCommands.Length; i++) { if (input == UserCommands[i]) { OnUserCommand?.Invoke(input); return; } } AddMessage(GameLanguages.GetCurrentLocalization("ConsoleUnknownCommand"), false, false); } }
private void ClientOnOnChatCommandReceived(object sender, OnChatCommandReceivedArgs e) { Debug.Log($"[Client] Chat command {e.Command.ChatMessage.Username}: {e.Command.CommandText} args = [ {string.Join(", ", e.Command.ArgumentsAsList)} ]"); var command = e.Command.CommandText; var userName = e.Command.ChatMessage.Username; if (string.IsNullOrEmpty(command)) { return; } var user = _db.GetOrCreate(userName); user.IsActive = true; user.LastInteraction = Time.time; user.IsModerator = e.Command.ChatMessage.IsModerator; user.IsBroadcaster = e.Command.ChatMessage.IsBroadcaster; user.IsSubscriber = e.Command.ChatMessage.IsSubscriber; var args = e.Command.ArgumentsAsList; OnUserCommand?.Invoke(user, command, args); }