diff --git a/ModAssistant/Classes/Utils.cs b/ModAssistant/Classes/Utils.cs
index a44f41c..a0831d8 100644
--- a/ModAssistant/Classes/Utils.cs
+++ b/ModAssistant/Classes/Utils.cs
@@ -25,6 +25,7 @@ namespace ModAssistant
{
public const string BeatSaberAPPID = "620980";
public const string BeatModsAPIUrl = "https://beatmods.com/api/v1/";
+ public const string TeknikAPIUrl = "https://api.teknik.io/v1/";
public const string BeatModsURL = "https://beatmods.com";
public const string BeatModsModsOptions = "mod?status=approved";
public const string MD5Spacer = " ";
@@ -38,6 +39,20 @@ namespace ModAssistant
};
}
+ public class TeknikPasteResponse
+ {
+ public Result result;
+ public class Result
+ {
+ public string id;
+ public string url;
+ public string title;
+ public string syntax;
+ public DateTime? expiration;
+ public string password;
+ }
+ }
+
public static void SendNotify(string message, string title = "Mod Assistant")
{
var notification = new System.Windows.Forms.NotifyIcon()
diff --git a/ModAssistant/ModAssistant.csproj b/ModAssistant/ModAssistant.csproj
index ee3d9ed..2a46dad 100644
--- a/ModAssistant/ModAssistant.csproj
+++ b/ModAssistant/ModAssistant.csproj
@@ -43,6 +43,7 @@
+
diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs
index 89ccdda..cec36d1 100644
--- a/ModAssistant/Pages/Options.xaml.cs
+++ b/ModAssistant/Pages/Options.xaml.cs
@@ -15,6 +15,9 @@ using System.Windows.Shapes;
using System.Globalization;
using System.IO;
using Path = System.IO.Path;
+using System.Net;
+using System.Web.Script.Serialization;
+using System.Web;
namespace ModAssistant.Pages
{
@@ -34,8 +37,7 @@ namespace ModAssistant.Pages
public bool ModelSaberProtocolHandlerEnabled { get; set; }
public bool BeatSaverProtocolHandlerEnabled { get; set; }
public bool ModSaberProtocolHandlerEnabled { get; set; }
-
-
+ public string LogURL { get; private set; }
public Options()
{
@@ -149,9 +151,56 @@ namespace ModAssistant.Pages
Properties.Settings.Default.Save();
}
- private void OpenLogsDirButton_Click(object sender, RoutedEventArgs e)
+ private async void OpenLogsDirButton_Click(object sender, RoutedEventArgs e)
{
- System.Diagnostics.Process.Start(Path.Combine(InstallDirectory, "Logs"));
+ try
+ {
+ MainWindow.Instance.MainText = "Uploading Log...";
+ await Task.Run(() => UploadLog());
+
+ System.Diagnostics.Process.Start(LogURL);
+ Clipboard.SetText(LogURL);
+ MainWindow.Instance.MainText = "Log URL Copied To Clipboard!";
+ }
+ catch (Exception exception)
+ {
+ MainWindow.Instance.MainText = "Uploading Log Failed.";
+ MessageBox.Show("Could not upload log file to Teknik, please try again or send the file manually.\n ================= \n" + exception, "Uploading log failed!");
+ System.Diagnostics.Process.Start(Path.Combine(InstallDirectory, "Logs"));
+ }
+ }
+
+ private void UploadLog()
+ {
+ const string DateFormat = "yyyy-mm-dd HH:mm:ss";
+ DateTime now = DateTime.Now;
+ Utils.TeknikPasteResponse TeknikResponse;
+
+ string postData =
+ "title=" + "_latest.log (" + now.ToString(DateFormat) + ")" +
+ "&expireUnit=hour&expireLength=5" +
+ "&code=" + HttpUtility.UrlEncode(File.ReadAllText(Path.Combine(InstallDirectory, "Logs", "_latest.log")));
+ byte[] byteArray = Encoding.UTF8.GetBytes(postData);
+
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Utils.Constants.TeknikAPIUrl + "Paste");
+ request.AutomaticDecompression = DecompressionMethods.GZip;
+ request.UserAgent = "ModAssistant/" + App.Version;
+ request.Method = "POST";
+ request.ContentType = "application/x-www-form-urlencoded";
+ request.ContentLength = byteArray.Length;
+
+ Stream dataStream = request.GetRequestStream();
+ dataStream.Write(byteArray, 0, byteArray.Length);
+ dataStream.Close();
+
+ using (WebResponse response = (WebResponse)request.GetResponse())
+ using (Stream stream = response.GetResponseStream())
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ var serializer = new JavaScriptSerializer();
+ TeknikResponse = serializer.Deserialize(reader.ReadToEnd());
+ }
+ LogURL = TeknikResponse.result.url;
}
private async void YeetBSIPAButton_Click(object sender, RoutedEventArgs e)