添加ignore的列表操作
This commit is contained in:
parent
ad1aceb96c
commit
5024755e17
@ -159,6 +159,46 @@ namespace Milimoe.RainBOT.Command
|
||||
SendMessage(send_group, target_id, msg);
|
||||
}
|
||||
}
|
||||
else if (command.Contains(".osm ignore"))
|
||||
{
|
||||
if (user_id == GeneralSettings.Master)
|
||||
{
|
||||
string str = command.Replace(".osm ignore", "").Trim();
|
||||
string[] strs = Regex.Split(str, @"\s+");
|
||||
if (strs.Length >= 3)
|
||||
{
|
||||
string part = strs[0].ToString().Trim();
|
||||
string addorremove = strs[1].ToString().Trim();
|
||||
string value = string.Join("", strs[2..]).Trim();
|
||||
if (addorremove == "add" || addorremove == "remove" || addorremove == "+" || addorremove == "-")
|
||||
{
|
||||
bool isadd = addorremove == "add" || addorremove == "+";
|
||||
bool access = GeneralSettings.Master == user_id;
|
||||
if (access)
|
||||
{
|
||||
if (Ignore.AddValue(part, isadd, value))
|
||||
{
|
||||
string msg = AddValue_Ignore(part, isadd, value);
|
||||
SendMessage(send_group, target_id, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Access_Denied(send_group, target_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Access_Denied(send_group, target_id);
|
||||
return;
|
||||
}
|
||||
SendMessage(send_group, target_id, Execute_Worker(".osm missingcommand", ""));
|
||||
return;
|
||||
}
|
||||
else if (command.Contains(".osm showlist"))
|
||||
{
|
||||
string str = command.Replace(".osm showlist", "").Trim();
|
||||
@ -170,6 +210,10 @@ namespace Milimoe.RainBOT.Command
|
||||
{
|
||||
GeneralSettings.ShowAccessGroupMemberList(target_id, part, send_group);
|
||||
}
|
||||
if (part.Contains("ignore"))
|
||||
{
|
||||
Ignore.ShowList(target_id, part, send_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
SayNo.ShowList(target_id, part, send_group);
|
||||
@ -603,5 +647,15 @@ namespace Milimoe.RainBOT.Command
|
||||
SayNo.SaveConfig();
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static string AddValue_Ignore(string part, bool isadd, string value, ConsoleColor color = ConsoleColor.Cyan)
|
||||
{
|
||||
string msg = "OSM Core:" + part + $"已{(isadd ? "添加" : "移除")}:" + value + "。";
|
||||
Console.ForegroundColor = color;
|
||||
Console.WriteLine(msg);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Ignore.SaveConfig();
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,14 @@ namespace Milimoe.RainBOT.Settings
|
||||
{
|
||||
public static HashSet<string> RepeatIgnore { get; set; } = [];
|
||||
|
||||
public static List<long> IgnoreQQGroup { get; set; } = [];
|
||||
public static List<string> CallBrotherQQIgnore { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 这个属性暂时没用到 标记一下
|
||||
/// </summary>
|
||||
public static List<long> QQGroupIgnore { get; set; } = [];
|
||||
|
||||
public static PluginConfig Configs { get; set; } = new("rainbot", "ignore");
|
||||
|
||||
public static void InitIgnore()
|
||||
{
|
||||
@ -16,10 +23,70 @@ namespace Milimoe.RainBOT.Settings
|
||||
{
|
||||
RepeatIgnore = new HashSet<string>((List<string>)value);
|
||||
}
|
||||
if (configs.TryGetValue("IgnoreQQGroup", out value) && value != null)
|
||||
if (configs.TryGetValue("CallBrotherQQIgnore", out value) && value != null)
|
||||
{
|
||||
IgnoreQQGroup = (List<long>)value;
|
||||
CallBrotherQQIgnore = new List<string>((List<string>)value);
|
||||
}
|
||||
if (configs.TryGetValue("QQGroupIgnore", out value) && value != null)
|
||||
{
|
||||
QQGroupIgnore = (List<long>)value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveConfig()
|
||||
{
|
||||
Configs.Add("RepeatIgnore", RepeatIgnore);
|
||||
Configs.Add("CallBrotherQQIgnore", CallBrotherQQIgnore);
|
||||
Configs.Add("QQGroupIgnore", QQGroupIgnore);
|
||||
Configs.Save();
|
||||
}
|
||||
|
||||
public static bool AddValue(string part, bool isadd, object value)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (part.ToLower())
|
||||
{
|
||||
case "repeatignore":
|
||||
if (isadd) RepeatIgnore.Add((string)value);
|
||||
else RepeatIgnore.Remove((string)value);
|
||||
break;
|
||||
case "callbrotherqqignore":
|
||||
if (isadd) CallBrotherQQIgnore.Add((string)value);
|
||||
else CallBrotherQQIgnore.Remove((string)value);
|
||||
break;
|
||||
case "qqgroupignore":
|
||||
if (isadd) QQGroupIgnore.Add((long)value);
|
||||
else QQGroupIgnore.Remove((long)value);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ShowList(long target, string group, bool isgroup)
|
||||
{
|
||||
List<string> list = [];
|
||||
switch (group.ToLower())
|
||||
{
|
||||
case "repeatignore":
|
||||
list = [..RepeatIgnore];
|
||||
break;
|
||||
case "callbrotherqqignore":
|
||||
list = CallBrotherQQIgnore;
|
||||
break;
|
||||
case "qqgroupignore":
|
||||
list = QQGroupIgnore.Select(x => x.ToString()).ToList();
|
||||
break;
|
||||
}
|
||||
string msg = list.Count > 0 ? "列表" + group + "拥有一下成员:" + "\r\n" + string.Join("\r\n", list) : "此列表不存在或没有任何成员。";
|
||||
_ = isgroup ? Bot.SendGroupMessage(target, "显示列表成员", msg) : Bot.SendFriendMessage(target, "显示列表成员", msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
public class OSMCore
|
||||
{
|
||||
public const string version = "v1.0";
|
||||
public const string version2 = "Patch7 Test";
|
||||
public const string time = "Jun. 30th, 2024";
|
||||
public const string version2 = "Patch7 Test2";
|
||||
public const string time = "July 1st, 2024";
|
||||
|
||||
public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user