添加新指令

This commit is contained in:
milimoe 2024-12-30 23:55:51 +08:00
parent fdbc3f4612
commit 4d458fa985
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
8 changed files with 1474 additions and 848 deletions

View File

@ -242,7 +242,7 @@ namespace Milimoe.RainBOT.Command
Daily.InitDaily();
SayNo.InitSayNo();
Ignore.InitIgnore();
Bot.FunGameSimulation = false;
FunGame.FunGameSimulation = false;
SendMessage(send_group, target_id, "参数设定以及权限组重新加载完成。");
}
else Access_Denied(send_group, target_id);

View File

@ -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 (!Bot.FunGameSimulation)
if (!FunGame.FunGameSimulation)
{
Bot.FunGameSimulation = true;
FunGame.FunGameSimulation = true;
List<string> msgs = await Bot.HttpGet<List<string>>("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);
}
Bot.FunGameSimulation = false;
FunGame.FunGameSimulation = false;
}
else
{

View File

@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event;
@ -16,7 +17,6 @@ namespace Milimoe.RainBOT.ListeningTask
private static long dice = 0;
private readonly static string[] EEWords = ["ee", "鹅鹅", "呃呃", "谔谔", "饿饿"];
private readonly static string[] MuteCommands = ["禁言", "解禁"];
private readonly static List<string> FunGameItemType = ["卡包", "武器", "防具", "鞋子", "饰品", "消耗品", "魔法卡", "收藏品", "特殊物品", "任务物品", "礼包", "其他"];
public static async Task<GroupMsgEventQuickReply?> ListeningTask_handler(GroupMessageEvent e)
{
@ -102,8 +102,10 @@ namespace Milimoe.RainBOT.ListeningTask
}
}
if (!GeneralSettings.IsRun)
if (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);
return quick_reply;
}
@ -130,849 +132,17 @@ namespace Milimoe.RainBOT.ListeningTask
return quick_reply;
}
if (e.detail.Length >= 9 && e.detail[..9].Equals("FunGame模拟", StringComparison.CurrentCultureIgnoreCase))
if (!GeneralSettings.IsRun)
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
if (!Bot.FunGameSimulation)
{
Bot.FunGameSimulation = true;
List<string> msgs = await Bot.HttpGet<List<string>>("https://api.milimoe.com/fungame/test?isweb=false") ?? [];
List<string> real = [];
int remain = 7;
string merge = "";
for (int i = 0; i < msgs.Count - 2; i++)
{
remain--;
merge += msgs[i] + "\r\n";
if (remain == 0)
{
real.Add(merge);
merge = "";
if ((msgs.Count - i - 3) < 7)
{
remain = msgs.Count - i - 3;
}
else remain = 7;
}
}
if (msgs.Count > 2)
{
real.Add(msgs[^2]);
real.Add(msgs[^1]);
}
foreach (string msg in real)
{
await Bot.SendGroupMessage(e.group_id, "FunGame模拟", msg.Trim());
await Task.Delay(5500);
}
Bot.FunGameSimulation = false;
}
else
{
await Bot.SendGroupMessage(e.group_id, "FunGame模拟", "游戏正在模拟中,请勿重复请求!");
}
return quick_reply;
}
if (e.detail.Length >= 11 && e.detail[..11].Equals("FunGame团队模拟", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
if (!Bot.FunGameSimulation)
{
Bot.FunGameSimulation = true;
List<string> msgs = await Bot.HttpGet<List<string>>("https://api.milimoe.com/fungame/test?isweb=false&isteam=true") ?? [];
List<string> real = [];
if (msgs.Count > 0)
{
real.Add(msgs[0]);
}
int remain = 7;
string merge = "";
for (int i = 1; i < msgs.Count - 2; i++)
{
remain--;
merge += msgs[i] + "\r\n";
if (remain == 0)
{
real.Add(merge);
merge = "";
if ((msgs.Count - i - 3) < 7)
{
remain = msgs.Count - i - 3;
}
else remain = 7;
}
}
if (msgs.Count > 2)
{
real.Add(msgs[^2]);
real.Add(msgs[^1]);
}
foreach (string msg in real)
{
await Bot.SendGroupMessage(e.group_id, "FunGame团队模拟", msg.Trim());
await Task.Delay(5500);
}
Bot.FunGameSimulation = false;
}
else
{
await Bot.SendGroupMessage(e.group_id, "FunGame团队模拟", "游戏正在模拟中,请勿重复请求!");
}
return quick_reply;
}
if (e.detail.Length >= 3 && e.detail[..3].Equals("查数据", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string detail = e.detail.Replace("查数据", "").Trim();
if (int.TryParse(detail, out int id))
{
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/stats?id=" + id) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 5 && e.detail[..5].Equals("查团队数据", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string detail = e.detail.Replace("查团队数据", "").Trim();
if (int.TryParse(detail, out int id))
{
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/teamstats?id=" + id) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 5 && e.detail[..5].Equals("查个人胜率", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string[] msg = await Bot.HttpGet<string[]>("https://api.milimoe.com/fungame/winraterank?isteam=false") ?? [];
if (msg.Length > 0)
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", string.Join("\r\n\r\n", msg));
}
return quick_reply;
}
if (e.detail.Length >= 5 && e.detail[..5].Equals("查团队胜率", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string[] msg = await Bot.HttpGet<string[]>("https://api.milimoe.com/fungame/winraterank?isteam=true") ?? [];
if (msg.Length > 0)
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", string.Join("\r\n\r\n", msg));
}
return quick_reply;
}
if (e.detail.Length >= 3 && e.detail[..3].Equals("查角色", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string detail = e.detail.Replace("查角色", "").Trim();
if (int.TryParse(detail, out int id))
{
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/characterinfo?id=" + id) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 3 && e.detail[..3].Equals("查技能", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string detail = e.detail.Replace("查技能", "").Trim();
if (int.TryParse(detail, out int id))
{
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/skillinfo?id=" + id) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame角色技能", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 3 && e.detail[..3].Equals("查物品", StringComparison.CurrentCultureIgnoreCase))
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string detail = e.detail.Replace("查物品", "").Trim();
if (int.TryParse(detail, out int id))
{
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/iteminfo?id=" + id) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查询FunGame物品信息", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 6 && e.detail[..6] == "生成魔法卡包")
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/newmagiccardpack") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "生成魔法卡包", msg);
}
return quick_reply;
}
else if (e.detail.Length >= 5 && e.detail[..5] == "生成魔法卡")
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/newmagiccard") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "生成魔法卡", msg);
}
return quick_reply;
}
if (e.detail == "创建存档")
if (await FunGame.Handler(e))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/createsaved?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "创建存档", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "还原存档")
if (GeneralSettings.FunGameGroup.Contains(e.group_id))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/restoresaved?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "还原存档", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "生成自建角色")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/newcustomcharacter?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "角色改名")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/rename?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "改名", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "角色重随")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/randomcustom?qq={e.user_id}&confirm=false", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "确认角色重随")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/randomcustom?qq={e.user_id}&confirm=true", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "取消角色重随")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/cancelrandomcustom?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "角色重随", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "抽卡")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/drawcard?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "十连抽卡")
{
List<string> msgs = (await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/drawcards?qq={e.user_id}", "") ?? []);
if (msgs.Count > 0)
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "十连抽卡", "\r\n" + string.Join("\r\n", msgs));
}
return quick_reply;
}
if (e.detail == "材料抽卡")
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/drawcardm?qq={e.user_id}", "") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料抽卡", "\r\n" + msg);
}
return quick_reply;
}
if (e.detail == "材料十连抽卡")
{
List<string> msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/drawcardsm?qq={e.user_id}", "") ?? [];
if (msgs.Count > 0)
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "材料十连抽卡", "\r\n" + string.Join("\r\n", msgs));
}
return quick_reply;
}
if (e.detail.Length >= 4 && (e.detail.StartsWith("查看库存") || e.detail.StartsWith("我的库存") || e.detail.StartsWith("我的背包")))
{
string detail = e.detail.Replace("查看库存", "").Replace("我的库存", "").Trim();
List<string> msgs = [];
if (int.TryParse(detail, out int page))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo2?qq={e.user_id}&page={page}", "") ?? [];
}
else if (FunGameItemType.FirstOrDefault(detail.Contains) is string matchedType)
{
int typeIndex = FunGameItemType.IndexOf(matchedType);
string remain = detail.Replace(matchedType, "").Trim();
if (int.TryParse(remain, out page))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={typeIndex}", "") ?? [];
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={typeIndex}", "") ?? [];
}
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo2?qq={e.user_id}&page=1", "") ?? [];
}
if (msgs.Count > 0)
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "查看库存", "\r\n" + string.Join("\r\n", msgs));
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail.StartsWith("物品库存"))
{
string detail = e.detail.Replace("物品库存", "").Trim();
List<string> msgs = [];
if (int.TryParse(detail, out int page))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo3?qq={e.user_id}&page={page}&order=2&orderqty=2", "") ?? [];
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo3?qq={e.user_id}&page=1&order=2&orderqty=2", "") ?? [];
}
if (msgs.Count > 0)
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "查看分类库存", "\r\n" + string.Join("\r\n", msgs));
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail.StartsWith("角色库存"))
{
string detail = e.detail.Replace("角色库存", "").Trim();
List<string> msgs = [];
if (int.TryParse(detail, out int page))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo5?qq={e.user_id}&page={page}", "") ?? [];
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo5?qq={e.user_id}&page=1", "") ?? [];
}
if (msgs.Count > 0)
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "查看角色库存", "\r\n" + string.Join("\r\n", msgs));
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail.StartsWith("分类库存"))
{
string detail = e.detail.Replace("分类库存", "").Trim();
string[] strings = detail.Split(" ");
int t = -1;
if (strings.Length > 0 && int.TryParse(strings[0].Trim(), out t))
{
List<string> msgs = [];
if (strings.Length > 1 && int.TryParse(strings[1].Trim(), out int page))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page={page}&type={t}", "") ?? [];
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/inventoryinfo4?qq={e.user_id}&page=1&type={t}", "") ?? [];
}
if (msgs.Count > 0)
{
await Bot.SendGroupMessageAt(e.user_id, e.group_id, "查看分类库存", "\r\n" + string.Join("\r\n", msgs));
}
}
return quick_reply;
}
if (e.detail.Length >= 3 && e.detail[..3].Equals("我角色", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("我角色", "").Trim();
string msg = "";
if (int.TryParse(detail, out int seq))
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=true") ?? "").Trim();
}
else
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=true") ?? "").Trim();
}
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查库存角色", msg);
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("我的角色", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("我的角色", "").Trim();
string msg = "";
if (int.TryParse(detail, out int seq))
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq={seq}&simple=false") ?? "").Trim();
}
else
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/showcharacterinfo?qq={e.user_id}&seq=1&simple=false") ?? "").Trim();
}
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查库存角色", msg);
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("我的物品", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("我的物品", "").Trim();
if (int.TryParse(detail, out int index))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/showiteminfo?qq={e.user_id}&seq={index}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "查库存物品", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("兑换金币", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("兑换金币", "").Trim();
if (int.TryParse(detail, out int materials))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/exchangecredits?qq={e.user_id}&materials={materials}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "兑换金币", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("取消装备", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("取消装备", "").Trim();
string[] strings = detail.Split(" ");
int c = -1, i = -1;
if (strings.Length > 0 && int.TryParse(strings[0].Trim(), out c) && strings.Length > 1 && int.TryParse(strings[1].Trim(), out i))
{
if (c != -1 && i != -1)
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/unequipitem?qq={e.user_id}&c={c}&i={i}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "取消装备", msg);
}
}
}
return quick_reply;
}
if (e.detail.Length >= 2 && e.detail[..2].Equals("装备", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("装备", "").Trim();
string[] strings = detail.Split(" ");
int c = -1, i = -1;
if (strings.Length > 0 && int.TryParse(strings[0].Trim(), out c) && strings.Length > 1 && int.TryParse(strings[1].Trim(), out i))
{
if (c != -1 && i != -1)
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/equipitem?qq={e.user_id}&c={c}&i={i}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "装备", msg);
}
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("角色升级", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("角色升级", "").Trim();
string msg = "";
if (int.TryParse(detail, out int cid))
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/characterlevelup?qq={e.user_id}&c={cid}") ?? "").Trim();
}
else
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/characterlevelup?qq={e.user_id}&c=1") ?? "").Trim();
}
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "角色升级", msg);
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("角色突破", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("角色突破", "").Trim();
string msg = "";
if (int.TryParse(detail, out int cid))
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/characterlevelbreak?qq={e.user_id}&c={cid}") ?? "").Trim();
}
else
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/characterlevelbreak?qq={e.user_id}&c=1") ?? "").Trim();
}
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "角色突破", msg);
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("突破信息", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("突破信息", "").Trim();
string msg = "";
if (int.TryParse(detail, out int cid))
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/getlevelbreakneedy?qq={e.user_id}&id={cid}") ?? "").Trim();
}
else
{
msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/getlevelbreakneedy?qq={e.user_id}&id=1") ?? "").Trim();
}
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "突破信息", msg);
}
return quick_reply;
}
if (e.detail.Length >= 2 && e.detail[..2].Equals("使用", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("使用", "").Trim();
char[] chars = [',', ' '];
string pattern = @"\s*(?<itemName>[^\d]+)\s*(?<count>\d+)\s*(?:角色\s*(?<characterIds>[\d\s]*))?";
Match match = Regex.Match(detail, pattern);
if (match.Success)
{
string itemName = match.Groups["itemName"].Value.Trim();
if (int.TryParse(match.Groups["count"].Value, out int count))
{
string characterIdsString = match.Groups["characterIds"].Value;
int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1];
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}", System.Text.Json.JsonSerializer.Serialize(characterIds)) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "使用", msg);
}
}
}
else
{
pattern = @"\s*(?<itemId>\d+)\s*(?:角色\s*(?<characterIds>[\d\s]*))?";
match = Regex.Match(detail, pattern);
if (match.Success)
{
if (int.TryParse(match.Groups["itemId"].Value, out int itemId))
{
string characterIdsString = match.Groups["characterIds"].Value;
int[] characterIds = characterIdsString != "" ? [.. characterIdsString.Split(chars, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)] : [1];
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/useitem?qq={e.user_id}&id={itemId}", System.Text.Json.JsonSerializer.Serialize(characterIds)) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "使用", msg);
}
}
}
else
{
pattern = @"\s*(?<itemName>[^\d]+)\s*(?<count>\d+)\s*";
match = Regex.Match(detail, pattern);
if (match.Success)
{
string itemName = match.Groups["itemName"].Value.Trim();
if (int.TryParse(match.Groups["count"].Value, out int count))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/useitem2?qq={e.user_id}&name={itemName}&count={count}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "使用", msg);
}
}
}
else
{
pattern = @"\s*(?<itemId>\d+)\s*";
match = Regex.Match(detail, pattern);
if (match.Success)
{
if (int.TryParse(match.Groups["itemId"].Value, out int itemId))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/useitem?qq={e.user_id}&id={itemId}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "使用", msg);
}
}
}
}
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("分解物品", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("分解物品", "").Trim();
List<int> ids = [];
foreach (string str in detail.Split(' '))
{
if (int.TryParse(str, out int id))
{
ids.Add(id);
}
}
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/decomposeitem?qq={e.user_id}", System.Text.Json.JsonSerializer.Serialize(ids)) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "分解物品", msg);
}
return quick_reply;
}
if (e.detail.Length >= 2 && e.detail[..2].Equals("分解", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("分解", "").Trim();
string pattern = @"\s*(?<itemName>[^\d]+)\s*(?<count>\d+)\s*";
Match match = Regex.Match(detail, pattern);
if (match.Success)
{
string itemName = match.Groups["itemName"].Value.Trim();
if (int.TryParse(match.Groups["count"].Value, out int count))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/decomposeitem2?qq={e.user_id}&name={itemName}&count={count}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "分解", msg);
}
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("品质分解", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("品质分解", "").Trim();
if (int.TryParse(detail, out int q))
{
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/decomposeitem3?qq={e.user_id}&q={q}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "品质分解", msg);
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("熟圣之力", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("熟圣之力", "").Trim();
string[] strings = detail.Split(" ");
int count = -1;
if (strings.Length > 1 && int.TryParse(strings[1].Trim(), out count))
{
string name = strings[0].Trim();
if (count > 0)
{
long userid = e.user_id;
if (strings.Length > 2 && long.TryParse(strings[2].Replace("@", "").Trim(), out long temp))
{
userid = temp;
}
string msg = (await Bot.HttpPost<string>($"https://api.milimoe.com/fungame/createitem?qq={e.user_id}&name={name}&count={count}&target={userid}") ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "熟圣之力", msg);
}
}
else
{
await Bot.SendGroupMessage(e.group_id, "熟圣之力", "数量不能为0请重新输入。");
}
}
return quick_reply;
}
if (e.detail.Length >= 4 && e.detail[..4].Equals("完整决斗", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("完整决斗", "").Replace("@", "").Trim();
List<string> msgs = [];
if (long.TryParse(detail.Trim(), out long eqq))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=true") ?? [];
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=true") ?? [];
}
List<string> real = [];
if (msgs.Count > 2)
{
if (msgs.Count < 20)
{
int remain = 7;
string merge = "";
for (int i = 0; i < msgs.Count - 1; i++)
{
remain--;
merge += msgs[i] + "\r\n";
if (remain == 0)
{
real.Add(merge);
merge = "";
if ((msgs.Count - i - 2) < 7)
{
remain = msgs.Count - i - 2;
}
else remain = 7;
}
}
}
else
{
real.Add(msgs[^2]);
}
real.Add(msgs[^1]);
}
else
{
real = msgs;
}
foreach (string msg in real)
{
await Bot.SendGroupMessage(e.group_id, "完整决斗", msg.Trim());
await Task.Delay(1500);
}
return quick_reply;
}
if (e.detail.Length >= 2 && e.detail[..2].Equals("决斗", StringComparison.CurrentCultureIgnoreCase))
{
string detail = e.detail.Replace("决斗", "").Replace("@", "").Trim();
List<string> msgs = [];
if (long.TryParse(detail.Trim(), out long eqq))
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/fightcustom?qq={e.user_id}&eqq={eqq}&all=false") ?? [];
}
else
{
msgs = await Bot.HttpPost<List<string>>($"https://api.milimoe.com/fungame/fightcustom2?qq={e.user_id}&name={detail.Trim()}&all=false") ?? [];
}
List<string> real = [];
if (msgs.Count > 2)
{
int remain = 7;
string merge = "";
for (int i = 0; i < msgs.Count - 1; i++)
{
remain--;
merge += msgs[i] + "\r\n";
if (remain == 0)
{
real.Add(merge);
merge = "";
if ((msgs.Count - i - 3) < 7)
{
remain = msgs.Count - i - 3;
}
else remain = 7;
}
}
real.Add(msgs[^1]);
}
else
{
real = msgs;
}
foreach (string msg in real)
{
await Bot.SendGroupMessage(e.group_id, "决斗", msg.Trim());
await Task.Delay(1500);
}
return quick_reply;
}
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 quick_reply;
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/reload?master=" + GeneralSettings.Master) ?? "").Trim();
if (msg != "")
{
await Bot.SendGroupMessage(e.group_id, "重载FunGame", msg);
}
return quick_reply;
}
// 发图API
@ -1443,7 +613,22 @@ namespace Milimoe.RainBOT.ListeningTask
{
GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_id));
content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 1 ? 2 : name.Length), "哥")));
switch (Random.Shared.Next(4))
{
case 0:
content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 1 ? 2 : name.Length), "哥")));
break;
case 1:
content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 1 ? 2 : name.Length), "姐")));
break;
case 2:
content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "圣")));
break;
case 3:
default:
content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 0 ? 1 : name.Length), "出")));
break;
}
await Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000);
return quick_reply;
}

