56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Milimoe.FunGame.WebAPI.Constant;
|
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
|
using Milimoe.FunGame.Core.Api.Utility;
|
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
|
|
|
namespace Milimoe.FunGame.WebAPI
|
|
{
|
|
public class MilimoeWebAPI : WebAPIPlugin
|
|
{
|
|
public override string Name => Constants.WebAPI;
|
|
|
|
public override string Description => Constants.Description;
|
|
|
|
public override string Version => Constants.Version;
|
|
|
|
public override string Author => Constants.Author;
|
|
|
|
public override void ProcessInput(string input)
|
|
{
|
|
try
|
|
{
|
|
if (input.Trim() != "")
|
|
{
|
|
Controller.WriteLine("Console Reply");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Controller.Error(e);
|
|
}
|
|
}
|
|
|
|
public override void AfterLoad(WebAPIPluginLoader loader, params object[] objs)
|
|
{
|
|
Configs.Load();
|
|
Configs.Save();
|
|
Statics.RunningPlugin ??= this;
|
|
Statics.WebAPIPluginLoader ??= loader;
|
|
Controller.NewSQLHelper();
|
|
Controller.NewMailSender();
|
|
WebAPIAuthenticator.WebAPICustomBearerTokenAuthenticator += CustomBearerTokenAuthenticator;
|
|
}
|
|
|
|
private string CustomBearerTokenAuthenticator(string token)
|
|
{
|
|
if (Configs.TokenList.Contains(token))
|
|
{
|
|
return "APIUser";
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
}
|