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"
+5 -5
View File
@@ -231,7 +231,7 @@ class LootController:
f"{loot_item.get_item_str()}",
request.sender.char_id)
blob += f"{i:d}. {loot_item.get_item_str()}\n"
blob += f" | Winners: <red>{'<end>, <red>'.join(winners)}<end>\n\n"
blob += f" | Winners: <red>{'</red>, <red>'.join(winners)}</red>\n\n"
if loot_item.count == 0:
remove.append(i)
for i in remove:
@@ -310,7 +310,7 @@ class LootController:
item = self.items_controller.get_by_item_id(item_id)
if not item:
return f"Could not find item with ID <highlight>{item_id}<end>."
return f"Could not find item with ID <highlight>{item_id}</highlight>."
self.add_item_to_loot(item, item_count=item_count)
@@ -346,7 +346,7 @@ class LootController:
else:
loot += item
self.add_item_to_loot(item, item_count=item_count)
self.bot.send_private_channel_message(f"<highlight>{loot}<end> was added to loot list.")
self.bot.send_private_channel_message(f"<highlight>{loot}</highlight> was added to loot list.")
@timerevent(budatime="1h",
description="Periodically check when loot list was last modified, and clear it "
@@ -405,8 +405,8 @@ class LootController:
f"[ {self.text.make_tellcmd('REM', f'loot remitem {i}')} ]</yellow>\n\n"
else:
if len(bidders) > 0:
blob += f"<yellow>{', '.join(bidders)}<end>\n\n"
blob += f"<yellow>{', '.join(bidders)}</yellow>\n\n"
else:
blob += "<yellow>None added<end>\n\n"
blob += "<yellow>None added</yellow>\n\n"
return ChatBlob(f"Loot ({len(self.loot_list):d})", blob)
+12 -11
View File
@@ -42,7 +42,8 @@ class LootListsController:
"r&pu": "Rings and Preservation Units",
"symbs": "Symbiants",
"spirits": "Spirits",
"pgems": "Profession Gems",
"gem": "Profession Gems",
"gems": "Profession Gems",
"gen": "General",
"db1": "DB1",
"db2": "DB2",
@@ -143,7 +144,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "APF", category, add_all))
else:
return f"No loot registered for <highlight>{category}<end>."
return f"No loot registered for <highlight>{category}</highlight>."
@command(command="apf", params=[], description="Get list of items from APF", access_level="member")
def apf_tables_cmd(self, _):
@@ -167,7 +168,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "Albtraum", category))
else:
return f"No loot registered for <highlight>{category}<end>."
return f"No loot registered for <highlight>{category}</highlight>."
# #
# Pandemonium #
@@ -185,7 +186,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "Pande", category))
else:
return f"No loot registered for <highlight>{category_name}<end>."
return f"No loot registered for <highlight>{category_name}</highlight>."
@command(command="pande", params=[], description="Get list of items from Pandemonium", access_level="member")
def pande_tables_cmd(self, _):
@@ -202,7 +203,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "DustBrigade", category))
else:
return f"No loot registered for <highlight>{category}<end>."
return f"No loot registered for <highlight>{category}</highlight>."
@command(command="db", params=[], description="Get list of items from DustBrigade", access_level="member")
def db_tables_cmd(self, _):
@@ -255,7 +256,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "poh", category))
else:
return f"No loot registered for <highlight>{category_name}<end>."
return f"No loot registered for <highlight>{category_name}</highlight>."
@command(command="poh", params=[], description="Get list of items from Pyramid of Home", access_level="member")
def poh_tables_cmd(self, _):
@@ -275,7 +276,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "totwh", category))
else:
return f"No loot registered for <highlight>{category_name}<end>."
return f"No loot registered for <highlight>{category_name}</highlight>."
@command(command="totwh", params=[], description="Get list of items from Temple of Three Winds", access_level="member")
def totwh_tables_cmd(self, _):
@@ -294,7 +295,7 @@ class LootListsController:
if items:
return ChatBlob(f"{category} loot table", self.build_list(items, "subh", category))
else:
return f"No loot registered for <highlight>{category_name}<end>."
return f"No loot registered for <highlight>{category_name}</highlight>."
@command(command="subh", params=[], description="Get list of items from Condemned Subway (HL)",
access_level="member")
@@ -313,7 +314,7 @@ class LootListsController:
sql = "SELECT COUNT(*) AS count FROM raid_loot WHERE category = ? and raid=?"
count = self.db.query_single(sql, [raid.category, name]).count
blob += f"<highlight>{raid.category}<end> - {count} items\n"
blob += f"<highlight>{raid.category}</highlight> - {count} items\n"
blob += f" └ [{show_loot}]\n\n"
blob += "<pagebreak>"
if not name and not cmd:
@@ -336,7 +337,7 @@ class LootListsController:
title = raid[0][1] if isinstance(raid[0], tuple) else raid[0]
cmd = raid[1]
show_loot = self.text.make_chatcmd("Loot table", f"/tell <myname> {cmd}")
blob += f"<highlight>{title}<end>\n"
blob += f"<highlight>{title}</highlight>\n"
blob += f" └ [{show_loot}]\n\n"
blob += "<pagebreak>"
return blob
@@ -352,7 +353,7 @@ class LootListsController:
if add_all:
blob += f"{self.text.make_chatcmd('Add all', f'/tell <myname> loot addraid {raid} {category}')} items to loot list\n\n"
blob += f"<header2>{category}<end>\n" if category is not None else ""
blob += f"<header2>{category}</header2>\n" if category is not None else ""
for item in items:
comment = f" ({item.comment})" if item.comment != "" else ""