适配最新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,14 +46,12 @@ 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;
{
if (!await Bot.CheckBlackList(false, e.user_id, e.user_id)) return;
string msg = ""; string msg = "";
foreach (long group_id in Bot.Groups.Select(g => g.group_id)) foreach (long group_id in Bot.Groups.Select(g => g.group_id))
{ {
@ -67,8 +65,7 @@ namespace Milimoe.RainBOT.ListeningTask
} }
if (msg == "") msg = "你无需忏悔。请注意:我不能帮你解除由管理员手动操作的禁言。"; if (msg == "") msg = "你无需忏悔。请注意:我不能帮你解除由管理员手动操作的禁言。";
await Bot.SendFriendMessage(e.user_id, "忏悔", msg); await Bot.SendFriendMessage(e.user_id, "忏悔", msg);
}); return quick_reply;
return;
} }
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
MasterCommand.Execute(e.detail, e.user_id, onOSMCore, e.group_id, true); MasterCommand.Execute(e.detail, e.user_id, onOSMCore, e.group_id, true);
return; return quick_reply;
});
} }
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,23 +67,21 @@ 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 (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
if (GeneralSettings.Challenge12ClockGroup.Contains(e.user_id)) if (GeneralSettings.Challenge12ClockGroup.Contains(e.user_id))
{ {
await Bot.SendGroupMessage(e.group_id, "12点大挑战", "请勿重复加入。"); await Bot.SendGroupMessage(e.group_id, "12点大挑战", "请勿重复加入。");
@ -97,147 +92,111 @@ namespace Milimoe.RainBOT.ListeningTask
await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功加入~\r\n发送【退出12点】退出挑战。"); await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功加入~\r\n发送【退出12点】退出挑战。");
GeneralSettings.SaveConfig(); GeneralSettings.SaveConfig();
} }
return; return quick_reply;
});
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GeneralSettings.Challenge12ClockGroup.Remove(e.user_id); GeneralSettings.Challenge12ClockGroup.Remove(e.user_id);
await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功退出~\r\n发送【加入12点】即可再次参加。"); await Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功退出~\r\n发送【加入12点】即可再次参加。");
GeneralSettings.SaveConfig(); GeneralSettings.SaveConfig();
return; return quick_reply;
});
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cdntop")); content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=random"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=yin")); content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=yin"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
if (e.detail == "猫耳") if (e.detail == "猫耳")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cat")); content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cat"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
if (e.detail == "壁纸") if (e.detail == "壁纸")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=pc")); content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=pc"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
if (e.detail == "新闻") if (e.detail == "新闻")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb")); content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
if (e.detail == "买家秀") if (e.detail == "买家秀")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://api.03c3.cn/api/taobaoBuyerShow")); content.message.Add(new ImageMessage("https://api.03c3.cn/api/taobaoBuyerShow"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\long\long (" + (new Random().Next(1540) + 1) + ").jpg")); content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\long\long (" + (new Random().Next(1540) + 1) + ").jpg"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\dingzhen\dz" + (new Random().Next(82) + 1) + ".jpg")); content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\dingzhen\dz" + (new Random().Next(82) + 1) + ".jpg"));
await Bot.SendGroupMessage(e.group_id, "Image", content); await Bot.SendGroupMessage(e.group_id, "Image", content);
return; return quick_reply;
});
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
GroupMessageContent content = new(e.group_id); GroupMessageContent content = new(e.group_id);
content.message.Add(new RecordMessage(Music.MusicList[match_music.First()])); content.message.Add(new RecordMessage(Music.MusicList[match_music.First()]));
await Bot.SendGroupMessage(e.group_id, "Record", content); await Bot.SendGroupMessage(e.group_id, "Record", content);
}); return quick_reply;
return;
} }
// 我的运势 // 我的运势
if (e.detail == "我的运势") if (e.detail == "我的运势")
{ {
TaskUtility.NewTask(async () => if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
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));
if (Daily.UserDailys.TryGetValue(e.user_id, out string? value) && value != null && value.Trim() != "") if (Daily.UserDailys.TryGetValue(e.user_id, out string? value) && value != null && value.Trim() != "")
@ -284,28 +243,22 @@ namespace Milimoe.RainBOT.ListeningTask
await Bot.SendGroupMessage(e.group_id, "我的运势配图", content); await Bot.SendGroupMessage(e.group_id, "我的运势配图", content);
Daily.SaveDaily(); Daily.SaveDaily();
} }
}); return quick_reply;
return;
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
Daily.UserDailys.Remove(e.user_id); Daily.UserDailys.Remove(e.user_id);
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("你的今日运势已重置。")); content.message.Add(new TextMessage("你的今日运势已重置。"));
await Bot.SendGroupMessage(e.group_id, "重置运势", content); await Bot.SendGroupMessage(e.group_id, "重置运势", content);
Daily.SaveDaily(); Daily.SaveDaily();
}); return quick_reply;
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
string[] strs = e.detail.Replace("查看", "").Replace("运势", "").Trim().Split(' '); string[] strs = e.detail.Replace("查看", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs) foreach (string str_qq in strs)
{ {
@ -329,14 +282,11 @@ namespace Milimoe.RainBOT.ListeningTask
} }
} }
} }
}); return quick_reply;
return;
} }
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return;
string[] strs = e.detail.Replace("重置", "").Replace("运势", "").Trim().Split(' '); string[] strs = e.detail.Replace("重置", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs) foreach (string str_qq in strs)
{ {
@ -347,19 +297,16 @@ namespace Milimoe.RainBOT.ListeningTask
Daily.SaveDaily(); Daily.SaveDaily();
} }
} }
}); return quick_reply;
return;
} }
// 下面是开启了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 (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return;
if (e.user_id != GeneralSettings.Master) if (e.user_id != GeneralSettings.Master)
{ {
await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "2秒后开奖\r\n如需要忏悔请在开奖后3秒内发送忏悔开奖前发送无效。"); await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "2秒后开奖\r\n如需要忏悔请在开奖后3秒内发送忏悔开奖前发送无效。");
@ -373,23 +320,19 @@ namespace Milimoe.RainBOT.ListeningTask
} }
else else
{ {
_ = Bot.SendGroupMessage(e.group_id, "禁言抽奖", "我不能禁言主人!"); await Bot.SendGroupMessage(e.group_id, "禁言抽奖", "我不能禁言主人!");
} }
}); return quick_reply;
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;
{
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id) || !Bot.BotIsAdmin(e.group_id)) return;
await Task.Delay(3800); await Task.Delay(3800);
MuteRecall.WillMute.Remove(e.user_id); MuteRecall.WillMute.Remove(e.user_id);
await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0), true); await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0), true);
await Bot.SendGroupMessage(e.group_id, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。"); await Bot.SendGroupMessage(e.group_id, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。");
}); return quick_reply;
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";
} }