添加烂梗
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,6 +470,14 @@ 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);
|
||||
if (e.CheckThrow(30, out _) && OpenGetRequest.OpenGetRequestList.TryGetValue("烂梗", out string? url) && url?.Length > 0)
|
||||
{
|
||||
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)
|
||||
@ -524,6 +532,7 @@ namespace Milimoe.RainBOT.ListeningTask
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (content.message.Count > 0)
|
||||
{
|
||||
await Bot.SendGroupMessage(e.group_id, "随机反驳不", content);
|
||||
|
||||
@ -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