-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (37 loc) · 1.42 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from lurker.capture import Capture
from lurker.game import GameWindow
from time import time, sleep
from lurker.nwconfig import NWUI
from lurker.processors import BuyOrdersProcessor
from PIL import Image
import requests
import os
game = GameWindow("New World")
capture = Capture(NWUI.orders_rect)
processor = BuyOrdersProcessor()
if __name__ == '__main__':
while 1:
sleep(5)
game.anti_afk()
timestamp = int(time())
os.makedirs(f'screens/{timestamp}')
resp = requests.get(url='http://192.168.1.90:3401/api/watchlist')
items = resp.json()
for item in items:
game.tp_search(item['search_query'], item['search_offset'])
sleep(2)
tp_image = Image.fromarray(capture.screenshot(), 'L')
tp_image.save(f'screens/{timestamp}/{item["name"]}.png')
try:
orders = processor.process(tp_image)
requests.post('http://192.168.1.90:3401/api/v2/prices', json={
"item": item['name'],
"orders": orders,
"timestamp": timestamp
})
except requests.exceptions.RequestException:
print(f"{timestamp} {item['name']}: ERROR: API request failed")
game.anti_afk()
sleep_duration = max(60, int(9 * 60 - (time() - timestamp)))
print(f'Sleep for {sleep_duration}sec')
sleep(sleep_duration)