diff --git a/ASFEnhance/ASFEnhance.cs b/ASFEnhance/ASFEnhance.cs
index b9c9ac9a..2a2c5695 100644
--- a/ASFEnhance/ASFEnhance.cs
+++ b/ASFEnhance/ASFEnhance.cs
@@ -260,7 +260,7 @@ public Task OnLoaded()
"PLUGINSUPDATE" or
"PLUGINUPDATE" or
"PU" when access >= EAccess.Master =>
- Update.Command.ResponsePluginUpdate(null),
+ Update.Command.ResponsePluginUpdate(bot, access, null),
//Event
"DL2" when access >= EAccess.Operator =>
@@ -353,6 +353,9 @@ public Task OnLoaded()
"PHONESUFFIX" when access >= EAccess.Operator =>
Account.Command.ResponseGetPhoneSuffix(bot),
+ "REGISTEDATE" when access >= EAccess.Operator =>
+ Account.Command.ResponseGetRegisteDate(bot),
+
//Cart
"CART" or
"C" when access >= EAccess.Operator =>
@@ -498,7 +501,7 @@ public Task OnLoaded()
"PLUGINSUPDATE" or
"PLUGINUPDATE" or
"PU" when access >= EAccess.Master =>
- Update.Command.ResponsePluginUpdate(Utilities.GetArgsAsText(args, 1, ",")),
+ Update.Command.ResponsePluginUpdate(bot, access, Utilities.GetArgsAsText(args, 1, ",")),
//Event
"DL2" when argLength > 2 && access >= EAccess.Operator =>
@@ -639,6 +642,9 @@ public Task OnLoaded()
"PHONESUFFIX" when access >= EAccess.Operator =>
Account.Command.ResponseGetPhoneSuffix(Utilities.GetArgsAsText(args, 1, ",")),
+ "REGISTEDATE" when access >= EAccess.Operator =>
+ Account.Command.ResponseGetRegisteDate(Utilities.GetArgsAsText(args, 1, ",")),
+
//Cart
"CART" or
"C" when access >= EAccess.Operator =>
diff --git a/ASFEnhance/Account/Command.cs b/ASFEnhance/Account/Command.cs
index 6a4d5118..3aebb349 100644
--- a/ASFEnhance/Account/Command.cs
+++ b/ASFEnhance/Account/Command.cs
@@ -1349,11 +1349,9 @@ private static string NotificationTargetToString(NotificationTarget target)
}
///
- /// 检查市场限制
+ /// 获取手机尾号
///
///
- ///
- ///
///
internal static async Task ResponseGetPhoneSuffix(Bot bot)
{
@@ -1367,11 +1365,9 @@ private static string NotificationTargetToString(NotificationTarget target)
}
///
- /// 检查市场限制 (多个Bot)
+ /// 获取手机尾号 (多个Bot)
///
///
- ///
- ///
///
///
internal static async Task ResponseGetPhoneSuffix(string botNames)
@@ -1393,4 +1389,46 @@ private static string NotificationTargetToString(NotificationTarget target)
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
}
+
+ ///
+ /// 获取注册时间
+ ///
+ ///
+ ///
+ internal static async Task ResponseGetRegisteDate(Bot bot)
+ {
+ if (!bot.IsConnectedAndLoggedOn)
+ {
+ return bot.FormatBotResponse(Strings.BotNotConnected);
+ }
+
+ var response = await WebRequest.GetRegisteDate(bot).ConfigureAwait(false);
+ return bot.FormatBotResponse(response ?? Langs.NetworkError);
+ }
+
+ ///
+ /// 获取注册时间 (多个Bot)
+ ///
+ ///
+ ///
+ ///
+ internal static async Task ResponseGetRegisteDate(string botNames)
+ {
+ if (string.IsNullOrEmpty(botNames))
+ {
+ throw new ArgumentNullException(nameof(botNames));
+ }
+
+ var bots = Bot.GetBots(botNames);
+
+ if (bots == null || bots.Count == 0)
+ {
+ return FormatStaticResponse(Strings.BotNotFound, botNames);
+ }
+
+ var results = await Utilities.InParallel(bots.Select(bot => ResponseGetRegisteDate(bot))).ConfigureAwait(false);
+ var responses = new List(results.Where(result => !string.IsNullOrEmpty(result)));
+
+ return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
+ }
}
diff --git a/ASFEnhance/Account/WebRequest.cs b/ASFEnhance/Account/WebRequest.cs
index a55eafbb..4f30333c 100644
--- a/ASFEnhance/Account/WebRequest.cs
+++ b/ASFEnhance/Account/WebRequest.cs
@@ -526,14 +526,13 @@ internal static async Task ToggleAppPrivacy(Bot bot, List appIds, bo
}
///
- /// 获取电话号码后缀
+ /// 获取注册时间
///
///
///
- internal static async Task GetBirthday(Bot bot)
+ internal static async Task GetRegisteDate(Bot bot)
{
- var path = await Utils.GetProfileLink(bot).ConfigureAwait(false);
- var request = new Uri(SteamStoreURL, $"/phone/manage?l={Langs.Language}");
+ var request = new Uri(SteamCommunityURL, $"/profiles/{bot.SteamID}/badges/1?l={Langs.Language}");
var response = await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(request).ConfigureAwait(false);
if (response?.Content == null)
@@ -541,6 +540,6 @@ internal static async Task ToggleAppPrivacy(Bot bot, List appIds, bo
return null;
}
- return response.Content.QuerySelector("div.phone_header_description>span")?.TextContent?.Trim();
+ return response.Content.QuerySelector("div.badge_description")?.TextContent?.Trim();
}
}
diff --git a/ASFEnhance/Update/Command.cs b/ASFEnhance/Update/Command.cs
index cd21c54f..a3dd73ca 100644
--- a/ASFEnhance/Update/Command.cs
+++ b/ASFEnhance/Update/Command.cs
@@ -1,6 +1,7 @@
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Plugins;
using ArchiSteamFarm.Plugins.Interfaces;
+using ArchiSteamFarm.Steam;
using ASFEnhance.Data;
using ASFEnhance.Data.Plugin;
using ASFEnhance.Explorer;
@@ -135,13 +136,16 @@ internal static class Command
///
/// 检查插件版本
///
+ ///
+ ///
///
///
- internal static async Task ResponsePluginUpdate(string? pluginNames = null)
+ internal static async Task ResponsePluginUpdate(Bot bot, EAccess access, string? pluginNames = null)
{
var entries = pluginNames?.ToUpperInvariant().Split(',', StringSplitOptions.RemoveEmptyEntries);
- var tasks = new List>();
+ const string channel = "stable";
+ List plugins = [];
if (entries?.Length > 0)
{
@@ -149,55 +153,33 @@ internal static class Command
{
if (entry == "ASFE" || entry == "ASFENHANCE")
{
- tasks.Add(WebRequest.UpdatePluginFile("ASFEnhance", MyVersion, "ASFEnhance"));
+ plugins.Add("ASFEnhance");
}
foreach (var (pluginId, subModule) in _Adapter_.ExtensionCore.SubModules)
{
if (pluginId == entry || subModule.MatchCmdPrefix(entry))
{
- tasks.Add(WebRequest.UpdatePluginFile(subModule.PluginName, subModule.PluginVersion, subModule.RepoName));
+ plugins.Add(subModule.PluginName);
}
}
-
}
}
else
{
- tasks.Add(WebRequest.UpdatePluginFile("ASFEnhance", MyVersion, "ASFEnhance"));
+ plugins.Add("ASFEnhance");
foreach (var subModule in _Adapter_.ExtensionCore.SubModules.Values)
{
- tasks.Add(WebRequest.UpdatePluginFile(subModule.PluginName, subModule.PluginVersion, subModule.RepoName));
+ plugins.Add(subModule.PluginName);
}
}
- if (tasks.Count == 0)
+ if (plugins.Count == 0)
{
return FormatStaticResponse(Langs.UpdateFailedPluginNotFound, pluginNames);
}
- var results = await Utilities.InParallel(tasks).ConfigureAwait(false);
-
- var sb = new StringBuilder();
- sb.AppendLine(FormatStaticResponse(Langs.UpdatePluginUpdateInfo));
-
- foreach (var info in results)
- {
- sb.AppendLine(Static.Line);
- sb.AppendLineFormat(Langs.UpdatePluginListItemName, info.PluginName, info.Tips);
- sb.AppendLineFormat(Langs.UpdatePluginListItemVersion, info.CurrentVersion, info.OnlineVersion?.ToString() ?? "-.-.-.-");
- sb.AppendLineFormat(Langs.UpdatePluginListItemStatus, info.UpdateLog);
-
- if (!string.IsNullOrEmpty(info.ReleaseNote))
- {
- sb.AppendLine(Langs.UpdatePluginListItemReleaseNote);
- sb.AppendLine(info.ReleaseNote);
- }
- }
-
- sb.AppendLine(Static.Line);
- sb.AppendLine(Langs.UpdatePluginListItemUpdateTips);
-
- return sb.ToString();
+ var cmd = string.Format("UPDATEPLUGINS {0} {1}", channel, string.Join(',', plugins));
+ return await bot.Commands.Response(access, cmd, 0).ConfigureAwait(false);
}
}
diff --git a/ASFEnhance/Update/WebRequest.cs b/ASFEnhance/Update/WebRequest.cs
index 2c6c1b27..591caa24 100644
--- a/ASFEnhance/Update/WebRequest.cs
+++ b/ASFEnhance/Update/WebRequest.cs
@@ -85,150 +85,4 @@ internal static async Task GetPluginReleaseNote(string plu
//如果没有找到当前语言的版本, 则下载第一个
return relesaeData.Assets.FirstOrDefault()?.DownloadURL;
}
-
- ///
- /// 自动更新插件
- ///
- ///
- ///
- ///
- ///
- internal static async Task UpdatePluginFile(string pluginName, Version pluginVersion, string? pluginRepo)
- {
- var response = new PluginUpdateResponse
- {
- PluginName = pluginName,
- CurrentVersion = pluginVersion,
- OnlineVersion = null,
- ReleaseNote = "",
- };
-
- if (string.IsNullOrEmpty(pluginRepo))
- {
- response.UpdateLog = Langs.PluginUpdateNotSupport;
- }
- else
- {
- if (!pluginRepo.Contains('/'))
- {
- pluginRepo = "chr233/" + pluginRepo;
- }
-
- var relesaeData = await GitHubService.GetLatestRelease(pluginRepo, true, default).ConfigureAwait(false);
- if (relesaeData == null)
- {
- response.UpdateLog = Langs.GetReleaseInfoFailedNetworkError;
- }
- else
- {
- response.ReleaseNote = relesaeData.MarkdownBody;
- response.OnlineVersion = Version.TryParse(relesaeData.Tag, out var version) ? version : null;
-
- if (!response.CanUpdate)
- {
- response.UpdateLog = response.IsLatest ? Langs.AlreadyLatest : Langs.VersionHigher;
- }
- else
- {
- var downloadUri = FetchDownloadUrl(relesaeData);
- if (downloadUri == null)
- {
- response.UpdateLog = Langs.NoAssetFoundInReleaseInfo;
- }
- else
- {
- var mirrorUrl = new Uri(downloadUri.AbsoluteUri.Replace("https://github.com/chr233", "https://dl.chrxw.com"));
- var binResponse = await DownloadRelease(mirrorUrl).ConfigureAwait(false) ?? await DownloadRelease(downloadUri).ConfigureAwait(false);
-
- if (binResponse == null)
- {
- response.UpdateLog = Langs.DownloadFailed;
- }
- else
- {
- response.UpdateLog = await UnzipRelease(binResponse).ConfigureAwait(false);
- }
- }
- }
- }
- }
-
- return response;
- }
-
- ///
- /// 下载发行版
- ///
- ///
- ///
- internal static Task DownloadRelease(Uri request)
- {
- return ASF.WebBrowser?.UrlGetToBinary(request) ?? Task.FromResult(null);
- }
-
- ///
- /// 下载发行版
- ///
- ///
- ///
- internal static async Task UnzipRelease(BinaryResponse binResponse)
- {
- var zipBytes = binResponse?.Content as byte[] ?? binResponse?.Content?.ToArray();
- if (zipBytes == null)
- {
- return Langs.DownloadPluginFailed;
- }
-
- var ms = new MemoryStream(zipBytes);
- try
- {
- await using (ms.ConfigureAwait(false))
- {
- using var zipArchive = new ZipArchive(ms);
- string pluginFolder = MyDirectory;
-
- var updateFolder = Path.Combine(pluginFolder, "_ASFEnhanceTemp_");
- if (Directory.Exists(updateFolder))
- {
- Directory.Delete(updateFolder, true);
- }
-
- zipArchive.ExtractToDirectory(updateFolder);
-
- foreach (var filePath in Directory.GetFiles(updateFolder, "*.dll"))
- {
- var pluginName = Path.GetFileName(filePath);
-
- var oldPluginPath = Path.Combine(pluginFolder, pluginName);
-
- if (File.Exists(oldPluginPath))
- {
- var originPath = Path.Combine(pluginFolder, pluginName);
- var backupPath = $"{oldPluginPath}.autobak";
-
- int i = 1;
- while (File.Exists(backupPath))
- {
- backupPath = $"{oldPluginPath}.{i++}.autobak";
-
- if (i >= 10)
- {
- return Langs.DownloadFailedFileConflict;
- }
- }
-
- File.Move(oldPluginPath, backupPath, true);
- File.Move(filePath, oldPluginPath, true);
- }
- }
-
- return Langs.DownloadPluginSuccess;
- }
- }
- catch (Exception ex)
- {
- ASFLogger.LogGenericException(ex);
- return Langs.DownloadPluginFailedUnzipError;
- }
- }
}
diff --git a/Directory.Build.props b/Directory.Build.props
index 9876e886..a0e95709 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,6 +1,6 @@
- 2.1.10.4
+ 2.1.11.0