添加刷屏禁言
This commit is contained in:
parent
45ad0e3b47
commit
15958d6bfa
@ -40,6 +40,15 @@ namespace Milimoe.RainBOT.ListeningTask
|
|||||||
|
|
||||||
if (MuteRecall.Muted.TryGetValue(e.group_id, out Dictionary<long, long>? mute_group) && mute_group != null) mute_group.Remove(e.user_id);
|
if (MuteRecall.Muted.TryGetValue(e.group_id, out Dictionary<long, long>? mute_group) && mute_group != null) mute_group.Remove(e.user_id);
|
||||||
|
|
||||||
|
if (NoSpamming.NoSpammingData.TryGetValue(e.group_id, out NoSpamming? value) && value != null)
|
||||||
|
{
|
||||||
|
if (await value.Check(e.user_id))
|
||||||
|
{
|
||||||
|
await Bot.SendGroupMessage(e.group_id, "刷屏检测", "喜欢刷屏?吔屎啦你!");
|
||||||
|
return quick_reply;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool onOSMCore = GeneralSettings.OSMCoreGroup.Contains(e.group_id);
|
bool onOSMCore = GeneralSettings.OSMCoreGroup.Contains(e.group_id);
|
||||||
// OSM指令
|
// OSM指令
|
||||||
if (e.detail.Length >= 4 && e.detail[..4] == ".osm")
|
if (e.detail.Length >= 4 && e.detail[..4] == ".osm")
|
||||||
@ -376,7 +385,7 @@ namespace Milimoe.RainBOT.ListeningTask
|
|||||||
{
|
{
|
||||||
if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq))
|
if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq))
|
||||||
{
|
{
|
||||||
string msg = await Bot.HttpPost<string>($"https://{GeneralSettings.FunGameServer}/userdaily/remove/" + e.user_id, "") ?? "";
|
string msg = await Bot.HttpPost<string>($"https://{GeneralSettings.FunGameServer}/userdaily/remove/" + qq, "") ?? "";
|
||||||
if (msg != "")
|
if (msg != "")
|
||||||
{
|
{
|
||||||
await Bot.SendGroupMessage(e.group_id, "重置运势", "已重置" + Bot.GetMemberNickName(e.group_id, qq) + "(" + qq + ")的今日运势。");
|
await Bot.SendGroupMessage(e.group_id, "重置运势", "已重置" + Bot.GetMemberNickName(e.group_id, qq) + "(" + qq + ")的今日运势。");
|
||||||
|
|||||||
11
src/Main.cs
11
src/Main.cs
@ -110,6 +110,7 @@ try
|
|||||||
SayNo.InitSayNo();
|
SayNo.InitSayNo();
|
||||||
Ignore.InitIgnore();
|
Ignore.InitIgnore();
|
||||||
QQOpenID.LoadConfig();
|
QQOpenID.LoadConfig();
|
||||||
|
NoSpamming.Init(Bot.Groups);
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine("初始化完毕!");
|
Console.WriteLine("初始化完毕!");
|
||||||
@ -212,6 +213,16 @@ try
|
|||||||
}
|
}
|
||||||
// 重置AI状态
|
// 重置AI状态
|
||||||
AI.CD = false;
|
AI.CD = false;
|
||||||
|
// 刷屏检测重置
|
||||||
|
foreach (NoSpamming ns in NoSpamming.NoSpammingData.Values)
|
||||||
|
{
|
||||||
|
ns.Times.Clear();
|
||||||
|
if (NoSpamming.Refresh++ > 4)
|
||||||
|
{
|
||||||
|
ns.History.Clear();
|
||||||
|
NoSpamming.Refresh = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
60
src/Settings/NoSpamming.cs
Normal file
60
src/Settings/NoSpamming.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using Milimoe.OneBot.Framework;
|
||||||
|
using Milimoe.OneBot.Model.Content;
|
||||||
|
using Milimoe.OneBot.Model.Other;
|
||||||
|
|
||||||
|
namespace Milimoe.RainBOT.Settings
|
||||||
|
{
|
||||||
|
public class NoSpamming(long groupId)
|
||||||
|
{
|
||||||
|
public static int Refresh { get; set; } = 0;
|
||||||
|
public static ConcurrentDictionary<long, NoSpamming> NoSpammingData { get; } = [];
|
||||||
|
|
||||||
|
public List<long> History { get; } = [];
|
||||||
|
public long GroupId { get; set; } = groupId;
|
||||||
|
public Dictionary<long, int> Times { get; } = [];
|
||||||
|
|
||||||
|
public static void Init(IEnumerable<Group> groups)
|
||||||
|
{
|
||||||
|
foreach (Group group in groups)
|
||||||
|
{
|
||||||
|
if (!GeneralSettings.OSMCoreGroup.Contains(group.group_id))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NoSpammingData.TryAdd(group.group_id, new(group.group_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Check(long qq)
|
||||||
|
{
|
||||||
|
if (!Bot.BotIsAdmin(GroupId))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
History.Add(qq);
|
||||||
|
if (Times.TryGetValue(qq, out int times))
|
||||||
|
{
|
||||||
|
Times[qq] = ++times;
|
||||||
|
int total = Times.Values.Sum();
|
||||||
|
double check = total > 8 ? times / total : 0;
|
||||||
|
if (qq != GeneralSettings.Master && (check > 0.9 || (History.Count > 8 && History.TakeLast(8).All(q => q == qq))))
|
||||||
|
{
|
||||||
|
Times.Remove(qq);
|
||||||
|
await Bot.SendMessage(SupportedAPI.set_group_ban, GroupId, "禁言", new SetGroupBanContent(GroupId, qq, 120), true);
|
||||||
|
await OshimaController.Instance.SCAdd(qq, GroupId, "刷屏惩罚", -5);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Times[qq] = 1;
|
||||||
|
}
|
||||||
|
if (History.Count > 200)
|
||||||
|
{
|
||||||
|
History.Clear();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user