Skip to content

Commit 1c1f9b6

Browse files
committed
0.23.2 sync
1 parent 79de6c6 commit 1c1f9b6

17 files changed

+262
-100
lines changed

AutoAFK.py

Lines changed: 125 additions & 55 deletions
Large diffs are not rendered by default.

activities.py

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ def collectMail():
8787
clickXY(960, 630, seconds=2) # Click Mail
8888
click('buttons/collect_all')
8989
clickXY(550, 1600) # Clear any popups
90-
clickXY(300, 1600) # Delete messages
91-
clickXY(700, 1260) # Confirm
90+
91+
if config.getboolean('DAILIES', 'deletemail'):
92+
clickXY(300, 1600) # Delete messages
93+
clickXY(700, 1260) # Confirm
94+
9295
click('buttons/back', region=boundaries['backMenu'])
9396
printGreen(' Mail collected!')
9497
# else:
@@ -99,7 +102,7 @@ def collectMail():
99102
def collectCompanionPoints(mercs=False):
100103
printBlue('Attempting to send/receive companion points')
101104
if isVisible('buttons/friends', region=boundaries['friends']):
102-
if (pixelCheck(1020, 688, 0) > 240): # We check if the pixel where the notification sits has a red value of higher than 240
105+
if (pixelCheck(1020, 688, 0) > 220): # We check if the pixel where the notification sits has a red value of higher than 220
103106
clickXY(960, 810)
104107
click('buttons/sendandreceive', region=boundaries['sendrecieve'])
105108
if mercs is True:
@@ -112,14 +115,14 @@ def collectCompanionPoints(mercs=False):
112115
click('buttons/back', region=boundaries['backMenu'])
113116
printGreen(' Friends Points Sent')
114117
else:
115-
printWarning(' Friends notification not found')
118+
printError(' Friends notification not found')
116119

117120
def collectFastRewards(count):
118121
printBlue('Attempting to collecting Fast Rewards ' + str(count) + 'x times')
119122
counter = 0
120123
confirmLocation('campaign', region=boundaries['campaignSelect'])
121124
if isVisible('buttons/fastrewards', region=boundaries['fastrewards']):
122-
if (pixelCheck(980, 1620, 0) > 220): # We check if the pixel where the notification sits has a red value of higher than 240
125+
if (pixelCheck(980, 1620, 0) > 220): # We check if the pixel where the notification sits has a red value of higher than 220
123126
clickXY(950, 1660)
124127
while counter < count:
125128
clickXY(710, 1260, seconds=3)
@@ -244,8 +247,8 @@ def handleArenaOfHeroes(count, opponent, app):
244247
confirmLocation('darkforest', region=boundaries['darkforestSelect'])
245248
clickXY(740, 1100)
246249
clickXY(550, 50)
247-
if isVisible('labels/arenaofheroes_new'): # The label font changes for reasons
248-
click('labels/arenaofheroes_new', suppress=True)
250+
if isVisible('labels/arenaofheroes'): # The label font changes for reasons
251+
click('labels/arenaofheroes', suppress=True)
249252
wait(1)
250253
click('buttons/challenge', retry=3, region=boundaries['challengeAoH']) # retries for animated button
251254
while counter < count:
@@ -277,7 +280,7 @@ def handleArenaOfHeroes(count, opponent, app):
277280
def collectGladiatorCoins():
278281
printBlue('Collecting Gladiator Coins')
279282
confirmLocation('darkforest', region=boundaries['darkforestSelect'])
280-
clickXY(740, 1050)
283+
clickXY(740, 1100)
281284
clickXY(550, 50)
282285
swipe(550, 800, 550, 500, duration=200, seconds=2) # scroll down
283286
if isVisible('labels/legendstournament_new'): # The label font changes for reasons
@@ -338,6 +341,7 @@ def collectTSRewards():
338341
click('buttons/back', retry=3, region=boundaries['backMenu'])
339342
click('buttons/back', retry=3, region=boundaries['backMenu'])
340343
printGreen(' Treasure Scramble daily loot collected!')
344+
recover(True)
341345
return
342346
else:
343347
printError(' Treasure Scramble not found, attempting to recover')
@@ -347,7 +351,7 @@ def collectFountainOfTime():
347351
printBlue('Collecting Fountain of Time')
348352
confirmLocation('darkforest', region=boundaries['darkforestSelect'])
349353
clickXY(850, 700, seconds=4)
350-
if isVisible('buttons/collect'):
354+
if isVisible('buttons/collect_wide'):
351355
clickXY(550, 1450)
352356
clickXY(290, 70)
353357

