Skip to content

Commit

Permalink
fix bot cannot send adventures (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaghost authored Oct 26, 2022
1 parent 695e3ca commit 270f062
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions MainCore/MainCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<!--<Server>TRAVIAN_OFFICIAL</Server>-->
<!--<Server>TRAVIAN_OFFICIAL_HEROUI</Server>-->
<Server>TTWARS</Server>
<Server>TRAVIAN_OFFICIAL_HEROUI</Server>
<!--<Server>TTWARS</Server>-->

<DefineConstants Condition="'$(Server)' != ''">$(DefineConstants);$(Server)</DefineConstants>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions MainCore/Tasks/Update/UpdateAdventures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public override void Execute()
taskAutoSend.CopyFrom(this);
taskAutoSend.Execute();
taskUpdate.Execute();
NavigateHelper.Sleep(800, 1500);
NextExecute();
}
}
Expand All @@ -62,12 +63,14 @@ private void NextExecute()
#endif
if (tileDetails is null)
{
throw new Exception("Cannot find timer");
ExecuteAt = DateTime.Now.AddMinutes(Random.Shared.Next(5, 10));
return;
}
var timer = tileDetails.Descendants("span").FirstOrDefault(x => x.HasClass("timer"));
if (timer is null)
{
throw new Exception("Cannot find timer");
ExecuteAt = DateTime.Now.AddMinutes(Random.Shared.Next(5, 10));
return;
}

int sec = int.Parse(timer.GetAttributeValue("value", "0"));
Expand Down
2 changes: 2 additions & 0 deletions TravianOfficialNewHeroUICore/Parsers/HeroInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ public static (int, int) GetAdventureCoordinates(HtmlNode node)
if (tdList.Length < 2) return (0, 0);
var coords = tdList[1].InnerText.Split('|');
if (coords.Length < 2) return (0, 0);
coords[0] = coords[0].Replace('−', '-');
var valueX = new string(coords[0].Where(c => char.IsDigit(c) || c == '-').ToArray());
if (string.IsNullOrEmpty(valueX)) return (0, 0);
coords[1] = coords[1].Replace('−', '-');
var valueY = new string(coords[1].Where(c => char.IsDigit(c) || c == '-').ToArray());
if (string.IsNullOrEmpty(valueY)) return (0, 0);
return (int.Parse(valueX), int.Parse(valueY));
Expand Down

0 comments on commit 270f062

Please sign in to comment.