mirror of
https://github.com/yawaflua/spworlds-csharp-library.git
synced 2025-12-10 04:29:25 +02:00
sloved errors
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
|
||||
25
src/obj/Debug/net6.0/spworlds.AssemblyInfo.cs
Normal file
25
src/obj/Debug/net6.0/spworlds.AssemblyInfo.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Mih4n")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyDescriptionAttribute("данная библиотека предназначена для работы с сайтом spworlds. Ознакомиться с доку" +
|
||||
"ментацией можно в гитхабе проекта")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.1.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.1")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("spworlds")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("spworlds")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.1.0")]
|
||||
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/Mih4n/spworlds")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
|
||||
1
src/obj/Debug/net6.0/spworlds.AssemblyInfoInputs.cache
Normal file
1
src/obj/Debug/net6.0/spworlds.AssemblyInfoInputs.cache
Normal file
@@ -0,0 +1 @@
|
||||
3b79596e0f193799e87c2d642144700f8551bcf8
|
||||
@@ -0,0 +1,11 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net6.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = spworlds
|
||||
build_property.ProjectDir = c:\Users\losev\OneDrive\Рабочий стол\spworlds\spworlds-csharp-library\src\
|
||||
8
src/obj/Debug/net6.0/spworlds.GlobalUsings.g.cs
Normal file
8
src/obj/Debug/net6.0/spworlds.GlobalUsings.g.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.IO;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Net.Http;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
@@ -24,26 +24,13 @@ public class SPWorlds
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Base64BearerToken);
|
||||
}
|
||||
|
||||
|
||||
// Полностью бесполезная функция, вебхук, возвращающийся от сайта по факту невозможно валидировать.
|
||||
private async Task<bool> ValidateWebHook(string webHook, string bodyHash)
|
||||
{
|
||||
// Если я правильно все понял, то вот
|
||||
// Конвертим из string в bytes body_hash
|
||||
byte[] body = Encoding.UTF8.GetBytes(bodyHash);
|
||||
// потом конвертим вебхук
|
||||
byte[] webhook = Encoding.UTF8.GetBytes(webHook);
|
||||
// создаем объект с токеном(тоже encoded в bytes) для сопостовления
|
||||
var key = new HMACSHA256(Encoding.UTF8.GetBytes(token));
|
||||
// Переводим в Base64
|
||||
string webhook64 = Convert.ToBase64String(key.ComputeHash(webhook));
|
||||
return webhook64.Equals(body);
|
||||
/**
|
||||
* Тот же код, но на Python:
|
||||
hmacData = hmac.new(token.encode('utf - 8'), webhook.encode('utf - 8'), sha256).digest()
|
||||
base64Data = b64encode(hmacData)
|
||||
return hmac.compare_digest(base64Data, bodyHash.encode('utf-8'))
|
||||
**/
|
||||
}
|
||||
|
||||
private async Task<string> SendRequest(string endpoint, Boolean getResult = true, Dictionary<string, object>? body = null)
|
||||
@@ -93,9 +80,8 @@ public class SPWorlds
|
||||
|
||||
public async Task<User> GetUser(string discordId)
|
||||
{
|
||||
var userResponse = JsonObject.Parse(await SendRequest($"users/{discordId}"));
|
||||
var userName = userResponse["username"];
|
||||
User user = new() { Name = userName}
|
||||
string userName = (string)JsonObject.Parse(await SendRequest($"users/{discordId}"))["username"];
|
||||
User user = new(userName);
|
||||
return (User)user;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user