Moved the coloring from <color>[text]<end> to <color>[test]</color>, which allows the discord module to reparse the messages more accurately

This commit is contained in:
2022-04-29 20:12:15 +02:00
parent fcea02e1c9
commit 3cade228fe
22 changed files with 177 additions and 421 deletions
@@ -76,7 +76,7 @@ class AuctionStrategy:
bid_link = self.get_auction_list()
bid_link = self.text.paginate_single(ChatBlob("Click to bid", bid_link.msg))
msg = self.format_auction(f"1. {item}\n"
f"Average winning bid: <highlight>{avg_win_bid}<end>\n"
f"Average winning bid: <highlight>{avg_win_bid}</highlight>\n"
f"» {bid_link}")
self.spam_raid_message(msg)
@@ -140,19 +140,19 @@ class AuctionStrategy:
if winning_bid.sender.char_id == sender.char_id:
return "You're already holding the highest bid."
if bid_amount <= winning_bid.current_amount:
return f"Your bid of <highlight>{bid_amount:d}<end> points was not enough. " \
f"<highlight>{winning_bid.sender.name}<end> is currently winning with a " \
f"bid of <highlight>{winning_bid.current_amount:d}<end>."
return f"Your bid of <highlight>{bid_amount:d}</highlight> points was not enough. " \
f"<highlight>{winning_bid.sender.name}</highlight> is currently winning with a " \
f"bid of <highlight>{winning_bid.current_amount:d}</highlight>."
elif bid_amount <= winning_bid.max_amount:
winning_bid.current_amount = bid_amount
return f"Your bid of <highlight>{bid_amount}<end> points was not enough. " \
f"<highlight>{winning_bid.sender.name}<end> is currently " \
f"winning with a bid of <highlight>{winning_bid.current_amount}<end>."
return f"Your bid of <highlight>{bid_amount}</highlight> points was not enough. " \
f"<highlight>{winning_bid.sender.name}</highlight> is currently " \
f"winning with a bid of <highlight>{winning_bid.current_amount}</highlight>."
else:
current_amount = winning_bid.max_amount
self.bot.send_private_message(winning_bid.sender.char_id,
f"Your bid on {item} has been "
f"overtaken by <highlight>{sender.name}<end>.")
f"overtaken by <highlight>{sender.name}</highlight>.")
# increment 1 past current max bid
current_amount += 1
@@ -160,16 +160,16 @@ class AuctionStrategy:
if self.auction_end_time - time.time() < 10:
self.auction_end_time += 10
self.spam_raid_message(
f"<highlight>{sender.name}<end> now holds the leading "
f"bid for {item} with a bid of <highlight>{current_amount:d}<end>. [AS: +10 seconds]")
f"<highlight>{sender.name}</highlight> now holds the leading "
f"bid for {item} with a bid of <highlight>{current_amount:d}</highlight>. [AS: +10 seconds]")
else:
self.spam_raid_message(
f"<highlight>{sender.name}<end> now holds the leading bid for {item} "
f"with a bid of <highlight>{current_amount:d}<end>.")
f"<highlight>{sender.name}</highlight> now holds the leading bid for {item} "
f"with a bid of <highlight>{current_amount:d}</highlight>.")
return f"Your max bid of <highlight>{bid_amount:d}<end> points for {item} has put you in the lead. " \
f"You have <highlight>{points_available - bid_amount:d}<end> points left for bidding."
return f"Your max bid of <highlight>{bid_amount:d}</highlight> points for {item} has put you in the lead. " \
f"You have <highlight>{points_available - bid_amount:d}</highlight> points left for bidding."
def end(self):
self.cancel_job()
@@ -190,7 +190,7 @@ class AuctionStrategy:
winning_bid.current_amount, 0])
items += f"{i}. <highlight>{item}</highlight> (<highlight>{winning_bid.sender.name} » " \
f"{winning_bid.current_amount}P</highlight>)\n"
blob += "%d. %s, won by <highlight>%s<end> with <green>%d<end> points\n" % (
blob += "%d. %s, won by <highlight>%s</highlight> with <green>%d</green> points\n" % (
i, item, winning_bid.sender.name, winning_bid.current_amount)
main_id = self.account_service.get_main(winning_bid.sender.char_id).char_id
self.account_service.rem_pts(main_id,
@@ -231,8 +231,8 @@ class AuctionStrategy:
blob += f"{i:d}. {img}{item}"
winning_bid = self.winning_bids.get(i, None)
if winning_bid:
blob += f"<br><tab><highlight>{winning_bid.sender.name}<end> has the " \
f"winning bid of <highlight>{winning_bid.current_amount:d}<end>\n["
blob += f"<br><tab><highlight>{winning_bid.sender.name}</highlight> has the " \
f"winning bid of <highlight>{winning_bid.current_amount:d}</highlight>\n["
blob += self.text.make_chatcmd("bid +1", f"/tell <myname> bid {winning_bid.current_amount + 1} {i}")
blob += "]<tab>["
blob += self.text.make_chatcmd("bid +10", f"/tell <myname> bid {winning_bid.current_amount + 10} {i}")
@@ -246,7 +246,7 @@ class AuctionStrategy:
blob += self.text.make_chatcmd("bid Max", f"/tell <myname> bid all {i}")
blob += "]\n────────────────────────────────\n"
else:
blob += "<br><tab><green>No bidders<end>\n["
blob += "<br><tab><green>No bidders</green>\n["
blob += self.text.make_chatcmd("bid 1", f"/tell <myname> bid 1 {i:d}")
blob += "]<tab>["
blob += self.text.make_chatcmd("bid 10", f"/tell <myname> bid 10 {i:d}")
@@ -296,8 +296,8 @@ class AuctionStrategy:
winning_bid = self.winning_bids.get(item_index, None)
if winning_bid:
winner = f"<highlight>{winning_bid.sender.name}<end> now holds the " \
f"leading bid with a bid of <highlight>{winning_bid.current_amount:d}<end>."
winner = f"<highlight>{winning_bid.sender.name}</highlight> now holds the " \
f"leading bid with a bid of <highlight>{winning_bid.current_amount:d}</highlight>."
else:
winner = "No bids made."
msg = self.format_auction(f"1. {item}\n"