Skip to content

Commit

Permalink
fix(plugins/autologinplugin/): 依赖KonataPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Jan 14, 2023
1 parent 982f3d7 commit fa5e786
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
15 changes: 7 additions & 8 deletions plugins/AutoLoginPlugin/AutoLoginPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
using Konata.Core;
using Konata.Core.Events.Model;
using Konata.Core.Interfaces.Api;
using QQBotHub.Sdk.IPlugins;
using AutoLoginPlugin.Utils;
using Konata.Core.Message.Model;
using Konata.Core.Common;
using System.Text;
using QQBotHub.Sdk;
using Konata.Core.Message;
using System.Collections.Generic;
using Konata.Core.Interfaces;
using System.IO;
using PluginCore;
using KonataPlugin;

namespace AutoLoginPlugin
{
Expand Down Expand Up @@ -46,9 +45,9 @@ public async Task ExecuteAsync()
{
SettingsModel settingsModel = PluginCore.PluginSettingsModelFactory.Create<SettingsModel>(nameof(AutoLoginPlugin));
string filePath = Path.Combine(PluginPathProvider.PluginsRootPath(), nameof(AutoLoginPlugin), "BotKeyStore.json");
if (QQBotStore.Bot != null && QQBotStore.Bot.IsOnline() && QQBotStore.Bot.KeyStore != null)
if (KonataBotStore.Bot != null && KonataBotStore.Bot.IsOnline() && KonataBotStore.Bot.KeyStore != null)
{
string jsonStr = QQBotHub.Sdk.Utils.JsonUtil.Obj2JsonStr(QQBotStore.Bot.KeyStore);
string jsonStr = KonataPlugin.Utils.JsonUtil.Obj2JsonStr(KonataBotStore.Bot.KeyStore);
File.WriteAllText(filePath, contents: jsonStr, Encoding.UTF8);
}
// 取消: 发现这么调用, 会触发验证, 而直接 用 BotKeyStore new 一个, 就不会(好多次这样都没有验证)
Expand All @@ -64,8 +63,8 @@ public async Task ExecuteAsync()
{
#region 重新 new
string jsonStr = File.ReadAllText(filePath, Encoding.UTF8);
BotKeyStore botKeyStore = QQBotHub.Sdk.Utils.JsonUtil.JsonStr2Obj<BotKeyStore>(jsonStr);
QQBotStore.Bot = BotFather.Create(BotConfig.Default(), BotDevice.Default(), botKeyStore);
BotKeyStore botKeyStore = KonataPlugin.Utils.JsonUtil.JsonStr2Obj<BotKeyStore>(jsonStr);
KonataBotStore.Bot = BotFather.Create(BotConfig.Default(), BotDevice.Default(), botKeyStore);
#endregion

#region 重新登录
Expand All @@ -87,7 +86,7 @@ private static async Task Login(SettingsModel settingsModel)
bool isLoginSuccess = false;
try
{
isLoginSuccess = await QQBotStore.Bot.Login();
isLoginSuccess = await KonataBotStore.Bot.Login();
}
catch (Exception ex)
{
Expand All @@ -98,7 +97,7 @@ private static async Task Login(SettingsModel settingsModel)
{
if (!string.IsNullOrEmpty(settingsModel.AdminQQ) && uint.TryParse(settingsModel.AdminQQ, out uint adminUin))
{
await QQBotStore.Bot.SendFriendMessage(friendUin: adminUin, "自动重新登录成功");
await KonataBotStore.Bot.SendFriendMessage(friendUin: adminUin, "自动重新登录成功");
}
}
else
Expand Down
11 changes: 1 addition & 10 deletions plugins/AutoLoginPlugin/AutoLoginPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@
</PackageReference>
<!--<PackageReference Include="Dapper" Version="2.0.123" />-->
<!--<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115.5" />-->
</ItemGroup>

<!-- 方便开发debug,与发布到nuget -->
<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="QQBotHub.Sdk" Version="0.1.0">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\..\src\QQBotHub.Sdk\QQBotHub.Sdk.csproj">
<ProjectReference Include="..\KonataPlugin\KonataPlugin.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>
Expand Down
2 changes: 1 addition & 1 deletion plugins/AutoLoginPlugin/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"DisplayName": "自动重新登录插件",
"Description": "出现异常离线后,自动重新登录",
"Author": "yiyun",
"Version": "0.0.1",
"Version": "0.1.0",
"SupportedVersions": [ "0.0.1" ]
}

0 comments on commit fa5e786

Please sign in to comment.