|
|
@@ -1,9 +1,11 @@
|
|
|
|
|
|
+using COSXML.Network;
|
|
|
using dodohold.core;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.FileSystemGlobbing.Internal;
|
|
|
using Sayaka.Common;
|
|
|
using Spire.Pdf.Annotations;
|
|
|
+using System.Security.Cryptography;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Web;
|
|
|
using System.Xml.Linq;
|
|
|
@@ -218,11 +220,28 @@ namespace molilian.core
|
|
|
var match = regex.Match(content);
|
|
|
if (match.Success)
|
|
|
{
|
|
|
+
|
|
|
if (match.Groups.Count > 1)
|
|
|
{
|
|
|
for (var i = 1; i < match.Groups.Count; i++)
|
|
|
{
|
|
|
string val = match.Groups[i].Value;
|
|
|
+
|
|
|
+
|
|
|
+ switch (rule.plugin)
|
|
|
+ {
|
|
|
+ case "redu":
|
|
|
+ string deeplink_url = await PluginDyParseAsync(text, val, result);
|
|
|
+ if (!string.IsNullOrEmpty(deeplink_url))
|
|
|
+ {
|
|
|
+ result.itemName = prompt_text;
|
|
|
+ result.deeplink_url = deeplink_url;
|
|
|
+ result.success = true;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
if (deeplink.Contains("{url:"))
|
|
|
{
|
|
|
string encodedUrl = HttpUtility.UrlEncode(val);
|
|
|
@@ -336,6 +355,81 @@ namespace molilian.core
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static async Task<string> PluginDyParseAsync(string content, string matchText, DeeplinkParseDataDTO deeplinkResult, CancellationToken cancellationToken = default)
|
|
|
+ {
|
|
|
+ string ip = deeplinkResult.ip;
|
|
|
+ string oaid = deeplinkResult.oaid;
|
|
|
+
|
|
|
+ var result = DyUnionPlus.GetFormattedObject(content, ip, oaid);
|
|
|
+ result.create_time = deeplinkResult.create_time;
|
|
|
+
|
|
|
+
|
|
|
+ result.rawContent = content;
|
|
|
+ bool IfExceptional = false;
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ if (DyUnionPlus.ShouldIgnoreRequest(ip, oaid, out string reason))
|
|
|
+ {
|
|
|
+ result.success = false;
|
|
|
+ result.message = "放弃转链";
|
|
|
+ result.reason = reason;
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ var account = ReduPoolCore.GetOne();
|
|
|
+ if (account == null)
|
|
|
+ {
|
|
|
+ result.success = false;
|
|
|
+ result.message = "放弃转链";
|
|
|
+ result.reason = "没有匹配账号";
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ var now = DateTime.Now;
|
|
|
+ var ts2 = now - result.create_time;
|
|
|
+ result.elapsedTime2 = (int)ts2.TotalMilliseconds;
|
|
|
+ result = await DyUnionPlus.DyParseAsync(account, matchText, result, cancellationToken);
|
|
|
+ result.deeplink_url = result.deeplink_url.Replace("snssdk1128://", "snssdk561124://");
|
|
|
+
|
|
|
+ var ts3 = DateTime.Now - now;
|
|
|
+ result.elapsedTime3 = (int)ts3.TotalMilliseconds;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ if (ex.Message.Contains("was canceled"))
|
|
|
+ {
|
|
|
+ result.success = false;
|
|
|
+ result.message = "放弃转链";
|
|
|
+ result.reason = "请求超时";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IfExceptional = true;
|
|
|
+ _ = new LoggerLibrary("unionParse", "dy_error")
|
|
|
+ .Info(ip, oaid)
|
|
|
+ .Info(content)
|
|
|
+ .Info(ex.Message, ex.StackTrace)
|
|
|
+ .SaveAsync();
|
|
|
+ NotifyCore.Notify(new NifyMessage
|
|
|
+ {
|
|
|
+ message = $"【转链异常DY】\n{content}\n\n{ex.Message}\n{ex.StackTrace}",
|
|
|
+ priority = NifyMessagePriority.high,
|
|
|
+ tags = ["red_circle"]
|
|
|
+ });
|
|
|
+ result.success = false;
|
|
|
+ result.message = "内部错误";
|
|
|
+ result.reason = "转链接口异常";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var ts = DateTime.Now - result.create_time;
|
|
|
+ result.elapsedTime = (int)ts.TotalMilliseconds;
|
|
|
+ _ = TkLogCore.ParseLogAsync(result);
|
|
|
+ return result.deeplink_url;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|