View File

@ -1,5 +1,4 @@
using System.IO;
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Message;
using Milimoe.OneBot.Model.Other;

View File

@ -23,8 +23,6 @@ namespace Milimoe.RainBOT.Settings
public static Dictionary<long, List<Member>> GroupMembers { get; set; } = [];
public static bool FunGameSimulation { get; set; } = false;
public static bool IsAdmin(long group_id, long user_id)
{
if (GroupMembers.TryGetValue(group_id, out List<Member>? members) && members != null && members.Any(m => m.user_id == user_id && (m.role == "owner" || m.role == "admin")))
@ -346,8 +344,9 @@ namespace Milimoe.RainBOT.Settings
private static readonly HttpClient client = new();
public static async Task<T?> HttpGet<T>(string url)
public static async Task<T?> HttpGet<T>(string url, bool fungame = false)
{
if (fungame) client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", GeneralSettings.FunGameToken);
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
@ -356,9 +355,10 @@ namespace Milimoe.RainBOT.Settings
return result;
}
public static async Task<T?> HttpPost<T>(string url, string json = "")
public static async Task<T?> HttpPost<T>(string url, string json = "", bool fungame = false)
{
HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
if (fungame) client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", GeneralSettings.FunGameToken);
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();

1415
src/Settings/FunGame.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,10 @@ namespace Milimoe.RainBOT.Settings
public static List<long> SayNoAccessGroup { get; set; } = [];
public static List<long> OSMCoreGroup { get; set; } = [];
public static List<long> FunGameGroup { get; set; } = [];
public static string FunGameToken { get; set; } = "";
public static PluginConfig Configs { get; set; } = new("rainbot", "config");
@ -152,6 +156,14 @@ namespace Milimoe.RainBOT.Settings
{
OSMCoreGroup = (List<long>)value;
}
if (configs.TryGetValue("FunGameGroup", out value) && value != null)
{
FunGameGroup = (List<long>)value;
}
if (configs.TryGetValue("FunGameToken", out value) && value != null)
{
FunGameToken = (string)value;
}
}
public static void SaveConfig()
@ -178,6 +190,8 @@ namespace Milimoe.RainBOT.Settings
Configs.Add("RecallAccessGroup", RecallAccessGroup);
Configs.Add("SayNoAccessGroup", SayNoAccessGroup);
Configs.Add("OSMCoreGroup", OSMCoreGroup);
Configs.Add("FunGameGroup", FunGameGroup);
Configs.Add("FunGameToken", FunGameToken);
Configs.Save();
}
@ -201,6 +215,9 @@ namespace Milimoe.RainBOT.Settings
case "osmcoregroup":
list = OSMCoreGroup;
break;
case "fungamegroup":
list = FunGameGroup;
break;
}
string msg = list.Count > 0 ? "权限组" + group + "拥有以下成员:" + "\r\n" + string.Join("\r\n", list) : "此权限组不存在或没有任何成员。";
_ = isgroup ? Bot.SendGroupMessage(target, "显示列表成员", msg) : Bot.SendFriendMessage(target, "显示列表成员", msg);

