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
+6 -6
View File
@@ -41,19 +41,19 @@ class BotController(BaseModule):
def cmd_orgs_bots_add(self, request, _, _1, bot):
player = self.pork.request_char_info(bot.name, 5)
if self.db.exec("INSERT IGNORE INTO org_bots(char_id, org_id) VALUES(?, ?)", [bot.char_id, player.org_id]) == 0:
request.reply(f"The bot <highlight>{bot.name}<end> is already marked as a chatbot.")
request.reply(f"The bot <highlight>{bot.name}</highlight> is already marked as a chatbot.")
else:
self.db.exec("DELETE FROM online where char_id=?", [bot.char_id])
request.reply(f"Successfully marked <highlight>{bot.name}<end> as a chatbot.")
request.reply(f"Successfully marked <highlight>{bot.name}</highlight> as a chatbot.")
@command(command="orgs", params=[Const("bots"), Const("rem"), Character("botname")], access_level="admin",
description="Add an bot to the bot list", sub_command="bots_mng")
def cmd_orgs_bots_rem(self, request, _, _1, bot):
if self.db.exec("DELETE FROM org_bots WHERE char_id=?", [bot.char_id]) == 0:
request.reply(f"<highlight>{bot.name}<end> is not a chatbot.")
request.reply(f"<highlight>{bot.name}</highlight> is not a chatbot.")
else:
request.reply(f"Successfully removed <highlight>{bot.name}<end> as a chatbot. The character will show up in !online again after its next login.")
request.reply(f"Successfully removed <highlight>{bot.name}</highlight> as a chatbot. The character will show up in !online again after its next login.")
@command(command="orgs",
params=[Const("bots")],
@@ -63,8 +63,8 @@ class BotController(BaseModule):
def cmd_orgs_bots_show(self, _, _1):
def format_row(query):
bud = self.buddy_service.is_online(query["char_id"])
buddy = "<green>O<end>" if bud == 1 else "<red>O<end>" if bud == 0 else "<grey>U<end>"
return "- [{status}] <highlight>{name}<end> (<notice>{org_name}<end>)\n".format(**query, status=buddy)
buddy = "<green>O</green>" if bud == 1 else "<red>O</red>" if bud == 0 else "<grey>U</grey>"
return "- [{status}] <highlight>{name}</highlight> (<notice>{org_name}</notice>)\n".format(**query, status=buddy)
data = self.db.query("SELECT * FROM org_bots o LEFT JOIN player p on o.char_id = p.char_id order by p.org_name")
blob = ""
@@ -64,19 +64,19 @@ class OrgAliasController:
orgs = orgs[0]
if self.db.exec("REPLACE INTO org_alias(org_id, org_alias) VALUES (?, ?)", [orgs.org_id, alias]):
self.prefix_cache[orgs.org_id] = alias
return f"Alias for <highlight>{orgs.org_name}<end> has been set to [<highlight>{alias}</highlight>]."
return f"Alias for <highlight>{orgs.org_name}</highlight> has been set to [<highlight>{alias}</highlight>]."
else:
return f"There's already an alias for <highlight>{orgs.org_name}<end>.. its [<highlight>{self.get_alias(orgs.org_id)}</highlight>]"
return f"There's already an alias for <highlight>{orgs.org_name}</highlight>.. its [<highlight>{self.get_alias(orgs.org_id)}</highlight>]"
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("Set Alias", f"/tell <myname> orgs alias set {alias} {org.org_id}")}]' \
f'[{self.text.make_chatcmd("More", f"/tell <myname> orgs 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)
@@ -89,17 +89,17 @@ class OrgAliasController:
orgs = orgs[0]
if self.db.exec("DELETE FROM org_alias where org_id=?", [orgs.org_id]) == 1:
self.prefix_cache.pop(orgs.org_id)
return f"Alias for <highlight>{orgs.org_name}<end> has been removed."
return f"Alias for <highlight>{orgs.org_name}</highlight> has been removed."
else:
return f"There's no alias for <highlight>{orgs.org_name}<end>.."
return f"There's no alias for <highlight>{orgs.org_name}</highlight>.."
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("Set Alias", f"/tell <myname> orgs alias rem {org.org_id}")}]' \
f'[{self.text.make_chatcmd("More", f"/tell <myname> orgs 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)
+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>] ",