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);