View File

@ -16,6 +16,8 @@ namespace Milimoe.RainBOT.Settings
public static List<long> RepeatQQIgnore { get; set; } = [];
public static List<long> ReverseAtIgnore { get; set; } = [];
public static HashSet<string> CustomIgnore { get; set; } = [];
public static PluginConfig Configs { get; set; } = new("rainbot", "ignore");
@ -52,6 +54,7 @@ namespace Milimoe.RainBOT.Settings
Configs.Add("QQGroupIgnore", QQGroupIgnore);
Configs.Add("RepeatQQIgnore", RepeatQQIgnore);
Configs.Add("ReverseAtIgnore", ReverseAtIgnore);
Configs.Add("CustomIgnore", CustomIgnore);
Configs.Save();
}
@ -94,6 +97,10 @@ namespace Milimoe.RainBOT.Settings
else ReverseAtIgnore.Remove(lv);
}
break;
case "customignore":
if (isadd) CustomIgnore.Add(strv);
else CustomIgnore.Remove(strv);
break;
default:
return false;
}
@ -125,6 +132,9 @@ namespace Milimoe.RainBOT.Settings
case "reverseatignore":
list = ReverseAtIgnore.Select(x => x.ToString()).ToList();
break;
case "customignore":
list = CustomIgnore.Select(x => x.ToString()).ToList();
break;
}
string msg = list.Count > 0 ? "列表" + group + "拥有以下成员:" + "\r\n" + string.Join("\r\n", list) : "此列表不存在或没有任何成员。";
_ = isgroup ? Bot.SendGroupMessage(target, "显示列表成员", msg) : Bot.SendFriendMessage(target, "显示列表成员", msg);