Some more sendkeys messages
This commit is contained in:
parent
d67b574969
commit
1c50451187
@ -2,9 +2,12 @@ General:
|
|||||||
log_file: 'D:\Poe\logs\Client.txt'
|
log_file: 'D:\Poe\logs\Client.txt'
|
||||||
log_level: 'DEBUG'
|
log_level: 'DEBUG'
|
||||||
Chat:
|
Chat:
|
||||||
|
# Define chat messages with the following placeholders:
|
||||||
|
# message, date, channel, user, guild, to_from, item, amount, currency, tab, row, col, league,
|
||||||
pickup: 'Your item {item} for {amount} {currency} is ready to pickup.'
|
pickup: 'Your item {item} for {amount} {currency} is ready to pickup.'
|
||||||
wait: 'I am currently busy. Please wait.'
|
wait: 'I am currently busy. Please wait.'
|
||||||
ty: 'Thank you and good luck.'
|
ty: 'Thank you and good luck.'
|
||||||
|
sold: 'Sorry, {item} is already sold'
|
||||||
Parser:
|
Parser:
|
||||||
re_log: '(?P<date>\d\d\d\d/\d\d/\d\d \d\d:\d\d:\d\d) (\d+) (\S+) \[(?P<level>\S+) (\S+) (\d+)\] (?P<channel>[#@%$&]?)(?P<ToFrom>To|From)?\s?(?P<guild><\S+>)? ?(?P<user>[^:]+): (?P<message>.*)'
|
re_log: '(?P<date>\d\d\d\d/\d\d/\d\d \d\d:\d\d:\d\d) (\d+) (\S+) \[(?P<level>\S+) (\S+) (\d+)\] (?P<channel>[#@%$&]?)(?P<ToFrom>To|From)?\s?(?P<guild><\S+>)? ?(?P<user>[^:]+): (?P<message>.*)'
|
||||||
re_trade: 'Hi, I would like to buy your (?P<item>.+) listed for (?P<amount>\d+) (?P<currency>\S+) in (?P<league>\S+) \(stash tab "(?P<tab>.+)"; position: left (?P<col>\d+), top (?P<row>\d+)\)'
|
re_trade: 'Hi, I would like to buy your (?P<item>.+) listed for (?P<amount>\d+) (?P<currency>\S+) in (?P<league>\S+) \(stash tab "(?P<tab>.+)"; position: left (?P<col>\d+), top (?P<row>\d+)\)'
|
||||||
|
@ -1,32 +1,54 @@
|
|||||||
|
|
||||||
from pywinauto.application import Application
|
from pywinauto.application import Application
|
||||||
|
from src import data
|
||||||
|
|
||||||
|
|
||||||
def send_text(text: str) -> None:
|
def send_text(text: str) -> None:
|
||||||
app = Application()
|
app = Application()
|
||||||
app.connect(title='Path of Exile')
|
app.connect(title='Path of Exile')
|
||||||
win = app.window_(title_re='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)
|
||||||
|
|
||||||
|
|
||||||
|
def escape_mods(text: str) -> str:
|
||||||
|
text = text.replace('%', '{%}')
|
||||||
|
text = text.replace('+', '{+}')
|
||||||
|
text = text.replace('^', '{^}')
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def send_to(user: str, text: str) -> None:
|
def send_to(user: str, text: str) -> None:
|
||||||
send_text(f'@{user} {text}')
|
send_text(f'@{user} {text}')
|
||||||
|
|
||||||
|
|
||||||
def invite(user: str) -> None:
|
def send_to_format(type: str, message: data.Message, conf: dict()) -> None:
|
||||||
send_text(f'/invite {user}')
|
"""[summary]
|
||||||
|
|
||||||
|
Args:
|
||||||
|
type (str): [description]
|
||||||
|
message (data.Message): [description]
|
||||||
|
conf (dict): [description]
|
||||||
|
"""
|
||||||
|
text = conf['Chat'][type].format(message=message.message,
|
||||||
|
date=message.date,
|
||||||
|
channel=message.channel.name,
|
||||||
|
user=message.user,
|
||||||
|
guild=message.guild,
|
||||||
|
to_from=message.to_from,
|
||||||
|
item=message.trade.item,
|
||||||
|
amount=message.trade.amount,
|
||||||
|
currency=message.trade.currency,
|
||||||
|
tab=message.trade.tab,
|
||||||
|
row=message.trade.row,
|
||||||
|
col=message.trade.col,
|
||||||
|
league=message.trade.league)
|
||||||
|
send_to(message.user, text)
|
||||||
|
|
||||||
|
|
||||||
def send_ty(user: str, conf: dict) -> None:
|
def invite(message: data.Message) -> None:
|
||||||
send_to(user, conf['Chat']['ty'])
|
send_text(f'/invite {message.user}')
|
||||||
|
|
||||||
|
|
||||||
def send_wait(user: str, conf: dict) -> None:
|
def trade(message: data.Message) -> None:
|
||||||
send_to(user, conf['Chat']['wait'])
|
send_text(f'/tradewith {message.user}')
|
||||||
|
|
||||||
|
|
||||||
def send_pickup(user: str, item: str, amount: int, currency: str, conf: dict) -> None:
|
|
||||||
text = conf['Chat']['pickup'].replace('{item}', item)
|
|
||||||
text = text.replace('{amount}', str(amount))
|
|
||||||
text = text.replace('{currency}', currency)
|
|
||||||
send_to(user, text)
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from src import sendkeys
|
from src import sendkeys
|
||||||
from src import config
|
from src import config
|
||||||
|
from src import data
|
||||||
|
|
||||||
|
|
||||||
def test_sendkeys():
|
def test_sendkeys():
|
||||||
@ -7,12 +8,16 @@ def test_sendkeys():
|
|||||||
|
|
||||||
|
|
||||||
def test_send_to():
|
def test_send_to():
|
||||||
sendkeys.send_to('Sinusal', 'Hi, how are you?')
|
sendkeys.send_to('Sinusal', 'Your item level 21 23% Vaal Impurity of Lightning for 18 chaos is ready to pickup.')
|
||||||
|
|
||||||
|
|
||||||
def test_pickup():
|
def test_pickup():
|
||||||
conf = config.read_config(r'config.yaml')
|
conf = config.read_config(r'config.yaml')
|
||||||
sendkeys.send_pickup('Sinusal', 'Watcher\'s Eye', 11, 'Exalts', conf)
|
data.compile_regex(conf)
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
def test_wait():
|
def test_wait():
|
||||||
@ -23,3 +28,12 @@ def test_wait():
|
|||||||
def test_ty():
|
def test_ty():
|
||||||
conf = config.read_config(r'config.yaml')
|
conf = config.read_config(r'config.yaml')
|
||||||
sendkeys.send_ty('Sinusal', conf)
|
sendkeys.send_ty('Sinusal', conf)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sold():
|
||||||
|
conf = config.read_config(r'config.yaml')
|
||||||
|
data.compile_regex(conf)
|
||||||
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user