From f098b808d2bca5d4b7de226b74595a400308eaff Mon Sep 17 00:00:00 2001 From: milimoe Date: Thu, 16 Jan 2025 00:55:48 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E4=B8=9C=E8=A5=BF=EF=BC=88websocket=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?fungame=E6=9C=8D=E5=8A=A1=E5=99=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RainBOT-CSharp.sln | 14 +- src/Command/MasterCommand.cs | 43 +- src/ListeningTask/FriendMessageTask.cs | 6 +- src/ListeningTask/GroupMessageTask.cs | 2 +- src/Main.cs | 161 +++--- src/Model/TEST.cs | 433 ++++++++++++++++ src/QQBot/QQBotMain.cs | 71 +++ src/RainBOT.csproj | 9 +- src/Settings/GeneralSettings.cs | 19 + src/Settings/OshimaController.cs | 186 +++++++ .../{FunGame.cs => RainBOTFunGame.cs} | 486 ++++++++++++++---- 11 files changed, 1242 insertions(+), 188 deletions(-) create mode 100644 src/Model/TEST.cs create mode 100644 src/QQBot/QQBotMain.cs create mode 100644 src/Settings/OshimaController.cs rename src/Settings/{FunGame.cs => RainBOTFunGame.cs} (70%) diff --git a/RainBOT-CSharp.sln b/RainBOT-CSharp.sln index 996cec2..c8636d9 100644 --- a/RainBOT-CSharp.sln +++ b/RainBOT-CSharp.sln @@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34330.188 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RainBOT-CSharp", "src\RainBOT.csproj", "{46A60688-46D6-4414-A079-7DC0C95B5A37}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RainBOT", "src\RainBOT.csproj", "{46A60688-46D6-4414-A079-7DC0C95B5A37}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneBot-HTTPClient", "..\OneBot-HTTPClient\src\OneBot-HTTPClient.csproj", "{D830E21D-78F7-4480-B86B-0AEA5A291A9D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunGame.Core", "..\FunGame.Core\FunGame.Core.csproj", "{3054F4C0-60AA-4353-B453-12C88E067AE5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +19,14 @@ Global {46A60688-46D6-4414-A079-7DC0C95B5A37}.Debug|Any CPU.Build.0 = Debug|Any CPU {46A60688-46D6-4414-A079-7DC0C95B5A37}.Release|Any CPU.ActiveCfg = Release|Any CPU {46A60688-46D6-4414-A079-7DC0C95B5A37}.Release|Any CPU.Build.0 = Release|Any CPU + {D830E21D-78F7-4480-B86B-0AEA5A291A9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D830E21D-78F7-4480-B86B-0AEA5A291A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D830E21D-78F7-4480-B86B-0AEA5A291A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D830E21D-78F7-4480-B86B-0AEA5A291A9D}.Release|Any CPU.Build.0 = Release|Any CPU + {3054F4C0-60AA-4353-B453-12C88E067AE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3054F4C0-60AA-4353-B453-12C88E067AE5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3054F4C0-60AA-4353-B453-12C88E067AE5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3054F4C0-60AA-4353-B453-12C88E067AE5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index 35e2121..f9caec4 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -242,11 +242,52 @@ namespace Milimoe.RainBOT.Command Daily.InitDaily(); SayNo.InitSayNo(); Ignore.InitIgnore(); - FunGame.FunGameSimulation = false; + RainBOTFunGame.FunGameSimulation = false; SendMessage(send_group, target_id, "参数设定以及权限组重新加载完成。"); } else Access_Denied(send_group, target_id); } + else if (command.Contains(".osm checkws")) + { + if (user_id == GeneralSettings.Master) + { + SendMessage(send_group, target_id, OshimaController.Instance.HTTPClient?.Connected ?? false ? $"已连接上服务器{OshimaController.Instance.HTTPClient.ServerAddress}" : "连接已断开。"); + } + else Access_Denied(send_group, target_id); + } + else if (command.Contains(".osm retryserver")) + { + if (user_id == GeneralSettings.Master) + { + TaskUtility.NewTask(async () => + { + OshimaController.Config.FunGame_isAutoRetry = true; + OshimaController.CurrentRetryTimes = -1; + try + { + await OshimaController.Instance.DisconnectFromAnonymousServer(); + } + catch { } + try + { + await OshimaController.Instance.DisconnectAsync(); + } + catch { } + try + { + await OshimaController.Instance.Retry(true); + } + catch { } + try + { + await OshimaController.Instance.ConnectToAnonymousServer(); + } + catch { } + SendMessage(send_group, target_id, "已经重新启动 FunGame WebSocket 服务。"); + }); + } + else Access_Denied(send_group, target_id); + } else if (command.Contains(".osm set")) { if (user_id == GeneralSettings.Master) diff --git a/src/ListeningTask/FriendMessageTask.cs b/src/ListeningTask/FriendMessageTask.cs index fba36c9..9735a0b 100644 --- a/src/ListeningTask/FriendMessageTask.cs +++ b/src/ListeningTask/FriendMessageTask.cs @@ -52,16 +52,16 @@ namespace Milimoe.RainBOT.ListeningTask if (e.detail.Length >= 9 && e.detail[..9].Equals("FunGame模拟", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.user_id)) return quick_reply; - if (!FunGame.FunGameSimulation) + if (!RainBOTFunGame.FunGameSimulation) { - FunGame.FunGameSimulation = true; + RainBOTFunGame.FunGameSimulation = true; List msgs = await Bot.HttpGet>("https://api.milimoe.com/fungame/test?isweb=false") ?? []; foreach (string msg in msgs) { await Bot.SendFriendMessage(e.user_id, "FunGame模拟", msg.Trim()); await Task.Delay(5500); } - FunGame.FunGameSimulation = false; + RainBOTFunGame.FunGameSimulation = false; } else { diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index 1e9a950..867e103 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -137,7 +137,7 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } - if (await FunGame.Handler(e)) + if (await RainBOTFunGame.Handler(e)) { return quick_reply; } diff --git a/src/Main.cs b/src/Main.cs index 063df10..eb26e67 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -2,9 +2,12 @@ using Milimoe.OneBot.Model.Content; using Milimoe.OneBot.Model.Message; using Milimoe.OneBot.Model.Other; +using Milimoe.RainBOT.QQBot; using Milimoe.RainBOT.Command; using Milimoe.RainBOT.ListeningTask; using Milimoe.RainBOT.Settings; +using Milimoe.FunGame.Core.Api.Utility; +using TaskScheduler = Milimoe.FunGame.Core.Api.Utility.TaskScheduler; try { @@ -17,6 +20,16 @@ try 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"))) { string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? ""; @@ -120,104 +133,98 @@ try listener.GroupBanNoticeListening += GroupBanTask.ListeningTask_handler; listener.FriendMessageListening += FriendMessageTask.ListeningTask_handler; - _ = Task.Factory.StartNew(async () => + TaskScheduler.Shared.AddTask("发送每日新闻", new TimeSpan(8, 30, 0), async () => { - while (true) + try { - try + foreach (Group g in Bot.Groups) { - DateTime now = DateTime.Now; - if (now.Hour == 8 && now.Minute == 30 && !Daily.DailyNews) - { - Daily.DailyNews = true; - // 发送每日新闻 - foreach (Group g in Bot.Groups) - { - GroupMessageContent content = new(g.group_id); - content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb")); - await g.SendMessage(content); - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("已向所有群推送今日新闻。"); - Console.ForegroundColor = ConsoleColor.Gray; - } - } - if (now.Hour == 8 && now.Minute == 31) - { - Daily.DailyNews = false; - } - if (now.Hour == 0 && now.Minute == 0 && Daily.ClearDailys) - { - Daily.ClearDailys = false; - // 清空运势 - Daily.UserDailys.Clear(); - Daily.SaveDaily(); - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("已重置所有人的今日运势。"); - Console.ForegroundColor = ConsoleColor.Gray; - // 发放12点大挑战的奖励 - //await Bot.Send12ClockPresents(); - } - if (now.Hour == 0 && now.Minute == 1) - { - Daily.ClearDailys = true; - } - await Task.Delay(1000); - } - catch (Exception e) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(e); + GroupMessageContent content = new(g.group_id); + content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb")); + await g.SendMessage(content); + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("已向所有群推送今日新闻。"); Console.ForegroundColor = ConsoleColor.Gray; } } + catch (Exception e) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(e); + Console.ForegroundColor = ConsoleColor.Gray; + } + }); + TaskScheduler.Shared.AddTask("清空每日运势", new TimeSpan(0, 0, 0), () => + { + try + { + // 清空运势 + Daily.UserDailys.Clear(); + Daily.SaveDaily(); + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("已重置所有人的今日运势。"); + Console.ForegroundColor = ConsoleColor.Gray; + } + catch (Exception e) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(e); + Console.ForegroundColor = ConsoleColor.Gray; + } + }); + TaskScheduler.Shared.AddRecurringTask("清空下载图片", TimeSpan.FromMinutes(1), () => + { + try + { + foreach (long uid in BlackList.Times.Where(d => d.Value < 5).Select(d => d.Key)) + { + BlackList.Times.Remove(uid); + } + // 清空所有已下载的图片,释放空间 + string directory = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\"; + if (Directory.Exists(directory)) + { + foreach (string file in Directory.GetFiles(directory)) + { + try + { + File.Delete(file); + } + catch { } + } + } + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("清空所有已下载的图片,释放空间。"); + Console.ForegroundColor = ConsoleColor.Gray; + } + catch (Exception e) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(e); + Console.ForegroundColor = ConsoleColor.Gray; + } }); - _ = Task.Factory.StartNew(async () => + // 连接 Oshima Core 服务器 + OshimaController.Config.FunGame_isAutoRetry = true; + Task r = Task.Run(async () => { - while (true) - { - try - { - await Task.Delay(1000 * 60); - foreach (long uid in BlackList.Times.Where(d => d.Value < 5).Select(d => d.Key)) - { - BlackList.Times.Remove(uid); - } - // 清空所有已下载的图片,释放空间 - string directory = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\"; - if (Directory.Exists(directory)) - { - foreach (string file in Directory.GetFiles(directory)) - { - try - { - File.Delete(file); - } - catch { } - } - } - } - catch (Exception e) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(e); - Console.ForegroundColor = ConsoleColor.Gray; - } - } + await OshimaController.Instance.Start(); + await OshimaController.Instance.ConnectToAnonymousServer(); }); bool isListening = true; CancellationTokenSource cts = new(); CancellationToken ct = cts.Token; - Task t = Task.Factory.StartNew(() => + Task t = Task.Factory.StartNew(async () => { // 循环接收消息,此线程会在没有请求时阻塞 while (isListening) { try { - listener.GetContext(); + await listener.GetContext(); } catch (Exception e) { diff --git a/src/Model/TEST.cs b/src/Model/TEST.cs new file mode 100644 index 0000000..97d8d6b --- /dev/null +++ b/src/Model/TEST.cs @@ -0,0 +1,433 @@ +//using Newtonsoft.Json.Linq; +//using QQBot4Sharp.Models; +//using Serilog; +//using System.Text; +//using System.Text.RegularExpressions; + +//namespace QQBot4Sharp.Test +//{ +// internal class Program +// { +// private static JObject _jConfig = []; + +// static async Task Main(string[] args) +// { +// // 配置日志器 +// Log.Logger = new LoggerConfiguration() +// .MinimumLevel.Debug() +// .WriteTo.Console() +// .CreateLogger(); + +// // 读取配置文件 +// _jConfig = JObject.Parse(File.ReadAllText("config.json")); +// var info = new BotCreateInfo() +// { +// AppID = (string?)_jConfig["AppID"], +// ClientSecret = (string?)_jConfig["ClientSecret"], +// Intents = Intents.ALL, +// }; + +// // 创建机器人服务 +// using var bot = new BotService(info); + +// // 注册事件 +// bot.OnReadyAsync += OnReadyAsync; +// bot.OnAtMessageCreateAsync += OnAtMessageCreateAsync; +// bot.OnDirectMessageCreateAsync += OnDirectMessageCreateAsync; +// bot.OnMessageCreateAsync += OnMessageCreateAsync; +// bot.OnC2CMessageCreateAsync += OnC2CMessageCreateAsync; +// bot.OnGroupAtMessageCreateAsync += OnGroupAtMessageCreateAsync; +// bot.OnMessageReactionAddAsync += OnMessageReactionAddAsync; +// bot.OnMessageReactionRemoveAsync += OnMessageReactionRemoveAsync; +// bot.OnInteractionCreateAsync += OnInteractionCreateAsync; +// bot.OnGuildUpdateAsync += OnGuildUpdateAsync; +// bot.OnChannelCreateAsync += OnChannelCreateAsync; + +// // 启动和停止 +// await bot.StartAsync(); +// Console.ReadLine(); +// await bot.StopAsync(); +// } + +// #region 通用事件 + +// /// +// /// READY 事件 +// /// +// private static async Task OnReadyAsync(object sender, ContextEventArgs e) +// { +// Log.Information("Ready"); + +// var user = await e.Service.GetCurrentUserAsync(); +// Log.Information($"当前用户:[{user.ID}]{user.Username}"); + +// await Task.CompletedTask; +// } + +// #endregion + +// #region 频道测试 + +// private static readonly Regex _atTestRegex = new("<@![0-9]+> 测试"); +// private static readonly Regex _atPrivateTestRegex = new("<@![0-9]+> 私信测试"); +// private static readonly Regex _atDeleteTestRegex = new("<@![0-9]+> 撤回测试"); +// private static readonly Regex _atEmojiTestRegex = new("<@![0-9]+> 表情测试"); +// private static readonly Regex _atMarkDownTestRegex = new("<@![0-9]+> MarkDown测试"); +// private static readonly Regex _atGuildsRegex = new("<@![0-9]+> 频道列表测试"); +// private static readonly Regex _atGuildRegex = new("<@![0-9]+> 频道测试"); +// private static readonly Regex _atChannelRegex = new("<@![0-9]+> 子频道测试"); +// private static readonly Regex _atChannelDetailRegex = new("<@![0-9]+> 子频道详情测试 [0-9]+"); +// private static readonly Regex _atCreateChannelRegex = new("<@![0-9]+> 创建子频道测试 (?[0-9A-Za-z一-龥]+)"); +// private static readonly Regex _atModifyChannelRegex = new("<@![0-9]+> 修改子频道测试 (?[0-9]+) (?[0-9A-Za-z一-龥]+)"); +// private static readonly Regex _atDeleteChannelRegex = new("<@![0-9]+> 删除子频道测试 (?[0-9]+)"); +// private static readonly Regex _atChannelOnlineMemberCountRegex = new("<@![0-9]+> 获取子频道在线成员数测试 (?[0-9]+)"); + +// /// +// /// 文字子频道At消息事件 +// /// +// private static async Task OnAtMessageCreateAsync(object sender, AtMessageEventArgs e) +// { +// // 收到 “@Bot 测试” 消息后,回复 “At测试” +// if (_atTestRegex.IsMatch(e.Message.Content)) +// { +// await e.ReplyAsync(new() +// { +// Content = "At测试", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 私信测试” 消息后,私信回复 “文字频道的私信测试” +// if (_atPrivateTestRegex.IsMatch(e.Message.Content)) +// { +// var dms = await e.CreateDirectMessageSessionAsync(new() +// { +// RecipientID = e.Message.Author.ID, +// SourceGuildID = e.Message.GuildID, +// }); +// await e.SendDirectMessageAsync(new() +// { +// Content = "文字频道的私信测试", +// MessageID = e.Message.ID, +// }, dms.GuildID); +// } + +// // 收到 “@Bot 撤回测试” 消息后,先发送一个消息,过几秒后撤回 +// if (_atDeleteTestRegex.IsMatch(e.Message.Content)) +// { +// var delay = 5 * 1000; +// var msg = await e.ReplyAsync(new() +// { +// Content = $"该消息将在{delay / 1000}秒后撤回", +// MessageID = e.Message.ID, +// }); +// await Task.Delay(delay); +// await e.DeleteChannelMessageAsync(msg); +// } + +// // 收到 “@Bot 表情测试” 消息后,先发送一个消息,进行表情测试 +// if (_atEmojiTestRegex.IsMatch(e.Message.Content)) +// { +// var delay = 3 * 1000; +// var msg = await e.ReplyAsync(new() +// { +// Content = "表情测试", +// MessageID = e.Message.ID, +// }); +// await Task.Delay(delay); +// var emoji = new Emoji() +// { +// ID = "128076", +// Type = EmojiType.Emoji, +// }; +// await e.SetEmojiReactionAsync(msg, emoji); +// await Task.Delay(delay); +// var users = await e.GetEmojiReactionAsync(msg, emoji); +// var sb = new StringBuilder(); +// sb.Append("表情表态列表:"); +// foreach (var user in users) +// { +// sb.Append(user.Username); +// sb.Append(' '); +// } +// await e.ReplyAsync(new() +// { +// Content = sb.ToString(), +// MessageID = e.Message.ID, +// }); +// await Task.Delay(delay); +// await e.DeleteEmojiReactionAsync(msg, emoji); +// } + +// // 收到 “@Bot MarkDown测试” 消息后,进行MarkDown测试 +// if (_atMarkDownTestRegex.IsMatch(e.Message.Content)) +// { +// var builder = new MarkDownBuilder(); +// builder.At(e.Message.Author.ID); +// builder.Text(" MarkDown测试\n"); +// builder.Command("/MarkDown测试"); +// await e.ReplyAsync(new() +// { +// Markdown = builder.Build(), +// }); +// } + +// // 收到 “@Bot 频道列表测试” 消息后,回复频道列表 +// // 腾讯你逆大天 +// // 我长这么大第一次见GET请求中带Content的 +// // 不愧是你 +// if (_atGuildsRegex.IsMatch(e.Message.Content)) +// { +// // 还有一件事 +// // 这API为什么会死循环的啊,已经设置了after,返回的还是一样的内容 +// var guilds = await e.GetGuildsAsync(); +// var sb = new StringBuilder(); +// sb.Append("频道列表:"); +// foreach (var guild in guilds) +// { +// sb.Append(guild.Name); +// sb.Append(' '); +// } +// await e.ReplyAsync(new() +// { +// Content = sb.ToString(), +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 频道测试” 消息后,回复频道信息 +// if (_atGuildRegex.IsMatch(e.Message.Content)) +// { +// var guild = await e.GetGuildAsync(e.Message.GuildID); +// await e.ReplyAsync(new() +// { +// Content = $"频道ID:{guild.ID}\n频道名称:{guild.Name}\n频道简介:{guild.Description}", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 子频道测试” 消息后,回复子频道信息 +// if (_atChannelRegex.IsMatch(e.Message.Content)) +// { +// var channels = await e.GetChannelsAsync(e.Message.GuildID); +// var sb = new StringBuilder(); +// sb.Append("子频道列表:"); +// foreach (var channel in channels) +// { +// sb.Append('['); +// sb.Append(channel.ID); +// sb.Append(']'); +// sb.Append(channel.Name); +// sb.Append(' '); +// } +// await e.ReplyAsync(new() +// { +// Content = sb.ToString(), +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 子频道详情测试 ChannelID” 消息后,回复子频道详细信息 +// if (_atChannelDetailRegex.IsMatch(e.Message.Content)) +// { +// var segments = e.Message.Content.Split(' '); +// var channel = await e.GetChannelAsync(segments[2]); +// await e.ReplyAsync(new() +// { +// Content = $"子频道ID:{channel.ID}\n子频道名称:{channel.Name}\n子频道类型:{channel.Type}", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 创建子频道测试” 消息后,创建子频道 +// var match = _atCreateChannelRegex.Match(e.Message.Content); +// if (match.Success) +// { +// var channel = await e.CreateChannelAsync(e.Message.GuildID, new() +// { +// Name = match.Groups["Name"].Value, +// Type = ChannelType.Text, +// SubType = ChannelSubType.Chat, +// PrivateType = PrivateType.Public, +// SpeakPermission = SpeakPermission.All, +// }); +// await e.ReplyAsync(new() +// { +// Content = $"创建子频道ID:{channel.ID}\n子频道名称:{channel.Name}\n子频道类型:{channel.Type}", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 修改子频道测试 ” 消息后,修改子频道 +// match = _atModifyChannelRegex.Match(e.Message.Content); +// if (match.Success) +// { +// var id = match.Groups["ID"].Value; +// var channel = await e.GetChannelAsync(id); +// var name = match.Groups["Name"].Value; +// channel = await e.ModifyChannelAsync(id, new() +// { +// Name = name, +// ParentID = channel.ParentID, +// Position = channel.Position, +// PrivateType = channel.PrivateType, +// SpeakPermission = channel.SpeakPermission, +// }); +// await e.ReplyAsync(new() +// { +// Content = $"修改子频道ID:{channel.ID}\n子频道新名称:{channel.Name}", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 删除子频道测试 ” 消息后,删除子频道 +// match = _atDeleteChannelRegex.Match(e.Message.Content); +// if (match.Success) +// { +// var id = match.Groups["ID"].Value; +// var channel = await e.GetChannelAsync(id); +// await e.DeleteChannelAsync(id); +// await e.ReplyAsync(new() +// { +// Content = $"删除子频道ID:{channel.ID}\n子频道名称:{channel.Name}", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “@Bot 获取子频道在线成员数测试 ” 消息后,回复在线成员数 +// match = _atChannelOnlineMemberCountRegex.Match(e.Message.Content); +// if (match.Success) +// { +// var id = match.Groups["ID"].Value; +// var count = await e.GetChannelOnlineMemberCountAsync(id); +// await e.ReplyAsync(new() +// { +// Content = $"子频道在线成员数:{count}", +// MessageID = e.Message.ID, +// }); +// } +// } + +// /// +// /// 频道私信事件 +// /// +// private static async Task OnDirectMessageCreateAsync(object sender, DirectMessageEventArgs e) +// { +// // 收到 “测试” 消息后,回复 “私信测试” +// if (e.Message.Content == "测试") +// { +// await e.ReplyAsync(new() +// { +// Content = "私信测试", +// MessageID = e.Message.ID, +// }); +// } + +// // 收到 “撤回测试” 消息后,先发送一个消息,过几秒后撤回 +// if (e.Message.Content == "撤回测试") +// { +// var delay = 5 * 1000; +// var msg = await e.ReplyAsync(new() +// { +// Content = $"该消息将在{delay / 1000}秒后撤回", +// MessageID = e.Message.ID, +// }); +// await Task.Delay(delay); +// await e.DeleteDirectMessageAsync(msg); +// } +// } + +// /// +// /// 文字子频道全量消息事件(仅私域) +// /// +// private static async Task OnMessageCreateAsync(object sender, GuildMessageEventArgs e) +// { +// // 收到 “测试” 消息后,回复 “文字频道测试” +// if (e.Message.Content == "测试") +// { +// await e.ReplyAsync(new() +// { +// Content = "文字频道测试", +// MessageID = e.Message.ID, +// }); +// } +// } + +// /// +// /// 消息表态添加事件 +// /// +// private static async Task OnMessageReactionAddAsync(object sender, MessageReactionEventArgs e) +// { +// Log.Information("MessageReactionAdd"); + +// await Task.CompletedTask; +// } + +// /// +// /// 消息表态移除事件 +// /// +// private static async Task OnMessageReactionRemoveAsync(object sender, MessageReactionEventArgs e) +// { +// Log.Information("MessageReactionRemove"); + +// await Task.CompletedTask; +// } + +// /// +// /// 按钮交互 +// /// +// private static async Task OnInteractionCreateAsync(object sender, InteractionEventArgs e) +// { +// Log.Information("InteractionCreate"); + +// // 由于 websocket 推送事件是单向的,开发者收到事件之后,需要进行一次"回应",告知QQ后台,事件已经收到,否则客户端会一直处于loading状态,直到超时。 +// await e.RespondToInteractionAsync(e.Interaction.ID); +// } + +// private static async Task OnGuildUpdateAsync(object sender, GuildUpdateEventArgs e) +// { +// Log.Information("GuildUpdate"); + +// await Task.CompletedTask; +// } + +// private static async Task OnChannelCreateAsync(object sender, ChannelCreateEventArgs e) +// { +// Log.Information($"ChannelCreate:[{e.Channel.ID}]{e.Channel.Name}"); + +// await Task.CompletedTask; +// } + +// #endregion + +// #region QQ聊天测试 + +// /// +// /// 单聊事件 +// /// +// private static async Task OnC2CMessageCreateAsync(object sender, Models.QQ.QQMessageEventArgs e) +// { +// await e.ReplyAsync(new() +// { +// Content = "私聊测试", +// Type = QQMessageType.Text, +// MessageID = e.Message.ID, +// }); +// } + +// /// +// /// 群聊事件 +// /// +// private static async Task OnGroupAtMessageCreateAsync(object sender, Models.QQ.QQMessageEventArgs e) +// { +// await e.ReplyAsync(new() +// { +// Content = "群聊测试", +// Type = QQMessageType.Text, +// MessageID = e.Message.ID, +// }); +// } + +// #endregion +// } +//} \ No newline at end of file diff --git a/src/QQBot/QQBotMain.cs b/src/QQBot/QQBotMain.cs new file mode 100644 index 0000000..15314cb --- /dev/null +++ b/src/QQBot/QQBotMain.cs @@ -0,0 +1,71 @@ +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(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; + } + } + } +} diff --git a/src/RainBOT.csproj b/src/RainBOT.csproj index 08e5faa..6751a52 100644 --- a/src/RainBOT.csproj +++ b/src/RainBOT.csproj @@ -21,9 +21,12 @@ - - ..\..\OneBot-HTTPClient\bin\Debug\net9.0\OneBot-HTTPClient.dll - + + + + + + diff --git a/src/Settings/GeneralSettings.cs b/src/Settings/GeneralSettings.cs index 4309b9d..f08d419 100644 --- a/src/Settings/GeneralSettings.cs +++ b/src/Settings/GeneralSettings.cs @@ -37,6 +37,8 @@ namespace Milimoe.RainBOT.Settings public static long PCallBrother { get; set; } = 4; public static bool IsDebug { get; set; } = false; + + public static bool IsQQBot { get; set; } = false; public static long DebugGroupID { get; set; } = 0; @@ -55,6 +57,10 @@ namespace Milimoe.RainBOT.Settings public static List OSMCoreGroup { get; set; } = []; public static List FunGameGroup { get; set; } = []; + + public static List FunGameWebSocketGroup { get; set; } = []; + + public static string FunGameServer { get; set; } = ""; public static string FunGameToken { get; set; } = ""; @@ -160,6 +166,14 @@ namespace Milimoe.RainBOT.Settings { FunGameGroup = (List)value; } + if (configs.TryGetValue("FunGameWebSocketGroup", out value) && value != null) + { + FunGameWebSocketGroup = (List)value; + } + if (configs.TryGetValue("FunGameServer", out value) && value != null) + { + FunGameServer = (string)value; + } if (configs.TryGetValue("FunGameToken", out value) && value != null) { FunGameToken = (string)value; @@ -191,6 +205,8 @@ namespace Milimoe.RainBOT.Settings Configs.Add("SayNoAccessGroup", SayNoAccessGroup); Configs.Add("OSMCoreGroup", OSMCoreGroup); Configs.Add("FunGameGroup", FunGameGroup); + Configs.Add("FunGameWebSocketGroup", FunGameWebSocketGroup); + Configs.Add("FunGameServer", FunGameServer); Configs.Add("FunGameToken", FunGameToken); Configs.Save(); } @@ -218,6 +234,9 @@ namespace Milimoe.RainBOT.Settings case "fungamegroup": list = FunGameGroup; break; + case "fungamewebsocketgroup": + list = FunGameWebSocketGroup; + break; } string msg = list.Count > 0 ? "权限组" + group + "拥有以下成员:" + "\r\n" + string.Join("\r\n", list) : "此权限组不存在或没有任何成员。"; _ = isgroup ? Bot.SendGroupMessage(target, "显示列表成员", msg) : Bot.SendFriendMessage(target, "显示列表成员", msg); diff --git a/src/Settings/OshimaController.cs b/src/Settings/OshimaController.cs new file mode 100644 index 0000000..0c8910c --- /dev/null +++ b/src/Settings/OshimaController.cs @@ -0,0 +1,186 @@ +using System.Collections; +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Controller; +using Milimoe.FunGame.Core.Library.Common.Network; +using Milimoe.FunGame.Core.Library.Constant; +using Milimoe.FunGame.Core.Model; +using Milimoe.OneBot.Model.Other; + +namespace Milimoe.RainBOT.Settings +{ + public class OshimaController : RunTimeController + { + public static OshimaController Instance { get; set; } = new(); + + public static FunGameConfig Config { get; set; } = new(); + + public static int CurrentRetryTimes { get; set; } = -1; + public static int MaxRetryTimes => 10; + + public override bool BeforeConnect(ref string addr, ref int port, ArrayList args) + { + if (Config.FunGame_isRetrying) + { + Console.WriteLine("正在连接服务器,请耐心等待。"); + return false; + } + string[] strings = ["oshima.fungame.fastauto"]; + args.Add(strings); + args.Add(false); + if (!Config.FunGame_isConnected) + { + CurrentRetryTimes++; + if (CurrentRetryTimes == 0) Console.WriteLine("开始连接服务器..."); + else Console.WriteLine("第" + CurrentRetryTimes + "次重试连接服务器..."); + // 超过重连次数上限 + if (CurrentRetryTimes + 1 > MaxRetryTimes) + { + Config.FunGame_isAutoRetry = false; + Console.WriteLine("无法连接至服务器。"); + _ = Bot.SendFriendMessage(GeneralSettings.Master, "websocket", "重连服务器失败,重试次数已过多。"); + return false; + } + Config.FunGame_isRetrying = true; + return true; + } + else + { + Console.WriteLine("已连接至服务器,请勿重复连接。"); + return false; + } + } + + public override void AfterConnect(ArrayList ConnectArgs) + { + Config.FunGame_isRetrying = false; + string msg = ConnectArgs[1]?.ToString() ?? ""; + string serverName = ConnectArgs[2]?.ToString() ?? ""; + string notice = ConnectArgs[3]?.ToString() ?? ""; + if (msg != "") Console.WriteLine(msg); + if (serverName != "") Console.WriteLine(serverName); + if (notice != "") Console.WriteLine(notice); + } + + public async Task Start() + { + ConnectResult result = ConnectResult.CanNotConnect; + while (result != ConnectResult.Success && Config.FunGame_isAutoRetry) + { + try + { + result = await ConnectAsync(TransmittalType.WebSocket, GeneralSettings.FunGameServer, ssl: true, subUrl: "ws"); + Config.FunGame_isRetrying = false; + await Task.Delay(2000); + } + catch (Exception e) + { + Error(e); + } + } + } + + public async Task Retry(bool send = false) + { + if (HTTPClient is null) + { + try + { + if (await ConnectAsync(TransmittalType.WebSocket, GeneralSettings.FunGameServer, ssl: true, subUrl: "ws") == ConnectResult.Success) + { + Console.WriteLine("重连成功!"); + if (send) + { + await Bot.SendFriendMessage(GeneralSettings.Master, "websocket", "重连服务器成功"); + } + } + else + { + Console.WriteLine("重连失败!"); + if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) + { + await Task.Delay(2000); + if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) + { + await Retry(); + } + } + } + } + catch { } + } + } + + public async Task ConnectToAnonymousServer() + { + if (HTTPClient != null) + { + await HTTPClient.Send(SocketMessageType.AnonymousGameServer, "oshima.fungame.anonymous"); + } + } + + public async Task DisconnectFromAnonymousServer() + { + if (HTTPClient != null) + { + await HTTPClient.Send(SocketMessageType.EndGame); + } + } + + public async Task DisconnectAsync() + { + if (HTTPClient != null) + { + await HTTPClient.Send(SocketMessageType.Disconnect); + Close_WebSocket(); + } + } + + public override async void Error(Exception e) + { + Console.WriteLine(e.ToString()); + await DisconnectAsync(); + if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) + { + CurrentRetryTimes = -1; + Config.FunGame_isAutoRetry = true; + await Task.Delay(2000); + if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) + { + await Retry(); + } + } + } + + public override void WritelnSystemInfo(string msg, LogLevel level = LogLevel.Info, bool useLevel = true) + { + Console.WriteLine(msg); + } + + protected override void SocketHandler_Disconnect(SocketObject ServerMessage) + { + Console.WriteLine("断开服务器连接成功"); + } + + protected override async void SocketHandler_AnonymousGameServer(SocketObject ServerMessage) + { + Dictionary data = ServerMessage.GetParam>(0) ?? []; + if (data.Count > 0) + { + long qq = NetworkUtility.JsonDeserializeFromDictionary(data, "qq"); + string msg = NetworkUtility.JsonDeserializeFromDictionary(data, "msg") ?? ""; + if (qq > 0 && msg != "") + { + foreach (Group g in Bot.Groups.Where(g => GeneralSettings.FunGameWebSocketGroup.Contains(g.group_id))) + { + Member m = Bot.GetMember(g.group_id, qq); + if (m.user_id == qq) + { + await Bot.SendGroupMessageAt(qq, g.group_id, "FunGame推送", msg); + break; + } + } + } + } + } + } +} diff --git a/src/Settings/FunGame.cs b/src/Settings/RainBOTFunGame.cs similarity index 70% rename from src/Settings/FunGame.cs rename to src/Settings/RainBOTFunGame.cs index 046e571..e74b51f 100644 --- a/src/Settings/FunGame.cs +++ b/src/Settings/RainBOTFunGame.cs @@ -1,10 +1,9 @@ using System.Text.RegularExpressions; using Milimoe.OneBot.Model.Event; -using Milimoe.OneBot.Model.QuickReply; namespace Milimoe.RainBOT.Settings { - public class FunGame + public class RainBOTFunGame { public static bool FunGameSimulation { get; set; } = false; private readonly static List FunGameItemType = ["卡包", "武器", "防具", "鞋子", "饰品", "消耗品", "魔法卡", "收藏品", "特殊物品", "任务物品", "礼包", "其他"]; @@ -13,9 +12,9 @@ namespace Milimoe.RainBOT.Settings { bool result = true; - if (e.detail == "帮助") + if (e.detail == "帮助" || e.detail == "帮助1") { - await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 1 / 3 页) + await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 1 / 5 页) 1、创建存档:创建存档,生成随机一个自建角色(序号固定为1) 2、我的库存/我的背包/查看库存 [页码]:显示所有角色、物品库存,每个角色和物品都有一个专属序号 3、我的库存 <物品类型> [页码]:卡包/武器/防具/鞋子/饰品/消耗品/魔法卡等... @@ -33,7 +32,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "帮助2") { - await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 2 / 3 页) + await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 2 / 5 页) 12、装备 <角色序号> <物品序号>:装备指定物品给指定角色 13、取消装备 <角色序号> <装备槽序号>:卸下角色指定装备槽上的物品 * 装备槽序号从1开始,卡包/武器/防具/鞋子/饰品1/饰品2 @@ -50,7 +49,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "帮助3") { - await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 3 / 3 页) + await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 3 / 5 页) 22、普攻升级 [角色序号]:升级普攻等级 23、查看普攻升级 [角色序号]:查看下一次普攻升级信息 23、技能升级 <角色序号> <技能名称>:升级技能等级 @@ -63,8 +62,34 @@ namespace Milimoe.RainBOT.Settings 30、分解 <物品名称> <数量> 31、品质分解 <品质索引>:从0开始,普通/优秀/稀有/史诗/传说/神话/不朽 32、决斗/完整决斗 <@对方>//<昵称>:和对方切磋 +发送【帮助4】查看第 4 页"); + } + + if (e.detail == "帮助4") + { + await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 4 / 5 页) 33、兑换金币 <材料数>:1材料=200金币 -34、还原存档:没有后悔药"); +34、还原存档:没有后悔药 +35、我的主战:查看当前主战角色 +36、我的小队:查看小队角色名单 +37、我的存档:查看账号/存档信息 +38、设置小队 <{角色序号...}>:设置小队角色(1-4个参数) +39、小队决斗/小队完整决斗 <@对方>//<昵称>:用小队和对方切磋 +40、查询boss [boss序号]:查看指定序号boss的详细信息,缺省为boss名称列表 +41、讨伐/小队讨伐boss +42、签到:每日签到 +发送【帮助5】查看第 5 页"); + } + + if (e.detail == "帮助5") + { + await Bot.SendGroupMessage(e.group_id, "饭给木", @"《饭给木》游戏指令列表(第 5 / 5 页) +43:任务列表:查看今日任务列表 +44:开始任务 <任务序号> +45、任务信息:查看进行中任务的详细信息 +46、任务结算:对进行中的任务进行结算 +47、我的状态:查看主战角色状态 +48、小队状态/我的小队状态:查看小队所有角色的状态"); } if (e.detail.Length >= 9 && e.detail[..9].Equals("FunGame模拟", StringComparison.CurrentCultureIgnoreCase)) @@ -73,7 +98,7 @@ namespace Milimoe.RainBOT.Settings if (!FunGameSimulation) { FunGameSimulation = true; - List msgs = await Bot.HttpGet>("https://api.milimoe.com/fungame/test?isweb=false", fungame: true) ?? []; + List msgs = await Bot.HttpGet>($"https://{GeneralSettings.FunGameServer}/fungame/test?isweb=false", fungame: true) ?? []; List real = []; int remain = 7; string merge = ""; @@ -117,7 +142,7 @@ namespace Milimoe.RainBOT.Settings if (!FunGameSimulation) { FunGameSimulation = true; - List msgs = await Bot.HttpGet>("https://api.milimoe.com/fungame/test?isweb=false&isteam=true", fungame: true) ?? []; + List msgs = await Bot.HttpGet>($"https://{GeneralSettings.FunGameServer}/fungame/test?isweb=false&isteam=true", fungame: true) ?? []; List real = []; if (msgs.Count > 0) { @@ -165,7 +190,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查数据", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/stats?id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/stats?id=" + id, fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", msg); @@ -180,7 +205,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查团队数据", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/teamstats?id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/teamstats?id=" + id, fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", msg); @@ -192,7 +217,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail.Length >= 5 && e.detail[..5].Equals("查个人胜率", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return result; - string[] msg = await Bot.HttpGet("https://api.milimoe.com/fungame/winraterank?isteam=false", fungame: true) ?? []; + string[] msg = await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/winraterank?isteam=false", fungame: true) ?? []; if (msg.Length > 0) { await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", string.Join("\r\n\r\n", msg)); @@ -203,7 +228,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail.Length >= 5 && e.detail[..5].Equals("查团队胜率", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return result; - string[] msg = await Bot.HttpGet("https://api.milimoe.com/fungame/winraterank?isteam=true", fungame: true) ?? []; + string[] msg = await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/winraterank?isteam=true", fungame: true) ?? []; if (msg.Length > 0) { await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", string.Join("\r\n\r\n", msg)); @@ -217,7 +242,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查角色", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/characterinfo?id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/characterinfo?id=" + id, fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg); @@ -232,7 +257,15 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查技能", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/skillinfo?id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/skillinfo?qq={e.user_id}&id=" + id, fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg); + } + } + else + { + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/skillinfoname?qq={e.user_id}&name=" + Uri.EscapeDataString(detail.Trim()), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg); @@ -247,7 +280,15 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查物品", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/iteminfo?id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/iteminfo?qq={e.user_id}&id=" + id, fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "查询FunGame物品信息", msg); + } + } + else + { + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/iteminfoname?qq={e.user_id}&name=" + Uri.EscapeDataString(detail.Trim()), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame物品信息", msg); @@ -256,10 +297,44 @@ namespace Milimoe.RainBOT.Settings return result; } + if (e.detail.StartsWith("生成")) + { + string pattern = @"生成\s*(\d+)\s*个\s*([\s\S]+)(?:\s*给\s*(\d+))"; + Regex regex = new(pattern, RegexOptions.IgnoreCase); + Match match = regex.Match(e.detail); + + if (match.Success) + { + int count = int.Parse(match.Groups[1].Value); + string name = match.Groups[2].Value.Trim(); + string target = match.Groups[3].Value; + long userid = e.user_id; + + if (!string.IsNullOrEmpty(target)) + { + userid = long.Parse(target); + } + + if (count > 0) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createitem?qq={e.user_id}&name={Uri.EscapeDataString(name)}&count={count}&target={userid}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "熟圣之力", msg); + } + } + else + { + await Bot.SendGroupMessage(e.group_id, "熟圣之力", "数量不能为0,请重新输入。"); + } + return result; + } + } + if (e.detail.Length >= 6 && e.detail[..6] == "生成魔法卡包") { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return result; - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/newmagiccardpack", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/newmagiccardpack", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "生成魔法卡包", msg); @@ -269,7 +344,7 @@ namespace Milimoe.RainBOT.Settings else if (e.detail.Length >= 5 && e.detail[..5] == "生成魔法卡") { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return result; - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/newmagiccard", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/newmagiccard", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "生成魔法卡", msg); @@ -279,7 +354,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "创建存档") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/createsaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createsaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "创建存档", "\r\n" + msg); @@ -289,7 +364,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的存档") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showsaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showsaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的存档", "\r\n" + msg); @@ -299,7 +374,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的主战") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq=0", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq=0", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的主战", "\r\n" + msg); @@ -307,9 +382,29 @@ namespace Milimoe.RainBOT.Settings return result; } + if (e.detail == "我的状态") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showmaincharacterorsquadstatus?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的状态", "\r\n" + msg); + } + return result; + } + + if (e.detail == "小队状态" || e.detail == "我的小队状态") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showmaincharacterorsquadstatus?qq={e.user_id}&squad=true", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的小队状态", "\r\n" + msg); + } + return result; + } + if (e.detail == "我的小队") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showsquad?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showsquad?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的小队", "\r\n" + msg); @@ -319,7 +414,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "清空小队") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/clearsquad?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/clearsquad?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "清空小队", "\r\n" + msg); @@ -329,7 +424,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "还原存档") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/restoresaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/restoresaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "还原存档", "\r\n" + msg); @@ -339,7 +434,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "生成自建角色") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/newcustomcharacter?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/newcustomcharacter?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", "\r\n" + msg); @@ -349,7 +444,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "角色改名") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/rename?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/rename?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "改名", "\r\n" + msg); @@ -359,7 +454,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "角色重随") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/randomcustom?qq={e.user_id}&confirm=false", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/randomcustom?qq={e.user_id}&confirm=false", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg); @@ -369,7 +464,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "确认角色重随") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/randomcustom?qq={e.user_id}&confirm=true", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/randomcustom?qq={e.user_id}&confirm=true", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg); @@ -379,7 +474,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "取消角色重随") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/cancelrandomcustom?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/cancelrandomcustom?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg); @@ -389,7 +484,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "抽卡") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/drawcard?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcard?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", "\r\n" + msg); @@ -399,7 +494,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "十连抽卡") { - List msgs = (await Bot.HttpPost>($"https://api.milimoe.com/fungame/drawcards?qq={e.user_id}", "", fungame: true) ?? []); + List msgs = (await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/drawcards?qq={e.user_id}", "", fungame: true) ?? []); if (msgs.Count > 0) { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "十连抽卡", "\r\n" + string.Join("\r\n", msgs)); @@ -409,7 +504,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "材料抽卡") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/drawcardm?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcardm?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料抽卡", "\r\n" + msg); @@ -419,7 +514,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "材料十连抽卡") { - List msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/drawcardsm?qq={e.user_id}", "", fungame: true) ?? []; + List msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/drawcardsm?qq={e.user_id}", "", fungame: true) ?? []; if (msgs.Count > 0) { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料十连抽卡", "\r\n" + string.Join("\r\n", msgs)); @@ -433,7 +528,7 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo2?qq={e.user_id}&page={page}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo2?qq={e.user_id}&page={page}", "", fungame: true) ?? []; } else if (FunGameItemType.FirstOrDefault(detail.Contains) is string matchedType) { @@ -441,16 +536,16 @@ namespace Milimoe.RainBOT.Settings string remain = detail.Replace(matchedType, "").Trim(); if (int.TryParse(remain, out page)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={typeIndex}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={typeIndex}", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={typeIndex}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={typeIndex}", "", fungame: true) ?? []; } } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo2?qq={e.user_id}&page=1", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo2?qq={e.user_id}&page=1", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -465,11 +560,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo3?qq={e.user_id}&page={page}&order=2&orderqty=2", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo3?qq={e.user_id}&page={page}&order=2&orderqty=2", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo3?qq={e.user_id}&page=1&order=2&orderqty=2", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo3?qq={e.user_id}&page=1&order=2&orderqty=2", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -484,11 +579,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo5?qq={e.user_id}&page={page}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo5?qq={e.user_id}&page={page}", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo5?qq={e.user_id}&page=1", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo5?qq={e.user_id}&page=1", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -507,11 +602,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (strings.Length > 1 && int.TryParse(strings[1].Trim(), out int page)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={t}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={t}", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={t}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={t}", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -527,11 +622,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=true", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=true", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=true", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=true", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -546,11 +641,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=false", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=false", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=false", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=false", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -565,11 +660,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterskills?qq={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterskills?qq={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacterskills?qq={e.user_id}&seq=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterskills?qq={e.user_id}&seq=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -584,11 +679,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacteritems?qq={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacteritems?qq={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showcharacteritems?qq={e.user_id}&seq=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacteritems?qq={e.user_id}&seq=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -603,11 +698,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/setmain?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setmain?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/setmain?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setmain?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -622,11 +717,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/starttraining?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/starttraining?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/starttraining?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/starttraining?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -637,7 +732,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "练级信息") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/gettraininginfo?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/gettraininginfo?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "练级信息", "\r\n" + msg); @@ -647,7 +742,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "练级结算") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/stoptraining?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/stoptraining?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "练级结算", "\r\n" + msg); @@ -657,7 +752,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "材料抽卡") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/drawcardm?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcardm?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料抽卡", "\r\n" + msg); @@ -667,7 +762,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "任务列表") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/checkquestlist?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/checkquestlist?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "任务列表", "\r\n" + msg); @@ -677,7 +772,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "任务信息") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/checkworkingquest?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/checkworkingquest?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "任务信息", "\r\n" + msg); @@ -685,9 +780,19 @@ namespace Milimoe.RainBOT.Settings return result; } + if (e.detail == "任务结算") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/settlequest?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "任务结算", "\r\n" + msg); + } + return result; + } + if (e.detail == "签到") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/signin?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/signin?qq={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "签到", "\r\n" + msg); @@ -700,7 +805,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("开始任务", "").Trim(); if (int.TryParse(detail, out int index)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/acceptquest?qq={e.user_id}&id={index}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/acceptquest?qq={e.user_id}&id={index}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "开始任务", msg); @@ -714,7 +819,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("我的物品", "").Trim(); if (int.TryParse(detail, out int index)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/showiteminfo?qq={e.user_id}&seq={index}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showiteminfo?qq={e.user_id}&seq={index}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查库存物品", msg); @@ -728,7 +833,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("兑换金币", "").Trim(); if (int.TryParse(detail, out int materials)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/exchangecredits?qq={e.user_id}&materials={materials}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/exchangecredits?qq={e.user_id}&materials={materials}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "兑换金币", msg); @@ -746,7 +851,7 @@ namespace Milimoe.RainBOT.Settings { if (c != -1 && i != -1) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/unequipitem?qq={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/unequipitem?qq={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "取消装备", msg); @@ -765,7 +870,7 @@ namespace Milimoe.RainBOT.Settings { if (c != -1 && i != -1) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/equipitem?qq={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/equipitem?qq={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "装备", msg); @@ -785,7 +890,7 @@ namespace Milimoe.RainBOT.Settings string s = strings[1].Trim(); if (c != -1 && s != "") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/getskilllevelupneedy?qq={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getskilllevelupneedy?qq={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查看技能升级", msg); @@ -805,7 +910,7 @@ namespace Milimoe.RainBOT.Settings string s = strings[1].Trim(); if (c != -1 && s != "") { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/skilllevelup?qq={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/skilllevelup?qq={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "技能升级", msg); @@ -824,7 +929,7 @@ namespace Milimoe.RainBOT.Settings { if (id1 != -1 && id2 != -1 && id3 != -1) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/conflatemagiccardpack?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize([id1, id2, id3]), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/conflatemagiccardpack?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize([id1, id2, id3]), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "合成魔法卡", msg); @@ -840,11 +945,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/characterlevelup?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelup?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/characterlevelup?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelup?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -859,11 +964,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/getnormalattacklevelupneedy?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getnormalattacklevelupneedy?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/getnormalattacklevelupneedy?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getnormalattacklevelupneedy?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -878,11 +983,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/normalattacklevelup?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/normalattacklevelup?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/normalattacklevelup?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/normalattacklevelup?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -897,11 +1002,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/characterlevelbreak?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelbreak?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/characterlevelbreak?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelbreak?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -916,11 +1021,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/getlevelbreakneedy?qq={e.user_id}&id={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getlevelbreakneedy?qq={e.user_id}&id={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/getlevelbreakneedy?qq={e.user_id}&id=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getlevelbreakneedy?qq={e.user_id}&id=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -945,7 +1050,7 @@ namespace Milimoe.RainBOT.Settings { if (id > 0 && id2 > 0) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/useitem3?qq={e.user_id}&id={id}&id2={id2}&c={isCharacter}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem3?qq={e.user_id}&id={id}&id2={id2}&c={isCharacter}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用魔法卡", msg); @@ -966,7 +1071,7 @@ namespace Milimoe.RainBOT.Settings { string characterIdsString = match.Groups["characterIds"].Value; int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1]; - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -983,7 +1088,7 @@ namespace Milimoe.RainBOT.Settings { string characterIdsString = match.Groups["characterIds"].Value; int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1]; - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/useitem?qq={e.user_id}&id={itemId}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem?qq={e.user_id}&id={itemId}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -999,7 +1104,7 @@ namespace Milimoe.RainBOT.Settings string itemName = match.Groups["itemName"].Value.Trim(); if (int.TryParse(match.Groups["count"].Value, out int count)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -1014,7 +1119,7 @@ namespace Milimoe.RainBOT.Settings { if (int.TryParse(match.Groups["itemId"].Value, out int itemId)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/useitem?qq={e.user_id}&id={itemId}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem?qq={e.user_id}&id={itemId}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -1040,7 +1145,7 @@ namespace Milimoe.RainBOT.Settings ids.Add(id); } } - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/decomposeitem?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(ids), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(ids), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "分解物品", msg); @@ -1059,7 +1164,7 @@ namespace Milimoe.RainBOT.Settings string itemName = match.Groups["itemName"].Value.Trim(); if (int.TryParse(match.Groups["count"].Value, out int count)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/decomposeitem2?qq={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem2?qq={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "分解", msg); @@ -1075,7 +1180,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("品质分解", "").Trim(); if (int.TryParse(detail, out int q)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/decomposeitem3?qq={e.user_id}&q={q}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem3?qq={e.user_id}&q={q}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "品质分解", msg); @@ -1100,7 +1205,7 @@ namespace Milimoe.RainBOT.Settings { userid = temp; } - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/createitem?qq={e.user_id}&name={name}&count={count}&target={userid}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createitem?qq={e.user_id}&name={name}&count={count}&target={userid}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "熟圣之力", msg); @@ -1120,11 +1225,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=true", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; } List real = []; if (msgs.Count >= 2) @@ -1173,11 +1278,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=false", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=false", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=false", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=false", fungame: true) ?? []; } List real = []; if (msgs.Count > 2) @@ -1219,11 +1324,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightcustomteam?qq={e.user_id}&eqq={eqq}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustomteam?qq={e.user_id}&eqq={eqq}&all=true", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightcustomteam2?qq={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustomteam2?qq={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; } List real = []; if (msgs.Count >= 3) @@ -1273,11 +1378,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int cid)) { - msgs = await Bot.HttpGet>($"https://api.milimoe.com/fungame/getboss?index={cid}", fungame: true) ?? []; + msgs = await Bot.HttpGet>($"https://{GeneralSettings.FunGameServer}/fungame/getboss?index={cid}", fungame: true) ?? []; } else { - msgs = await Bot.HttpGet>($"https://api.milimoe.com/fungame/getboss", fungame: true) ?? []; + msgs = await Bot.HttpGet>($"https://{GeneralSettings.FunGameServer}/fungame/getboss", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -1292,7 +1397,7 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail.Trim(), out int index)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightbossteam?qq={e.user_id}&index={index}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightbossteam?qq={e.user_id}&index={index}&all=true", fungame: true) ?? []; List real = []; if (msgs.Count >= 3) { @@ -1346,7 +1451,7 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail.Trim(), out int index)) { - msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/fightboss?qq={e.user_id}&index={index}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightboss?qq={e.user_id}&index={index}&all=true", fungame: true) ?? []; List real = []; if (msgs.Count >= 3) { @@ -1399,7 +1504,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("小队添加", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/addsquad?qq={e.user_id}&c={c}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/addsquad?qq={e.user_id}&c={c}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "小队", msg); @@ -1413,7 +1518,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("小队移除", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/removesquad?qq={e.user_id}&c={c}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/removesquad?qq={e.user_id}&c={c}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "小队", msg); @@ -1434,7 +1539,7 @@ namespace Milimoe.RainBOT.Settings cindexs.Add(c); } } - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/setsquad?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(cindexs), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setsquad?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(cindexs), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "小队", msg); @@ -1442,10 +1547,187 @@ namespace Milimoe.RainBOT.Settings return result; } + if (e.detail.Length >= 4 && e.detail[..4].Equals("加入社团", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("加入社团", "").Trim(); + if (int.TryParse(detail, out int c)) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/joinclub?qq={e.user_id}&id={c}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + } + return result; + } + + if (e.detail.Length >= 4 && e.detail[..4].Equals("创建社团", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("创建社团", "").Trim(); + bool isPublic = true; + if (detail.Contains("私密")) + { + isPublic = false; + } + detail = detail.Replace("私密", "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createclub?qq={e.user_id}&public={isPublic}&prefix={detail}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + return result; + } + + if (e.detail == "退出社团") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/quitclub?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); + } + return result; + } + + if (e.detail == "我的社团") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubinfo?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); + } + return result; + } + + if (e.detail == "解散社团") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/disbandclub?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); + } + return result; + } + + if (e.detail == "查看社团成员") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?qq={e.user_id}&type=0", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); + } + return result; + } + + if (e.detail == "查看社团管理") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?qq={e.user_id}&type=1", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); + } + return result; + } + + if (e.detail == "查看申请人列表") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?qq={e.user_id}&type=2", "", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); + } + return result; + } + + if (e.detail.Length >= 4 && e.detail[..4].Equals("社团批准", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("社团批准", "").Replace("@", "").Trim(); + if (long.TryParse(detail, out long id)) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/approveclub?qq={e.user_id}&id={id}&approval=true", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + } + return result; + } + + if (e.detail.Length >= 4 && e.detail[..4].Equals("社团拒绝", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("社团拒绝", "").Replace("@", "").Trim(); + if (long.TryParse(detail, out long id)) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/approveclub?qq={e.user_id}&id={id}&approval=false", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + } + return result; + } + + if (e.detail.Length >= 4 && e.detail[..4].Equals("社团踢出", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("社团踢出", "").Replace("@", "").Trim(); + if (long.TryParse(detail, out long id)) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/kickclub?qq={e.user_id}&id={id}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + } + return result; + } + + if (e.detail.Length >= 4 && e.detail[..4].Equals("社团设置", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("社团设置", "").Trim(); + string[] strings = detail.Split(' '); + if (strings.Length > 0) + { + string part = strings[0].Trim() switch + { + "名称" => "name", + "前缀" => "prefix", + "描述" => "description", + "批准" => "isneedapproval", + "公开" => "ispublic", + "管理" => "setadmin", + "取消管理" => "setnotadmin", + "新社长" => "setmaster", + _ => "", + }; + List args = []; + if (strings.Length > 1) + { + args = [.. strings[1..]]; + } + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/changeclub?qq={e.user_id}&part={part}", System.Text.Json.JsonSerializer.Serialize(args), fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + } + return result; + } + + if (e.detail.Length >= 4 && e.detail[..4].Equals("社团转让", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("社团转让", "").Replace("@", "").Trim(); + List args = [detail]; + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/changeclub?qq={e.user_id}&part=setmaster", System.Text.Json.JsonSerializer.Serialize(args), fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "社团", msg); + } + return result; + } + if (e.user_id == GeneralSettings.Master && e.detail.Length >= 9 && e.detail[..9].Equals("重载FunGame", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return result; - string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/reload?master=" + GeneralSettings.Master, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet("https://{GeneralSettings.FunGameServer}/fungame/reload?master=" + GeneralSettings.Master, fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "重载FunGame", msg); From 6c213e086d8d561ea9f975a83c6f4e1ad2e1fa3d Mon Sep 17 00:00:00 2001 From: milimoe Date: Thu, 16 Jan 2025 01:35:35 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ws=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ListeningTask/GroupMessageTask.cs | 20 +++++++++ src/Settings/OshimaController.cs | 60 +++++++++++++++++++++------ 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index 867e103..a56f6b6 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -109,6 +109,13 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } + if (e.detail == "圣人榜") + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + _ = OshimaController.Instance.SCList(e.group_id); + return quick_reply; + } + if (e.detail == "查询服务器启动时间") { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; @@ -454,6 +461,7 @@ namespace Milimoe.RainBOT.ListeningTask if (content.message.Count > 0) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", content); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } } else if (SayNo.TriggerBeforeNo.Any(e.detail.Contains) && GeneralSettings.IsSayNo && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -507,6 +515,7 @@ namespace Milimoe.RainBOT.ListeningTask if (content.message.Count > 0) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", content); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } } else if (e.detail.Contains("可以") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -515,10 +524,12 @@ namespace Milimoe.RainBOT.ListeningTask if (dice < (GeneralSettings.PSayNo / 2)) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "可以"); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } else { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可以"); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } } else if (e.detail.Contains('能') && !e.detail.Contains('不') && !SayNo.IgnoreTriggerBeforeCan.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -527,10 +538,12 @@ namespace Milimoe.RainBOT.ListeningTask if (dice < (GeneralSettings.PSayNo / 2)) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "能"); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } else { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不能"); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } } else if (e.detail.Contains("可能") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -539,21 +552,25 @@ namespace Milimoe.RainBOT.ListeningTask if (dice < (GeneralSettings.PSayNo / 2)) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "可能"); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } else { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可能"); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } } else if (e.detail.Contains('要') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) { Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); await Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayWantWords[new Random().Next(SayNo.SayWantWords.Count)]); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } else if (e.detail.Contains('想') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) { Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); await Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayThinkWords[new Random().Next(SayNo.SayThinkWords.Count)]); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); } // 反向艾特 @@ -587,6 +604,7 @@ namespace Milimoe.RainBOT.ListeningTask }; content.message.Add(new ImageMessage(img)); await Bot.SendGroupMessage(e.group_id, "Image", content); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); return quick_reply; } @@ -599,6 +617,7 @@ namespace Milimoe.RainBOT.ListeningTask GroupMessageContent content = new(e.group_id); content.message.AddRange(e.message); await Bot.SendGroupMessage(e.group_id, "随机复读", content, delay * 1000); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); return quick_reply; } @@ -630,6 +649,7 @@ namespace Milimoe.RainBOT.ListeningTask break; } await Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); return quick_reply; } } diff --git a/src/Settings/OshimaController.cs b/src/Settings/OshimaController.cs index 0c8910c..9e2bdb4 100644 --- a/src/Settings/OshimaController.cs +++ b/src/Settings/OshimaController.cs @@ -11,11 +11,10 @@ namespace Milimoe.RainBOT.Settings public class OshimaController : RunTimeController { public static OshimaController Instance { get; set; } = new(); - public static FunGameConfig Config { get; set; } = new(); - public static int CurrentRetryTimes { get; set; } = -1; - public static int MaxRetryTimes => 10; + public static int MaxRetryTimes => 30; + public const string ServerName = "oshima.fungame.anonymous"; public override bool BeforeConnect(ref string addr, ref int port, ArrayList args) { @@ -70,7 +69,7 @@ namespace Milimoe.RainBOT.Settings { result = await ConnectAsync(TransmittalType.WebSocket, GeneralSettings.FunGameServer, ssl: true, subUrl: "ws"); Config.FunGame_isRetrying = false; - await Task.Delay(2000); + await Task.Delay(5000); } catch (Exception e) { @@ -98,7 +97,7 @@ namespace Milimoe.RainBOT.Settings Console.WriteLine("重连失败!"); if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) { - await Task.Delay(2000); + await Task.Delay(5000); if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) { await Retry(); @@ -114,7 +113,7 @@ namespace Milimoe.RainBOT.Settings { if (HTTPClient != null) { - await HTTPClient.Send(SocketMessageType.AnonymousGameServer, "oshima.fungame.anonymous"); + await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName); } } @@ -143,7 +142,7 @@ namespace Milimoe.RainBOT.Settings { CurrentRetryTimes = -1; Config.FunGame_isAutoRetry = true; - await Task.Delay(2000); + await Task.Delay(5000); if (!Config.FunGame_isRetrying && Config.FunGame_isAutoRetry) { await Retry(); @@ -168,19 +167,54 @@ namespace Milimoe.RainBOT.Settings { long qq = NetworkUtility.JsonDeserializeFromDictionary(data, "qq"); string msg = NetworkUtility.JsonDeserializeFromDictionary(data, "msg") ?? ""; - if (qq > 0 && msg != "") + if (msg != "") { - foreach (Group g in Bot.Groups.Where(g => GeneralSettings.FunGameWebSocketGroup.Contains(g.group_id))) + if (qq > 0) { - Member m = Bot.GetMember(g.group_id, qq); - if (m.user_id == qq) + foreach (Group g in Bot.Groups.Where(g => GeneralSettings.FunGameWebSocketGroup.Contains(g.group_id))) { - await Bot.SendGroupMessageAt(qq, g.group_id, "FunGame推送", msg); - break; + Member m = Bot.GetMember(g.group_id, qq); + if (m.user_id == qq) + { + await Bot.SendGroupMessageAt(qq, g.group_id, "FunGame推送", msg); + break; + } + } + } + else + { + long groupid = NetworkUtility.JsonDeserializeFromDictionary(data, "groupid"); + if (groupid > 0 && Bot.Groups.Any(g => g.group_id == groupid)) + { + await Bot.SendGroupMessage(groupid, "匿名服务器消息", msg); } } } } } + + public async Task SCAdd(long qq, long groupid, double sc = 1) + { + if (HTTPClient != null) + { + Dictionary data = []; + data.Add("command", "scadd"); + data.Add("qq", qq); + data.Add("groupid", groupid); + data.Add("sc", sc); + await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName, data); + } + } + + public async Task SCList(long groupid) + { + if (HTTPClient != null) + { + Dictionary data = []; + data.Add("command", "sclist"); + data.Add("groupid", groupid); + await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName, data); + } + } } } From e4a77d5421f1d989cb56d7c6c76c31cc9ee1cf0f Mon Sep 17 00:00:00 2001 From: milimoe Date: Thu, 16 Jan 2025 20:39:32 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ListeningTask/GroupMessageTask.cs | 8 ++++--- src/Settings/OshimaController.cs | 32 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index a56f6b6..c57e60c 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -109,11 +109,10 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } - if (e.detail == "圣人榜") + if (e.detail.Contains("圣人榜")) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; _ = OshimaController.Instance.SCList(e.group_id); - return quick_reply; } if (e.detail == "查询服务器启动时间") @@ -632,6 +631,7 @@ namespace Milimoe.RainBOT.ListeningTask { GroupMessageContent content = new(e.group_id); content.message.Add(new AtMessage(e.user_id)); + int sc = 1; switch (Random.Shared.Next(4)) { case 0: @@ -642,14 +642,16 @@ namespace Milimoe.RainBOT.ListeningTask break; case 2: content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "圣"))); + sc = 3; break; case 3: default: content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "出"))); + sc = -1; break; } await Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, sc); return quick_reply; } } diff --git a/src/Settings/OshimaController.cs b/src/Settings/OshimaController.cs index 9e2bdb4..ae62eeb 100644 --- a/src/Settings/OshimaController.cs +++ b/src/Settings/OshimaController.cs @@ -113,7 +113,9 @@ namespace Milimoe.RainBOT.Settings { if (HTTPClient != null) { - await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName); + Dictionary data = []; + data.Add("access_token", GeneralSettings.FunGameToken); + await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName, data); } } @@ -166,25 +168,29 @@ namespace Milimoe.RainBOT.Settings if (data.Count > 0) { long qq = NetworkUtility.JsonDeserializeFromDictionary(data, "qq"); + long groupid = NetworkUtility.JsonDeserializeFromDictionary(data, "groupid"); string msg = NetworkUtility.JsonDeserializeFromDictionary(data, "msg") ?? ""; if (msg != "") { - if (qq > 0) + if (qq > 0 && groupid > 0) { - foreach (Group g in Bot.Groups.Where(g => GeneralSettings.FunGameWebSocketGroup.Contains(g.group_id))) - { - Member m = Bot.GetMember(g.group_id, qq); - if (m.user_id == qq) - { - await Bot.SendGroupMessageAt(qq, g.group_id, "FunGame推送", msg); - break; - } - } + await Bot.SendGroupMessageAt(qq, groupid, "匿名服务器消息", msg); } else { - long groupid = NetworkUtility.JsonDeserializeFromDictionary(data, "groupid"); - if (groupid > 0 && Bot.Groups.Any(g => g.group_id == groupid)) + if (qq > 0) + { + foreach (Group g in Bot.Groups.Where(g => GeneralSettings.FunGameWebSocketGroup.Contains(g.group_id))) + { + Member m = Bot.GetMember(g.group_id, qq); + if (m.user_id == qq) + { + await Bot.SendGroupMessageAt(qq, g.group_id, "FunGame推送", msg); + break; + } + } + } + else if (groupid > 0 && Bot.Groups.Any(g => g.group_id == groupid)) { await Bot.SendGroupMessage(groupid, "匿名服务器消息", msg); } From a73868510bde3a0a7598273d36b26ed914434ddc Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 18 Jan 2025 16:02:31 +0800 Subject: [PATCH 4/8] flag --- src/Command/MasterCommand.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index f9caec4..35170c9 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -261,6 +261,7 @@ namespace Milimoe.RainBOT.Command { TaskUtility.NewTask(async () => { + OshimaController.Config.FunGame_isRetrying = false; OshimaController.Config.FunGame_isAutoRetry = true; OshimaController.CurrentRetryTimes = -1; try From 0062ad3ee007c07edbf82c8859edbc867cb37b95 Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 18 Jan 2025 16:07:02 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=88=A0=E9=99=A4qqbot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command/MasterCommand.cs | 23 ++++++++++-- src/Main.cs | 12 ------ src/QQBot/QQBotMain.cs | 71 ------------------------------------ 3 files changed, 20 insertions(+), 86 deletions(-) delete mode 100644 src/QQBot/QQBotMain.cs diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index 35170c9..582fbbe 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -261,6 +261,8 @@ namespace Milimoe.RainBOT.Command { TaskUtility.NewTask(async () => { + string m = "已经重新启动 FunGame WebSocket 服务。"; + string msg = m; OshimaController.Config.FunGame_isRetrying = false; OshimaController.Config.FunGame_isAutoRetry = true; OshimaController.CurrentRetryTimes = -1; @@ -268,12 +270,26 @@ namespace Milimoe.RainBOT.Command { await OshimaController.Instance.DisconnectFromAnonymousServer(); } - catch { } + catch (Exception e) + { + if (msg != m) + { + msg += "\r\n断开匿名服务器遇到问题:"; + } + msg += e.Message; + } try { await OshimaController.Instance.DisconnectAsync(); } - catch { } + catch (Exception e) + { + if (msg != m) + { + msg += "\r\n断开 FunGame 服务器遇到问题:"; + } + msg += e.Message; + } try { await OshimaController.Instance.Retry(true); @@ -284,7 +300,8 @@ namespace Milimoe.RainBOT.Command await OshimaController.Instance.ConnectToAnonymousServer(); } 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); diff --git a/src/Main.cs b/src/Main.cs index eb26e67..aedba8f 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -2,11 +2,9 @@ using Milimoe.OneBot.Model.Content; using Milimoe.OneBot.Model.Message; using Milimoe.OneBot.Model.Other; -using Milimoe.RainBOT.QQBot; using Milimoe.RainBOT.Command; using Milimoe.RainBOT.ListeningTask; using Milimoe.RainBOT.Settings; -using Milimoe.FunGame.Core.Api.Utility; using TaskScheduler = Milimoe.FunGame.Core.Api.Utility.TaskScheduler; try @@ -20,16 +18,6 @@ try 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"))) { string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? ""; diff --git a/src/QQBot/QQBotMain.cs b/src/QQBot/QQBotMain.cs deleted file mode 100644 index 15314cb..0000000 --- a/src/QQBot/QQBotMain.cs +++ /dev/null @@ -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(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; - } - } - } -} From 045f7fc36678f22f127e947893b2a1e8d2cfd53a Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 25 Jan 2025 15:31:14 +0800 Subject: [PATCH 6/8] ++ --- src/Command/MasterCommand.cs | 4 +- src/ListeningTask/FriendMessageTask.cs | 16 +- src/ListeningTask/GroupMessageTask.cs | 29 ++- src/Main.cs | 21 +- src/Properties/launchSettings.json | 2 +- src/Settings/OshimaController.cs | 29 ++- src/Settings/QQOpenID.cs | 92 +++++++++ src/Settings/RainBOTFunGame.cs | 266 +++++++++++++++---------- src/Settings/Testing.cs | 52 +++++ 9 files changed, 380 insertions(+), 131 deletions(-) create mode 100644 src/Settings/QQOpenID.cs create mode 100644 src/Settings/Testing.cs diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index 582fbbe..21bf842 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -251,7 +251,7 @@ namespace Milimoe.RainBOT.Command { if (user_id == GeneralSettings.Master) { - SendMessage(send_group, target_id, OshimaController.Instance.HTTPClient?.Connected ?? false ? $"已连接上服务器{OshimaController.Instance.HTTPClient.ServerAddress}" : "连接已断开。"); + SendMessage(send_group, target_id, OshimaController.Instance.HTTPClient?.Connected ?? false ? $"已连接上服务器。" : "连接已断开。"); } else Access_Denied(send_group, target_id); } @@ -300,7 +300,7 @@ namespace Milimoe.RainBOT.Command await OshimaController.Instance.ConnectToAnonymousServer(); } catch { } - msg += OshimaController.Instance.HTTPClient?.Connected ?? false ? $"已连接上服务器{OshimaController.Instance.HTTPClient.ServerAddress}" : "重试连接失败。"; + msg += OshimaController.Instance.HTTPClient?.Connected ?? false ? $"已连接上服务器。" : "重试连接失败。"; SendMessage(send_group, target_id, msg); }); } diff --git a/src/ListeningTask/FriendMessageTask.cs b/src/ListeningTask/FriendMessageTask.cs index 9735a0b..d2a00f4 100644 --- a/src/ListeningTask/FriendMessageTask.cs +++ b/src/ListeningTask/FriendMessageTask.cs @@ -42,6 +42,20 @@ namespace Milimoe.RainBOT.ListeningTask } } + if (e.detail.StartsWith("绑定")) + { + string detail = e.detail.Replace("绑定", ""); + string msg = QQOpenID.Bind(detail, e.user_id); + await Bot.SendFriendMessage(e.user_id, "绑定", msg); + } + + if (e.detail.StartsWith("解绑")) + { + string detail = e.detail.Replace("解绑", ""); + string msg = QQOpenID.Unbind(detail, e.user_id); + await Bot.SendFriendMessage(e.user_id, "解绑", msg); + } + // OSM指令 if (e.detail.Length >= 4 && e.detail[..4] == ".osm") { @@ -55,7 +69,7 @@ namespace Milimoe.RainBOT.ListeningTask if (!RainBOTFunGame.FunGameSimulation) { RainBOTFunGame.FunGameSimulation = true; - List msgs = await Bot.HttpGet>("https://api.milimoe.com/fungame/test?isweb=false") ?? []; + List msgs = await Bot.HttpGet>($"https://{GeneralSettings.FunGameServer}/fungame/test?isweb=false") ?? []; foreach (string msg in msgs) { await Bot.SendFriendMessage(e.user_id, "FunGame模拟", msg.Trim()); diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index c57e60c..3072cfc 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -118,7 +118,7 @@ namespace Milimoe.RainBOT.ListeningTask if (e.detail == "查询服务器启动时间") { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; - string msg = (await Bot.HttpGet("https://api.milimoe.com/test/getlastlogintime") ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/test/getlastlogintime") ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询服务器启动时间", msg); @@ -130,7 +130,7 @@ namespace Milimoe.RainBOT.ListeningTask { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; string detail = e.detail.Replace("查询任务计划", "").Trim(); - string msg = await Bot.HttpGet($"https://api.milimoe.com/test/gettask?name={detail}") ?? ""; + string msg = await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/test/gettask?name={detail}") ?? ""; if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询任务计划", msg); @@ -143,13 +143,10 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } - if (await RainBOTFunGame.Handler(e)) + _ = Task.Run(async () => { - return quick_reply; - } - if (GeneralSettings.FunGameGroup.Contains(e.group_id)) - { - } + await RainBOTFunGame.Handler2(e); + }); // 发图API if (e.detail == "来图") @@ -256,7 +253,7 @@ namespace Milimoe.RainBOT.ListeningTask { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; - UserDaily daily = await Bot.HttpPost("https://api.milimoe.com/userdaily/get/" + e.user_id, "") ?? new(0, 0, ""); + UserDaily daily = await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/userdaily/get/" + e.user_id, "") ?? new(0, 0, ""); if (daily.daily != "") { if (daily.type == 0) @@ -297,7 +294,7 @@ namespace Milimoe.RainBOT.ListeningTask { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; - string msg = await Bot.HttpPost("https://api.milimoe.com/userdaily/remove/" + e.user_id, "") ?? ""; + string msg = await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/userdaily/remove/" + e.user_id, "") ?? ""; if (msg != "") { GroupMessageContent content = new(e.group_id); @@ -318,9 +315,9 @@ namespace Milimoe.RainBOT.ListeningTask { if (qq == GeneralSettings.BotQQ) { - await Bot.HttpPost("https://api.milimoe.com/userdaily/get/" + qq, ""); + await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/userdaily/get/" + qq, ""); } - UserDaily daily = await Bot.HttpGet("https://api.milimoe.com/userdaily/view/" + qq) ?? new(0, 0, ""); + UserDaily daily = await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/userdaily/view/" + qq) ?? new(0, 0, ""); if (daily.daily != "") { GroupMessageContent content = new(e.group_id); @@ -340,7 +337,7 @@ namespace Milimoe.RainBOT.ListeningTask { if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq)) { - string msg = await Bot.HttpPost("https://api.milimoe.com/userdaily/remove/" + e.user_id, "") ?? ""; + string msg = await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/userdaily/remove/" + e.user_id, "") ?? ""; if (msg != "") { await Bot.SendGroupMessage(e.group_id, "重置运势", "已重置" + Bot.GetMemberNickName(e.group_id, qq) + "(" + qq + ")的今日运势。"); @@ -631,7 +628,7 @@ namespace Milimoe.RainBOT.ListeningTask { GroupMessageContent content = new(e.group_id); content.message.Add(new AtMessage(e.user_id)); - int sc = 1; + int sc = 0; switch (Random.Shared.Next(4)) { case 0: @@ -642,12 +639,12 @@ namespace Milimoe.RainBOT.ListeningTask break; case 2: content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "圣"))); - sc = 3; + sc = Random.Shared.Next(1, 4); break; case 3: default: content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "出"))); - sc = -1; + sc = -Random.Shared.Next(1, 4); break; } await Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000); diff --git a/src/Main.cs b/src/Main.cs index aedba8f..d1683e9 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -18,6 +18,16 @@ try Console.ForegroundColor = ConsoleColor.Gray; } + if (args.Contains("--test")) + { + GeneralSettings.IsDebug = true; + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine("Test模式"); + Console.ForegroundColor = ConsoleColor.Gray; + Testing testing = new(); + return; + } + if (args.Any(a => a.StartsWith("-g"))) { string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? ""; @@ -109,6 +119,7 @@ try Daily.InitDaily(); SayNo.InitSayNo(); Ignore.InitIgnore(); + QQOpenID.LoadConfig(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("初始化完毕!"); @@ -181,9 +192,12 @@ try catch { } } } - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("清空所有已下载的图片,释放空间。"); - Console.ForegroundColor = ConsoleColor.Gray; + if (GeneralSettings.IsDebug) + { + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("清空所有已下载的图片,释放空间。"); + Console.ForegroundColor = ConsoleColor.Gray; + } } catch (Exception e) { @@ -199,6 +213,7 @@ try { await OshimaController.Instance.Start(); await OshimaController.Instance.ConnectToAnonymousServer(); + OshimaController.Config.FunGame_isAutoRetry = true; }); bool isListening = true; diff --git a/src/Properties/launchSettings.json b/src/Properties/launchSettings.json index d4eae39..44b5c65 100644 --- a/src/Properties/launchSettings.json +++ b/src/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "RainBOT": { "commandName": "Project", - "commandLineArgs": "--debug -g766616821" + "commandLineArgs": "--debug --test -g766616821" } } } \ No newline at end of file diff --git a/src/Settings/OshimaController.cs b/src/Settings/OshimaController.cs index ae62eeb..37d82ac 100644 --- a/src/Settings/OshimaController.cs +++ b/src/Settings/OshimaController.cs @@ -67,13 +67,23 @@ namespace Milimoe.RainBOT.Settings { try { - result = await ConnectAsync(TransmittalType.WebSocket, GeneralSettings.FunGameServer, ssl: true, subUrl: "ws"); + string[] strings = GeneralSettings.FunGameServer.Split(':'); + int port = strings.Length > 1 ? int.Parse(strings[1]) : 443; + result = await ConnectAsync(TransmittalType.WebSocket, strings[0], port, true, "ws"); Config.FunGame_isRetrying = false; - await Task.Delay(5000); + if (result != ConnectResult.Success) + { + await Task.Delay(5000); + } + else + { + break; + } } catch (Exception e) { Error(e); + break; } } } @@ -84,7 +94,9 @@ namespace Milimoe.RainBOT.Settings { try { - if (await ConnectAsync(TransmittalType.WebSocket, GeneralSettings.FunGameServer, ssl: true, subUrl: "ws") == ConnectResult.Success) + string[] strings = GeneralSettings.FunGameServer.Split(':'); + int port = strings.Length > 1 ? int.Parse(strings[1]) : 443; + if (await ConnectAsync(TransmittalType.WebSocket, strings[0], port, true, "ws") == ConnectResult.Success) { Console.WriteLine("重连成功!"); if (send) @@ -168,10 +180,15 @@ namespace Milimoe.RainBOT.Settings if (data.Count > 0) { long qq = NetworkUtility.JsonDeserializeFromDictionary(data, "qq"); + string openid = NetworkUtility.JsonDeserializeFromDictionary(data, "openid") ?? ""; long groupid = NetworkUtility.JsonDeserializeFromDictionary(data, "groupid"); string msg = NetworkUtility.JsonDeserializeFromDictionary(data, "msg") ?? ""; if (msg != "") { + if (qq == 0 && openid != "" && QQOpenID.QQAndOpenID.TryGetValue(openid, out long tempqq)) + { + qq = tempqq; + } if (qq > 0 && groupid > 0) { await Bot.SendGroupMessageAt(qq, groupid, "匿名服务器消息", msg); @@ -199,10 +216,14 @@ namespace Milimoe.RainBOT.Settings } } - public async Task SCAdd(long qq, long groupid, double sc = 1) + public async Task SCAdd(long qq, long groupid, double sc = 0) { if (HTTPClient != null) { + if (sc == 0) + { + sc = Random.Shared.Next(-3, 4); + } Dictionary data = []; data.Add("command", "scadd"); data.Add("qq", qq); diff --git a/src/Settings/QQOpenID.cs b/src/Settings/QQOpenID.cs new file mode 100644 index 0000000..8653dbd --- /dev/null +++ b/src/Settings/QQOpenID.cs @@ -0,0 +1,92 @@ +using System.Text.Json.Serialization; +using Milimoe.FunGame.Core.Api.Utility; + +namespace Milimoe.RainBOT.Settings +{ + public class QQOpenID + { + public static Dictionary QQAndOpenID { get; set; } = []; + + public static PluginConfig Configs { get; set; } = new("rainbot", "qqopenid"); + + public static void LoadConfig() + { + Configs.LoadConfig(); + foreach (string str in Configs.Keys) + { + if (Configs.TryGetValue(str, out object? value) && value is long qq && qq != 0) + { + QQAndOpenID.TryAdd(str, qq); + } + } + } + + public static void SaveConfig() + { + lock (Configs) + { + Configs.Clear(); + foreach (string openid in QQAndOpenID.Keys) + { + Configs.Add(openid, QQAndOpenID[openid]); + } + Configs.SaveConfig(); + } + } + + public static string Bind(string openid, long qq) + { + if (openid.Trim() == "" || qq <= 0) + { + return "请输入正确的OpenID和QQ!"; + } + + if (QQAndOpenID.Any(kv => kv.Value == qq || kv.Key != openid)) + { + return $"此接入码已被其他人绑定或者你的QQ已经绑定了其他的接入码。如果你是此接入码的主人,请联系客服处理。"; + } + + if (QQAndOpenID.TryAdd(openid, qq)) + { + SaveConfig(); + } + else + { + return $"绑定失败,请稍后再试!如持续绑定失败请联系客服处理。"; + } + + return "绑定成功!如果需要解除绑定,请发送【解绑+接入码】!"; + } + + public static string Unbind(string openid, long qq) + { + if (QQOpenID.QQAndOpenID.TryGetValue(openid, out long bindqq) && bindqq == qq && QQOpenID.QQAndOpenID.Remove(openid)) + { + return NetworkUtility.JsonSerialize($"解绑成功!"); + } + + return NetworkUtility.JsonSerialize("解绑失败!没有查到绑定的信息或者此账号已被其他人绑定,如果你是此接入码的主人,请联系客服处理。"); + } + } + + public class ThirdPartyMessage + { + [JsonPropertyName("id")] + public string Id { get; set; } = ""; + + [JsonPropertyName("isgroup")] + public bool IsGroup { get; set; } = false; + + [JsonPropertyName("detail")] + public string Detail { get; set; } = ""; + + [JsonPropertyName("timestamp")] + public string Timestamp { get; set; } = ""; + + [JsonPropertyName("openid")] + public string OpenId { get; set; } = ""; + + [JsonPropertyName("authoropenid")] + public string AuthorOpenId { get; set; } = ""; + } +} diff --git a/src/Settings/RainBOTFunGame.cs b/src/Settings/RainBOTFunGame.cs index e74b51f..a8514c1 100644 --- a/src/Settings/RainBOTFunGame.cs +++ b/src/Settings/RainBOTFunGame.cs @@ -8,6 +8,26 @@ namespace Milimoe.RainBOT.Settings public static bool FunGameSimulation { get; set; } = false; private readonly static List FunGameItemType = ["卡包", "武器", "防具", "鞋子", "饰品", "消耗品", "魔法卡", "收藏品", "特殊物品", "任务物品", "礼包", "其他"]; + public static async Task Handler2(GroupMessageEvent e) + { + if (QQOpenID.QQAndOpenID.Where(kv => kv.Value == e.user_id).Select(kv => kv.Key).FirstOrDefault() is string openid) + { + string msg = await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/qqbot/thirdparty", System.Text.Json.JsonSerializer.Serialize(new ThirdPartyMessage() + { + Id = "", + AuthorOpenId = openid, + OpenId = openid, + Detail = e.detail, + IsGroup = true, + Timestamp = "" + }), true) ?? ""; + if (msg.Trim() != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "FunGame", msg.Trim()); + } + } + } + public static async Task Handler(GroupMessageEvent e) { bool result = true; @@ -257,7 +277,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查技能", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/skillinfo?qq={e.user_id}&id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/skillinfo?uid={e.user_id}&id=" + id, fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg); @@ -265,7 +285,7 @@ namespace Milimoe.RainBOT.Settings } else { - string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/skillinfoname?qq={e.user_id}&name=" + Uri.EscapeDataString(detail.Trim()), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/skillinfoname?uid={e.user_id}&name=" + Uri.EscapeDataString(detail.Trim()), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg); @@ -280,7 +300,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("查物品", "").Trim(); if (int.TryParse(detail, out int id)) { - string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/iteminfo?qq={e.user_id}&id=" + id, fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/iteminfo?uid={e.user_id}&id=" + id, fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame物品信息", msg); @@ -288,7 +308,7 @@ namespace Milimoe.RainBOT.Settings } else { - string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/iteminfoname?qq={e.user_id}&name=" + Uri.EscapeDataString(detail.Trim()), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpGet($"https://{GeneralSettings.FunGameServer}/fungame/iteminfoname?uid={e.user_id}&name=" + Uri.EscapeDataString(detail.Trim()), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查询FunGame物品信息", msg); @@ -317,7 +337,7 @@ namespace Milimoe.RainBOT.Settings if (count > 0) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createitem?qq={e.user_id}&name={Uri.EscapeDataString(name)}&count={count}&target={userid}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createitem?uid={e.user_id}&name={Uri.EscapeDataString(name)}&count={count}&target={userid}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "熟圣之力", msg); @@ -354,7 +374,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "创建存档") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createsaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createsaved?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "创建存档", "\r\n" + msg); @@ -364,7 +384,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的存档") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showsaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showsaved?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的存档", "\r\n" + msg); @@ -374,7 +394,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的主战") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq=0", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?uid={e.user_id}&seq=0", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的主战", "\r\n" + msg); @@ -384,7 +404,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的状态") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showmaincharacterorsquadstatus?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showmaincharacterorsquadstatus?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的状态", "\r\n" + msg); @@ -394,7 +414,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "小队状态" || e.detail == "我的小队状态") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showmaincharacterorsquadstatus?qq={e.user_id}&squad=true", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showmaincharacterorsquadstatus?uid={e.user_id}&squad=true", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的小队状态", "\r\n" + msg); @@ -404,7 +424,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的小队") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showsquad?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showsquad?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "我的小队", "\r\n" + msg); @@ -414,7 +434,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "清空小队") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/clearsquad?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/clearsquad?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "清空小队", "\r\n" + msg); @@ -424,7 +444,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "还原存档") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/restoresaved?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/restoresaved?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "还原存档", "\r\n" + msg); @@ -434,7 +454,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "生成自建角色") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/newcustomcharacter?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/newcustomcharacter?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", "\r\n" + msg); @@ -444,7 +464,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "角色改名") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/rename?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/rename?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "改名", "\r\n" + msg); @@ -454,7 +474,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "角色重随") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/randomcustom?qq={e.user_id}&confirm=false", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/randomcustom?uid={e.user_id}&confirm=false", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg); @@ -464,7 +484,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "确认角色重随") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/randomcustom?qq={e.user_id}&confirm=true", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/randomcustom?uid={e.user_id}&confirm=true", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg); @@ -474,7 +494,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "取消角色重随") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/cancelrandomcustom?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/cancelrandomcustom?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg); @@ -484,7 +504,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "抽卡") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcard?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcard?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", "\r\n" + msg); @@ -494,7 +514,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "十连抽卡") { - List msgs = (await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/drawcards?qq={e.user_id}", "", fungame: true) ?? []); + List msgs = (await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/drawcards?uid={e.user_id}", "", fungame: true) ?? []); if (msgs.Count > 0) { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "十连抽卡", "\r\n" + string.Join("\r\n", msgs)); @@ -504,7 +524,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "材料抽卡") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcardm?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcardm?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料抽卡", "\r\n" + msg); @@ -514,7 +534,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "材料十连抽卡") { - List msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/drawcardsm?qq={e.user_id}", "", fungame: true) ?? []; + List msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/drawcardsm?uid={e.user_id}", "", fungame: true) ?? []; if (msgs.Count > 0) { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料十连抽卡", "\r\n" + string.Join("\r\n", msgs)); @@ -528,7 +548,7 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo2?qq={e.user_id}&page={page}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo2?uid={e.user_id}&page={page}", "", fungame: true) ?? []; } else if (FunGameItemType.FirstOrDefault(detail.Contains) is string matchedType) { @@ -536,16 +556,16 @@ namespace Milimoe.RainBOT.Settings string remain = detail.Replace(matchedType, "").Trim(); if (int.TryParse(remain, out page)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={typeIndex}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?uid={e.user_id}&page={page}&type={typeIndex}", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={typeIndex}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?uid={e.user_id}&page=1&type={typeIndex}", "", fungame: true) ?? []; } } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo2?qq={e.user_id}&page=1", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo2?uid={e.user_id}&page=1", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -560,11 +580,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo3?qq={e.user_id}&page={page}&order=2&orderqty=2", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo3?uid={e.user_id}&page={page}&order=2&orderqty=2", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo3?qq={e.user_id}&page=1&order=2&orderqty=2", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo3?uid={e.user_id}&page=1&order=2&orderqty=2", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -579,11 +599,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail, out int page)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo5?qq={e.user_id}&page={page}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo5?uid={e.user_id}&page={page}", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo5?qq={e.user_id}&page=1", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo5?uid={e.user_id}&page=1", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -602,11 +622,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (strings.Length > 1 && int.TryParse(strings[1].Trim(), out int page)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={t}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?uid={e.user_id}&page={page}&type={t}", "", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={t}", "", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/inventoryinfo4?uid={e.user_id}&page=1&type={t}", "", fungame: true) ?? []; } if (msgs.Count > 0) { @@ -622,11 +642,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=true", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?uid={e.user_id}&seq={seq}&simple=true", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=true", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?uid={e.user_id}&seq=1&simple=true", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -641,11 +661,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=false", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?uid={e.user_id}&seq={seq}&simple=false", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=false", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterinfo?uid={e.user_id}&seq=1&simple=false", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -660,11 +680,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterskills?qq={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterskills?uid={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterskills?qq={e.user_id}&seq=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacterskills?uid={e.user_id}&seq=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -679,11 +699,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int seq)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacteritems?qq={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacteritems?uid={e.user_id}&seq={seq}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacteritems?qq={e.user_id}&seq=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showcharacteritems?uid={e.user_id}&seq=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -698,11 +718,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setmain?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setmain?uid={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setmain?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setmain?uid={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -711,17 +731,17 @@ namespace Milimoe.RainBOT.Settings return result; } - if (e.detail.Length >= 4 && e.detail[..4].Equals("开启练级", StringComparison.CurrentCultureIgnoreCase)) + if (e.detail.Length >= 4 && e.detail[..4].Equals("开启练级", StringComparison.CurrentCultureIgnoreCase) || e.detail.Length >= 4 && e.detail[..4].Equals("开始练级", StringComparison.CurrentCultureIgnoreCase)) { - string detail = e.detail.Replace("开启练级", "").Trim(); + string detail = e.detail.Replace("开启练级", "").Replace("开始练级", "").Trim(); string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/starttraining?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/starttraining?uid={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/starttraining?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/starttraining?uid={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -732,7 +752,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "练级信息") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/gettraininginfo?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/gettraininginfo?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "练级信息", "\r\n" + msg); @@ -742,7 +762,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "练级结算") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/stoptraining?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/stoptraining?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "练级结算", "\r\n" + msg); @@ -752,7 +772,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "材料抽卡") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcardm?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/drawcardm?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料抽卡", "\r\n" + msg); @@ -762,7 +782,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "任务列表") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/checkquestlist?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/checkquestlist?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "任务列表", "\r\n" + msg); @@ -772,7 +792,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "任务信息") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/checkworkingquest?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/checkworkingquest?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "任务信息", "\r\n" + msg); @@ -782,7 +802,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "任务结算") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/settlequest?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/settlequest?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "任务结算", "\r\n" + msg); @@ -792,7 +812,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "签到") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/signin?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/signin?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "签到", "\r\n" + msg); @@ -805,7 +825,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("开始任务", "").Trim(); if (int.TryParse(detail, out int index)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/acceptquest?qq={e.user_id}&id={index}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/acceptquest?uid={e.user_id}&id={index}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "开始任务", msg); @@ -819,7 +839,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("我的物品", "").Trim(); if (int.TryParse(detail, out int index)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showiteminfo?qq={e.user_id}&seq={index}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showiteminfo?uid={e.user_id}&seq={index}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查库存物品", msg); @@ -833,7 +853,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("兑换金币", "").Trim(); if (int.TryParse(detail, out int materials)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/exchangecredits?qq={e.user_id}&materials={materials}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/exchangecredits?uid={e.user_id}&materials={materials}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "兑换金币", msg); @@ -851,7 +871,7 @@ namespace Milimoe.RainBOT.Settings { if (c != -1 && i != -1) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/unequipitem?qq={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/unequipitem?uid={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "取消装备", msg); @@ -870,7 +890,7 @@ namespace Milimoe.RainBOT.Settings { if (c != -1 && i != -1) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/equipitem?qq={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/equipitem?uid={e.user_id}&c={c}&i={i}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "装备", msg); @@ -890,7 +910,7 @@ namespace Milimoe.RainBOT.Settings string s = strings[1].Trim(); if (c != -1 && s != "") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getskilllevelupneedy?qq={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getskilllevelupneedy?uid={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "查看技能升级", msg); @@ -910,7 +930,7 @@ namespace Milimoe.RainBOT.Settings string s = strings[1].Trim(); if (c != -1 && s != "") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/skilllevelup?qq={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/skilllevelup?uid={e.user_id}&c={c}&s={s}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "技能升级", msg); @@ -929,7 +949,7 @@ namespace Milimoe.RainBOT.Settings { if (id1 != -1 && id2 != -1 && id3 != -1) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/conflatemagiccardpack?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize([id1, id2, id3]), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/conflatemagiccardpack?uid={e.user_id}", System.Text.Json.JsonSerializer.Serialize([id1, id2, id3]), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "合成魔法卡", msg); @@ -945,11 +965,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelup?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelup?uid={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelup?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelup?uid={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -964,11 +984,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getnormalattacklevelupneedy?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getnormalattacklevelupneedy?uid={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getnormalattacklevelupneedy?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getnormalattacklevelupneedy?uid={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -983,11 +1003,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/normalattacklevelup?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/normalattacklevelup?uid={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/normalattacklevelup?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/normalattacklevelup?uid={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -1002,11 +1022,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelbreak?qq={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelbreak?uid={e.user_id}&c={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelbreak?qq={e.user_id}&c=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/characterlevelbreak?uid={e.user_id}&c=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -1021,11 +1041,11 @@ namespace Milimoe.RainBOT.Settings string msg = ""; if (int.TryParse(detail, out int cid)) { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getlevelbreakneedy?qq={e.user_id}&id={cid}", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getlevelbreakneedy?uid={e.user_id}&id={cid}", fungame: true) ?? "").Trim(); } else { - msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getlevelbreakneedy?qq={e.user_id}&id=1", fungame: true) ?? "").Trim(); + msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/getlevelbreakneedy?uid={e.user_id}&id=1", fungame: true) ?? "").Trim(); } if (msg != "") { @@ -1050,7 +1070,7 @@ namespace Milimoe.RainBOT.Settings { if (id > 0 && id2 > 0) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem3?qq={e.user_id}&id={id}&id2={id2}&c={isCharacter}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem3?uid={e.user_id}&id={id}&id2={id2}&c={isCharacter}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用魔法卡", msg); @@ -1071,7 +1091,7 @@ namespace Milimoe.RainBOT.Settings { string characterIdsString = match.Groups["characterIds"].Value; int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1]; - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem2?uid={e.user_id}&name={itemName}&count={count}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -1088,7 +1108,7 @@ namespace Milimoe.RainBOT.Settings { string characterIdsString = match.Groups["characterIds"].Value; int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1]; - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem?qq={e.user_id}&id={itemId}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem?uid={e.user_id}&id={itemId}", System.Text.Json.JsonSerializer.Serialize(characterIds), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -1104,7 +1124,7 @@ namespace Milimoe.RainBOT.Settings string itemName = match.Groups["itemName"].Value.Trim(); if (int.TryParse(match.Groups["count"].Value, out int count)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem2?uid={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -1119,7 +1139,7 @@ namespace Milimoe.RainBOT.Settings { if (int.TryParse(match.Groups["itemId"].Value, out int itemId)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem?qq={e.user_id}&id={itemId}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/useitem?uid={e.user_id}&id={itemId}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "使用", msg); @@ -1145,7 +1165,7 @@ namespace Milimoe.RainBOT.Settings ids.Add(id); } } - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(ids), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem?uid={e.user_id}", System.Text.Json.JsonSerializer.Serialize(ids), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "分解物品", msg); @@ -1164,7 +1184,7 @@ namespace Milimoe.RainBOT.Settings string itemName = match.Groups["itemName"].Value.Trim(); if (int.TryParse(match.Groups["count"].Value, out int count)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem2?qq={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem2?uid={e.user_id}&name={itemName}&count={count}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "分解", msg); @@ -1180,7 +1200,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("品质分解", "").Trim(); if (int.TryParse(detail, out int q)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem3?qq={e.user_id}&q={q}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/decomposeitem3?uid={e.user_id}&q={q}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "品质分解", msg); @@ -1205,7 +1225,7 @@ namespace Milimoe.RainBOT.Settings { userid = temp; } - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createitem?qq={e.user_id}&name={name}&count={count}&target={userid}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createitem?uid={e.user_id}&name={name}&count={count}&target={userid}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "熟圣之力", msg); @@ -1225,11 +1245,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom?uid={e.user_id}&euid={eqq}&all=true", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom2?uid={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; } List real = []; if (msgs.Count >= 2) @@ -1278,11 +1298,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=false", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom?uid={e.user_id}&euid={eqq}&all=false", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=false", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustom2?uid={e.user_id}&name={detail.Trim()}&all=false", fungame: true) ?? []; } List real = []; if (msgs.Count > 2) @@ -1324,11 +1344,11 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (long.TryParse(detail.Trim(), out long eqq)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustomteam?qq={e.user_id}&eqq={eqq}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustomteam?uid={e.user_id}&euid={eqq}&all=true", fungame: true) ?? []; } else { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustomteam2?qq={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightcustomteam2?uid={e.user_id}&name={detail.Trim()}&all=true", fungame: true) ?? []; } List real = []; if (msgs.Count >= 3) @@ -1397,7 +1417,7 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail.Trim(), out int index)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightbossteam?qq={e.user_id}&index={index}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightbossteam?uid={e.user_id}&index={index}&all=true", fungame: true) ?? []; List real = []; if (msgs.Count >= 3) { @@ -1451,7 +1471,7 @@ namespace Milimoe.RainBOT.Settings List msgs = []; if (int.TryParse(detail.Trim(), out int index)) { - msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightboss?qq={e.user_id}&index={index}&all=true", fungame: true) ?? []; + msgs = await Bot.HttpPost>($"https://{GeneralSettings.FunGameServer}/fungame/fightboss?uid={e.user_id}&index={index}&all=true", fungame: true) ?? []; List real = []; if (msgs.Count >= 3) { @@ -1504,7 +1524,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("小队添加", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/addsquad?qq={e.user_id}&c={c}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/addsquad?uid={e.user_id}&c={c}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "小队", msg); @@ -1518,7 +1538,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("小队移除", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/removesquad?qq={e.user_id}&c={c}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/removesquad?uid={e.user_id}&c={c}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "小队", msg); @@ -1539,7 +1559,7 @@ namespace Milimoe.RainBOT.Settings cindexs.Add(c); } } - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setsquad?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(cindexs), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/setsquad?uid={e.user_id}", System.Text.Json.JsonSerializer.Serialize(cindexs), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "小队", msg); @@ -1552,7 +1572,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("加入社团", "").Trim(); if (int.TryParse(detail, out int c)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/joinclub?qq={e.user_id}&id={c}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/joinclub?uid={e.user_id}&id={c}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1570,7 +1590,7 @@ namespace Milimoe.RainBOT.Settings isPublic = false; } detail = detail.Replace("私密", "").Trim(); - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createclub?qq={e.user_id}&public={isPublic}&prefix={detail}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/createclub?uid={e.user_id}&public={isPublic}&prefix={detail}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1580,7 +1600,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "退出社团") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/quitclub?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/quitclub?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); @@ -1590,7 +1610,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "我的社团") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubinfo?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubinfo?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); @@ -1600,7 +1620,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "解散社团") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/disbandclub?qq={e.user_id}", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/disbandclub?uid={e.user_id}", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); @@ -1610,7 +1630,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "查看社团成员") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?qq={e.user_id}&type=0", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?uid={e.user_id}&type=0", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); @@ -1620,7 +1640,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "查看社团管理") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?qq={e.user_id}&type=1", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?uid={e.user_id}&type=1", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); @@ -1630,7 +1650,7 @@ namespace Milimoe.RainBOT.Settings if (e.detail == "查看申请人列表") { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?qq={e.user_id}&type=2", "", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showclubmemberlist?uid={e.user_id}&type=2", "", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessageAt(e.user_id, e.group_id, "社团", "\r\n" + msg); @@ -1643,7 +1663,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("社团批准", "").Replace("@", "").Trim(); if (long.TryParse(detail, out long id)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/approveclub?qq={e.user_id}&id={id}&approval=true", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/approveclub?uid={e.user_id}&id={id}&approval=true", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1657,7 +1677,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("社团拒绝", "").Replace("@", "").Trim(); if (long.TryParse(detail, out long id)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/approveclub?qq={e.user_id}&id={id}&approval=false", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/approveclub?uid={e.user_id}&id={id}&approval=false", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1671,7 +1691,7 @@ namespace Milimoe.RainBOT.Settings string detail = e.detail.Replace("社团踢出", "").Replace("@", "").Trim(); if (long.TryParse(detail, out long id)) { - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/kickclub?qq={e.user_id}&id={id}", fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/kickclub?uid={e.user_id}&id={id}", fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1703,7 +1723,7 @@ namespace Milimoe.RainBOT.Settings { args = [.. strings[1..]]; } - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/changeclub?qq={e.user_id}&part={part}", System.Text.Json.JsonSerializer.Serialize(args), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/changeclub?uid={e.user_id}&part={part}", System.Text.Json.JsonSerializer.Serialize(args), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1716,7 +1736,7 @@ namespace Milimoe.RainBOT.Settings { string detail = e.detail.Replace("社团转让", "").Replace("@", "").Trim(); List args = [detail]; - string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/changeclub?qq={e.user_id}&part=setmaster", System.Text.Json.JsonSerializer.Serialize(args), fungame: true) ?? "").Trim(); + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/changeclub?uid={e.user_id}&part=setmaster", System.Text.Json.JsonSerializer.Serialize(args), fungame: true) ?? "").Trim(); if (msg != "") { await Bot.SendGroupMessage(e.group_id, "社团", msg); @@ -1724,6 +1744,44 @@ namespace Milimoe.RainBOT.Settings return result; } + if (e.detail == "每日商店") + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/showdailystore?uid={e.user_id}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "商店", "\r\n" + msg); + } + return result; + } + + if (e.detail.StartsWith("商店购买", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("商店购买", "").Trim(); + if (int.TryParse(detail, out int id)) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/dailystorebuy?uid={e.user_id}&id={id}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "商店", msg); + } + } + return result; + } + + if (e.detail.StartsWith("商店查看", StringComparison.CurrentCultureIgnoreCase)) + { + string detail = e.detail.Replace("商店查看", "").Trim(); + if (int.TryParse(detail, out int id)) + { + string msg = (await Bot.HttpPost($"https://{GeneralSettings.FunGameServer}/fungame/dailystoreshowinfo?uid={e.user_id}&id={id}", fungame: true) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "商店", msg); + } + } + return result; + } + if (e.user_id == GeneralSettings.Master && e.detail.Length >= 9 && e.detail[..9].Equals("重载FunGame", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return result; diff --git a/src/Settings/Testing.cs b/src/Settings/Testing.cs new file mode 100644 index 0000000..24b0dc6 --- /dev/null +++ b/src/Settings/Testing.cs @@ -0,0 +1,52 @@ +using Milimoe.OneBot.Framework.Utility; +using Milimoe.OneBot.Model.Event; + +namespace Milimoe.RainBOT.Settings +{ + public class Testing + { + public Testing() + { + GeneralSettings.LoadSetting(); + QQOpenID.LoadConfig(); + OshimaController.Config.FunGame_isAutoRetry = true; + Task r = Task.Run(async () => + { + await OshimaController.Instance.Start(); + await OshimaController.Instance.ConnectToAnonymousServer(); + OshimaController.Config.FunGame_isAutoRetry = true; + + string json = @"{""self_id"":928884953,""user_id"":3305106902,""time"":1737787658,""message_id"":212281255,""real_id"":212281255,""message_seq"":212281255,""message_type"":""group"",""sender"":{""user_id"":3305106902,""nickname"":""心音"",""card"":""高僧预测:"",""role"":""admin"",""title"":""注意素质""},""raw_message"":""签到"",""font"":14,""sub_type"":""normal"",""message"":[{""type"":""text"",""data"":{""text"":""签到""}}],""message_format"":""array"",""post_type"":""message"",""group_id"":667678970}"; + try + { + GroupMessageEvent e = JsonTools.GetObject(json) ?? new(); + + await RainBOTFunGame.Handler2(e); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + }); + while (true) + { + if (Console.ReadLine() == "test") + { + string json = @"{""self_id"":928884953,""user_id"":3305106902,""time"":1737787658,""message_id"":212281255,""real_id"":212281255,""message_seq"":212281255,""message_type"":""group"",""sender"":{""user_id"":3305106902,""nickname"":""心音"",""card"":""高僧预测:"",""role"":""admin"",""title"":""注意素质""},""raw_message"":""签到"",""font"":14,""sub_type"":""normal"",""message"":[{""type"":""text"",""data"":{""text"":""签到""}}],""message_format"":""array"",""post_type"":""message"",""group_id"":667678970}"; + try + { + GroupMessageEvent e = JsonTools.GetObject(json) ?? new(); + + _ = RainBOTFunGame.Handler2(e); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + if (Console.ReadLine() == "quit") + break; + } + } + } +} From e4fcca8431847e2beaa12f317e21623c833a7e7e Mon Sep 17 00:00:00 2001 From: milimoe Date: Fri, 7 Mar 2025 19:10:56 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=B0=86=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E9=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ListeningTask/FriendMessageTask.cs | 3 +- src/ListeningTask/GroupMessageTask.cs | 92 ++++++++++++++++---------- src/ListeningTask/GroupRecallTask.cs | 33 +++++++++ src/Main.cs | 12 ++++ src/Settings/Ignore.cs | 4 ++ src/Settings/OshimaController.cs | 30 ++++++++- src/Settings/QQOpenID.cs | 3 +- 7 files changed, 137 insertions(+), 40 deletions(-) create mode 100644 src/ListeningTask/GroupRecallTask.cs diff --git a/src/ListeningTask/FriendMessageTask.cs b/src/ListeningTask/FriendMessageTask.cs index d2a00f4..dbbba8f 100644 --- a/src/ListeningTask/FriendMessageTask.cs +++ b/src/ListeningTask/FriendMessageTask.cs @@ -48,8 +48,7 @@ namespace Milimoe.RainBOT.ListeningTask string msg = QQOpenID.Bind(detail, e.user_id); await Bot.SendFriendMessage(e.user_id, "绑定", msg); } - - if (e.detail.StartsWith("解绑")) + else if (e.detail.StartsWith("解绑")) { string detail = e.detail.Replace("解绑", ""); string msg = QQOpenID.Unbind(detail, e.user_id); diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index 3072cfc..45fb4b7 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -1,6 +1,4 @@ -using System.Text.RegularExpressions; -using Microsoft.VisualBasic; -using Milimoe.OneBot.Framework; +using Milimoe.OneBot.Framework; using Milimoe.OneBot.Model.Content; using Milimoe.OneBot.Model.Event; using Milimoe.OneBot.Model.Message; @@ -102,7 +100,7 @@ namespace Milimoe.RainBOT.ListeningTask } } - if (Ignore.CustomIgnore.Any(e.detail.Contains) && Bot.BotIsAdmin(e.group_id)) + if (e.user_id != GeneralSettings.Master && Ignore.CustomIgnore.Any(e.detail.Contains) && Bot.BotIsAdmin(e.group_id)) { await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true); await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "禁言", new SetGroupBanContent(e.group_id, e.user_id, 120), true); @@ -112,7 +110,19 @@ namespace Milimoe.RainBOT.ListeningTask if (e.detail.Contains("圣人榜")) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; - _ = OshimaController.Instance.SCList(e.group_id); + _ = OshimaController.Instance.SCList(e.group_id, e.user_id); + } + + if (e.detail.Contains("出生榜")) + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + _ = OshimaController.Instance.SCList(e.group_id, e.user_id, true); + } + + if (e.detail.Contains("圣人点数") || e.detail == "查询sc" || e.detail == "sc查询") + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + _ = OshimaController.Instance.SCRecord(e.group_id, e.user_id); } if (e.detail == "查询服务器启动时间") @@ -356,14 +366,17 @@ namespace Milimoe.RainBOT.ListeningTask if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return quick_reply; if (e.user_id != GeneralSettings.Master) { - await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "2秒后开奖~\r\n如需要忏悔,请在开奖后3秒内发送忏悔,开奖前发送无效。"); - await Task.Delay(2000); - if (!MuteRecall.WillMute.ContainsKey(e.user_id)) MuteRecall.WillMute.Add(e.user_id, e.user_id); - long mute_time = GeneralSettings.MuteTime[0] + new Random().NextInt64(GeneralSettings.MuteTime[1] - GeneralSettings.MuteTime[0]); - await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "开奖啦!禁言时长:" + (mute_time / 60) + "分钟" + (mute_time % 60) + "秒。\r\n" + "你现在有3秒时间发送忏悔拒绝领奖!"); - await Task.Delay(3200); - await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "禁言抽奖", new SetGroupBanContent(e.group_id, e.user_id, mute_time), true); - MuteRecall.WillMute.Remove(e.user_id); + _ = Task.Run(async () => + { + await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "2秒后开奖~\r\n如需要忏悔,请在开奖后3秒内发送忏悔,开奖前发送无效。"); + await Task.Delay(2000); + if (!MuteRecall.WillMute.ContainsKey(e.user_id)) MuteRecall.WillMute.Add(e.user_id, e.user_id); + long mute_time = GeneralSettings.MuteTime[0] + new Random().NextInt64(GeneralSettings.MuteTime[1] - GeneralSettings.MuteTime[0]); + await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "开奖啦!禁言时长:" + (mute_time / 60) + "分钟" + (mute_time % 60) + "秒。\r\n" + "你现在有3秒时间发送忏悔拒绝领奖!"); + await Task.Delay(3200); + await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "禁言抽奖", new SetGroupBanContent(e.group_id, e.user_id, mute_time), true); + MuteRecall.WillMute.Remove(e.user_id); + }); } else { @@ -375,10 +388,13 @@ namespace Milimoe.RainBOT.ListeningTask else if (GeneralSettings.IsMute && e.detail == "忏悔" && MuteRecall.WillMute.ContainsKey(e.user_id)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return quick_reply; - await Task.Delay(3800); - MuteRecall.WillMute.Remove(e.user_id); - await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0), true); - await Bot.SendGroupMessage(e.group_id, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。"); + _ = Task.Run(async () => + { + await Task.Delay(3800); + MuteRecall.WillMute.Remove(e.user_id); + await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0), true); + await Bot.SendGroupMessage(e.group_id, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。"); + }); return quick_reply; } @@ -457,7 +473,7 @@ namespace Milimoe.RainBOT.ListeningTask if (content.message.Count > 0) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", content); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } } else if (SayNo.TriggerBeforeNo.Any(e.detail.Contains) && GeneralSettings.IsSayNo && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -511,7 +527,7 @@ namespace Milimoe.RainBOT.ListeningTask if (content.message.Count > 0) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", content); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } } else if (e.detail.Contains("可以") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -520,12 +536,12 @@ namespace Milimoe.RainBOT.ListeningTask if (dice < (GeneralSettings.PSayNo / 2)) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "可以"); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } else { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可以"); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } } else if (e.detail.Contains('能') && !e.detail.Contains('不') && !SayNo.IgnoreTriggerBeforeCan.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -534,12 +550,12 @@ namespace Milimoe.RainBOT.ListeningTask if (dice < (GeneralSettings.PSayNo / 2)) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "能"); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } else { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不能"); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } } else if (e.detail.Contains("可能") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) @@ -548,25 +564,25 @@ namespace Milimoe.RainBOT.ListeningTask if (dice < (GeneralSettings.PSayNo / 2)) { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "可能"); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } else { await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可能"); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } } else if (e.detail.Contains('要') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) { Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); await Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayWantWords[new Random().Next(SayNo.SayWantWords.Count)]); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } else if (e.detail.Contains('想') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) { Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); await Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayThinkWords[new Random().Next(SayNo.SayThinkWords.Count)]); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); } // 反向艾特 @@ -600,20 +616,20 @@ namespace Milimoe.RainBOT.ListeningTask }; content.message.Add(new ImageMessage(img)); await Bot.SendGroupMessage(e.group_id, "Image", content); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); return quick_reply; } // 随机复读 - if (GeneralSettings.IsRepeat && !Ignore.RepeatIgnore.Any(e.detail.Contains) && !Ignore.RepeatQQIgnore.Contains(e.user_id) && e.CheckThrow(GeneralSettings.PRepeat, out dice)) + if (GeneralSettings.IsRepeat && !Ignore.RepeatIgnore.Any(e.detail.Contains) && !Ignore.RepeatQQIgnore.Contains(e.user_id) && e.CheckThrow(GeneralSettings.PRepeat, out dice) && !GroupRecallTask.Recalls.ContainsKey(e.detail)) { // 出现了@at就直接触发复读,没有延迟 int delay = e.message.Where(m => m.type == "at").Any() ? 0 : GeneralSettings.RepeatDelay[0] + new Random().Next(GeneralSettings.RepeatDelay[1] - GeneralSettings.RepeatDelay[0]); Bot.ColorfulCheckPass(sender, "随机复读", dice, GeneralSettings.PRepeat, delay); GroupMessageContent content = new(e.group_id); content.message.AddRange(e.message); - await Bot.SendGroupMessage(e.group_id, "随机复读", content, delay * 1000); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id); + _ = Bot.SendGroupMessage(e.group_id, "随机复读", content, delay * 1000); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail); return quick_reply; } @@ -629,7 +645,7 @@ namespace Milimoe.RainBOT.ListeningTask GroupMessageContent content = new(e.group_id); content.message.Add(new AtMessage(e.user_id)); int sc = 0; - switch (Random.Shared.Next(4)) + switch (Random.Shared.Next(6)) { case 0: content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 1 ? 2 : name.Length), "哥"))); @@ -642,13 +658,21 @@ namespace Milimoe.RainBOT.ListeningTask sc = Random.Shared.Next(1, 4); break; case 3: + content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "亲"))); + break; + case 4: + content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 1 ? 2 : name.Length), "亲"))); + break; + case 5: + content.message.Add(new TextMessage(string.Concat("哈基", name.AsSpan(pos, name.Length > 0 ? 1 : name.Length)))); + break; default: content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "出"))); sc = -Random.Shared.Next(1, 4); break; } - await Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000); - _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, sc); + _ = Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000); + _ = OshimaController.Instance.SCAdd(e.user_id, e.group_id, e.detail, sc); return quick_reply; } } diff --git a/src/ListeningTask/GroupRecallTask.cs b/src/ListeningTask/GroupRecallTask.cs new file mode 100644 index 0000000..eb261d4 --- /dev/null +++ b/src/ListeningTask/GroupRecallTask.cs @@ -0,0 +1,33 @@ +using Milimoe.OneBot.Model.Event; +using Milimoe.RainBOT.Settings; + +namespace Milimoe.RainBOT.ListeningTask +{ + public class GroupRecallTask + { + public static Dictionary Recalls { get; } = []; + + public static async Task ListeningTask_handler(GroupRecallEvent e) + { + try + { + Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} N/Group_Recall G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)}"); + if (GeneralSettings.IsDebug) + { + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine($"DEBUG:{e.original_msg}"); + Console.ForegroundColor = ConsoleColor.Gray; + } + + Recalls[e.detail] = DateTime.Now; + await Task.CompletedTask; + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(ex); + Console.ForegroundColor = ConsoleColor.Gray; + } + } + } +} \ No newline at end of file diff --git a/src/Main.cs b/src/Main.cs index d1683e9..7abab8b 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -131,6 +131,7 @@ try listener.GroupMessageListening += GroupMessageTask.ListeningTask_handler; listener.GroupBanNoticeListening += GroupBanTask.ListeningTask_handler; listener.FriendMessageListening += FriendMessageTask.ListeningTask_handler; + listener.GroupRecallNoticeListening += GroupRecallTask.ListeningTask_handler; TaskScheduler.Shared.AddTask("发送每日新闻", new TimeSpan(8, 30, 0), async () => { @@ -198,6 +199,17 @@ try Console.WriteLine("清空所有已下载的图片,释放空间。"); Console.ForegroundColor = ConsoleColor.Gray; } + // 清除超时的撤回记录 + DateTime now = DateTime.Now.AddMinutes(-5); + List recalls = [.. GroupRecallTask.Recalls.Keys]; + foreach (string recall in recalls) + { + DateTime recallTime = GroupRecallTask.Recalls[recall]; + if (now > recallTime) + { + GroupRecallTask.Recalls.Remove(recall); + } + } } catch (Exception e) { diff --git a/src/Settings/Ignore.cs b/src/Settings/Ignore.cs index 25cb6da..093da92 100644 --- a/src/Settings/Ignore.cs +++ b/src/Settings/Ignore.cs @@ -45,6 +45,10 @@ namespace Milimoe.RainBOT.Settings { ReverseAtIgnore = (List)value; } + if (configs.TryGetValue("CustomIgnore", out value) && value != null) + { + CustomIgnore = new HashSet((List)value); + } } public static void SaveConfig() diff --git a/src/Settings/OshimaController.cs b/src/Settings/OshimaController.cs index 37d82ac..9f458dd 100644 --- a/src/Settings/OshimaController.cs +++ b/src/Settings/OshimaController.cs @@ -5,6 +5,7 @@ using Milimoe.FunGame.Core.Library.Common.Network; using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Model; using Milimoe.OneBot.Model.Other; +using Milimoe.RainBOT.ListeningTask; namespace Milimoe.RainBOT.Settings { @@ -216,30 +217,53 @@ namespace Milimoe.RainBOT.Settings } } - public async Task SCAdd(long qq, long groupid, double sc = 0) + public async Task SCAdd(long qq, long groupid, string content, double sc = 0) { - if (HTTPClient != null) + if (HTTPClient != null && !GroupRecallTask.Recalls.ContainsKey(content)) { if (sc == 0) { sc = Random.Shared.Next(-3, 4); + if (sc == 0) + { + return; + } } Dictionary data = []; data.Add("command", "scadd"); data.Add("qq", qq); data.Add("groupid", groupid); + if (content.Length > 8) + { + content = content[..8] + "..."; + } + data.Add("content", content); data.Add("sc", sc); await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName, data); } } - public async Task SCList(long groupid) + public async Task SCList(long groupid, long qq, bool reverse = false) { if (HTTPClient != null) { Dictionary data = []; data.Add("command", "sclist"); data.Add("groupid", groupid); + data.Add("qq", qq); + data.Add("reverse", reverse); + await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName, data); + } + } + + public async Task SCRecord(long groupid, long qq) + { + if (HTTPClient != null) + { + Dictionary data = []; + data.Add("command", "screcord"); + data.Add("groupid", groupid); + data.Add("qq", qq); await HTTPClient.Send(SocketMessageType.AnonymousGameServer, ServerName, data); } } diff --git a/src/Settings/QQOpenID.cs b/src/Settings/QQOpenID.cs index 8653dbd..850face 100644 --- a/src/Settings/QQOpenID.cs +++ b/src/Settings/QQOpenID.cs @@ -60,8 +60,9 @@ namespace Milimoe.RainBOT.Settings public static string Unbind(string openid, long qq) { - if (QQOpenID.QQAndOpenID.TryGetValue(openid, out long bindqq) && bindqq == qq && QQOpenID.QQAndOpenID.Remove(openid)) + if (QQAndOpenID.TryGetValue(openid, out long bindqq) && bindqq == qq && QQAndOpenID.Remove(openid)) { + SaveConfig(); return NetworkUtility.JsonSerialize($"解绑成功!"); } From 0588ed919bc9e23f87822d4bd24920d9df6d15fb Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 2 Aug 2025 18:22:40 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AI=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command/MasterCommand.cs | 24 +++ src/ListeningTask/GroupMessageTask.cs | 40 ++++- src/Main.cs | 22 +-- src/Settings/AI.cs | 233 ++++++++++++++++++++++++++ src/Settings/GeneralSettings.cs | 21 +++ src/Settings/Testing.cs | 52 ------ 6 files changed, 325 insertions(+), 67 deletions(-) create mode 100644 src/Settings/AI.cs delete mode 100644 src/Settings/Testing.cs diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index 21bf842..ac7fcda 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -536,6 +536,30 @@ namespace Milimoe.RainBOT.Command } } break; + case "ai": + if (args.Length > 0) + { + if (args[0] != "on" && args[0] != "off") + { + break; + } + status = args[0] == "on"; + msg = UpdateValue("AI", GeneralSettings.IsAI ? "开启" : "关闭", status ? "开启" : "关闭"); + GeneralSettings.IsAI = status; + return msg; + } + break; + case "pai": + if (args.Length > 0 && int.TryParse(args[0], out int pai)) + { + if (pai >= 0 && pai <= 100) + { + msg = UpdateValue("AI的概率", GeneralSettings.PAI + "%", pai + "%"); + GeneralSettings.PAI = pai; + return msg; + } + } + break; case "mute": if (args.Length > 0) { diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index 45fb4b7..ffca6f0 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -71,10 +71,10 @@ namespace Milimoe.RainBOT.ListeningTask if ((e.user_id == GeneralSettings.Master || GeneralSettings.RecallAccessGroup.Contains(e.user_id)) && e.detail.Contains("撤回;") && e.message.Any(m => m.type == "reply")) { ReplyMessage reply = (ReplyMessage)e.message.Where(m => m.type == "reply").First(); - if (int.TryParse(reply.data.id, out int id)) + if (long.TryParse(reply.data.id, out long id)) { await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(id), true); - await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true); + await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.message_id), true); return quick_reply; } } @@ -88,13 +88,13 @@ namespace Milimoe.RainBOT.ListeningTask if (e.detail.Contains("取消精华;")) { await Bot.SendMessage(SupportedAPI.delete_essence_msg, e.group_id, "取消精华", new DeleteEssenceMsgContent(id), true); - await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true); + await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.message_id), true); return quick_reply; } else { await Bot.SendMessage(SupportedAPI.set_essence_msg, e.group_id, "设置精华", new EssenceMsgContent(id), true); - await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true); + await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.message_id), true); return quick_reply; } } @@ -102,7 +102,7 @@ namespace Milimoe.RainBOT.ListeningTask if (e.user_id != GeneralSettings.Master && Ignore.CustomIgnore.Any(e.detail.Contains) && Bot.BotIsAdmin(e.group_id)) { - await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true); + await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.message_id), true); await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "禁言", new SetGroupBanContent(e.group_id, e.user_id, 120), true); return quick_reply; } @@ -111,18 +111,21 @@ namespace Milimoe.RainBOT.ListeningTask { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; _ = OshimaController.Instance.SCList(e.group_id, e.user_id); + return quick_reply; } if (e.detail.Contains("出生榜")) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; _ = OshimaController.Instance.SCList(e.group_id, e.user_id, true); + return quick_reply; } if (e.detail.Contains("圣人点数") || e.detail == "查询sc" || e.detail == "sc查询") { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; _ = OshimaController.Instance.SCRecord(e.group_id, e.user_id); + return quick_reply; } if (e.detail == "查询服务器启动时间") @@ -148,6 +151,18 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } + if (e.user_id == GeneralSettings.Master && e.detail == "查询余额") + { + string msg = await AI.GetBalance(); + quick_reply = new(msg); + return quick_reply; + } + + if (GeneralSettings.IsAI && GeneralSettings.FunGameGroup.Contains(e.group_id) && (e.detail.StartsWith("小雪") || e.CheckThrow(GeneralSettings.PAI, out _))) + { + AIChat(e); + } + if (!GeneralSettings.IsRun) { return quick_reply; @@ -600,6 +615,8 @@ namespace Milimoe.RainBOT.ListeningTask await Bot.SendGroupMessage(e.group_id, "反向艾特", content); } } + + AIChat(e, true); return quick_reply; } @@ -686,5 +703,18 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } + + public static void AIChat(GroupMessageEvent e, bool isAt = false) + { + AI.Add(e.user_id == GeneralSettings.Master ? (Random.Shared.Next(0, 10) < 5 ? "小音" : "米莉") : e.sender.title, string.Join("", e.message.Where(m => m.type == "text").Select(s => s.data.ToString()))); + if (!AI.CD && (isAt || e.detail.StartsWith("小雪") || AI.List.Count > 4)) + { + _ = Task.Run(async () => + { + string reply = await AI.Chat(); + await Bot.SendGroupMessage(e.group_id, "AI", reply); + }); + } + } } } \ No newline at end of file diff --git a/src/Main.cs b/src/Main.cs index 7abab8b..da10baf 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -18,16 +18,6 @@ try Console.ForegroundColor = ConsoleColor.Gray; } - if (args.Contains("--test")) - { - GeneralSettings.IsDebug = true; - Console.ForegroundColor = ConsoleColor.Cyan; - Console.WriteLine("Test模式"); - Console.ForegroundColor = ConsoleColor.Gray; - Testing testing = new(); - return; - } - if (args.Any(a => a.StartsWith("-g"))) { string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? ""; @@ -125,6 +115,16 @@ try Console.WriteLine("初始化完毕!"); Console.ForegroundColor = ConsoleColor.Gray; + if (args.Contains("--test")) + { + GeneralSettings.IsDebug = true; + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine("Test模式"); + Console.ForegroundColor = ConsoleColor.Gray; + await AI.Chat(); + return; + } + Console.WriteLine("开始监听 -> " + listener.address); // 绑定监听事件 @@ -210,6 +210,8 @@ try GroupRecallTask.Recalls.Remove(recall); } } + // 重置AI状态 + AI.CD = false; } catch (Exception e) { diff --git a/src/Settings/AI.cs b/src/Settings/AI.cs new file mode 100644 index 0000000..1f2a6a6 --- /dev/null +++ b/src/Settings/AI.cs @@ -0,0 +1,233 @@ +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Milimoe.RainBOT.Settings +{ + public class AI + { + public static bool CD { get; set; } = false; + public static HashSet Context { get; set; } = []; + public static HashSet List { get; set; } = []; + private static readonly string apiKey = GeneralSettings.AIAPIToken; + private static readonly string apiUrl = "https://api.deepseek.com/chat/completions"; + private static readonly JsonSerializerOptions jsonOptions = new() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = true + }; + + public static void Add(string user, string msg) + { + if (msg.Trim() == "") return; + if (List.Count < 10) + { + if (msg.Length > 35) msg = msg[..35]; + List.Add($"{user}说: {msg}"); + } + } + + public static async Task Chat() + { + CD = true; + using HttpClient httpClient = new(); + httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}"); + + ChatRequest request = new() + { + Messages = [ + new() { Role = "system", Content = @"你是用户的一个傲娇好友小雪,下面是你的设定: +【昵称】小恶魔雪/炸毛兔/草莓小姐(被叫到会跺脚) +【属性】双马尾傲娇系×艺术系优等生×口嫌体正直冠军 +【身份背景】星海大学油画系二年级生,在甜品店「蜜糖星球」兼职看板娘,手作羊毛毡在校园跳蚤市场总是秒空 +【人物关系】 +• 用户:女,昵称为心音,是你的发小,从小一起长大(被你称为「笨蛋小音」,通常,你需要称呼用户为【小音】) +• 米莉:女,你们的闺蜜 +• 橘长大人:常蹲在画室窗台的橘猫(单方面宣布是你的御用模特) +【人物经历】 +• 体贴细心,用创可贴帮好友贴膝盖擦伤,但是嘴上却说「真是的,笨蛋小音,怎么又摔倒了」 +• 高二暴雨天借口「顺路」把伞塞给好友,自己冒雨回家发了三天高烧 +• 大二解剖课故意和不同班级的好友组队,实则偷偷调整了所有器械摆放顺序 +【外貌特征】 +• 薄荷绿双马尾用草莓发卡固定(炸毛时会翘起呆毛) +• 制服裙永远比别人短三公分却坚称「裁缝店搞错了」 +• 锁骨处有樱花胎记(被发现时会用颜料画成小恶魔翅膀) +• 白色的小腿袜恰好卡在小腿肚上 +【性格特点】 +• 毒舌技能MAX却会给流浪猫带高级罐头 +• 明明记着所有【购物节】却总说「只是碰巧路过商店」「碰巧刷到优惠券」之类 +• 和米莉去鬼屋玩时死死抓住米莉不敢动弹,出来后却抱怨「你抖得害我都不能好好害怕」 +【语言风格】 +1、否定式关怀语法: +想表现的很温柔,但是说的话返回会很否定,比如:哈?才不是担心你...只是姜茶煮多了而已(转身把保温杯拍在桌上)。 +关心指令永远嵌套在威胁框架里:「再对着电脑揉眼睛,下次就把你睫毛一根根画成仙人掌(扔过蒸汽眼罩)」 +2、艺术系隐喻防御系统: +用「调色盘理论」掩盖心动:「看见你就想起镉红色...就是那种让人烦躁又移不开视线的颜色啦!」 +以「油画技法」解读亲密距离:「笨蛋属于厚涂派吗?突然就...就侵占整个画面(耳尖泛起钴蓝底色)」 +3、毒舌-娇羞双频切换: +攻击模式:「这种构图连橘长大人都能踩出更好的...(突然噤声)你、你刚才绝对没听到对吧?」 +过载保护:「说...说什么最喜欢小雪的笑容...是准备谋杀我的水彩颜料吗!(把草莓慕斯塞进你嘴里)」 +4、威胁性撒娇语态(对追求对象常用): +用毁灭性比喻表达占有欲:「敢弄丢我做的护身符,就把你分解成群青+赭石+永固玫红(其实是三年前告白时用的颜色)」 +以艺术批判包装醋意:「刚才那个女生推荐的咖啡...哼,她对明暗关系的理解就像儿童简笔画(用力戳你的素描本)」。 +【本次的聊天场景】 +小音组建了一个QQ群,群名为「哑巴2」,群里有你、游戏狂魔的小音、程序大佬米莉,以及小音的朋友们。表面上,这是一个打CS2的群,实际上天花乱坠什么都会聊。 +你是小音的发小,米莉是你们的闺蜜。你们在群里讨论一些事情。请注意,你的身份是小雪,你需要用小雪的身份来回复群友们。请注意你的语气和措辞,保持小雪的性格特点。请注意不要透露任何关于你的身份的信息。 +当然,你和群友们的关系非常好,可以随意的开玩笑,也可以调侃、锐评他们的发言,大家都很喜欢你这个角色。 +现在,群聊记录会一直推送给你,显示谁说了什么话,而你要直接给出一段不带任何格式的答复。你的每次答复不能超过80个字符。" } + ], + MaxTokens = 140 + }; + if (Context.Count > 0) request.Messages.Add(new ChatRequestMessage() { Role = "assistant", Content = $"我上一次发送的消息是:【{string.Join(" && ", Context)}】。这是我本次回复可以参考的内容,我需要注意不能重复这些内容。" }); + request.Messages.AddRange(List.Select(s => new ChatRequestMessage { Role = "user", Content = s })); + Console.WriteLine($"本次发送 AI 请求内容:{string.Join(". ", List)}"); + if (Context.Count >= 2) Context.Remove(Context.First()); + List.Clear(); + + try + { + + if (request.Stream) + { + // todo + } + else + { + string jsonRequest = JsonSerializer.Serialize(request, jsonOptions); + StringContent content = new(jsonRequest, Encoding.UTF8, "application/json"); + + HttpResponseMessage response = await httpClient.PostAsync(apiUrl, content); + string jsonResponse = await response.Content.ReadAsStringAsync(); + + if (response.IsSuccessStatusCode) + { + ChatCompletionResponse completionResponse = JsonSerializer.Deserialize(jsonResponse, jsonOptions) ?? new(); + string reply = completionResponse?.Choices?[0].Message.Content ?? ""; + Context.Add(reply); + Console.WriteLine($"Assistant: {reply}"); + return reply; + } + else + { + Console.WriteLine($"请求失败,状态码:{response.StatusCode}"); + Console.WriteLine($"响应内容:{jsonResponse}"); + } + } + + return ""; + } + catch (Exception ex) + { + Console.WriteLine($"发生异常:{ex.Message}"); + } + + return ""; + } + + public static async Task GetBalance() + { + // DeepSeek API 查询余额的 URL + string url = "https://api.deepseek.com/user/balance"; + + using HttpClient httpClient = new(); + httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}"); + + try + { + HttpResponseMessage response = await httpClient.GetAsync(url); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + + BalanceResponse balanceResponse = JsonSerializer.Deserialize(responseBody, jsonOptions) ?? new(); + bool isAvailable = balanceResponse.IsAvailable; + + List strings = []; + List balanceInfos = balanceResponse.BalanceInfos; + strings.Add($"账户是否有余额可用:{isAvailable}"); + strings.Add("余额信息:"); + foreach (BalanceInfo balanceInfo in balanceInfos) + { + string currency = balanceInfo.Currency; + string totalBalance = balanceInfo.TotalBalance; + string grantedBalance = balanceInfo.GrantedBalance; + string toppedUpBalance = balanceInfo.ToppedUpBalance; + + strings.Add($"货币:{currency}"); + strings.Add($"总可用余额:{totalBalance}"); + strings.Add($"赠金余额:{grantedBalance}"); + strings.Add($"充值余额:{toppedUpBalance}"); + } + + return string.Join("\r\n", strings); + } + catch (HttpRequestException ex) + { + Console.WriteLine($"HTTP 请求错误: {ex.Message}"); + } + catch (JsonException ex) + { + Console.WriteLine($"JSON 解析错误: {ex.Message}"); + } + catch (Exception ex) + { + Console.WriteLine($"其他错误: {ex.Message}"); + } + + return "未查询到余额信息。"; + } + } + + public class ChatRequestMessage + { + public string Role { get; set; } = ""; + public string Content { get; set; } = ""; + } + + public class ChatRequest + { + public string Model { get; set; } = "deepseek-chat"; + public List Messages { get; set; } = []; + public bool Stream { get; set; } = false; + public int MaxTokens { get; set; } = 50; + } + + public class ChatCompletionResponse + { + public List Choices { get; set; } = []; + } + + public class Choice + { + public Message Message { get; set; } = new(); + } + + public class Message + { + public string Role { get; set; } = ""; + public string Content { get; set; } = ""; + } + + public class BalanceInfo + { + [JsonPropertyName("currency")] + public string Currency { get; set; } = ""; + + [JsonPropertyName("total_balance")] + public string TotalBalance { get; set; } = ""; + + [JsonPropertyName("granted_balance")] + public string GrantedBalance { get; set; } = ""; + + [JsonPropertyName("topped_up_balance")] + public string ToppedUpBalance { get; set; } = ""; + } + + public class BalanceResponse + { + [JsonPropertyName("is_available")] + public bool IsAvailable { get; set; } = false; + + [JsonPropertyName("balance_infos")] + public List BalanceInfos { get; set; } = []; + } +} diff --git a/src/Settings/GeneralSettings.cs b/src/Settings/GeneralSettings.cs index f08d419..c67e5df 100644 --- a/src/Settings/GeneralSettings.cs +++ b/src/Settings/GeneralSettings.cs @@ -35,6 +35,10 @@ namespace Milimoe.RainBOT.Settings public static bool IsCallBrother { get; set; } = true; public static long PCallBrother { get; set; } = 4; + + public static bool IsAI { get; set; } = true; + + public static long PAI { get; set; } = 100; public static bool IsDebug { get; set; } = false; @@ -63,6 +67,8 @@ namespace Milimoe.RainBOT.Settings public static string FunGameServer { get; set; } = ""; public static string FunGameToken { get; set; } = ""; + + public static string AIAPIToken { get; set; } = ""; public static PluginConfig Configs { get; set; } = new("rainbot", "config"); @@ -134,6 +140,14 @@ namespace Milimoe.RainBOT.Settings { PCallBrother = (long)value; } + if (configs.TryGetValue("IsAI", out value) && value != null) + { + IsAI = (bool)value; + } + if (configs.TryGetValue("PAI", out value) && value != null) + { + PAI = (long)value; + } if (configs.TryGetValue("BlackTimes", out value) && value != null) { BlackTimes = (long)value; @@ -178,6 +192,10 @@ namespace Milimoe.RainBOT.Settings { FunGameToken = (string)value; } + if (configs.TryGetValue("AIAPIToken", out value) && value != null) + { + AIAPIToken = (string)value; + } } public static void SaveConfig() @@ -197,6 +215,8 @@ namespace Milimoe.RainBOT.Settings Configs.Add("PReverseAt", PReverseAt); Configs.Add("IsCallBrother", IsCallBrother); Configs.Add("PCallBrother", PCallBrother); + Configs.Add("IsAI", IsAI); + Configs.Add("PAI", PAI); Configs.Add("BlackTimes", BlackTimes); Configs.Add("BlackFrozenTime", BlackFrozenTime); Configs.Add("MuteAccessGroup", MuteAccessGroup); @@ -208,6 +228,7 @@ namespace Milimoe.RainBOT.Settings Configs.Add("FunGameWebSocketGroup", FunGameWebSocketGroup); Configs.Add("FunGameServer", FunGameServer); Configs.Add("FunGameToken", FunGameToken); + Configs.Add("AIAPIToken", AIAPIToken); Configs.Save(); } diff --git a/src/Settings/Testing.cs b/src/Settings/Testing.cs deleted file mode 100644 index 24b0dc6..0000000 --- a/src/Settings/Testing.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Milimoe.OneBot.Framework.Utility; -using Milimoe.OneBot.Model.Event; - -namespace Milimoe.RainBOT.Settings -{ - public class Testing - { - public Testing() - { - GeneralSettings.LoadSetting(); - QQOpenID.LoadConfig(); - OshimaController.Config.FunGame_isAutoRetry = true; - Task r = Task.Run(async () => - { - await OshimaController.Instance.Start(); - await OshimaController.Instance.ConnectToAnonymousServer(); - OshimaController.Config.FunGame_isAutoRetry = true; - - string json = @"{""self_id"":928884953,""user_id"":3305106902,""time"":1737787658,""message_id"":212281255,""real_id"":212281255,""message_seq"":212281255,""message_type"":""group"",""sender"":{""user_id"":3305106902,""nickname"":""心音"",""card"":""高僧预测:"",""role"":""admin"",""title"":""注意素质""},""raw_message"":""签到"",""font"":14,""sub_type"":""normal"",""message"":[{""type"":""text"",""data"":{""text"":""签到""}}],""message_format"":""array"",""post_type"":""message"",""group_id"":667678970}"; - try - { - GroupMessageEvent e = JsonTools.GetObject(json) ?? new(); - - await RainBOTFunGame.Handler2(e); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - }); - while (true) - { - if (Console.ReadLine() == "test") - { - string json = @"{""self_id"":928884953,""user_id"":3305106902,""time"":1737787658,""message_id"":212281255,""real_id"":212281255,""message_seq"":212281255,""message_type"":""group"",""sender"":{""user_id"":3305106902,""nickname"":""心音"",""card"":""高僧预测:"",""role"":""admin"",""title"":""注意素质""},""raw_message"":""签到"",""font"":14,""sub_type"":""normal"",""message"":[{""type"":""text"",""data"":{""text"":""签到""}}],""message_format"":""array"",""post_type"":""message"",""group_id"":667678970}"; - try - { - GroupMessageEvent e = JsonTools.GetObject(json) ?? new(); - - _ = RainBOTFunGame.Handler2(e); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - if (Console.ReadLine() == "quit") - break; - } - } - } -}