@@ -435,7 +439,7 @@ def pushTower(tower, formation=3, duration=1, app=None):
435439
wait(3)
436440
clickXY(550, 1750) # To clear the Limited Rewards pop up every 20 stages
437441
else: # If after clicking we don't get the Auto Battle notice pop up something has gone wrong so we recover() and load pushTower() again
438-
printWarning('AutoBattle screen not found, reloading auto-push..')
442+
printError('AutoBattle screen not found, reloading auto-push..')
439443
if recover() is True:
440444
towerPusher.towerOpen = False
441445
openTower(tower)
@@ -480,7 +484,7 @@ def configureBattleFormation(formation):
480484
if config.getboolean('ADVANCED', 'popularformations'): # Use popular formations tab
481485
clickXY(800, 1650, seconds=2) # Change to 'Popular' tab
482486
clickXY(850, 425 + (formation * 175), seconds=2)
483-
click('buttons/use', retry=3, region=boundaries['useAB'], seconds=2)
487+
click('buttons/use', retry=3, seconds=2)
484488

485489
# Configure Artifacts
486490
while artifacts is None and counter <= 5: # loop because sometimes isVisible returns None here
@@ -536,9 +540,8 @@ def collectInnGifts():
536540
continue
537541
checks += 1
538542
wait()
539-
click('buttons/back', region=boundaries['backMenu'])
540543
printGreen(' Inn Gifts collected.')
541-
wait(2) # wait before next task as loading ranhorn can be slow
544+
recover(1)
542545
else:
543546
printError(' Inn not found, attempting to recover')
544547
recover()
@@ -817,7 +820,7 @@ def handleTwistedRealm():
817820
printGreen(' Twisted Realm found, battling')
818821
if isVisible('buttons/challenge_tr', retry=3, confidence=0.8):
819822
clickXY(550, 1850, seconds=2)
820-
click('buttons/autobattle', retry=3, seconds=2)
823+
click('buttons/autobattle', retry=3, seconds=3)
821824
if isVisible('buttons/checkbox_blank'):
822825
clickXY(300, 975) # Activate Skip Battle Animations
823826
clickXY(700, 1300, seconds=6)
@@ -844,11 +847,21 @@ def handleTwistedRealm():
844847
def handleFightOfFates(battles=3):
845848
printBlue('Attempting to run Fight of Fates ' + str(battles) + ' times')
846849
counter = 0
847-
click('buttons/fightoffates', confidence=0.8, retry=5, seconds=3)
848-
if isVisible('labels/fightoffates'):
850+
click('buttons/events', confidence=0.8, retry=5, seconds=3)
851+
852+
if isVisible('labels/fightoffates', click=True):
853+
visible=True
854+
else:
855+
swipe(550, 600, 550, 300, duration=200, seconds=2)
856+
if isVisible('labels/fightoffates', click=True):
857+
visible=True
858+
else:
859+
visible=False
860+
861+
if visible:
849862
while counter < battles:
850863
click('buttons/challenge_tr', confidence=0.8, suppress=True, retry=3, seconds=15)
851-
while not isVisible('labels/fightoffates', confidence=0.95):
864+
while not isVisible('labels/fightoffates_inside', confidence=0.95):
852865
# Hero
853866
swipe(200, 1700, 290, 975, 200)
854867
# Skill 1
@@ -875,9 +888,10 @@ def handleFightOfFates(battles=3):
875888
# Back twice to exit
876889
clickXY(70, 1810, seconds=1)
877890
clickXY(70, 1810, seconds=1)
891+
clickXY(70, 1810, seconds=1)
878892
printGreen(' Fight of Fates attempted successfully')
879893
else:
880-
printWarning('Fight of Fates not found, recovering..')
894+
printError('Fight of Fates not found, recovering..')
881895
recover()
882896

883897
# Basic support for dailies quests, we simply choose the 5 cards from the top row of our hand
@@ -975,7 +989,7 @@ def handleBattleofBlood(battles=3):
975989
printWarning('Issue exiting Battle of Blood, recovering..')
976990
recover()
977991
else:
978-
printWarning('Battle of Blood not found, recovering..')
992+
printError('Battle of Blood not found, recovering..')
979993
recover()
980994

