Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Nov 3, 2023
1 parent cab3601 commit 4831fbd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
3 changes: 1 addition & 2 deletions ASFEnhance/ASFEnhance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ public Task OnASFInit(IReadOnlyDictionary<string, JToken>? additionalConfigPrope
/// <returns></returns>
public Task OnLoaded()
{
string pluginFolder = Path.GetDirectoryName(MyLocation) ?? ".";
foreach (var backupPath in Directory.GetFiles(pluginFolder, "*.autobak"))
foreach (var backupPath in Directory.GetFiles(MyDirectory, "*.autobak"))
{
try
{
Expand Down
3 changes: 1 addition & 2 deletions ASFEnhance/Other/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ internal static class Command
/// <returns></returns>
internal static string? ResponseDumpToFile(Bot bot, EAccess access, string command, ulong steamId)
{
var folderPath = Path.GetDirectoryName(MyLocation) ?? ".";
var filePath = Path.Combine(folderPath, $"ASFEDump_{DateTime.Now:yyyy-MM-dd}.txt");
var filePath = Path.Combine(MyDirectory, $"ASFEDump_{DateTime.Now:yyyy-MM-dd}.txt");

_ = Task.Run(async () =>
{
Expand Down
2 changes: 1 addition & 1 deletion ASFEnhance/Update/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ internal static async Task<string> DownloadRelease(string downloadUrl)
await using (ms.ConfigureAwait(false))
{
using var zipArchive = new ZipArchive(ms);
string pluginFolder = Path.GetDirectoryName(MyLocation) ?? ".";
string pluginFolder = MyDirectory;

foreach (var entry in zipArchive.Entries)
{
Expand Down
20 changes: 7 additions & 13 deletions ASFEnhance/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,14 @@ internal static class Utils
/// </summary>
internal static PluginConfig Config { get; set; } = new();

/// <summary>
/// 更新已就绪
/// </summary>
internal static bool UpdatePadding { get; set; }

/// <summary>
/// 更新标记
/// </summary>
/// <returns></returns>
private static string UpdateFlag => UpdatePadding ? "*" : "";

/// <summary>
/// 格式化返回文本
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
internal static string FormatStaticResponse(string message)
{
return $"<ASFE{UpdateFlag}> {message}";
return $"<ASFE> {message}";
}

/// <summary>
Expand All @@ -55,7 +44,7 @@ internal static string FormatStaticResponse(string message, params object?[] arg
/// <returns></returns>
internal static string FormatBotResponse(this Bot bot, string message)
{
return $"<{bot.BotName}{UpdateFlag}> {message}";
return $"<{bot.BotName}> {message}";
}

/// <summary>
Expand Down Expand Up @@ -203,6 +192,11 @@ internal static void BypassAgeCheck(this ArchiWebHandler webHandler)
/// </summary>
internal static string MyLocation => Assembly.GetExecutingAssembly().Location;

/// <summary>
/// 获取插件所在文件夹路径
/// </summary>
internal static string MyDirectory => Path.GetDirectoryName(MyLocation) ?? ".";

/// <summary>
/// Steam商店链接
/// </summary>
Expand Down

0 comments on commit 4831fbd

Please sign in to comment.