适配最新dll

This commit is contained in:
milimoe 2024-08-12 01:02:19 +08:00
parent c2a5b02883
commit 6fd8bd636f
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
6 changed files with 232 additions and 289 deletions

Binary file not shown.

View File

@ -1,5 +1,4 @@
using Milimoe.OneBot.Framework; using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Framework.Utility;
using Milimoe.OneBot.Model.Content; using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event; using Milimoe.OneBot.Model.Event;
using Milimoe.OneBot.Model.Other; using Milimoe.OneBot.Model.Other;
@ -13,13 +12,14 @@ namespace Milimoe.RainBOT.ListeningTask
{ {
private static long dice = 0; private static long dice = 0;
public static void ListeningTask_handler(FriendMessageEvent e, out FriendMsgEventQuickReply? quick_reply) public static async Task<FriendMsgEventQuickReply?> ListeningTask_handler(FriendMessageEvent e)
{ {
quick_reply = null; FriendMsgEventQuickReply? quick_reply = null;
try try
{ {
Sender sender = e.sender; Sender sender = e.sender;
if (e.user_id == 0 || e.sender.user_id == 0) return; if (e.user_id == 0 || e.sender.user_id == 0) return quick_reply;
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} P/{e.user_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)}"); Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} P/{e.user_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)}");
if (GeneralSettings.IsDebug) if (GeneralSettings.IsDebug)
@ -34,11 +34,11 @@ namespace Milimoe.RainBOT.ListeningTask
if (e.user_id != GeneralSettings.Master && e.CheckThrow(10, out dice)) if (e.user_id != GeneralSettings.Master && e.CheckThrow(10, out dice))
{ {
Bot.ColorfulCheckPass(sender, "反驳是", dice, 40); Bot.ColorfulCheckPass(sender, "反驳是", dice, 40);
_ = Bot.SendFriendMessage(e.user_id, "随机反驳是", "是你的头"); await Bot.SendFriendMessage(e.user_id, "随机反驳是", "是你的头");
} }
else if (e.user_id == GeneralSettings.Master) else if (e.user_id == GeneralSettings.Master)
{ {
_ = Bot.SendFriendMessage(e.user_id, "随机反驳是", "是你的头"); await Bot.SendFriendMessage(e.user_id, "随机反驳是", "是你的头");
} }
} }
@ -46,29 +46,26 @@ namespace Milimoe.RainBOT.ListeningTask
if (e.detail.Length >= 4 && e.detail[..4] == ".osm") if (e.detail.Length >= 4 && e.detail[..4] == ".osm")
{ {
MasterCommand.Execute(e.detail, e.user_id, false, e.user_id, false); MasterCommand.Execute(e.detail, e.user_id, false, e.user_id, false);
return; return quick_reply;
} }
if (GeneralSettings.IsMute && e.detail == "忏悔") if (GeneralSettings.IsMute && e.detail == "忏悔")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(false, e.user_id, e.user_id)) return quick_reply;
string msg = "";
foreach (long group_id in Bot.Groups.Select(g => g.group_id))
{ {
if (!await Bot.CheckBlackList(false, e.user_id, e.user_id)) return; if (Bot.BotIsAdmin(group_id) && MuteRecall.Muted[group_id].TryGetValue(e.user_id, out long operator_id) && operator_id == Bot.BotQQ)
string msg = "";
foreach (long group_id in Bot.Groups.Select(g => g.group_id))
{ {
if (Bot.BotIsAdmin(group_id) && MuteRecall.Muted[group_id].TryGetValue(e.user_id, out long operator_id) && operator_id == Bot.BotQQ) MuteRecall.Muted[group_id].Remove(e.user_id);
{ await Bot.SendMessage(SupportedAPI.set_group_ban, group_id, "忏悔", new SetGroupBanContent(group_id, e.user_id, 0), true);
MuteRecall.Muted[group_id].Remove(e.user_id); if (msg != "") msg += "\r\n";
await Bot.SendMessage(SupportedAPI.set_group_ban, group_id, "忏悔", new SetGroupBanContent(group_id, e.user_id, 0), true); msg += $"[{group_id}] 忏悔成功!!希望你保持纯真,保持野性的美。";
if (msg != "") msg += "\r\n";
msg += $"[{group_id}] 忏悔成功!!希望你保持纯真,保持野性的美。";
}
} }
if (msg == "") msg = "你无需忏悔。请注意:我不能帮你解除由管理员手动操作的禁言。"; }
await Bot.SendFriendMessage(e.user_id, "忏悔", msg); if (msg == "") msg = "你无需忏悔。请注意:我不能帮你解除由管理员手动操作的禁言。";
}); await Bot.SendFriendMessage(e.user_id, "忏悔", msg);
return; return quick_reply;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -77,6 +74,8 @@ namespace Milimoe.RainBOT.ListeningTask
Console.WriteLine(ex); Console.WriteLine(ex);
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
} }
return quick_reply;
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace Milimoe.RainBOT.ListeningTask
{ {
public class GroupBanTask public class GroupBanTask
{ {
public static async void ListeningTask_handler(GroupBanEvent e) public static async Task ListeningTask_handler(GroupBanEvent e)
{ {
try try
{ {

View File

@ -1,5 +1,4 @@
using Milimoe.OneBot.Framework; using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Framework.Utility;
using Milimoe.OneBot.Model.Content; using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event; using Milimoe.OneBot.Model.Event;
using Milimoe.OneBot.Model.Message; using Milimoe.OneBot.Model.Message;
@ -16,13 +15,14 @@ namespace Milimoe.RainBOT.ListeningTask
private readonly static string[] EEWords = ["ee", "鹅鹅", "呃呃", "谔谔", "饿饿"]; private readonly static string[] EEWords = ["ee", "鹅鹅", "呃呃", "谔谔", "饿饿"];
private readonly static string[] MuteCommands = ["禁言", "解禁"]; private readonly static string[] MuteCommands = ["禁言", "解禁"];
public static void ListeningTask_handler(GroupMessageEvent e, out GroupMsgEventQuickReply? quick_reply) public static async Task<GroupMsgEventQuickReply?> ListeningTask_handler(GroupMessageEvent e)
{ {
quick_reply = null; GroupMsgEventQuickReply? quick_reply = null;
try try
{ {
Sender sender = e.sender; Sender sender = e.sender;
if (e.user_id == 0 || e.sender.user_id == 0) return; if (e.user_id == 0 || e.sender.user_id == 0) return quick_reply;
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)} by {sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)}"); Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)} by {sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)}");
if (GeneralSettings.IsDebug) if (GeneralSettings.IsDebug)
@ -38,30 +38,27 @@ namespace Milimoe.RainBOT.ListeningTask
// OSM指令 // OSM指令
if (e.detail.Length >= 4 && e.detail[..4] == ".osm") if (e.detail.Length >= 4 && e.detail[..4] == ".osm")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ MasterCommand.Execute(e.detail, e.user_id, onOSMCore, e.group_id, true);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; return quick_reply;
MasterCommand.Execute(e.detail, e.user_id, onOSMCore, e.group_id, true);
return;
});
} }
if (e.detail.Length >= 5 && (e.detail[..5] == "禁言所有人" || e.detail[..5] == "解禁所有人") && (e.user_id == GeneralSettings.Master || GeneralSettings.UnMuteAccessGroup.Union(GeneralSettings.MuteAccessGroup).Contains(e.user_id)) && Bot.GroupMembers.TryGetValue(e.group_id, out List<Member>? members) && members != null) if (e.detail.Length >= 5 && (e.detail[..5] == "禁言所有人" || e.detail[..5] == "解禁所有人") && (e.user_id == GeneralSettings.Master || GeneralSettings.UnMuteAccessGroup.Union(GeneralSettings.MuteAccessGroup).Contains(e.user_id)) && Bot.GroupMembers.TryGetValue(e.group_id, out List<Member>? members) && members != null)
{ {
TaskUtility.NewTask(async () => await Bot.Mute(e.user_id, e.group_id, e.detail, members.Where(m => m.user_id != GeneralSettings.Master).Select(m => m.user_id))); await Bot.Mute(e.user_id, e.group_id, e.detail, members.Where(m => m.user_id != GeneralSettings.Master).Select(m => m.user_id));
return; return quick_reply;
} }
if (e.detail != "禁言抽奖" && e.detail.Length >= 2 && MuteCommands.Any(e.detail[..2].Contains)) if (e.detail != "禁言抽奖" && e.detail.Length >= 2 && MuteCommands.Any(e.detail[..2].Contains))
{ {
TaskUtility.NewTask(async () => await Bot.Mute(e.user_id, e.group_id, e.detail)); await Bot.Mute(e.user_id, e.group_id, e.detail);
return; return quick_reply;
} }
if (e.detail.Length >= 4 && e.detail[..4] == "跨群禁言") if (e.detail.Length >= 4 && e.detail[..4] == "跨群禁言")
{ {
TaskUtility.NewTask(async () => await Bot.MuteGroup(e.user_id, e.group_id, e.detail)); await Bot.MuteGroup(e.user_id, e.group_id, e.detail);
return; return quick_reply;
} }
// 撤回消息 // 撤回消息
@ -70,326 +67,272 @@ namespace Milimoe.RainBOT.ListeningTask
ReplyMessage reply = (ReplyMessage)e.message.Where(m => m.type == "reply").First(); ReplyMessage reply = (ReplyMessage)e.message.Where(m => m.type == "reply").First();
if (int.TryParse(reply.data.id, out int id)) if (int.TryParse(reply.data.id, out int id))
{ {
TaskUtility.NewTask(async () => await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(id), true)); await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(id), true);
TaskUtility.NewTask(async () => await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true)); await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true);
return; return quick_reply;
} }
} }
if (!GeneralSettings.IsRun) if (!GeneralSettings.IsRun)
{ {
return; return quick_reply;
} }
// 12点大挑战 // 12点大挑战
if (e.detail == "加入12点" || e.detail == "加入12点大挑战") if (e.detail == "加入12点" || e.detail == "加入12点大挑战")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
if (GeneralSettings.Challenge12ClockGroup.Contains(e.user_id))
{ {
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; await Bot.SendGroupMessage(e.group_id, "12点大挑战", "请勿重复加入。");
if (GeneralSettings.Challenge12ClockGroup.Contains(e.user_id)) }
{ else
await Bot.SendGroupMessage(e.group_id, "12点大挑战", "请勿重复加入。"); {
} GeneralSettings.Challenge12ClockGroup.Add(e.user_id);
else await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功加入~\r\n发送【退出12点】退出挑战。");
{ GeneralSettings.SaveConfig();
GeneralSettings.Challenge12ClockGroup.Add(e.user_id); }
await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功加入~\r\n发送【退出12点】退出挑战。"); return quick_reply;
GeneralSettings.SaveConfig();
}
return;
});
} }
else if ((e.detail == "退出12点" || e.detail == "退出12点大挑战") && GeneralSettings.Challenge12ClockGroup.Contains(e.user_id)) else if ((e.detail == "退出12点" || e.detail == "退出12点大挑战") && GeneralSettings.Challenge12ClockGroup.Contains(e.user_id))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GeneralSettings.Challenge12ClockGroup.Remove(e.user_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功退出~\r\n发送【加入12点】即可再次参加。");
GeneralSettings.Challenge12ClockGroup.Remove(e.user_id); GeneralSettings.SaveConfig();
await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功退出~\r\n发送【加入12点】即可再次参加。"); return quick_reply;
GeneralSettings.SaveConfig();
return;
});
} }
else if (e.detail == "12点大挑战") else if (e.detail == "12点大挑战")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ await Bot.SendGroupMessage(e.group_id, "12点大挑战", "欢迎加入12点大挑战。参加本挑战后你将在每晚的12点获得8小时禁言和优质的睡眠确保第二天的精神饱满\r\n发送【加入12点】即可参加。");
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; return quick_reply;
_ = Bot.SendGroupMessage(e.group_id, "12点大挑战", "欢迎加入12点大挑战。参加本挑战后你将在每晚的12点获得8小时禁言和优质的睡眠确保第二天的精神饱满\r\n发送【加入12点】即可参加。");
return;
});
} }
// 发图API // 发图API
if (e.detail == "来图") if (e.detail == "来图")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=random"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cdntop")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail.Contains("白毛")) if (e.detail.Contains("白毛"))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=yin"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=yin")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail == "猫耳") if (e.detail == "猫耳")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cat"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cat")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail == "壁纸") if (e.detail == "壁纸")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=pc"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=pc")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail == "新闻") if (e.detail == "新闻")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail == "买家秀") if (e.detail == "买家秀")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("https://api.03c3.cn/api/taobaoBuyerShow"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("https://api.03c3.cn/api/taobaoBuyerShow")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail.Contains("来龙")) if (e.detail.Contains("来龙"))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\long\long (" + (new Random().Next(1540) + 1) + ").jpg"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\long\long (" + (new Random().Next(1540) + 1) + ").jpg")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (e.detail == "一眼丁真" || e.detail == "一眼顶针") if (e.detail == "一眼丁真" || e.detail == "一眼顶针")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\dingzhen\dz" + (new Random().Next(82) + 1) + ".jpg"));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Image", content);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\dingzhen\dz" + (new Random().Next(82) + 1) + ".jpg")); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Image", content);
return;
});
} }
if (EEWords.Any(e.detail.Contains) && e.CheckThrow(20, out _)) if (EEWords.Any(e.detail.Contains) && e.CheckThrow(20, out _))
{ {
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\ee.png")); content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\ee.png"));
_ = Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
} }
// 发音频API // 发音频API
var match_music = Music.MusicList.Keys.Where(s => e.detail.Contains(s, StringComparison.CurrentCultureIgnoreCase)); var match_music = Music.MusicList.Keys.Where(s => e.detail.Contains(s, StringComparison.CurrentCultureIgnoreCase));
if (match_music.Any()) if (match_music.Any())
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ GroupMessageContent content = new(e.group_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new RecordMessage(Music.MusicList[match_music.First()]));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "Record", content);
content.message.Add(new RecordMessage(Music.MusicList[match_music.First()])); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "Record", content);
});
return;
} }
// 我的运势 // 我的运势
if (e.detail == "我的运势") if (e.detail == "我的运势")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_id));
if (Daily.UserDailys.TryGetValue(e.user_id, out string? value) && value != null && value.Trim() != "")
{ {
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; content.message.Add(new TextMessage("你已看过你的今日运势:\r\n"));
GroupMessageContent content = new(e.group_id); content.message.Add(new TextMessage(value));
content.message.Add(new AtMessage(e.user_id)); await Bot.SendGroupMessage(e.group_id, "我的运势", content);
if (Daily.UserDailys.TryGetValue(e.user_id, out string? value) && value != null && value.Trim() != "") }
else
{
int seq = new Random().Next(Daily.DailyContent.Count);
string text = Daily.DailyContent[seq];
Daily.UserDailys.Add(e.user_id, text);
content.message.Add(new TextMessage("你的今日运势是:\r\n" + text));
await Bot.SendGroupMessage(e.group_id, "我的运势", content);
// 配图
content = new(e.group_id);
string img = "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\zi\";
if (seq >= 0 && seq <= 5)
{ {
content.message.Add(new TextMessage("你已看过你的今日运势:\r\n")); img += "dj" + (new Random().Next(3) + 1) + ".png";
content.message.Add(new TextMessage(value));
await Bot.SendGroupMessage(e.group_id, "我的运势", content);
} }
else else if (seq >= 6 && seq <= 10)
{ {
int seq = new Random().Next(Daily.DailyContent.Count); img += "zj" + (new Random().Next(2) + 1) + ".png";
string text = Daily.DailyContent[seq];
Daily.UserDailys.Add(e.user_id, text);
content.message.Add(new TextMessage("你的今日运势是:\r\n" + text));
await Bot.SendGroupMessage(e.group_id, "我的运势", content);
// 配图
content = new(e.group_id);
string img = "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\zi\";
if (seq >= 0 && seq <= 5)
{
img += "dj" + (new Random().Next(3) + 1) + ".png";
}
else if (seq >= 6 && seq <= 10)
{
img += "zj" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 11 && seq <= 15)
{
img += "j" + (new Random().Next(4) + 1) + ".png";
}
else if (seq >= 16 && seq <= 22)
{
img += "mj" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 23 && seq <= 25)
{
img += "dx" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 26 && seq <= 29)
{
img += "x" + (new Random().Next(2) + 1) + ".png";
}
content.message.Add(new ImageMessage(img));
await Bot.SendGroupMessage(e.group_id, "我的运势配图", content);
Daily.SaveDaily();
} }
}); else if (seq >= 11 && seq <= 15)
return; {
img += "j" + (new Random().Next(4) + 1) + ".png";
}
else if (seq >= 16 && seq <= 22)
{
img += "mj" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 23 && seq <= 25)
{
img += "dx" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 26 && seq <= 29)
{
img += "x" + (new Random().Next(2) + 1) + ".png";
}
content.message.Add(new ImageMessage(img));
await Bot.SendGroupMessage(e.group_id, "我的运势配图", content);
Daily.SaveDaily();
}
return quick_reply;
} }
if (e.detail == "重置运势" && Daily.UserDailys.ContainsKey(e.user_id)) if (e.detail == "重置运势" && Daily.UserDailys.ContainsKey(e.user_id))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{ Daily.UserDailys.Remove(e.user_id);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; GroupMessageContent content = new(e.group_id);
Daily.UserDailys.Remove(e.user_id); content.message.Add(new AtMessage(e.user_id));
GroupMessageContent content = new(e.group_id); content.message.Add(new TextMessage("你的今日运势已重置。"));
content.message.Add(new AtMessage(e.user_id)); await Bot.SendGroupMessage(e.group_id, "重置运势", content);
content.message.Add(new TextMessage("你的今日运势已重置。")); Daily.SaveDaily();
await Bot.SendGroupMessage(e.group_id, "重置运势", content); return quick_reply;
Daily.SaveDaily();
});
return;
} }
if (e.detail.Length > 4 && e.detail[..2] == "查看" && (e.detail[^2..] == "运势")) if (e.detail.Length > 4 && e.detail[..2] == "查看" && (e.detail[^2..] == "运势"))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string[] strs = e.detail.Replace("查看", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs)
{ {
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq))
string[] strs = e.detail.Replace("查看", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs)
{ {
if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq)) if (qq == GeneralSettings.BotQQ && !Daily.UserDailys.ContainsKey(qq))
{ {
if (qq == GeneralSettings.BotQQ && !Daily.UserDailys.ContainsKey(qq)) string text = Daily.DailyContent[new Random().Next(Daily.DailyContent.Count)];
{ Daily.UserDailys.Add(GeneralSettings.BotQQ, text);
string text = Daily.DailyContent[new Random().Next(Daily.DailyContent.Count)]; Daily.SaveDaily();
Daily.UserDailys.Add(GeneralSettings.BotQQ, text); }
Daily.SaveDaily(); if (Daily.UserDailys.TryGetValue(qq, out string? daily) && daily != null)
} {
if (Daily.UserDailys.TryGetValue(qq, out string? daily) && daily != null) GroupMessageContent content = new(e.group_id);
{ content.message.Add(new TextMessage(Bot.GetMemberNickName(e.group_id, qq) + "" + qq + ")的今日运势是:\r\n" + daily));
GroupMessageContent content = new(e.group_id); await Bot.SendGroupMessage(e.group_id, "查看运势", content);
content.message.Add(new TextMessage(Bot.GetMemberNickName(e.group_id, qq) + "" + qq + ")的今日运势是:\r\n" + daily)); }
await Bot.SendGroupMessage(e.group_id, "查看运势", content); else
} {
else await Bot.SendGroupMessage(e.group_id, "查看运势", "TA今天还没有抽取运势哦快去提醒TA");
{
await Bot.SendGroupMessage(e.group_id, "查看运势", "TA今天还没有抽取运势哦快去提醒TA");
}
} }
} }
}); }
return; return quick_reply;
} }
if (e.user_id == GeneralSettings.Master && e.detail.Length > 4 && e.detail[..2] == "重置" && (e.detail[^2..] == "运势")) if (e.user_id == GeneralSettings.Master && e.detail.Length > 4 && e.detail[..2] == "重置" && (e.detail[^2..] == "运势"))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
string[] strs = e.detail.Replace("重置", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs)
{ {
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return; if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq))
string[] strs = e.detail.Replace("重置", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs)
{ {
if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq)) Daily.UserDailys.Remove(GeneralSettings.BotQQ);
{ await Bot.SendGroupMessage(e.group_id, "重置运势", "已重置" + Bot.GetMemberNickName(e.group_id, qq) + "" + qq + ")的今日运势。");
Daily.UserDailys.Remove(GeneralSettings.BotQQ); Daily.SaveDaily();
await Bot.SendGroupMessage(e.group_id, "重置运势", "已重置" + Bot.GetMemberNickName(e.group_id, qq) + "" + qq + ")的今日运势。");
Daily.SaveDaily();
}
} }
}); }
return; return quick_reply;
} }
// 下面是开启了OSM Core的群组才能使用的功能 // 下面是开启了OSM Core的群组才能使用的功能
if (!onOSMCore) return; if (!onOSMCore) return quick_reply;
// 禁言抽奖 // 禁言抽奖
if (GeneralSettings.IsMute && e.detail == "禁言抽奖" && !MuteRecall.WillMute.ContainsKey(e.user_id)) if (GeneralSettings.IsMute && e.detail == "禁言抽奖" && !MuteRecall.WillMute.ContainsKey(e.user_id))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return quick_reply;
if (e.user_id != GeneralSettings.Master)
{ {
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return; await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "2秒后开奖\r\n如需要忏悔请在开奖后3秒内发送忏悔开奖前发送无效。");
if (e.user_id != GeneralSettings.Master) await Task.Delay(2000);
{ if (!MuteRecall.WillMute.ContainsKey(e.user_id)) MuteRecall.WillMute.Add(e.user_id, e.user_id);
await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "2秒后开奖\r\n如需要忏悔请在开奖后3秒内发送忏悔开奖前发送无效。"); long mute_time = GeneralSettings.MuteTime[0] + new Random().NextInt64(GeneralSettings.MuteTime[1] - GeneralSettings.MuteTime[0]);
await Task.Delay(2000); await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "开奖啦!禁言时长:" + (mute_time / 60) + "分钟" + (mute_time % 60) + "秒。\r\n" + "你现在有3秒时间发送忏悔拒绝领奖");
if (!MuteRecall.WillMute.ContainsKey(e.user_id)) MuteRecall.WillMute.Add(e.user_id, e.user_id); await Task.Delay(3200);
long mute_time = GeneralSettings.MuteTime[0] + new Random().NextInt64(GeneralSettings.MuteTime[1] - GeneralSettings.MuteTime[0]); await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "禁言抽奖", new SetGroupBanContent(e.group_id, e.user_id, mute_time), true);
await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "开奖啦!禁言时长:" + (mute_time / 60) + "分钟" + (mute_time % 60) + "秒。\r\n" + "你现在有3秒时间发送忏悔拒绝领奖"); MuteRecall.WillMute.Remove(e.user_id);
await Task.Delay(3200); }
await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "禁言抽奖", new SetGroupBanContent(e.group_id, e.user_id, mute_time), true); else
MuteRecall.WillMute.Remove(e.user_id); {
} await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "我不能禁言主人!");
else }
{ return quick_reply;
_ = Bot.SendGroupMessage(e.group_id, "禁言抽奖", "我不能禁言主人!");
}
});
return;
} }
// 忏悔 // 忏悔
else if (GeneralSettings.IsMute && e.detail == "忏悔" && MuteRecall.WillMute.ContainsKey(e.user_id)) else if (GeneralSettings.IsMute && e.detail == "忏悔" && MuteRecall.WillMute.ContainsKey(e.user_id))
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return quick_reply;
{ await Task.Delay(3800);
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return; MuteRecall.WillMute.Remove(e.user_id);
await Task.Delay(3800); await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0), true);
MuteRecall.WillMute.Remove(e.user_id); await Bot.SendGroupMessage(e.group_id, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。");
await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0), true); return quick_reply;
await Bot.SendGroupMessage(e.group_id, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。");
});
return;
} }
// 随机反驳是 // 随机反驳是
@ -398,11 +341,11 @@ namespace Milimoe.RainBOT.ListeningTask
if (e.user_id != GeneralSettings.Master && e.CheckThrow(40, out dice)) if (e.user_id != GeneralSettings.Master && e.CheckThrow(40, out dice))
{ {
Bot.ColorfulCheckPass(sender, "反驳是", dice, 40); Bot.ColorfulCheckPass(sender, "反驳是", dice, 40);
_ = Bot.SendGroupMessage(e.group_id, "随机反驳是", "是你的头"); await Bot.SendGroupMessage(e.group_id, "随机反驳是", "是你的头");
} }
else if (e.user_id == GeneralSettings.Master) else if (e.user_id == GeneralSettings.Master)
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳是", "是你的头"); await Bot.SendGroupMessage(e.group_id, "随机反驳是", "是你的头");
} }
} }
@ -466,7 +409,7 @@ namespace Milimoe.RainBOT.ListeningTask
} }
if (content.message.Count > 0) if (content.message.Count > 0)
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", content); await Bot.SendGroupMessage(e.group_id, "随机反驳不", content);
} }
} }
else if (SayNo.TriggerBeforeNo.Any(e.detail.Contains) && GeneralSettings.IsSayNo && e.CheckThrow(GeneralSettings.PSayNo, out dice)) else if (SayNo.TriggerBeforeNo.Any(e.detail.Contains) && GeneralSettings.IsSayNo && e.CheckThrow(GeneralSettings.PSayNo, out dice))
@ -519,7 +462,7 @@ namespace Milimoe.RainBOT.ListeningTask
} }
if (content.message.Count > 0) if (content.message.Count > 0)
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", content); await Bot.SendGroupMessage(e.group_id, "随机反驳不", content);
} }
} }
else if (e.detail.Contains("可以") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) else if (e.detail.Contains("可以") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
@ -527,11 +470,11 @@ namespace Milimoe.RainBOT.ListeningTask
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (dice < (GeneralSettings.PSayNo / 2)) if (dice < (GeneralSettings.PSayNo / 2))
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", "可以"); await Bot.SendGroupMessage(e.group_id, "随机反驳不", "可以");
} }
else else
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可以"); await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可以");
} }
} }
else if (e.detail.Contains('能') && !e.detail.Contains('不') && !SayNo.IgnoreTriggerBeforeCan.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice)) else if (e.detail.Contains('能') && !e.detail.Contains('不') && !SayNo.IgnoreTriggerBeforeCan.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice))
@ -539,11 +482,11 @@ namespace Milimoe.RainBOT.ListeningTask
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (dice < (GeneralSettings.PSayNo / 2)) if (dice < (GeneralSettings.PSayNo / 2))
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", "能"); await Bot.SendGroupMessage(e.group_id, "随机反驳不", "能");
} }
else else
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", "不能"); await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不能");
} }
} }
else if (e.detail.Contains("可能") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) else if (e.detail.Contains("可能") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
@ -551,22 +494,22 @@ namespace Milimoe.RainBOT.ListeningTask
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (dice < (GeneralSettings.PSayNo / 2)) if (dice < (GeneralSettings.PSayNo / 2))
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", "可能"); await Bot.SendGroupMessage(e.group_id, "随机反驳不", "可能");
} }
else else
{ {
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可能"); await Bot.SendGroupMessage(e.group_id, "随机反驳不", "不可能");
} }
} }
else if (e.detail.Contains('要') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) else if (e.detail.Contains('要') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{ {
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayWantWords[new Random().Next(SayNo.SayWantWords.Count)]); await Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayWantWords[new Random().Next(SayNo.SayWantWords.Count)]);
} }
else if (e.detail.Contains('想') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice)) else if (e.detail.Contains('想') && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{ {
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo); Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
_ = Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayThinkWords[new Random().Next(SayNo.SayThinkWords.Count)]); await Bot.SendGroupMessage(e.group_id, "随机反驳不", SayNo.SayThinkWords[new Random().Next(SayNo.SayThinkWords.Count)]);
} }
// 反向艾特 // 反向艾特
@ -581,10 +524,10 @@ namespace Milimoe.RainBOT.ListeningTask
at.data.qq = e.user_id.ToString(); at.data.qq = e.user_id.ToString();
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.AddRange(e.message); content.message.AddRange(e.message);
_ = Bot.SendGroupMessage(e.group_id, "反向艾特", content); await Bot.SendGroupMessage(e.group_id, "反向艾特", content);
} }
} }
return; return quick_reply;
} }
// 随机OSM // 随机OSM
@ -599,8 +542,8 @@ namespace Milimoe.RainBOT.ListeningTask
_ => "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\osm.jpg", _ => "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\osm.jpg",
}; };
content.message.Add(new ImageMessage(img)); content.message.Add(new ImageMessage(img));
_ = Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
} }
// 随机复读 // 随机复读
@ -611,8 +554,8 @@ namespace Milimoe.RainBOT.ListeningTask
Bot.ColorfulCheckPass(sender, "随机复读", dice, GeneralSettings.PRepeat, delay); Bot.ColorfulCheckPass(sender, "随机复读", dice, GeneralSettings.PRepeat, delay);
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.AddRange(e.message); content.message.AddRange(e.message);
_ = Bot.SendGroupMessage(e.group_id, "随机复读", content, delay * 1000); await Bot.SendGroupMessage(e.group_id, "随机复读", content, delay * 1000);
return; return quick_reply;
} }
// 随机叫哥 // 随机叫哥
@ -627,8 +570,8 @@ namespace Milimoe.RainBOT.ListeningTask
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_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), "哥"))); content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, name.Length > 1 ? 2 : name.Length), "哥")));
_ = Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000); await Bot.SendGroupMessage(e.group_id, "随机叫哥", content, delay * 1000);
return; return quick_reply;
} }
} }
} }
@ -638,6 +581,8 @@ namespace Milimoe.RainBOT.ListeningTask
Console.WriteLine(ex); Console.WriteLine(ex);
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
} }
return quick_reply;
} }
} }
} }

View File

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

View File

@ -3,8 +3,8 @@
public class OSMCore public class OSMCore
{ {
public const string version = "v1.0"; public const string version = "v1.0";
public const string version2 = "Patch9 Test"; public const string version2 = "Patch9";
public const string time = "July 12th, 2024"; public const string time = "Aug. 12th 2024";
public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe"; public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";
} }