981995
def handleCircusTour(battles = 3):
@@ -1016,7 +1030,7 @@ def handleCircusTour(battles = 3):
10161030
printWarning('Issue exiting Circus Tour, recovering..')
10171031
recover()
10181032
else:
1019-
printWarning('Circus Tour not found, recovering..')
1033+
printError('Circus Tour not found, recovering..')
10201034
recover()
10211035

10221036
def handleLab():
@@ -1577,12 +1591,36 @@ def levelUp():
15771591
printBlue('Attempting to level up')
15781592
confirmLocation('ranhorn', region=boundaries['ranhornSelect'])
15791593
clickXY(700, 1500, seconds=2) # Resonating crystal
1580-
clickXY(520, 1860, seconds=2) # Level up
1581-
clickXY(710, 1260, seconds=2) # Confirm
1582-
if not isVisible("buttons/level_up"):
1583-
for _ in range(10):
1594+
1595+
if isVisible("buttons/level_up"):
1596+
clickXY(520, 1860, seconds=2) # Level up
1597+
clickXY(710, 1260, seconds=3) # Confirm
1598+
clickXY(700, 50, seconds=2) # Clear message
1599+
1600+
if isVisible("buttons/strengthen"):
1601+
while isVisible("buttons/strengthen", seconds=0.2):
15841602
clickXY(520, 1860)
1585-
printGreen('Leveled up successfully')
1603+
printGreen('Leveled up successfully')
15861604
else:
15871605
printWarning("Not enough dust to level up")
1588-
recover(True)
1606+
1607+
recover(True)
1608+
1609+
def getMercs():
1610+
if d.isoweekday() == 7: # Sunday
1611+
1612+
printBlue('Getting custom mercs')
1613+
confirmLocation('ranhorn', region=boundaries['ranhornSelect'])
1614+
1615+
clickXY(960, 810) # Friends
1616+
clickXY(725, 1760, seconds=2) # Short-Term
1617+
1618+
# Lan
1619+
clickXY(1000, 1600)
1620+
if isVisible("mercs/lan", click=True):
1621+
while isVisible("buttons/apply", click=True):
1622+
wait(1)
1623+
1624+
1625+
1626+
recover(True)

discord.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import requests
2+
from textwrap import dedent
3+
from AutoAFK import config
4+
5+
class Discord(object):
6+
7+
def __init__(self, channel_id: str, token: str):
8+
self.discord_api = f"https://discord.com/api/webhooks/{channel_id}/{token}"
9+
10+
def send(self, message: str) -> None:
11+
response = requests.post(
12+
url=self.discord_api,
13+
json={
14+
"content": dedent(message)
15+
}
16+
)
17+
18+
return {
19+
"status_code": response.status_code,
20+
"response": response.text
21+
}
22+
23+
if config.has_section('DISCORD') and config.getboolean('DISCORD', 'enable'):
24+
25+
# Initialize the Discord object
26+
discord = Discord(channel_id=config.get("DISCORD","channel_id"), token=config.get("DISCORD","token"))
27+
28+
# Custom print function that duplicates output to console and Discord
29+
def print_and_send_to_discord(*args, **kwargs):
30+
# Convert all arguments to strings and join them
31+
message = ' '.join(map(str, args))
32+
33+
# Print to console
34+
built_in_print(*args, **kwargs)
35+
36+
# Check if message is empty
37+
if message.strip():
38+
# List of prefixes to check
39+
prefixes = ['ERR', 'WAR', 'GRE', 'BLU', 'PUR']
40+
41+
# Check if the message starts with any of the prefixes
42+
if any(message.startswith(prefix) for prefix in prefixes):
43+
# Start from the fourth character
44+
processed_message = message[3:]
45+
# Send processed message to Discord
46+
response = discord.send(processed_message)
47+
else:
48+
# Send the original message to Discord
49+
response = discord.send(message)
50+
51+
# Save the built-in print function to avoid infinite recursion
52+
built_in_print = print
53+
54+
# Replace the built-in print function with our custom function
55+
print = print_and_send_to_discord

img/buttons/apply.png

12.4 KB
Loading

img/buttons/autobattle.png

-5.26 KB
Loading

img/buttons/collect_wide.png

22.3 KB
Loading

img/buttons/level_up.png

3.06 KB
Loading

img/buttons/strengthen.png

27 KB
Loading

img/buttons/use.png

-4.6 KB
Loading

img/labels/arenaofheroes.png

-13.2 KB
Loading

0 commit comments

Comments
 (0)