Skip to content

Commit

Permalink
add PublicOsuBotTransferWarpper
Browse files Browse the repository at this point in the history
  • Loading branch information
KedamaOvO committed Sep 17, 2019
1 parent ab603a4 commit 3ecb0c5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 24 deletions.
31 changes: 7 additions & 24 deletions OsuApi.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OsuRTDataProvider.Listen;
using OsuRTDataProvider.Mods;
using PublicOsuBotTransfer;
using RealTimePPDisplayer.Warpper;
using Sync;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -36,42 +36,25 @@ public class BeatPerformance

static class OsuApi
{
private static PublicOsuBotTransferPlugin s_pobt;
static bool Init()
{
if (SyncHost.Instance.EnumPluings().FirstOrDefault(p => p.Name == "PublicOsuBotTransferPlugin") is PublicOsuBotTransferPlugin pobt)
{
if (pobt.GetType().Assembly.GetName().Version >= Version.Parse("1.3.0"))
{
s_pobt = pobt;
return true;
}
else
{
Sync.Tools.IO.DefaultIO.WriteColor(DefaultLanguage.HINT_POBT_VERSION_LOWER, ConsoleColor.Yellow);
return false;
}
}

return false;
}
public static PublicOsuBotTransferWarpper publicOsuBotTransferWarpper;

public static List<BeatPerformance> GetBp(string player,OsuPlayMode mode)
{
HttpWebRequest req;
if(Setting.ByCuteSyncProxy)
{
if (s_pobt == null)
if (publicOsuBotTransferWarpper == null)
{
if (!Init())
publicOsuBotTransferWarpper = new PublicOsuBotTransferWarpper();
if (!publicOsuBotTransferWarpper.Init())
return null;
}
if(s_pobt.Username != player)
if(publicOsuBotTransferWarpper.Username != player)
{
Sync.Tools.IO.DefaultIO.WriteColor(DefaultLanguage.HINT_CANNOT_WATCH_OTHER_PLAYER, ConsoleColor.Yellow);
return null;
}
req = (HttpWebRequest)WebRequest.Create($"https://osubot.kedamaovo.moe/osuapi/bp?k={s_pobt.Token}&u={player}&type=string&limit=100&m={(uint)mode}");
req = (HttpWebRequest)WebRequest.Create($"https://osubot.kedamaovo.moe/osuapi/bp?k={publicOsuBotTransferWarpper.Token}&u={player}&type=string&limit=100&m={(uint)mode}");
}
else
{
Expand Down
1 change: 1 addition & 0 deletions RealTimePPDisplayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Compile Include="Displayer\View\PPWindow.xaml.cs">
<DependentUpon>PPWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Warpper\PublicOsuBotTransferWarpper.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\osuSync\OfficalPlugins\ConfigGUI\ConfigGUI.csproj">
Expand Down
36 changes: 36 additions & 0 deletions Warpper/PublicOsuBotTransferWarpper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using PublicOsuBotTransfer;
using Sync;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RealTimePPDisplayer.Warpper
{
class PublicOsuBotTransferWarpper
{
private PublicOsuBotTransferPlugin s_pobt;
public string Token => s_pobt.Token;
public string Username => s_pobt.Username;

public bool Init()
{
if (SyncHost.Instance.EnumPluings().FirstOrDefault(p => p.Name == "PublicOsuBotTransferPlugin") is PublicOsuBotTransferPlugin pobt)
{
if (pobt.GetType().Assembly.GetName().Version >= Version.Parse("1.3.0"))
{
s_pobt = pobt;
return true;
}
else
{
Sync.Tools.IO.DefaultIO.WriteColor(DefaultLanguage.HINT_POBT_VERSION_LOWER, ConsoleColor.Yellow);
return false;
}
}

return false;
}
}
}

0 comments on commit 3ecb0c5

Please sign in to comment.