Global conf and key press wait config option

This commit is contained in:
Oliver Hartmann 2021-03-14 14:38:24 +01:00
parent 06468bb224
commit 8c9cc4db88
4 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,7 @@
General:
log_file: 'D:\Poe\logs\Client.txt'
log_level: 'DEBUG'
after_sendkeys_key_wait: 0.001 # Amount of seconds to wait after a keypress. Default is 0.01
Chat:
# Define chat messages with the following placeholders:
# message, date, channel, user, guild, to_from, item, amount, currency, tab, row, col, league,

View File

@ -1,6 +1,10 @@
import yaml
conf = None
def read_config(filename):
with open(filename, 'r') as f:
return yaml.safe_load(f)
global conf
conf = yaml.safe_load(f)
return conf

View File

@ -1,6 +1,7 @@
from pywinauto.application import Application
from src import data
from src import config
def send_text(text: str) -> None:
@ -8,7 +9,7 @@ def send_text(text: str) -> None:
app.connect(title='Path of Exile')
win = app.window_(title_re='Path of Exile')
text = escape_mods(text)
win.TypeKeys('{ENTER}^A{DELETE}' + text + '{ENTER}', with_spaces=True)
win.TypeKeys('{ENTER}^A{DELETE}' + text + '{ENTER}', with_spaces=True, pause=config.conf['General']['after_sendkeys_key_wait'])
def escape_mods(text: str) -> str:
@ -22,7 +23,7 @@ def send_to(user: str, text: str) -> None:
send_text(f'@{user} {text}')
def send_to_format(type: str, message: data.Message, conf: dict()) -> None:
def send_to_format(type: str, message: data.Message) -> None:
"""Send a message defined in the conf dict to a user
Args:

View File

@ -17,7 +17,7 @@ def test_pickup():
text = '2021/03/08 23:24:52 17931875 bb3 [INFO Client 1492] @From Sinusal: Hi, I would like to buy your level 21 23% Vaal Impurity of Lightning ' \
'listed for 18 chaos in Ritual (stash tab "$"; position: left 22, top 5)'
message = data.Message.from_text(text)
sendkeys.send_to_format('pickup', message, conf)
sendkeys.send_to_format('pickup', message)
def test_wait():
@ -26,7 +26,7 @@ def test_wait():
text = '2021/03/08 23:24:52 17931875 bb3 [INFO Client 1492] @From Sinusal: Hi, I would like to buy your level 21 23% Vaal Impurity of Lightning ' \
'listed for 18 chaos in Ritual (stash tab "$"; position: left 22, top 5)'
message = data.Message.from_text(text)
sendkeys.send_to_format('wait', message, conf)
sendkeys.send_to_format('wait', message)
def test_ty():
@ -35,7 +35,7 @@ def test_ty():
text = '2021/03/08 23:24:52 17931875 bb3 [INFO Client 1492] @From Sinusal: Hi, I would like to buy your level 21 23% Vaal Impurity of Lightning ' \
'listed for 18 chaos in Ritual (stash tab "$"; position: left 22, top 5)'
message = data.Message.from_text(text)
sendkeys.send_to_format('ty', message, conf)
sendkeys.send_to_format('ty', message)
def test_sold():
@ -44,4 +44,4 @@ def test_sold():
text = '2021/03/08 23:24:52 17931875 bb3 [INFO Client 1492] @From Sinusal: Hi, I would like to buy your level 21 23% Vaal Impurity of Lightning ' \
'listed for 18 chaos in Ritual (stash tab "$"; position: left 22, top 5)'
message = data.Message.from_text(text)
sendkeys.send_to_format('sold', message, conf)
sendkeys.send_to_format('sold', message)