Skip to content

Commit

Permalink
fix 修正赠礼机器人不在线时导致的溢出问题
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Sep 5, 2024
1 parent bffd4da commit d904944
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ASFEnhance/Cart/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ internal static class Command
var targetBot = Bot.GetBot(giftee);
if (targetBot != null)
{
if (!targetBot.IsConnectedAndLoggedOn)
{
return bot.FormatBotResponse(Strings.BotNotConnected, targetBot.BotName);
}

steamId32 = SteamId2Steam32(targetBot.SteamID);
}
else if (ulong.TryParse(giftee, out var steamId))
Expand Down
15 changes: 12 additions & 3 deletions ASFEnhance/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,25 @@ internal static StringBuilder AppendLineFormat(this StringBuilder sb, string for
/// </summary>
/// <param name="steamId"></param>
/// <returns></returns>
internal static ulong SteamId2Steam32(ulong steamId) => steamId - 0x110000100000000;
internal static ulong SteamId2Steam32(ulong steamId)
{
return IsSteam32ID(steamId) ? steamId : steamId - 0x110000100000000;
}

/// <summary>
/// 转换SteamId
/// </summary>
/// <param name="steamId"></param>
/// <returns></returns>
internal static ulong Steam322SteamId(ulong steamId) => steamId + 0x110000100000000;
internal static ulong Steam322SteamId(ulong steamId)
{
return IsSteam32ID(steamId) ? steamId + 0x110000100000000 : steamId;
}

internal static bool IsSteam32ID(ulong id) => id <= 0xFFFFFFFF;
internal static bool IsSteam32ID(ulong id)
{
return id <= 0xFFFFFFFF;
}

/// <summary>
/// 匹配Steam商店Id
Expand Down

0 comments on commit d904944

Please sign in to comment.