diff --git a/Plugin.cs b/Plugin.cs index eb02759..665189c 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -16,10 +16,12 @@ public class Plugin : BaseUnityPlugin public static ConfigEntry URL; + // public static void ModalProxy(string title, string message) => Modal.ShowError(title, message); + private void Awake() { // Config - URL = Config.Bind("Networking", "WebsocketURL", "ws://127.0.0.1:3000/", "The ws[s]:// URL."); + URL = Config.Bind("Networking", "WebsocketURL", "ws://spook.redbigz.com/api/upload", "The ws[s]:// URL."); // Plugin startup logic Logger.LogInfo($"Spooktube has loaded."); @@ -45,14 +47,14 @@ class ReplayPatch { if (!PhotonNetwork.IsMasterClient) { - Modal.ShowError("Upload Error", "Only the host can upload videos to SpookedTube."); + // Modal.ShowError("Upload Error", "Only the host can upload videos to SpookedTube."); return false; } IPlayableVideo video = new Traverse(__instance).Field("m_replayVideo").GetValue() as IPlayableVideo; int views = new Traverse(__instance).Field("m_replayViews").GetValue(); CommentUI[] comments = new Traverse(__instance).Field("m_replayComments").GetValue() as CommentUI[]; - + GameObject States = __instance.m_videoPlayer.transform.parent.parent.parent.gameObject; GameObject ShowVideoState = Util.FindObject(States, "ShowVideoState"); diff --git a/SpookedTube.csproj b/SpookedTube.csproj index 2e455bf..c76e03f 100644 --- a/SpookedTube.csproj +++ b/SpookedTube.csproj @@ -60,6 +60,10 @@ ./lib/PhotonUnityNetworking.dll + + ./lib/PhotonRealtime.dll + + ./lib/com.rlabrecque.steamworks.net.dll @@ -67,5 +71,9 @@ ./lib/websocket-sharp.dll + + + ./lib/Photon3Unity3D.dll + diff --git a/Uploader.cs b/Uploader.cs index 206ec0b..b46bdec 100644 --- a/Uploader.cs +++ b/Uploader.cs @@ -1,9 +1,13 @@ using System; using System.Collections.Generic; +using System.Data.Common; using System.IO; using System.Linq; using HarmonyLib; +using Photon.Pun; using Steamworks; +using UnityEngine.UIElements; +using UnityEngine.UIElements.Collections; using WebSocketSharp; namespace SpookedTube; @@ -22,6 +26,22 @@ class SpookedUploader return; } + // Get co-conspirators lmao + // string[] coconspirators = new string[PhotonNetwork.CurrentRoom.PlayerCount]; + + // foreach (KeyValuePair player in PhotonNetwork.CurrentRoom.Players) + // { + // // if (player.Value.IsMasterClient) continue; + // coconspirators.AddItem(player.Value.NickName); + + // // if (player.Value.CustomProperties.ContainsKey("SteamID")) + // // { + // // player.Value.CustomProperties["SteamID"] + // // } + // } + + // string[] coconspirators = PhotonNetwork.CurrentRoom.Players.Select((player) => player.Value.NickName) as string[]; + ws = new WebSocket(Plugin.URL.Value); string viewableUrl = ""; @@ -61,10 +81,15 @@ class SpookedUploader if (evt.Data.StartsWith("fin")) { ws.Close(); + // Plugin.ModalProxy("Upload Complete", $"Video uploaded to {viewableUrl}! ({uuid})"); System.Diagnostics.Process.Start($"https://{viewableUrl}/#{uuid}"); - // Modal.ShowError("Upload Complete", $"Video uploaded to {viewableUrl}! ({uuid})"); onUpload(); } + + if (evt.Data.StartsWith("us")) + { + // Modal.ShowError("Unsafe Upload", "The server responded with an HEUR error. Your file has not been uploaded due to security reasons. If you believe this was an error, contact st.appeals.vid@redbigz.com with this ID:\n4cedcd69-b5e4-4cda-9142-104009841695\n\nYour appeal will be rejected if:\n- Your video uses mods such as Flashcard\n\nYour IP address will be banned if:\n- Your video contains illicit content\n- Your video contains sexual imagery\n\nYour email address WILL be blocked if you troll the email address above. It is an automated service and your address will be blacklisted, along with your IP address if it has connections to your email."); + } }; ws.OnError += (sender, evt) => @@ -74,7 +99,7 @@ class SpookedUploader ws.OnOpen += (sender, evt) => { - UnityEngine.Debug.Log(SteamUser.GetSteamID().m_SteamID.ToString()); + ws.Send("persona:" + SteamFriends.GetPersonaName()); ws.Send(SteamUser.GetSteamID().m_SteamID.ToString()); };