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:
@@ -50,11 +50,11 @@ class PresetController:
|
||||
count = self.db.query_single("SELECT COUNT(*) AS count FROM points_presets WHERE name = ?", [name]).count
|
||||
|
||||
if count > 0:
|
||||
return "A preset already exists with the name <highlight>%s<end>." % name
|
||||
return f"A preset already exists with the name <highlight>{name}</highlight>."
|
||||
|
||||
sql = "INSERT INTO points_presets (name, points) VALUES (?,?)"
|
||||
if self.db.exec(sql, [name, points]) > 0:
|
||||
return f"A preset with the name <highlight>{name}<end> was added, worth <green>{points:d}<end> points."
|
||||
return f"A preset with the name <highlight>{name}</highlight> was added, worth <green>{points}</green> points."
|
||||
|
||||
return "Failed to insert new preset in DB."
|
||||
|
||||
@@ -62,9 +62,9 @@ class PresetController:
|
||||
description="Delete preset", sub_command="mod")
|
||||
def presets_rem_cmd(self, _1, _2, preset_id: int):
|
||||
if self.db.exec("DELETE FROM points_presets WHERE preset_id = ?", [preset_id]) > 0:
|
||||
return "Successfully removed preset with ID <highlight>%d<end>." % preset_id
|
||||
return f"Successfully removed preset with ID <highlight>{preset_id}</highlight>."
|
||||
|
||||
return "No preset with given ID <highlight>%d<end>." % preset_id
|
||||
return f"No preset with given ID <highlight>{preset_id}</highlight>."
|
||||
|
||||
@command(command="presets",
|
||||
params=[Const("alter"), Int("preset_id"), Int("new_points")],
|
||||
@@ -75,10 +75,10 @@ class PresetController:
|
||||
|
||||
if preset:
|
||||
if self.db.exec("UPDATE points_presets SET points = ? WHERE preset_id = ?", [new_points, preset_id]) > 0:
|
||||
return f"Successfully updated the preset, <highlight>{preset.name}<end>, " \
|
||||
f"to dish out <green>{new_points:d}<end> points instead of <red>{preset.points:d}<end>."
|
||||
return f"Successfully updated the preset, <highlight>{preset.name}</highlight>, " \
|
||||
f"to dish out <green>{new_points}</green> points instead of <red>{preset.points}</red>."
|
||||
|
||||
return "Failed to update preset with ID <highlight>%d<end>." % preset_id
|
||||
return f"Failed to update preset with ID <highlight>{preset_id}</highlight>."
|
||||
|
||||
@command(command="presets", params=[], access_level="admin",
|
||||
description="See list of points presets")
|
||||
@@ -94,11 +94,11 @@ class PresetController:
|
||||
|
||||
for preset in presets:
|
||||
add_points_link = self.text.make_chatcmd("Add pts", f"/tell <myname> raid addpts {preset.name}")
|
||||
delete_link = self.text.make_chatcmd("Delete", f"/tell <myname> presets rem {preset.preset_id:d}")
|
||||
blob += f"<highlight>{preset.name}<end> worth <green>{preset.points:d}<end> points " \
|
||||
f"[id: {preset.preset_id:d}]\n | [{add_points_link}] [{delete_link}]\n\n"
|
||||
delete_link = self.text.make_chatcmd("Delete", f"/tell <myname> presets rem {preset.preset_id}")
|
||||
blob += f"<highlight>{preset.name}</highlight> worth <green>{preset.points}</green> points " \
|
||||
f"[id: {preset.preset_id}]\n | [{add_points_link}] [{delete_link}]\n\n"
|
||||
|
||||
return blob
|
||||
|
||||
return "No presets available. " \
|
||||
"To add new presets use <highlight><symbol>presets add preset_name preset_points<end>."
|
||||
"To add new presets use <highlight><symbol>presets add preset_name preset_points</highlight>."
|
||||
|
||||
@@ -92,27 +92,27 @@ class RaidbotController(BaseModule):
|
||||
t = int(time.time())
|
||||
|
||||
blob = ""
|
||||
blob += f"Name: <highlight>{self.raid.desc}<end>\n"
|
||||
blob += f"Name: <highlight>{self.raid.desc}</highlight>\n"
|
||||
blob += f"Minimum Level: <highlight>{self.raid.level}</highlight>\n"
|
||||
blob += f"Started By: <highlight>{self.raid.started_by.name}<end>\n"
|
||||
blob += f"Started By: <highlight>{self.raid.started_by.name}</highlight>\n"
|
||||
blob += f"Raidleader: " \
|
||||
f"<highlight>" \
|
||||
f"{self.leader.leader.name if self.leader.leader else '<red>not set - use !leader set<end>'}" \
|
||||
f"<end>\n"
|
||||
blob += f"Started At: <highlight>{self.util.format_datetime(self.raid.started_at)}<end> " \
|
||||
f"{self.leader.leader.name if self.leader.leader else '<red>not set - use !leader set</red>'}" \
|
||||
f"</highlight>\n"
|
||||
blob += f"Started At: <highlight>{self.util.format_datetime(self.raid.started_at)}</highlight> " \
|
||||
f"({self.util.time_to_readable(t - self.raid.started_at)} ago)\n"
|
||||
if self.raid.is_open:
|
||||
blob += f"Status: <green>Open<end> [{self.text.make_chatcmd('Join', '/tell <myname> raid join')}] " \
|
||||
f"<red>[{self.text.make_chatcmd('Lock', '/tell <myname> raid lock')}]<end>"
|
||||
blob += f"Status: <green>Open</green> [{self.text.make_chatcmd('Join', '/tell <myname> raid join')}] " \
|
||||
f"<red>[{self.text.make_chatcmd('Lock', '/tell <myname> raid lock')}]</red>"
|
||||
else:
|
||||
blob += f"Status: <red>Closed<end> " \
|
||||
f"<green>[{self.text.make_chatcmd('Unlock', '/tell <myname> raid open')}]<end>"
|
||||
blob += f"Status: <red>Closed</red> " \
|
||||
f"<green>[{self.text.make_chatcmd('Unlock', '/tell <myname> raid open')}]</green>"
|
||||
blob += "\n\n"
|
||||
|
||||
if self.raid.raid_orders:
|
||||
blob += "<header2>Orders<end>\n"
|
||||
blob += "<header2>Orders</header2>\n"
|
||||
blob += self.raid.raid_orders + "\n\n"
|
||||
blob += "<header2>Raiders<end>\n"
|
||||
blob += "<header2>Raiders</header2>\n"
|
||||
for raider in self.raid.raiders:
|
||||
if raider.is_active:
|
||||
blob += self.format_row(raider.get_active_char())
|
||||
@@ -132,7 +132,7 @@ class RaidbotController(BaseModule):
|
||||
description="Start new raid", access_level="leader", sub_command="manage")
|
||||
def raid_start_cmd(self, request: CommandRequest, _, raid_name: str):
|
||||
if self.raid:
|
||||
return "The <highlight>%s<end> raid is already running." % self.raid.raid_name
|
||||
return "The <highlight>%s</highlight> raid is already running." % self.raid.raid_name
|
||||
|
||||
self.raid = Raid(raid_name, request.sender)
|
||||
|
||||
@@ -141,11 +141,11 @@ class RaidbotController(BaseModule):
|
||||
join_link = self.get_raid_join_blob("Click here")
|
||||
|
||||
msg = "\n" \
|
||||
f"<highlight>────────[ Raid starting ]────────<end>\n" \
|
||||
f"Initiator: <highlight>{request.sender.name}<end>\n" \
|
||||
f"Raid Name: <highlight>{raid_name}<end>\n" \
|
||||
f"<highlight>────────[ Raid starting ]────────</highlight>\n" \
|
||||
f"Initiator: <highlight>{request.sender.name}</highlight>\n" \
|
||||
f"Raid Name: <highlight>{raid_name}</highlight>\n" \
|
||||
f"{join_link} to join\n" \
|
||||
f"<highlight>────────[ Raid starting ]────────<end>"
|
||||
f"<highlight>────────[ Raid starting ]────────</highlight>"
|
||||
self.leader.leader = None
|
||||
self.leader.set_raid_leader(request.sender, request.sender)
|
||||
# self.bot.send_org_message(msg)
|
||||
@@ -154,10 +154,10 @@ class RaidbotController(BaseModule):
|
||||
f"[<notice>STARTED</notice>] Raid with desc: <highlight>{raid_name}</highlight>",
|
||||
request.sender.char_id)
|
||||
if request.channel == "msg":
|
||||
return "You have been set as the <notice>active<end> Raidleader. " \
|
||||
"Set another Raidleader by using <notice>!leader set <name><end>"
|
||||
return "You have been set as the <notice>active</notice> Raidleader. " \
|
||||
"Set another Raidleader by using <notice>!leader set <name></notice>"
|
||||
else:
|
||||
return f"{request.sender.name} has been set as the <notice>active<end> Raidleader automatically."
|
||||
return f"{request.sender.name} has been set as the <notice>active</notice> Raidleader automatically."
|
||||
|
||||
@command(command="raid",
|
||||
params=[Const("desc"), Any("description")],
|
||||
@@ -198,7 +198,7 @@ class RaidbotController(BaseModule):
|
||||
if in_raid is not None:
|
||||
if in_raid.active_id == char.char_id:
|
||||
if in_raid.is_active:
|
||||
return f"The Character <highlight>{char.name}<end> is already participating in the Raid."
|
||||
return f"The Character <highlight>{char.name}</highlight> is already participating in the Raid."
|
||||
else:
|
||||
in_raid.is_active = True
|
||||
in_raid.was_kicked = None
|
||||
@@ -213,8 +213,8 @@ class RaidbotController(BaseModule):
|
||||
f"<highlight>{request.sender.name}</highlight>")
|
||||
elif in_raid.is_active:
|
||||
former_active_name = self.character_service.resolve_char_to_name(in_raid.active_id)
|
||||
return f"<highlight>{char.name}<end> is already participating in the raid with the char " \
|
||||
f"<highlight>{former_active_name}<end>"
|
||||
return f"<highlight>{char.name}</highlight> is already participating in the raid with the char " \
|
||||
f"<highlight>{former_active_name}</highlight>"
|
||||
else:
|
||||
alts = self.account_service.get_alts(char.char_id)
|
||||
self.raid.raiders.append(Raider(alts, char.char_id))
|
||||
@@ -284,7 +284,7 @@ class RaidbotController(BaseModule):
|
||||
request.sender.char_id)
|
||||
self.send_raid_msg("<green>JOIN</green>", f"<green>{request.sender.name}</green>")
|
||||
|
||||
# self.bot.send_private_channel_message("<highlight>%s<end> joined the raid." % request.sender.name)
|
||||
# self.bot.send_private_channel_message("<highlight>%s</highlight> joined the raid." % request.sender.name)
|
||||
else:
|
||||
return "Raid is closed."
|
||||
|
||||
@@ -302,7 +302,7 @@ class RaidbotController(BaseModule):
|
||||
f"[<notice>LEAVE</notice>] Raid: <highlight>{self.raid.raid_name}</highlight>",
|
||||
request.sender.char_id)
|
||||
self.send_raid_msg("<red>LEAVE</red>", f"<red>{request.sender.name}</red>")
|
||||
# self.bot.send_private_channel_message("<highlight>%s<end> left the raid." % request.sender.name)
|
||||
# self.bot.send_private_channel_message("<highlight>%s</highlight> left the raid." % request.sender.name)
|
||||
else:
|
||||
return "You are not in the raid."
|
||||
|
||||
@@ -357,7 +357,7 @@ class RaidbotController(BaseModule):
|
||||
warn_link = self.text.make_chatcmd("Warn",
|
||||
f"/tell <myname> cmd {raider_name} missed active check, "
|
||||
f"please give notice.")
|
||||
blob += "<highlight>%s<end> [%s] [%s]\n" % (raider_name, akick_link, warn_link)
|
||||
blob += f"<highlight>{raider_name}</highlight> [{akick_link}] [{warn_link}]\n"
|
||||
raider_names.append(raider_name)
|
||||
active_check_names = "/assist "
|
||||
active_check_names += "\\n /assist ".join(raider_names)
|
||||
@@ -377,7 +377,7 @@ class RaidbotController(BaseModule):
|
||||
|
||||
if in_raid is not None:
|
||||
if not in_raid.is_active:
|
||||
return "<highlight>%s<end> is not an active participant of the raid." % char.name
|
||||
return f"<highlight>{char.name}</highlight> is not an active participant of the raid."
|
||||
|
||||
in_raid.is_active = False
|
||||
in_raid.was_kicked = int(time.time())
|
||||
@@ -399,7 +399,7 @@ class RaidbotController(BaseModule):
|
||||
self.bot.get_char_id())
|
||||
self.send_raid_msg("KICKED", f"<highlight>{name}</highlight> for: <notice>{reason}</notice>")
|
||||
else:
|
||||
return "<highlight>%s<end> is not participating." % char.name
|
||||
return f"<highlight>{char.name}</highlight> is not participating."
|
||||
|
||||
@command(command="raid",
|
||||
params=[Options(["unlock", "open", "lock", "close"])],
|
||||
@@ -455,7 +455,7 @@ class RaidbotController(BaseModule):
|
||||
|
||||
self.raid = None
|
||||
self.leader.set_raid_leader(self.leader.leader, None)
|
||||
return "Raid has ended, logs got saved. <notice>Raidleader cleared.<end>"
|
||||
return "Raid has ended, logs got saved. <notice>Raidleader cleared.</notice>"
|
||||
|
||||
else:
|
||||
return "Failed to end raid. Try again."
|
||||
@@ -481,21 +481,21 @@ class RaidbotController(BaseModule):
|
||||
if not log_entry:
|
||||
return "No such log entry."
|
||||
|
||||
blob = f"Raid name: <highlight>{log_entry[0].raid_name}<end>\n"
|
||||
blob += f"Started by: <highlight>{self.character_service.resolve_char_to_name(log_entry[0].started_by)}<end>\n"
|
||||
blob += f"Start time: <highlight>{self.util.format_datetime(log_entry[0].raid_start)}<end>\n"
|
||||
blob += f"End time: <highlight>{self.util.format_datetime(log_entry[0].raid_end)}<end>\n"
|
||||
blob = f"Raid name: <highlight>{log_entry[0].raid_name}</highlight>\n"
|
||||
blob += f"Started by: <highlight>{self.character_service.resolve_char_to_name(log_entry[0].started_by)}</highlight>\n"
|
||||
blob += f"Start time: <highlight>{self.util.format_datetime(log_entry[0].raid_start)}</highlight>\n"
|
||||
blob += f"End time: <highlight>{self.util.format_datetime(log_entry[0].raid_end)}</highlight>\n"
|
||||
blob += f"Run time: " \
|
||||
f"<highlight>{self.util.time_to_readable(log_entry[0].raid_end - log_entry[0].raid_start)}<end>\n"
|
||||
blob += f"Total points: <highlight>{pts_sum}<end>\n\n"
|
||||
f"<highlight>{self.util.time_to_readable(log_entry[0].raid_end - log_entry[0].raid_start)}</highlight>\n"
|
||||
blob += f"Total points: <highlight>{pts_sum}</highlight>\n\n"
|
||||
|
||||
if char and log_entry_spec:
|
||||
raider_name = self.character_service.resolve_char_to_name(log_entry_spec.raider_id)
|
||||
main_info = self.account_service.get_main(log_entry_spec.raider_id)
|
||||
alt_link = f"Alt of {main_info.name}" if main_info.char_id != log_entry_spec.raider_id else "Alts"
|
||||
alt_link = self.text.make_chatcmd(alt_link, f"/tell <myname> alts {main_info.name}")
|
||||
blob += f"<header2>Log entry for {raider_name}<end>\n"
|
||||
blob += f"Raider: <highlight>{raider_name}<end> [{alt_link}]\n"
|
||||
blob += f"<header2>Log entry for {raider_name}</header2>\n"
|
||||
blob += f"Raider: <highlight>{raider_name}</highlight> [{alt_link}]\n"
|
||||
blob += "Left raid: %s\n" % ("n/a"
|
||||
if log_entry_spec.left_raid is None
|
||||
else self.util.format_datetime(log_entry_spec.left_raid))
|
||||
@@ -506,7 +506,7 @@ class RaidbotController(BaseModule):
|
||||
if log_entry_spec.was_kicked_reason is None
|
||||
else log_entry_spec.was_kicked_reason)
|
||||
|
||||
blob += "<header2>Participants<end>\n"
|
||||
blob += "<header2>Participants</header2>\n"
|
||||
for raider in log_entry:
|
||||
raider_name = self.character_service.resolve_char_to_name(raider.raider_id)
|
||||
main_info = self.account_service.get_main(raider.raider_id)
|
||||
@@ -534,8 +534,8 @@ class RaidbotController(BaseModule):
|
||||
participant_link = self.text.make_chatcmd("Log", "/tell <myname> raid logentry %d" % raid.raid_id)
|
||||
timestamp = self.util.format_datetime(raid.raid_start)
|
||||
leader_name = self.character_service.resolve_char_to_name(raid.started_by)
|
||||
blob += f"[{raid.raid_id:d}] [{timestamp}] <highlight>{raid.raid_name}<end> " \
|
||||
f"started by <highlight>{leader_name}<end> [{participant_link}]\n"
|
||||
blob += f"[{raid.raid_id:d}] [{timestamp}] <highlight>{raid.raid_name}</highlight> " \
|
||||
f"started by <highlight>{leader_name}</highlight> [{participant_link}]\n"
|
||||
|
||||
return ChatBlob("Raid history", blob)
|
||||
|
||||
@@ -551,21 +551,21 @@ class RaidbotController(BaseModule):
|
||||
self.bot.send_private_channel_message(f"[<notice>Raid: {msg_type}</notice>] {msg}")
|
||||
|
||||
def get_raid_join_blob(self, link_txt: str):
|
||||
blob = "<header2>1. Join the raid<end>\n" \
|
||||
"To join the current raid <highlight>%s<end>, send the following tell to <myname>\n" \
|
||||
blob = "<header2>1. Join the raid</header2>\n" \
|
||||
"To join the current raid <highlight>%s</highlight>, send the following tell to <myname>\n" \
|
||||
"<tab><tab><a href='chatcmd:///tell <myname> <symbol>raid join'>/tell <myname> raid join</a>\n" \
|
||||
"\n" \
|
||||
"<header2>2. Enable LFT<end>\n" \
|
||||
"<header2>2. Enable LFT</header2>\n" \
|
||||
"When you have joined the raid, go lft with \"<myname>\" as description\n" \
|
||||
"<tab><tab><a href='chatcmd:///lft <font color=#FFFF00>» <myname><end>'>/lft <myname></a>\n" \
|
||||
"<tab><tab><a href='chatcmd:///lft <font color=#FFFF00>» <myname></font>'>/lft <myname></a>\n" \
|
||||
"\n" \
|
||||
"<header2>3. Announce<end>\n" \
|
||||
"<header2>3. Announce</header2>\n" \
|
||||
"You could announce to the raid leader, that you have enabled LFT\n" \
|
||||
"<tab><tab><a href='chatcmd:///group <myname> I am on lft'>Announce</a> that you have enabled lft\n" \
|
||||
"\n" \
|
||||
"<header2>4. Rally with yer mateys<end>\n" \
|
||||
"<header2>4. Rally with yer mateys</header2>\n" \
|
||||
"Finally, move towards the starting location of the raid.\n" \
|
||||
"<highlight>Ask for help<end> if you're in doubt of where to go." % self.raid.raid_name
|
||||
"<highlight>Ask for help</highlight> if you're in doubt of where to go." % self.raid.raid_name
|
||||
|
||||
return self.text.paginate_single(ChatBlob(link_txt, blob))
|
||||
|
||||
@@ -573,15 +573,15 @@ class RaidbotController(BaseModule):
|
||||
def announce_raid(self, event_type, event_data):
|
||||
if self.raid:
|
||||
if self.raid.is_open:
|
||||
self.bot.send_private_channel_message(f"<highlight>Raid Running<end> "
|
||||
f"<yellow>::<end> <green>{self.raid.desc}<end> <yellow>::<end> %s" %
|
||||
self.bot.send_private_channel_message(f"<highlight>Raid Running</highlight> "
|
||||
f"<yellow>::</yellow> <green>{self.raid.desc}</green> <yellow>::</yellow> %s" %
|
||||
(
|
||||
f"<a href=\"text://{self.raid.raid_name}\">"
|
||||
f"{self.get_raid_join_blob('Click to Join')}"
|
||||
f"</a>"))
|
||||
else:
|
||||
self.bot.send_private_channel_message("<highlight>Raid Running<end> <yellow>::<end> <green>%s<end> "
|
||||
"<yellow>::<end> <red>Closed<end>" % self.raid.desc)
|
||||
self.bot.send_private_channel_message("<highlight>Raid Running</highlight> <yellow>::</yellow> <green>%s</green> "
|
||||
"<yellow>::</yellow> <red>Closed</red>" % self.raid.desc)
|
||||
|
||||
@timerevent(budatime="1m", description="No leader reminder")
|
||||
def leader_auto_remove(self, _1, _2):
|
||||
|
||||
Reference in New Issue
Block a user