+
KonataPlugin
+
+
+
+
+
加载中...
+
+
+
+
+
+
+ BotKeyStore.json (不修改留空)
+
+
+
+
登录
+
退出
+
+
+
+
+
\ No newline at end of file
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.css b/plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.css
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.css
rename to plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.css
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.css.map b/plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.css.map
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.css.map
rename to plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.css.map
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.min.css b/plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.min.css
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.min.css
rename to plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.min.css
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.min.css.map b/plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.min.css.map
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/css/mdui.min.css.map
rename to plugins/KonataPlugin/wwwroot/libs/mdui/css/mdui.min.css.map
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/LICENSE.txt b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/LICENSE.txt
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/LICENSE.txt
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/LICENSE.txt
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Black.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BlackItalic.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Bold.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-BoldItalic.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Light.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-LightItalic.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Medium.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-MediumItalic.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Regular.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-RegularItalic.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-Thin.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/fonts/roboto/Roboto-ThinItalic.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/LICENSE.txt b/plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/LICENSE.txt
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/LICENSE.txt
rename to plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/LICENSE.txt
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.ijmap b/plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.ijmap
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.ijmap
rename to plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.ijmap
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff b/plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff
rename to plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff2 b/plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff2
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff2
rename to plugins/KonataPlugin/wwwroot/libs/mdui/icons/material-icons/MaterialIcons-Regular.woff2
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.esm.js b/plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.esm.js
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.esm.js
rename to plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.esm.js
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.esm.js.map b/plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.esm.js.map
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.esm.js.map
rename to plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.esm.js.map
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.js b/plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.js
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.js
rename to plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.js
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.js.map b/plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.js.map
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.js.map
rename to plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.js.map
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.min.js b/plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.min.js
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.min.js
rename to plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.min.js
diff --git a/src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.min.js.map b/plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.min.js.map
similarity index 100%
rename from src/QQBotHub.Web/wwwroot/libs/mdui/js/mdui.min.js.map
rename to plugins/KonataPlugin/wwwroot/libs/mdui/js/mdui.min.js.map
diff --git a/src/QQBotHub.Sdk/QQBotHub.Sdk.csproj b/src/QQBotHub.Sdk/QQBotHub.Sdk.csproj
index 00aa78e6c..8dde1783f 100644
--- a/src/QQBotHub.Sdk/QQBotHub.Sdk.csproj
+++ b/src/QQBotHub.Sdk/QQBotHub.Sdk.csproj
@@ -5,7 +5,7 @@
enable
enable
QQBotHub.Sdk
-
0.1.1
+
1.0.0
yiyun
yiyun
QQBotHub 插件开发包
@@ -16,10 +16,6 @@
true
-
-
-
-
diff --git a/src/QQBotHub.Sdk/QQBotStore.cs b/src/QQBotHub.Sdk/QQBotStore.cs
deleted file mode 100644
index a0c5a38cc..000000000
--- a/src/QQBotHub.Sdk/QQBotStore.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using Konata.Core;
-using Konata.Core.Common;
-
-namespace QQBotHub.Sdk
-{
- public class QQBotStore
- {
- public static Bot Bot { get; set; }
-
-
-
- #region 废弃
- //public static class StoreUtil
- //{
- // public static T Get(string fileName, T defaultObj)
- // {
- // T rtnObj = defaultObj;
- // string configDir = Path.Combine(Directory.GetCurrentDirectory(), "App_Data");
- // if (!Directory.Exists(configDir))
- // {
- // Directory.CreateDirectory(configDir);
- // }
- // string filePath = Path.Combine(configDir, fileName);
- // if (!File.Exists(filePath))
- // {
- // string jsonStr = Utils.JsonUtil.Obj2JsonStr(rtnObj);
- // File.WriteAllText(path: filePath, contents: jsonStr, encoding: System.Text.Encoding.UTF8);
- // }
- // else
- // {
- // string jsonStr = File.ReadAllText(path: filePath, encoding: System.Text.Encoding.UTF8);
- // rtnObj = Utils.JsonUtil.JsonStr2Obj(jsonStr);
- // }
-
- // return rtnObj;
- // }
-
- // public static void Set(T obj, string fileName)
- // {
- // string configDir = Path.Combine(Directory.GetCurrentDirectory(), "App_Data");
- // if (!Directory.Exists(configDir))
- // {
- // Directory.CreateDirectory(configDir);
- // }
- // string filePath = Path.Combine(configDir, fileName);
- // string jsonStr = Utils.JsonUtil.Obj2JsonStr(obj);
- // File.WriteAllText(path: filePath, contents: jsonStr, encoding: System.Text.Encoding.UTF8);
- // }
-
- //}
-
- //public static BotConfig BotConfig
- //{
- // get
- // {
- // BotConfig botConfig = BotConfig.Default();
- // botConfig = StoreUtil.Get("config.json", botConfig);
-
- // return botConfig;
- // }
- // set
- // {
- // BotConfig botConfig = value;
- // StoreUtil.Set(botConfig, "config.json");
- // }
- //}
-
- //public static BotDevice BotDevice
- //{
- // get
- // {
- // BotDevice botDevice = BotDevice.Default();
- // botDevice = StoreUtil.Get("device.json", botDevice);
-
- // return botDevice;
- // }
- // set
- // {
- // BotDevice botDevice = value;
- // StoreUtil.Set(botDevice, "device.json");
- // }
- //}
-
- //public static BotKeyStore BotKeyStore
- //{
- // get
- // {
- // SettingsModel settingsModel = Utils.SettingsUtil.Get();
- // string account = settingsModel.QQ;
- // string password = settingsModel.Password;
- // BotKeyStore botKeyStore = new BotKeyStore(uin: account, password: password);
- // botKeyStore = StoreUtil.Get("keystore.json", botKeyStore);
-
- // return botKeyStore;
- // }
- // set
- // {
- // BotKeyStore botKeyStore = value;
- // StoreUtil.Set(botKeyStore, "keystore.json");
- // }
- //}
- #endregion
-
-
- }
-}
diff --git a/src/QQBotHub.Sdk/Utils/SettingsUtil.cs b/src/QQBotHub.Sdk/Utils/SettingsUtil.cs
new file mode 100644
index 000000000..69ca2c8d4
--- /dev/null
+++ b/src/QQBotHub.Sdk/Utils/SettingsUtil.cs
@@ -0,0 +1,51 @@
+
+
+using System.IO;
+
+namespace QQBotHub.Sdk.Utils
+{
+ public class SettingsUtil
+ {
+ public static void EnsureExist(string pluginId)
+ where T : PluginCore.Models.PluginSettingsModel, new()
+ {
+ string pluginDir = Path.Combine(PluginCore.PluginPathProvider.PluginsRootPath(), pluginId);
+ string filePath = Path.Combine(pluginDir, "settings.json");
+ if (!File.Exists(filePath))
+ {
+ Set(pluginId, new T());
+ }
+ }
+
+ public static T Get(string pluginId)
+ where T : PluginCore.Models.PluginSettingsModel, new()
+ {
+ string pluginDir = Path.Combine(PluginCore.PluginPathProvider.PluginsRootPath(), pluginId);
+ string filePath = Path.Combine(pluginDir, "settings.json");
+ if (!File.Exists(filePath))
+ {
+ T jsonModel = new T();
+ string jsonStr = JsonUtil.Obj2JsonStr(jsonModel);
+ File.WriteAllText(path: filePath, contents: jsonStr, encoding: System.Text.Encoding.UTF8);
+
+ return jsonModel;
+ }
+ else
+ {
+ string jsonStr = File.ReadAllText(path: filePath, encoding: System.Text.Encoding.UTF8);
+ T jsonModel = JsonUtil.JsonStr2Obj(jsonStr);
+
+ return jsonModel;
+ }
+ }
+
+ public static void Set(string pluginId, T settingsModel)
+ where T : PluginCore.Models.PluginSettingsModel, new()
+ {
+ string pluginDir = Path.Combine(PluginCore.PluginPathProvider.PluginsRootPath(), pluginId);
+ string filePath = Path.Combine(pluginDir, "settings.json");
+ string jsonStr = JsonUtil.Obj2JsonStr(settingsModel);
+ File.WriteAllText(path: filePath, contents: jsonStr, encoding: System.Text.Encoding.UTF8);
+ }
+ }
+}
diff --git a/src/QQBotHub.Web/Controllers/HomeController.cs b/src/QQBotHub.Web/Controllers/HomeController.cs
index ea098b6ab..eabe14247 100644
--- a/src/QQBotHub.Web/Controllers/HomeController.cs
+++ b/src/QQBotHub.Web/Controllers/HomeController.cs
@@ -5,467 +5,22 @@
using Microsoft.AspNetCore.Mvc;
using PluginCore.Interfaces;
using PluginCore.IPlugins;
-using QQBotHub.Sdk;
-using QQBotHub.Sdk.IPlugins;
-using QQBotHub.Sdk.Utils;
-using QQBotHub.Web.RequestModels;
-using QQBotHub.Web.ResponseModels;
using System.Threading.Tasks;
using static Konata.Core.Events.Model.CaptchaEvent;
namespace QQBotHub.Web.Controllers
{
- [Route("api/[action]")]
- [Authorize("PluginCore.Admin")]
+ [Route("")]
+ //[Authorize("PluginCore.Admin")]
[ApiController]
public class HomeController : ControllerBase
{
-
- #region Fields
-
- private readonly IPluginFinder _pluginFinder;
-
- private readonly bool _debug;
-
- #endregion
-
- #region Ctor
- public HomeController(IPluginFinder pluginFinder)
- {
- _pluginFinder = pluginFinder;
- string debugStr = EnvUtil.GetEnv("DEBUG");
- if (!string.IsNullOrEmpty(debugStr) && bool.TryParse(debugStr, out bool debug))
- {
- _debug = debug;
- }
- else
- {
- _debug = false;
- }
- }
- #endregion
-
-
- #region Actions
-
- [Route("/")]
+ [Route("")]
[HttpGet]
public async Task Index()
{
- string indexFilePath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "index.html");
-
- return PhysicalFile(indexFilePath, "text/html");
- }
-
-
- [HttpGet]
- public async Task Uin()
- {
- BaseResponseModel responseModel = new BaseResponseModel();
- try
- {
- var settings = Utils.SettingsUtil.Get();
- string uin = settings?.Uin ?? "";
- if (!string.IsNullOrEmpty(QQBotStore.Bot?.Uin.ToString()))
- {
- uin = QQBotStore.Bot?.Uin.ToString() ?? uin;
- }
-
- responseModel.Code = 1;
- responseModel.Message = "获取成功";
- responseModel.Data = uin;
- }
- catch (Exception ex)
- {
- responseModel.Code = -1;
- responseModel.Message = "获取失败";
- responseModel.Data = ex.ToString();
- }
-
- return await Task.FromResult(responseModel);
- }
-
- ///
- /// 登录后,定时访问此api, 获取验证等信息
- ///
- ///
- [HttpGet]
- public async Task Info()
- {
- BaseResponseModel responseModel = new BaseResponseModel();
- InfoResponseDataModel dataModel = new InfoResponseDataModel();
-
- if (QQBotStore.Bot == null)
- {
- // 未点击登录过
- responseModel.Code = 1;
- responseModel.Message = "未登录";
-
- dataModel.CaptchaTip = "";
- dataModel.IsOnline = false;
- dataModel.CaptchaType = "";
- dataModel.CaptchaUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-
- responseModel.Data = dataModel;
-
- return responseModel;
- }
-
- //if (QQBotStore.Bot.IsOnline())
- if (CaptchaStore.IsOnline)
- {
- responseModel.Code = 2;
- responseModel.Message = "已处于登录状态, 无需验证";
-
- dataModel.CaptchaTip = "";
- dataModel.IsOnline = true;
- dataModel.CaptchaType = "";
- dataModel.CaptchaUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-
- responseModel.Data = dataModel;
-
- return responseModel;
- }
-
- // 已经点击登录过一次
- responseModel.Code = 3;
- responseModel.Message = "需要验证";
- switch (CaptchaStore.CaptchaType)
- {
- case Konata.Core.Events.Model.CaptchaEvent.CaptchaType.Sms:
- dataModel.CaptchaType = "短信验证";
- break;
- case Konata.Core.Events.Model.CaptchaEvent.CaptchaType.Slider:
- dataModel.CaptchaType = "滑块验证";
- break;
- case Konata.Core.Events.Model.CaptchaEvent.CaptchaType.Unknown:
- dataModel.CaptchaType = "未知验证";
- break;
- default:
- dataModel.CaptchaType = "未知验证-不匹配的验证类型";
- break;
- }
- dataModel.IsOnline = false;
- dataModel.CaptchaTip = CaptchaStore.CaptchaTip;
- dataModel.CaptchaUpdateTime = CaptchaStore.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
-
- responseModel.Data = dataModel;
-
- return await Task.FromResult(responseModel);
- }
-
- ///
- /// 提交验证信息
- ///
- ///
- ///
- [HttpPost]
- public async Task SubmitCaptcha([FromBody] SubmitCaptchaRequestModel requestModel)
- {
- BaseResponseModel responseModel = new BaseResponseModel();
- string captcha = requestModel.Captcha;
- if (string.IsNullOrEmpty(captcha))
- {
- responseModel.Code = -1;
- responseModel.Message = "captcha 不能为空";
-
- return responseModel;
- }
- bool isSuccessCaptcha = false;
- try
- {
- switch (CaptchaStore.CaptchaType)
- {
- case Konata.Core.Events.Model.CaptchaEvent.CaptchaType.Sms:
- isSuccessCaptcha = QQBotStore.Bot.SubmitSmsCode(captcha);
- break;
- case Konata.Core.Events.Model.CaptchaEvent.CaptchaType.Slider:
- isSuccessCaptcha = QQBotStore.Bot.SubmitSliderTicket(captcha);
- break;
- case Konata.Core.Events.Model.CaptchaEvent.CaptchaType.Unknown:
- break;
- default:
- break;
- }
-
- responseModel.Code = 1;
- responseModel.Message = $"{(isSuccessCaptcha ? "验证通过" : "验证失败, 请重新验证")}";
- }
- catch (System.Exception ex)
- {
- responseModel.Code = -3;
- responseModel.Message = "提交验证失败";
- responseModel.Data = ex.ToString();
-
- Utils.LogUtil.Exception(ex);
- }
-
- return await Task.FromResult(responseModel);
+ return Content("正常运行中, 请前往 插件管理 ");
}
-
- [HttpPost]
- public async Task Login(LoginRequestModel requestModel)
- {
- BaseResponseModel responseModel = new BaseResponseModel();
- try
- {
- var oldSettings = Utils.SettingsUtil.Get();
- SettingsModel newSettings = new SettingsModel();
- if (requestModel.LoginType == "password")
- {
- newSettings = new SettingsModel
- {
- Uin = requestModel.Uin,
- Password = requestModel.Password,
- };
- if (string.IsNullOrEmpty(requestModel.Password?.Trim()))
- {
- newSettings.Password = oldSettings.Password;
- }
-
- InitQQBot(botKeyStore: new BotKeyStore(uin: newSettings.Uin, password: newSettings.Password));
-
- Utils.SettingsUtil.Set(newSettings);
- }
- else if (requestModel.LoginType == "config")
- {
- newSettings = new SettingsModel();
- if (!string.IsNullOrEmpty(requestModel.BotKeyStore?.Trim()))
- {
- try
- {
- newSettings.BotKeyStore = JsonUtil.JsonStr2Obj(requestModel.BotKeyStore.Trim());
- }
- catch (Exception ex)
- {
- Console.WriteLine("requestModel.BotKeyStore 转换失败:");
- Console.WriteLine(ex.ToString());
- }
- }
-
- if (string.IsNullOrEmpty(requestModel.BotKeyStore?.Trim()))
- {
- newSettings.BotKeyStore = oldSettings.BotKeyStore;
- }
-
- InitQQBot(botKeyStore: newSettings.BotKeyStore);
-
- Utils.SettingsUtil.Set(newSettings);
- }
- else
- {
- responseModel.Code = -2;
- responseModel.Message = "未知登录方式";
-
- return await Task.FromResult(responseModel);
- }
-
- Task taskLogin = QQBotStore.Bot.Login();
-
- responseModel.Code = 1;
- responseModel.Message = "提交登录成功";
- }
- catch (Exception ex)
- {
- responseModel.Code = -1;
- responseModel.Message = "提交登录失败";
- responseModel.Data = ex.ToString();
- }
-
- return await Task.FromResult(responseModel);
- }
-
- [HttpPost]
- public async Task Logout()
- {
- BaseResponseModel responseModel = new BaseResponseModel();
- try
- {
- Task taskLogout = QQBotStore.Bot.Logout();
-
- responseModel.Code = 1;
- responseModel.Message = "提交退出成功";
- }
- catch (Exception ex)
- {
- responseModel.Code = -1;
- responseModel.Message = "提交退出失败";
- responseModel.Data = ex.ToString();
- }
-
- return await Task.FromResult(responseModel);
- }
-
- #endregion
-
- #region Helpers
-
- [NonAction]
- public void InitQQBot(BotKeyStore botKeyStore)
- {
- #region Bot
-
- // Create a bot instance
- #region 准备数据
- // 优先从 环境变量 中获取
- BotConfig botConfig = BotConfig.Default();
- string botConfigJsonStr = EnvUtil.GetEnv("BOT_CONFIG");
- if (!string.IsNullOrEmpty(botConfigJsonStr))
- {
- botConfig = JsonUtil.JsonStr2Obj(botConfigJsonStr);
- }
-
- BotDevice botDevice = BotDevice.Default();
- string botDeviceJsonStr = EnvUtil.GetEnv("BOT_DEVICE");
- if (!string.IsNullOrEmpty(botDeviceJsonStr))
- {
- botDevice = JsonUtil.JsonStr2Obj(botDeviceJsonStr);
- }
-
- string botKeyStoreJsonStr = EnvUtil.GetEnv("BOT_KEYSTORE");
- if (!string.IsNullOrEmpty(botKeyStoreJsonStr))
- {
- botKeyStore = JsonUtil.JsonStr2Obj(botKeyStoreJsonStr);
- }
- #endregion
-
- var bot = BotFather.Create(botConfig, botDevice, botKeyStore);
- {
- // Print the log
- bot.OnLog += (s, e) =>
- {
- //#if DEBUG
- // Utils.LogUtil.Info(e.EventMessage);
- //#endif
- if (_debug)
- {
- Utils.LogUtil.Info(e.EventMessage);
- }
- };
-
- // Handle the captcha
- bot.OnCaptcha += (s, e) =>
- {
- Utils.LogUtil.Info("QQ 登录验证:");
- CaptchaStore.UpdateTime = DateTime.Now;
- CaptchaStore.CaptchaType = e.Type;
- if (e.Type == CaptchaType.Slider)
- {
- Utils.LogUtil.Info(e.SliderUrl);
- //((Bot)s).SubmitSliderTicket(Console.ReadLine());
- CaptchaStore.CaptchaTip = $"{e.SliderUrl}";
- }
- else if (e.Type == CaptchaType.Sms)
- {
- Utils.LogUtil.Info(e.Phone);
- //((Bot)s).SubmitSmsCode(Console.ReadLine());
- CaptchaStore.CaptchaTip = $"{e.Phone}";
- }
- };
-
- // Handle messages from group
- bot.OnGroupMessage += (s, e) =>
- {
- Utils.LogUtil.Info($"群消息: {DateTime.Now.ToString()}: {e.Message.Chain?.FirstOrDefault()?.ToString() ?? ""}");
-
- var plugins = _pluginFinder.EnablePlugins().ToList();
- Utils.LogUtil.Info($"响应: {plugins?.Count.ToString()} 个插件:");
- foreach (var plugin in plugins)
- {
- Utils.LogUtil.Info($"插件: {plugin.GetType().ToString()}");
- if (e.Message.Sender.Uin != s.Uin)
- {
- // 排除机器人自己
- plugin.OnGroupMessage((s, e), e.Message.Chain?.FirstOrDefault()?.ToString() ?? "", e.GroupName, e.GroupUin, e.MemberUin);
- }
- }
- };
-
- // Handle messages from friend
- bot.OnFriendMessage += (s, e) =>
- {
- Utils.LogUtil.Info($"好友消息: {DateTime.Now.ToString()}: {e.Message.Chain?.FirstOrDefault()?.ToString() ?? ""}");
-
- // 在获取插件这步正常, 没有触发 bot.OnFriendMessage
- var plugins = _pluginFinder.EnablePlugins().ToList();
- Utils.LogUtil.Info($"响应: {plugins?.Count.ToString()} 个插件:");
- //Utils.LogUtil.Info($"响应: {plugins?.Count.ToString()} 个插件: {e.Message.Chain?.FirstOrDefault()?.ToString() ?? ""}");
- foreach (var plugin in plugins)
- {
- Utils.LogUtil.Info($"插件: {plugin.GetType().ToString()}");
- if (e.Message.Sender.Uin != s.Uin)
- {
- // 排除机器人自己
- plugin.OnFriendMessage((s, e), e.Message.Chain?.FirstOrDefault()?.ToString() ?? "", e.FriendUin);
- }
- }
- };
-
- bot.OnBotOnline += (s, e) =>
- {
- Utils.LogUtil.Info($"{s.Name} 上线");
-
- CaptchaStore.IsOnline = true;
-
- var plugins = _pluginFinder.EnablePlugins();
- foreach (var plugin in plugins)
- {
- plugin.OnBotOnline((s, e), s.Name, s.Uin);
- }
- };
-
- bot.OnBotOffline += (s, e) =>
- {
- Utils.LogUtil.Info($"{s.Name} 离线");
-
- CaptchaStore.IsOnline = false;
-
- var plugins = _pluginFinder.EnablePlugins();
- foreach (var plugin in plugins)
- {
- plugin.OnBotOffline((s, e), s.Name, s.Uin);
- }
- };
- // ... More handlers
- }
-
- // Do login
- //Task loginTask = bot.Login();
-
- // 下方操作会阻塞, 并且是阻塞到过登录验证
- //if (!bot.Login().Result)
- //{
- // Utils.LogUtil.Info($"{nameof(QQBotPlugin)} 启用后 QQ 自动登录失败");
- // return base.AfterEnable();
- //}
- //else
- //{
- // Utils.LogUtil.Info($"{nameof(QQBotPlugin)} 启用后 QQ 自动登录成功");
- //}
-
- #endregion
-
- // 登录成功, 保存起来
- QQBotStore.Bot = bot;
- }
-
- #endregion
-
}
- #region More
-
- public static class CaptchaStore
- {
- public static Konata.Core.Events.Model.CaptchaEvent.CaptchaType CaptchaType { get; set; }
-
- public static string CaptchaTip { get; set; }
-
- public static DateTime UpdateTime { get; set; }
-
- public static bool IsOnline { get; set; }
- }
-
- #endregion
-
}
diff --git a/src/QQBotHub.Web/Program.cs b/src/QQBotHub.Web/Program.cs
index 52afd5b96..5e657700e 100644
--- a/src/QQBotHub.Web/Program.cs
+++ b/src/QQBotHub.Web/Program.cs
@@ -36,10 +36,6 @@
// wwwroot
app.UseStaticFiles();
-#region ȷ settings.json ļ
-QQBotHub.Web.Utils.SettingsUtil.EnsureExist();
-#endregion
-
app.MapControllers();
app.Run();
diff --git a/src/QQBotHub.Web/QQBotHub.Web.csproj b/src/QQBotHub.Web/QQBotHub.Web.csproj
index c96be681a..f8a9e9042 100644
--- a/src/QQBotHub.Web/QQBotHub.Web.csproj
+++ b/src/QQBotHub.Web/QQBotHub.Web.csproj
@@ -32,14 +32,15 @@
-
- Always
-
Always
+
+
+
+
bin\Release\net6.0\QQBot.Web.xml
diff --git a/src/QQBotHub.Web/ResponseModels/BaseResponseModel.cs b/src/QQBotHub.Web/ResponseModels/BaseResponseModel.cs
deleted file mode 100644
index a2f89c473..000000000
--- a/src/QQBotHub.Web/ResponseModels/BaseResponseModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace QQBotHub.Web.ResponseModels
-{
- public class BaseResponseModel
- {
- public int Code { get; set; }
-
- public string Message { get; set; }
-
- public object Data { get; set; }
- }
-}
diff --git a/src/QQBotHub.Web/SettingsModel.cs b/src/QQBotHub.Web/SettingsModel.cs
deleted file mode 100644
index f4a895fe9..000000000
--- a/src/QQBotHub.Web/SettingsModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-
-using Konata.Core.Common;
-
-namespace QQBotHub.Web
-{
- public class SettingsModel
- {
- // 使用 = "" , 确保不被 json 化为 null
- public string Uin { get; set; } = "";
- public string Password { get; set; } = "";
- public BotKeyStore BotKeyStore { get; set; }
- }
-}
diff --git a/src/QQBotHub.Web/Utils/LogUtil.cs b/src/QQBotHub.Web/Utils/LogUtil.cs
deleted file mode 100644
index 7515e00d4..000000000
--- a/src/QQBotHub.Web/Utils/LogUtil.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Text;
-using System.Linq;
-
-namespace QQBotHub.Web.Utils
-{
- public class LogUtil
- {
- public const string Sign = nameof(QQBotHub.Web);
-
- public static void Info(string message)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write($"{Sign}: ");
- Console.ResetColor();
- DateTime now = DateTime.Now;
- Console.WriteLine(now.ToString("yyyy-MM-dd HH:mm:ss"));
- Console.WriteLine(message);
- }
-
- public static void Error(string message)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write($"{Sign}: ");
- Console.ResetColor();
- DateTime now = DateTime.Now;
- Console.WriteLine(now.ToString("yyyy-MM-dd HH:mm:ss"));
- Console.WriteLine(message);
- }
-
- public static void Exception(Exception ex)
- {
- Error(ex.ToString());
- Exception exception = ex;
- while (exception.InnerException != null)
- {
- exception = ex.InnerException;
- Error(exception.Message);
- }
- }
-
- }
-}
diff --git a/src/QQBotHub.Web/wwwroot/css/main.css b/src/QQBotHub.Web/wwwroot/css/main.css
deleted file mode 100644
index 191068eaa..000000000
--- a/src/QQBotHub.Web/wwwroot/css/main.css
+++ /dev/null
@@ -1,9 +0,0 @@
-* {
- margin: 0;
- padding: 0;
-}
-
-#app {
- width: 100%;
- color: deepskyblue;
-}
\ No newline at end of file
diff --git a/src/QQBotHub.Web/wwwroot/index.html b/src/QQBotHub.Web/wwwroot/index.html
deleted file mode 100644
index 1e2bd83a1..000000000
--- a/src/QQBotHub.Web/wwwroot/index.html
+++ /dev/null
@@ -1,207 +0,0 @@
-
-
-
-
-
- QQBotHub
-
-
-
-
-
-
QQBotHub
-
-
-
-
-
加载中...
-
-
-
-
-
-
- BotKeyStore.json (不修改留空)
-
-
-
-
登录
-
退出
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/ConsoleApp/ConsoleApp.csproj b/test/KonataApp/KonataApp.csproj
similarity index 100%
rename from test/ConsoleApp/ConsoleApp.csproj
rename to test/KonataApp/KonataApp.csproj
diff --git a/test/ConsoleApp/Program.cs b/test/KonataApp/Program.cs
similarity index 98%
rename from test/ConsoleApp/Program.cs
rename to test/KonataApp/Program.cs
index fb8ad77ac..007b9c640 100644
--- a/test/ConsoleApp/Program.cs
+++ b/test/KonataApp/Program.cs
@@ -5,7 +5,7 @@
using System.Text.Json;
using static Konata.Core.Events.Model.CaptchaEvent;
-Console.WriteLine("QQBotHub ConsoleApp - QQ登录软件");
+Console.WriteLine("QQBotHub KonataApp - QQ登录软件");
// Create a bot instance