添加烂梗
This commit is contained in:
parent
9d69981780
commit
0c90b77878
@ -239,6 +239,7 @@ namespace Milimoe.RainBOT.Command
|
|||||||
{
|
{
|
||||||
GeneralSettings.LoadSetting();
|
GeneralSettings.LoadSetting();
|
||||||
Music.InitMusicList();
|
Music.InitMusicList();
|
||||||
|
OpenGetRequest.InitOpenGetRequestList();
|
||||||
Daily.InitDaily();
|
Daily.InitDaily();
|
||||||
SayNo.InitSayNo();
|
SayNo.InitSayNo();
|
||||||
Ignore.InitIgnore();
|
Ignore.InitIgnore();
|
||||||
|
|||||||
@ -470,57 +470,66 @@ namespace Milimoe.RainBOT.ListeningTask
|
|||||||
if (GeneralSettings.IsSayNo && SayNo.Trigger.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice))
|
if (GeneralSettings.IsSayNo && SayNo.Trigger.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice))
|
||||||
{
|
{
|
||||||
GroupMessageContent content = new(e.group_id);
|
GroupMessageContent content = new(e.group_id);
|
||||||
// 获取关键词在其中的位置
|
if (e.CheckThrow(30, out _) && OpenGetRequest.OpenGetRequestList.TryGetValue("烂梗", out string? url) && url?.Length > 0)
|
||||||
Dictionary<string, int> where = SayNo.Trigger
|
|
||||||
.ToDictionary(trigger => trigger, e.detail.IndexOf)
|
|
||||||
.Where(kvp => kvp.Value != -1)
|
|
||||||
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
|
||||||
foreach (string keyword in where.Keys)
|
|
||||||
{
|
{
|
||||||
// 通常,只反驳第一个词,除非无可反驳才会找下一个词
|
dynamic? result = await Bot.HttpGet<dynamic>(url);
|
||||||
int pos = where[keyword];
|
string barrage = result?.GetProperty("data").GetProperty("barrage").GetString() ?? "";
|
||||||
if (keyword == "不")
|
content.message.Add(new TextMessage(barrage));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 获取关键词在其中的位置
|
||||||
|
Dictionary<string, int> where = SayNo.Trigger
|
||||||
|
.ToDictionary(trigger => trigger, e.detail.IndexOf)
|
||||||
|
.Where(kvp => kvp.Value != -1)
|
||||||
|
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
foreach (string keyword in where.Keys)
|
||||||
{
|
{
|
||||||
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains))
|
// 通常,只反驳第一个词,除非无可反驳才会找下一个词
|
||||||
|
int pos = where[keyword];
|
||||||
|
if (keyword == "不")
|
||||||
{
|
{
|
||||||
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains))
|
||||||
content.message.Add(new TextMessage(string.Format(SayNo.SayNoWords[new Random().Next(SayNo.SayNoWords.Count)], e.detail[pos + 1])));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (keyword == "没")
|
|
||||||
{
|
|
||||||
if (pos + 1 < e.detail.Length)
|
|
||||||
{
|
|
||||||
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
|
||||||
if (e.detail[pos + 1] == '有')
|
|
||||||
{
|
{
|
||||||
content.message.Add(new TextMessage(string.Format(SayNo.SayDontHaveWords[new Random().Next(SayNo.SayDontHaveWords.Count - 3)], e.detail[pos + 1])));
|
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
||||||
break;
|
content.message.Add(new TextMessage(string.Format(SayNo.SayNoWords[new Random().Next(SayNo.SayNoWords.Count)], e.detail[pos + 1])));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
content.message.Add(new TextMessage(string.Format(SayNo.SayDontHaveWords[new Random().Next(SayNo.SayDontHaveWords.Count)], e.detail[pos + 1])));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (keyword == "没")
|
||||||
else if (keyword == "是")
|
|
||||||
{
|
|
||||||
if (pos + 1 < e.detail.Length && SayNo.TriggerAfterYes.Any(e.detail[(pos + 1)..].Contains))
|
|
||||||
{
|
{
|
||||||
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
if (pos + 1 < e.detail.Length)
|
||||||
content.message.Add(new TextMessage(SayNo.SayNotYesWords[new Random().Next(SayNo.SayNotYesWords.Count)]));
|
{
|
||||||
break;
|
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
||||||
|
if (e.detail[pos + 1] == '有')
|
||||||
|
{
|
||||||
|
content.message.Add(new TextMessage(string.Format(SayNo.SayDontHaveWords[new Random().Next(SayNo.SayDontHaveWords.Count - 3)], e.detail[pos + 1])));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
content.message.Add(new TextMessage(string.Format(SayNo.SayDontHaveWords[new Random().Next(SayNo.SayDontHaveWords.Count)], e.detail[pos + 1])));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (keyword == "是")
|
||||||
else if (keyword == "别")
|
|
||||||
{
|
|
||||||
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains) && !SayNo.WillNotSayNo.Any(e.detail[(pos + 1)..].Contains))
|
|
||||||
{
|
{
|
||||||
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
if (pos + 1 < e.detail.Length && SayNo.TriggerAfterYes.Any(e.detail[(pos + 1)..].Contains))
|
||||||
content.message.Add(new TextMessage(string.Format(SayNo.SayDontWords[new Random().Next(SayNo.SayDontWords.Count)], e.detail[pos + 1])));
|
{
|
||||||
break;
|
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
||||||
|
content.message.Add(new TextMessage(SayNo.SayNotYesWords[new Random().Next(SayNo.SayNotYesWords.Count)]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (keyword == "别")
|
||||||
|
{
|
||||||
|
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains) && !SayNo.WillNotSayNo.Any(e.detail[(pos + 1)..].Contains))
|
||||||
|
{
|
||||||
|
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
||||||
|
content.message.Add(new TextMessage(string.Format(SayNo.SayDontWords[new Random().Next(SayNo.SayDontWords.Count)], e.detail[pos + 1])));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,6 +106,7 @@ try
|
|||||||
|
|
||||||
Console.WriteLine("初始化音频/运势/词汇列表...");
|
Console.WriteLine("初始化音频/运势/词汇列表...");
|
||||||
Music.InitMusicList();
|
Music.InitMusicList();
|
||||||
|
OpenGetRequest.InitOpenGetRequestList();
|
||||||
Daily.InitDaily();
|
Daily.InitDaily();
|
||||||
SayNo.InitSayNo();
|
SayNo.InitSayNo();
|
||||||
Ignore.InitIgnore();
|
Ignore.InitIgnore();
|
||||||
|
|||||||
23
src/Settings/OpenGetRequest.cs
Normal file
23
src/Settings/OpenGetRequest.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using Milimoe.OneBot.Framework.Utility;
|
||||||
|
|
||||||
|
namespace Milimoe.RainBOT.Settings
|
||||||
|
{
|
||||||
|
public class OpenGetRequest
|
||||||
|
{
|
||||||
|
public static Dictionary<string, string> OpenGetRequestList { get; set; } = [];
|
||||||
|
|
||||||
|
public static void InitOpenGetRequestList()
|
||||||
|
{
|
||||||
|
PluginConfig configs = new("rainbot", "opengetrequestlist");
|
||||||
|
configs.Load();
|
||||||
|
foreach (string key in configs.Keys)
|
||||||
|
{
|
||||||
|
if (configs.TryGetValue(key, out object? value) && value != null && value.GetType() == typeof(string))
|
||||||
|
{
|
||||||
|
if (OpenGetRequestList.ContainsKey(key)) OpenGetRequestList[key] = (string)value;
|
||||||
|
else OpenGetRequestList.Add(key, (string)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -15,7 +15,7 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
public static FunGameConfig Config { get; set; } = new();
|
public static FunGameConfig Config { get; set; } = new();
|
||||||
public static int CurrentRetryTimes { get; set; } = -1;
|
public static int CurrentRetryTimes { get; set; } = -1;
|
||||||
public static int MaxRetryTimes => 30;
|
public static int MaxRetryTimes => 30;
|
||||||
public const string ServerName = "oshima.fungame.anonymous";
|
public const string ServerName = "milimoe.com.anonymous";
|
||||||
|
|
||||||
public override bool BeforeConnect(ref string addr, ref int port, ArrayList args)
|
public override bool BeforeConnect(ref string addr, ref int port, ArrayList args)
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
Console.WriteLine("正在连接服务器,请耐心等待。");
|
Console.WriteLine("正在连接服务器,请耐心等待。");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string[] strings = ["oshima.fungame.fastauto"];
|
string[] strings = ["milimoe.com.anonymous"];
|
||||||
args.Add(strings);
|
args.Add(strings);
|
||||||
args.Add(false);
|
args.Add(false);
|
||||||
if (!Config.FunGame_isConnected)
|
if (!Config.FunGame_isConnected)
|
||||||
@ -70,7 +70,7 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
{
|
{
|
||||||
string[] strings = GeneralSettings.FunGameServer.Split(':');
|
string[] strings = GeneralSettings.FunGameServer.Split(':');
|
||||||
int port = strings.Length > 1 ? int.Parse(strings[1]) : 443;
|
int port = strings.Length > 1 ? int.Parse(strings[1]) : 443;
|
||||||
result = await ConnectAsync(TransmittalType.WebSocket, strings[0], port, true, "ws");
|
result = await ConnectAsync(TransmittalType.WebSocket, strings[0], port, false, "ws");
|
||||||
Config.FunGame_isRetrying = false;
|
Config.FunGame_isRetrying = false;
|
||||||
if (result != ConnectResult.Success)
|
if (result != ConnectResult.Success)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace Milimoe.RainBOT.Settings
|
|||||||
{
|
{
|
||||||
string[] strings = GeneralSettings.FunGameServer.Split(':');
|
string[] strings = GeneralSettings.FunGameServer.Split(':');
|
||||||
int port = strings.Length > 1 ? int.Parse(strings[1]) : 443;
|
int port = strings.Length > 1 ? int.Parse(strings[1]) : 443;
|
||||||
if (await ConnectAsync(TransmittalType.WebSocket, strings[0], port, true, "ws") == ConnectResult.Success)
|
if (await ConnectAsync(TransmittalType.WebSocket, strings[0], port, false, "ws") == ConnectResult.Success)
|
||||||
{
|
{
|
||||||
Console.WriteLine("重连成功!");
|
Console.WriteLine("重连成功!");
|
||||||
if (send)
|
if (send)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user