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
+14 -14
View File
@@ -77,22 +77,22 @@ class OrgController:
orgs = orgs[0]
if self.db.exec("REPLACE INTO orgs(org_id) VALUES(?)",
[orgs.org_id]) == 1:
sender.reply(f"Adding the organisation <highlight>{orgs.org_name}<end> to the roster...")
sender.reply(f"Adding the organisation <highlight>{orgs.org_name}</highlight> to the roster...")
org_adder = Thread(name=orgs.org_id, target=self.fetch_single,
args=(orgs.org_id, orgs.org_name, sender))
self.threads[orgs.org_id] = org_adder
org_adder.start()
else:
return f"The organisation <highlight>{orgs.org_name}<end> is in the roster already."
return f"The organisation <highlight>{orgs.org_name}</highlight> is in the roster already."
elif len(orgs) == 0:
return f"No org with the name <highlight>{search}<end> was found on PoRK."
return f"No org with the name <highlight>{search}</highlight> was found on PoRK."
else:
blob = "Your search had multiple results; please pick an org:<br>"
for org in orgs:
blob += f'[{self.text.make_chatcmd("Add", f"/tell <myname> orgs add {org.org_id}")}]' \
f'[{self.text.make_chatcmd("More", f"/tell <myname> org info {org.org_id}")}]' \
f' <highlight>{org.org_name}<end> (<highlight>{org.org_id}<end>) ' \
f'<{org.faction.lower()}>{org.faction}<end> [<highlight>{org.member_count}<end> members]' \
f' <highlight>{org.org_name}</highlight> (<highlight>{org.org_id}</highlight>) ' \
f'<{org.faction.lower()}>{org.faction}</{org.faction.lower()}> [<highlight>{org.member_count}</highlight> members]' \
f'<br><pagebreak>'
return ChatBlob("Pick an Org", blob)
@@ -110,34 +110,34 @@ class OrgController:
org_remover = Thread(name=orgs.org_id, target=self.remove_single, args=(orgs.org_id, orgs.org_name))
self.threads[orgs.org_id] = org_remover
org_remover.start()
return f"Removed the organisation <highlight>{orgs.org_name}<end> from the roster."
return f"Removed the organisation <highlight>{orgs.org_name}</highlight> from the roster."
else:
return f"The organisation <highlight>{orgs.org_name}<end> is not on the roster list."
return f"The organisation <highlight>{orgs.org_name}</highlight> is not on the roster list."
elif len(orgs) == 0:
return f"The organisation <highlight>{search}<end> is not on the roster list."
return f"The organisation <highlight>{search}</highlight> is not on the roster list."
else:
blob = "Your search had multiple results; please pick an org:<br>"
for org in orgs:
blob += f'[{self.text.make_chatcmd("Remove", f"/tell <myname> orgs remove {org.org_id}")}]' \
f'[{self.text.make_chatcmd("More", f"/tell <myname> org info {org.org_id}")}]' \
f' <highlight>{org.org_name}<end> (<highlight>{org.org_id}<end>) ' \
f'<{org.faction.lower()}>{org.faction}<end> [<highlight>{org.member_count}<end> members]' \
f' <highlight>{org.org_name}</highlight> (<highlight>{org.org_id}</highlight>) ' \
f'<{org.faction.lower()}>{org.faction}</{org.faction.lower()}> [<highlight>{org.member_count}</highlight> members]' \
f'<br><pagebreak>'
return ChatBlob("Pick an Org", blob)
@command(command="orgs", params=[Const("list", is_optional=True)], access_level="member",
description="View all orgs on the online list", sub_command="online_info")
def orgs_list(self, sender: CommandRequest, _):
head = "<header>Organisations registered as Members<end>"
head = "<header>Organisations registered as Members</header>"
blob = ""
for org in self.db.query("SELECT o.*, a.*, oa.org_alias from orgs o "
"left join all_orgs a on o.org_id = a.org_id "
"left join org_alias oa on o.org_id = oa.org_id order by a.org_name"):
org = DictObject(org)
blob += "- %s%s%s<highlight>%s<end> (%d) with <highlight>%d<end> members\n" % (
"[<highlight>" + self.text.make_chatcmd("Info", "/tell <myname> orgs info %d" % org.org_id,
blob += "- %s%s%s<highlight>%s</highlight> (%d) with <highlight>%d</highlight> members\n" % (
"[<highlight>" + self.text.make_chatcmd("Info", f"/tell <myname> orgs info {org.org_id}",
style="style='text-decoration:none'") + "</highlight>] ",
"[<red>" + self.text.make_chatcmd("Remove", "/tell <myname> orgs rem %d" % org.org_id,
"[<red>" + self.text.make_chatcmd("Remove", f"/tell <myname> orgs rem {org.org_id}",
style="style='text-decoration:none'") + "</red>] " if
sender.sender.access_level["level"] <= 10 else "",
f"[<highlight>{self.org_alias.get_alias(org.org_id)}</highlight>] ",