release
This commit is contained in:
parent
83a414c8ab
commit
4ba00e7a90
@ -101,6 +101,37 @@ namespace Milimoe.RainBOT.Command
|
||||
{
|
||||
TaskUtility.NewTask(async () => await Bot.Mute(user_id, target_id, command));
|
||||
}
|
||||
else if (command.Contains(".osm sayno"))
|
||||
{
|
||||
string str = command.Replace(".osm sayno", "").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 = (isadd && (GeneralSettings.Master == user_id || GeneralSettings.SayNoAccessGroup.Contains(user_id))) || (!isadd && GeneralSettings.Master == user_id);
|
||||
if (access)
|
||||
{
|
||||
if (SayNo.AddWord(part, isadd, value))
|
||||
{
|
||||
string msg = AddValue_SayNo(part, isadd, value);
|
||||
SendMessage(send_group, target_id, msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Access_Denied(send_group, target_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
SendMessage(send_group, target_id, Execute_Worker(".osm missingcommand", ""));
|
||||
}
|
||||
else if (command.Contains(".osm refresh"))
|
||||
{
|
||||
if (user_id == GeneralSettings.Master)
|
||||
@ -458,6 +489,20 @@ namespace Milimoe.RainBOT.Command
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "saynoaccessgroup":
|
||||
if (args.Length > 1 && long.TryParse(args[1].Replace("@", "").Trim(), out long saynoaccess_qq))
|
||||
{
|
||||
string args0 = args[0].ToString().Trim();
|
||||
if (args0 == "add" || args0 == "remove" || args0 == "+" || args0 == "-")
|
||||
{
|
||||
isadd = args0 == "add" || args0 == "+";
|
||||
if (isadd) GeneralSettings.SayNoAccessGroup.Add(saynoaccess_qq);
|
||||
else GeneralSettings.SayNoAccessGroup.Remove(saynoaccess_qq);
|
||||
msg = AddRemoveAccessGroupMember("词汇编写组成员", isadd, saynoaccess_qq);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "osmcoregroup":
|
||||
if (args.Length > 1 && long.TryParse(args[1].Trim(), out long osmcoregroup_id))
|
||||
{
|
||||
@ -504,5 +549,15 @@ namespace Milimoe.RainBOT.Command
|
||||
GeneralSettings.SaveConfig();
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static string AddValue_SayNo(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;
|
||||
SayNo.SaveConfig();
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,8 @@ namespace Milimoe.RainBOT.Settings
|
||||
|
||||
public static List<long> RecallAccessGroup { get; set; } = [];
|
||||
|
||||
public static List<long> SayNoAccessGroup { get; set; } = [];
|
||||
|
||||
public static List<long> OSMCoreGroup { get; set; } = [];
|
||||
|
||||
public static PluginConfig Configs { get; set; } = new("rainbot", "config");
|
||||
@ -140,6 +142,10 @@ namespace Milimoe.RainBOT.Settings
|
||||
{
|
||||
RecallAccessGroup = (List<long>)value;
|
||||
}
|
||||
if (configs.TryGetValue("SayNoAccessGroup", out value) && value != null)
|
||||
{
|
||||
SayNoAccessGroup = (List<long>)value;
|
||||
}
|
||||
if (configs.TryGetValue("OSMCoreGroup", out value) && value != null)
|
||||
{
|
||||
OSMCoreGroup = (List<long>)value;
|
||||
@ -168,6 +174,7 @@ namespace Milimoe.RainBOT.Settings
|
||||
Configs.Add("MuteAccessGroup", MuteAccessGroup);
|
||||
Configs.Add("UnMuteAccessGroup", UnMuteAccessGroup);
|
||||
Configs.Add("RecallAccessGroup", RecallAccessGroup);
|
||||
Configs.Add("SayNoAccessGroup", SayNoAccessGroup);
|
||||
Configs.Add("OSMCoreGroup", OSMCoreGroup);
|
||||
Configs.Save();
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
{
|
||||
public const string version = "v1.0";
|
||||
public const string version2 = "Patch4";
|
||||
public const string time = "May 12th, 2024";
|
||||
public const string time = "May 16th, 2024";
|
||||
|
||||
public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ namespace Milimoe.RainBOT.Settings
|
||||
|
||||
public static List<string> SaySpecialNoWords { get; set; } = [];
|
||||
|
||||
public static PluginConfig Configs { get; set; } = new("rainbot", "sayno");
|
||||
|
||||
public static void InitSayNo()
|
||||
{
|
||||
PluginConfig configs = new("rainbot", "sayno");
|
||||
@ -83,6 +85,92 @@ namespace Milimoe.RainBOT.Settings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveConfig()
|
||||
{
|
||||
Configs.Add("Trigger", Trigger);
|
||||
Configs.Add("TriggerBeforeNo", TriggerBeforeNo);
|
||||
Configs.Add("IgnoreTriggerAfterNo", IgnoreTriggerAfterNo);
|
||||
Configs.Add("IgnoreTriggerBeforeCan", IgnoreTriggerBeforeCan);
|
||||
Configs.Add("TriggerAfterYes", TriggerAfterYes);
|
||||
Configs.Add("WillNotSayNo", WillNotSayNo);
|
||||
Configs.Add("SayNoWords", SayNoWords);
|
||||
Configs.Add("SayDontHaveWords", SayDontHaveWords);
|
||||
Configs.Add("SayNotYesWords", SayNotYesWords);
|
||||
Configs.Add("SayDontWords", SayDontWords);
|
||||
Configs.Add("SayWantWords", SayWantWords);
|
||||
Configs.Add("SayThinkWords", SayThinkWords);
|
||||
Configs.Add("SaySpecialNoWords", SaySpecialNoWords);
|
||||
Configs.Save();
|
||||
}
|
||||
|
||||
public static bool AddWord(string part, bool isadd, string value)
|
||||
{
|
||||
HashSet<string> set = [];
|
||||
List<string> list = [];
|
||||
bool islist = false;
|
||||
switch (part.ToLower())
|
||||
{
|
||||
case "trigger":
|
||||
set = Trigger;
|
||||
break;
|
||||
case "triggerbeforeno":
|
||||
set = TriggerBeforeNo;
|
||||
break;
|
||||
case "ignoretriggerafterno":
|
||||
set = IgnoreTriggerAfterNo;
|
||||
break;
|
||||
case "ignoretriggerbeforecan":
|
||||
set = IgnoreTriggerBeforeCan;
|
||||
break;
|
||||
case "triggerafteryes":
|
||||
set = TriggerAfterYes;
|
||||
break;
|
||||
case "willnotsayno":
|
||||
set = WillNotSayNo;
|
||||
break;
|
||||
case "saynowords":
|
||||
islist = true;
|
||||
list = SayNoWords;
|
||||
break;
|
||||
case "saydonthavewords":
|
||||
islist = true;
|
||||
list = SayDontHaveWords;
|
||||
break;
|
||||
case "saynotyeswords":
|
||||
islist = true;
|
||||
list = SayNotYesWords;
|
||||
break;
|
||||
case "saydontwords":
|
||||
islist = true;
|
||||
list = SayDontWords;
|
||||
break;
|
||||
case "saywantwords":
|
||||
islist = true;
|
||||
list = SayWantWords;
|
||||
break;
|
||||
case "saythinkwords":
|
||||
islist = true;
|
||||
list = SayThinkWords;
|
||||
break;
|
||||
case "sayspecialnowords":
|
||||
islist = true;
|
||||
list = SaySpecialNoWords;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
if (isadd)
|
||||
{
|
||||
if (islist) list.Add(value);
|
||||
else set.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (islist) list.Remove(value);
|
||||
else set.Remove(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user