RainBOT/src/ListeningTask/GroupBanTask.cs
2024-08-12 01:02:19 +08:00

47 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event;
using Milimoe.OneBot.Model.Other;
using Milimoe.RainBOT.Settings;
namespace Milimoe.RainBOT.ListeningTask
{
public class GroupBanTask
{
public static async Task ListeningTask_handler(GroupBanEvent e)
{
try
{
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} N/Group_Ban G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)}");
if (GeneralSettings.IsDebug)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"DEBUG{e.original_msg}");
Console.ForegroundColor = ConsoleColor.Gray;
}
if (e.sub_type == "ban" && e.duration > 0 && e.user_id == GeneralSettings.Master && e.operator_id != GeneralSettings.BotQQ)
{
MuteRecall.Muted[e.group_id].Remove(e.user_id);
MuteRecall.Muted[e.group_id].Add(e.user_id, GeneralSettings.Master);
SetGroupBanContent content_unmute_master = new(e.group_id, GeneralSettings.Master, 0);
SetGroupBanContent content_mute_operator = new(e.group_id, e.operator_id, 60);
await Bot.SendMessage(SupportedAPI.set_group_ban, e.group_id, "反制禁言", [content_unmute_master, content_mute_operator], true);
Member sender = Bot.GetMember(e.group_id, e.operator_id);
await e.SendMessage($"检测到主人被{sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)})禁言!");
}
else if (e.sub_type == "ban" && e.duration > 0)
{
MuteRecall.Muted[e.group_id].Remove(e.user_id);
MuteRecall.Muted[e.group_id].Add(e.user_id, e.operator_id);
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
}