Some more sendkeys messages
This commit is contained in:
@@ -1,32 +1,54 @@
|
||||
|
||||
from pywinauto.application import Application
|
||||
from src import data
|
||||
|
||||
|
||||
def send_text(text: str) -> None:
|
||||
app = Application()
|
||||
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)
|
||||
|
||||
|
||||
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:
|
||||
send_text(f'@{user} {text}')
|
||||
|
||||
|
||||
def invite(user: str) -> None:
|
||||
send_text(f'/invite {user}')
|
||||
def send_to_format(type: str, message: data.Message, conf: dict()) -> None:
|
||||
"""[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:
|
||||
send_to(user, conf['Chat']['ty'])
|
||||
def invite(message: data.Message) -> None:
|
||||
send_text(f'/invite {message.user}')
|
||||
|
||||
|
||||
def send_wait(user: str, conf: dict) -> None:
|
||||
send_to(user, conf['Chat']['wait'])
|
||||
|
||||
|
||||
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)
|
||||
def trade(message: data.Message) -> None:
|
||||
send_text(f'/tradewith {message.user}')
|
||||
|
||||
Reference in New Issue
Block a user