添加烂梗
This commit is contained in:
parent
9d69981780
commit
0c90b77878
@ -239,6 +239,7 @@ namespace Milimoe.RainBOT.Command
|
||||
{
|
||||
GeneralSettings.LoadSetting();
|
||||
Music.InitMusicList();
|
||||
OpenGetRequest.InitOpenGetRequestList();
|
||||
Daily.InitDaily();
|
||||
SayNo.InitSayNo();
|
||||
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))
|
||||
{
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
// 获取关键词在其中的位置
|
||||
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 (e.CheckThrow(30, out _) && OpenGetRequest.OpenGetRequestList.TryGetValue("烂梗", out string? url) && url?.Length > 0)
|
||||
{
|
||||
// 通常,只反驳第一个词,除非无可反驳才会找下一个词
|
||||
int pos = where[keyword];
|
||||
if (keyword == "不")
|
||||
dynamic? result = await Bot.HttpGet<dynamic>(url);
|
||||
string barrage = result?.GetProperty("data").GetProperty("barrage").GetString() ?? "";
|
||||
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);
|
||||
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] == '有')
|
||||
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains))
|
||||
{
|
||||
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])));
|
||||
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
||||
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 && SayNo.TriggerAfterYes.Any(e.detail[(pos + 1)..].Contains))
|
||||
else if (keyword == "没")
|
||||
{
|
||||
Bot.ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
|
||||
content.message.Add(new TextMessage(SayNo.SayNotYesWords[new Random().Next(SayNo.SayNotYesWords.Count)]));
|
||||
break;
|
||||
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])));
|
||||
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 == "别")
|
||||
{
|
||||
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains) && !SayNo.WillNotSayNo.Any(e.detail[(pos + 1)..].Contains))
|
||||
else if (keyword == "是")
|
||||
{
|
||||
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;
|
||||
if (pos + 1 < e.detail.Length && SayNo.TriggerAfterYes.Any(e.detail[(pos + 1)..].Contains))
|
||||
{
|
||||
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("初始化音频/运势/词汇列表...");
|
||||
Music.InitMusicList();
|
||||
OpenGetRequest.InitOpenGetRequestList();
|
||||
Daily.InitDaily();
|
||||
SayNo.InitSayNo();
|
||||
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 int CurrentRetryTimes { get; set; } = -1;
|
||||
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)
|
||||
{
|
||||
@ -24,7 +24,7 @@ namespace Milimoe.RainBOT.Settings
|
||||
Console.WriteLine("正在连接服务器,请耐心等待。");
|
||||
return false;
|
||||
}
|
||||
string[] strings = ["oshima.fungame.fastauto"];
|
||||
string[] strings = ["milimoe.com.anonymous"];
|
||||
args.Add(strings);
|
||||
args.Add(false);
|
||||
if (!Config.FunGame_isConnected)
|
||||
@ -70,7 +70,7 @@ namespace Milimoe.RainBOT.Settings
|
||||
{
|
||||
string[] strings = GeneralSettings.FunGameServer.Split(':');
|
||||
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;
|
||||
if (result != ConnectResult.Success)
|
||||
{
|
||||
@ -97,7 +97,7 @@ namespace Milimoe.RainBOT.Settings
|
||||
{
|
||||
string[] strings = GeneralSettings.FunGameServer.Split(':');
|
||||
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("重连成功!");
|
||||
if (send)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user