删除qqbot
This commit is contained in:
parent
a73868510b
commit
0062ad3ee0
@ -261,6 +261,8 @@ namespace Milimoe.RainBOT.Command
|
|||||||
{
|
{
|
||||||
TaskUtility.NewTask(async () =>
|
TaskUtility.NewTask(async () =>
|
||||||
{
|
{
|
||||||
|
string m = "已经重新启动 FunGame WebSocket 服务。";
|
||||||
|
string msg = m;
|
||||||
OshimaController.Config.FunGame_isRetrying = false;
|
OshimaController.Config.FunGame_isRetrying = false;
|
||||||
OshimaController.Config.FunGame_isAutoRetry = true;
|
OshimaController.Config.FunGame_isAutoRetry = true;
|
||||||
OshimaController.CurrentRetryTimes = -1;
|
OshimaController.CurrentRetryTimes = -1;
|
||||||
@ -268,12 +270,26 @@ namespace Milimoe.RainBOT.Command
|
|||||||
{
|
{
|
||||||
await OshimaController.Instance.DisconnectFromAnonymousServer();
|
await OshimaController.Instance.DisconnectFromAnonymousServer();
|
||||||
}
|
}
|
||||||
catch { }
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (msg != m)
|
||||||
|
{
|
||||||
|
msg += "\r\n断开匿名服务器遇到问题:";
|
||||||
|
}
|
||||||
|
msg += e.Message;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await OshimaController.Instance.DisconnectAsync();
|
await OshimaController.Instance.DisconnectAsync();
|
||||||
}
|
}
|
||||||
catch { }
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (msg != m)
|
||||||
|
{
|
||||||
|
msg += "\r\n断开 FunGame 服务器遇到问题:";
|
||||||
|
}
|
||||||
|
msg += e.Message;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await OshimaController.Instance.Retry(true);
|
await OshimaController.Instance.Retry(true);
|
||||||
@ -284,7 +300,8 @@ namespace Milimoe.RainBOT.Command
|
|||||||
await OshimaController.Instance.ConnectToAnonymousServer();
|
await OshimaController.Instance.ConnectToAnonymousServer();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
SendMessage(send_group, target_id, "已经重新启动 FunGame WebSocket 服务。");
|
msg += OshimaController.Instance.HTTPClient?.Connected ?? false ? $"已连接上服务器{OshimaController.Instance.HTTPClient.ServerAddress}" : "重试连接失败。";
|
||||||
|
SendMessage(send_group, target_id, msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else Access_Denied(send_group, target_id);
|
else Access_Denied(send_group, target_id);
|
||||||
|
|||||||
12
src/Main.cs
12
src/Main.cs
@ -2,11 +2,9 @@
|
|||||||
using Milimoe.OneBot.Model.Content;
|
using Milimoe.OneBot.Model.Content;
|
||||||
using Milimoe.OneBot.Model.Message;
|
using Milimoe.OneBot.Model.Message;
|
||||||
using Milimoe.OneBot.Model.Other;
|
using Milimoe.OneBot.Model.Other;
|
||||||
using Milimoe.RainBOT.QQBot;
|
|
||||||
using Milimoe.RainBOT.Command;
|
using Milimoe.RainBOT.Command;
|
||||||
using Milimoe.RainBOT.ListeningTask;
|
using Milimoe.RainBOT.ListeningTask;
|
||||||
using Milimoe.RainBOT.Settings;
|
using Milimoe.RainBOT.Settings;
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
|
||||||
using TaskScheduler = Milimoe.FunGame.Core.Api.Utility.TaskScheduler;
|
using TaskScheduler = Milimoe.FunGame.Core.Api.Utility.TaskScheduler;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -20,16 +18,6 @@ try
|
|||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Contains("--qqbot"))
|
|
||||||
{
|
|
||||||
GeneralSettings.IsQQBot = true;
|
|
||||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
|
||||||
Console.WriteLine("QQ官方BOT模式");
|
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
|
||||||
QQBotMain.RunQQBot();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.Any(a => a.StartsWith("-g")))
|
if (args.Any(a => a.StartsWith("-g")))
|
||||||
{
|
{
|
||||||
string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? "";
|
string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? "";
|
||||||
|
|||||||
@ -1,71 +0,0 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using Milimoe.OneBot.Model.Event;
|
|
||||||
using Milimoe.OneBot.Model.Message;
|
|
||||||
using Milimoe.RainBOT.Settings;
|
|
||||||
|
|
||||||
namespace Milimoe.RainBOT.QQBot
|
|
||||||
{
|
|
||||||
public class AppConfig
|
|
||||||
{
|
|
||||||
public int AppID { get; set; } = 0;
|
|
||||||
public string BotToken { get; set; } = "";
|
|
||||||
public string ClientSecret { get; set; } = "";
|
|
||||||
public string FunGameServer { get; set; } = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public class QQBotMain
|
|
||||||
{
|
|
||||||
public static void RunQQBot()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string json = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json"));
|
|
||||||
AppConfig config = JsonSerializer.Deserialize<AppConfig>(json) ?? new();
|
|
||||||
if (config != null)
|
|
||||||
{
|
|
||||||
// 官方BOT服务
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
string read = Console.ReadLine() ?? "";
|
|
||||||
if (read == "quit")
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (read == "test")
|
|
||||||
{
|
|
||||||
GroupMessageEvent groupMessageEvent = new();
|
|
||||||
groupMessageEvent.message.Add(new TextMessage("生成20个攻击之爪 +50给123456"));
|
|
||||||
_ = RainBOTFunGame.Handler(groupMessageEvent);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// OSM指令
|
|
||||||
if (read.Length >= 4 && read[..4] == ".osm")
|
|
||||||
{
|
|
||||||
//MasterCommand.Execute(read, GeneralSettings.Master, false, GeneralSettings.Master, false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (read.ToLower().Trim() ?? "")
|
|
||||||
{
|
|
||||||
case "debug on":
|
|
||||||
GeneralSettings.IsDebug = true;
|
|
||||||
Console.WriteLine("开启Debug模式");
|
|
||||||
break;
|
|
||||||
case "debug off":
|
|
||||||
GeneralSettings.IsDebug = false;
|
|
||||||
Console.WriteLine("关闭Debug模式");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else throw new Exception("config.json 文件不存在");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
Console.WriteLine(e);
|
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user