escape ( and )

This commit is contained in:
Oliver Hartmann 2021-03-14 14:54:59 +01:00
parent 8c9cc4db88
commit 6f5cbcc23a
2 changed files with 30 additions and 13 deletions

View File

@ -16,6 +16,8 @@ def escape_mods(text: str) -> str:
text = text.replace('%', '{%}')
text = text.replace('+', '{+}')
text = text.replace('^', '{^}')
text = text.replace('(', '{(}')
text = text.replace(')', '{)}')
return text
@ -31,20 +33,27 @@ def send_to_format(type: str, message: data.Message) -> None:
message (data.Message): Message data. Placeholders in the message type will be replaced with this data.
conf (dict): Configution dictionary where the messages are stored.
"""
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)
if message.trade:
text = text.format(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)
text = config.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)
else:
text = config.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)
send_to(message.user, text)

View File

@ -45,3 +45,11 @@ def test_sold():
'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)
def test_ty_wo_trade():
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, how are you doing? '
message = data.Message.from_text(text)
sendkeys.send_to_format('ty', message)