添加sc控制台指令;优化刷屏检测
This commit is contained in:
parent
1a93a41690
commit
2d1ec44507
@ -367,6 +367,34 @@ namespace Milimoe.RainBOT.Command
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (command.Contains(".osm sc"))
|
||||||
|
{
|
||||||
|
if (send_group)
|
||||||
|
{
|
||||||
|
if (user_id == GeneralSettings.Master)
|
||||||
|
{
|
||||||
|
string pattern = @"^\.osm\s+sc\s+(\d+)\s+([+-])(\d+)(?:\s+(.+))?$";
|
||||||
|
Match match = Regex.Match(command.ToLower().Trim().Replace("@", ""), pattern);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
long qq = long.Parse(match.Groups[1].Value);
|
||||||
|
bool isAdd = match.Groups[2].Value == "+";
|
||||||
|
int sc = Math.Abs(int.Parse(match.Groups[3].Value));
|
||||||
|
string reason = match.Groups.Count > 4 ? match.Groups[4].Value : "";
|
||||||
|
_ = OshimaController.Instance.SCAdd(qq, target_id, reason, isAdd ? sc : -sc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendMessage(send_group, target_id, "OSM Core:指令格式不正确或传入的参数不支持。\r\n格式:.osm sc <qq> (+/-)<sc> [reason]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else Access_Denied(send_group, target_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendMessage(send_group, target_id, "OSM Core:此命令仅允许在群聊中使用。");
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendMessage(send_group, target_id, Execute_Worker(".osm missingcommand", ""));
|
SendMessage(send_group, target_id, Execute_Worker(".osm missingcommand", ""));
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace Milimoe.RainBOT.ListeningTask
|
|||||||
|
|
||||||
if (NoSpamming.NoSpammingData.TryGetValue(e.group_id, out NoSpamming? value) && value != null)
|
if (NoSpamming.NoSpammingData.TryGetValue(e.group_id, out NoSpamming? value) && value != null)
|
||||||
{
|
{
|
||||||
if (await value.Check(e.user_id))
|
if (await value.Check(e.user_id, e.message.Any(e => e.type == "image")))
|
||||||
{
|
{
|
||||||
await Bot.SendGroupMessage(e.group_id, "刷屏检测", "喜欢刷屏?吔屎啦你!");
|
await Bot.SendGroupMessage(e.group_id, "刷屏检测", "喜欢刷屏?吔屎啦你!");
|
||||||
return quick_reply;
|
return quick_reply;
|
||||||
|
|||||||
@ -217,11 +217,8 @@ try
|
|||||||
foreach (NoSpamming ns in NoSpamming.NoSpammingData.Values)
|
foreach (NoSpamming ns in NoSpamming.NoSpammingData.Values)
|
||||||
{
|
{
|
||||||
ns.Times.Clear();
|
ns.Times.Clear();
|
||||||
if (NoSpamming.Refresh++ > 4)
|
ns.History.Clear();
|
||||||
{
|
ns.HistoryImage.Clear();
|
||||||
ns.History.Clear();
|
|
||||||
NoSpamming.Refresh = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
public static ConcurrentDictionary<long, NoSpamming> NoSpammingData { get; } = [];
|
public static ConcurrentDictionary<long, NoSpamming> NoSpammingData { get; } = [];
|
||||||
|
|
||||||
public List<long> History { get; } = [];
|
public List<long> History { get; } = [];
|
||||||
|
public List<long> HistoryImage { get; } = [];
|
||||||
public long GroupId { get; set; } = groupId;
|
public long GroupId { get; set; } = groupId;
|
||||||
public Dictionary<long, int> Times { get; } = [];
|
public Dictionary<long, int> Times { get; } = [];
|
||||||
|
|
||||||
@ -26,19 +27,20 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> Check(long qq)
|
public async Task<bool> Check(long qq, bool isImage = false)
|
||||||
{
|
{
|
||||||
if (!Bot.BotIsAdmin(GroupId))
|
if (!Bot.BotIsAdmin(GroupId))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
History.Add(qq);
|
if (!isImage) History.Add(qq);
|
||||||
|
else HistoryImage.Add(qq);
|
||||||
if (Times.TryGetValue(qq, out int times))
|
if (Times.TryGetValue(qq, out int times))
|
||||||
{
|
{
|
||||||
Times[qq] = ++times;
|
Times[qq] = ++times;
|
||||||
int total = Times.Values.Sum();
|
int total = Times.Values.Sum();
|
||||||
double check = total > 8 ? times / total : 0;
|
double check = total > 12 ? times / total : 0;
|
||||||
if (qq != GeneralSettings.Master && (check > 0.9 || (History.Count > 8 && History.TakeLast(8).All(q => q == qq))))
|
if (qq != GeneralSettings.Master && (check > 0.9 || (History.Count > 15 && History.TakeLast(15).All(q => q == qq))) || (HistoryImage.Count > 8 && HistoryImage.TakeLast(8).All(q => q == qq)))
|
||||||
{
|
{
|
||||||
Times.Remove(qq);
|
Times.Remove(qq);
|
||||||
await Bot.SendMessage(SupportedAPI.set_group_ban, GroupId, "禁言", new SetGroupBanContent(GroupId, qq, 120), true);
|
await Bot.SendMessage(SupportedAPI.set_group_ban, GroupId, "禁言", new SetGroupBanContent(GroupId, qq, 120), true);
|
||||||
@ -54,6 +56,10 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
{
|
{
|
||||||
History.Clear();
|
History.Clear();
|
||||||
}
|
}
|
||||||
|
if (HistoryImage.Count > 200)
|
||||||
|
{
|
||||||
|
HistoryImage.Clear();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user