Skip to content

Commit 270f062

Browse files
authored
fix bot cannot send adventures (#189)
1 parent 695e3ca commit 270f062

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

MainCore/MainCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<!--<Server>TRAVIAN_OFFICIAL</Server>-->
6-
<!--<Server>TRAVIAN_OFFICIAL_HEROUI</Server>-->
7-
<Server>TTWARS</Server>
6+
<Server>TRAVIAN_OFFICIAL_HEROUI</Server>
7+
<!--<Server>TTWARS</Server>-->
88

99
<DefineConstants Condition="'$(Server)' != ''">$(DefineConstants);$(Server)</DefineConstants>
1010
</PropertyGroup>

MainCore/Tasks/Update/UpdateAdventures.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public override void Execute()
4040
taskAutoSend.CopyFrom(this);
4141
taskAutoSend.Execute();
4242
taskUpdate.Execute();
43+
NavigateHelper.Sleep(800, 1500);
4344
NextExecute();
4445
}
4546
}
@@ -62,12 +63,14 @@ private void NextExecute()
6263
#endif
6364
if (tileDetails is null)
6465
{
65-
throw new Exception("Cannot find timer");
66+
ExecuteAt = DateTime.Now.AddMinutes(Random.Shared.Next(5, 10));
67+
return;
6668
}
6769
var timer = tileDetails.Descendants("span").FirstOrDefault(x => x.HasClass("timer"));
6870
if (timer is null)
6971
{
70-
throw new Exception("Cannot find timer");
72+
ExecuteAt = DateTime.Now.AddMinutes(Random.Shared.Next(5, 10));
73+
return;
7174
}
7275

7376
int sec = int.Parse(timer.GetAttributeValue("value", "0"));

TravianOfficialNewHeroUICore/Parsers/HeroInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ public static (int, int) GetAdventureCoordinates(HtmlNode node)
127127
if (tdList.Length < 2) return (0, 0);
128128
var coords = tdList[1].InnerText.Split('|');
129129
if (coords.Length < 2) return (0, 0);
130+
coords[0] = coords[0].Replace('−', '-');
130131
var valueX = new string(coords[0].Where(c => char.IsDigit(c) || c == '-').ToArray());
131132
if (string.IsNullOrEmpty(valueX)) return (0, 0);
133+
coords[1] = coords[1].Replace('−', '-');
132134
var valueY = new string(coords[1].Where(c => char.IsDigit(c) || c == '-').ToArray());
133135
if (string.IsNullOrEmpty(valueY)) return (0, 0);
134136
return (int.Parse(valueX), int.Parse(valueY));

0 commit comments

Comments
 (0)