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:
@@ -85,11 +85,11 @@ class OrgBanController(BaseModule):
|
||||
elif len(orgs) > 1:
|
||||
blob = "Your search had multiple results; please pick an org:<br>"
|
||||
for org in orgs:
|
||||
blob += "[%s] <highlight>%s<end> (<highlight>%s<end>) <%s>%s<end> [<highlight>%s<end> " \
|
||||
blob += "[%s] <highlight>%s</highlight> (<highlight>%s</highlight>) <%s>%s</%s> [<highlight>%s</highlight> " \
|
||||
"members]<br><pagebreak>" \
|
||||
% (self.text.make_chatcmd("Unban", "/tell <myname> orgban remove %s" % org.org_id),
|
||||
# self.text.make_chatcmd("More", "/tell <myname> org info %s" % org.org_id),
|
||||
org.org_name, org.org_id, org.faction.lower(), org.faction, org.member_count)
|
||||
org.org_name, org.org_id, org.faction.lower(), org.faction, org.faction.lower(), org.member_count)
|
||||
return ChatBlob("Pick an Org", blob)
|
||||
|
||||
@command(command="orgban", params=[Const("add", is_optional=True), Int("Organisation"),
|
||||
@@ -119,10 +119,10 @@ class OrgBanController(BaseModule):
|
||||
elif len(orgs) > 1:
|
||||
blob = "Your search had multiple results; please pick an org:<br>"
|
||||
for org in orgs:
|
||||
blob += "[%s] <highlight>%s<end> (<highlight>%s<end>) <%s>%s<end> [<highlight>%s<end> " \
|
||||
blob += "[%s] <highlight>%s</highlight> (<highlight>%s</highlight>) <%s>%s</%s> [<highlight>%s</highlight> " \
|
||||
"members]<br><pagebreak>" \
|
||||
% (self.text.make_chatcmd("Add Ban", "/tell <myname> orgban add %s" % org.org_id),
|
||||
org.org_name, org.org_id, org.faction.lower(), org.faction, org.member_count)
|
||||
org.org_name, org.org_id, org.faction.lower(), org.faction, org.faction.lower(), org.member_count)
|
||||
return ChatBlob("Pick an Org", blob)
|
||||
|
||||
def fetch_single(self, org_id, sender: object):
|
||||
|
||||
@@ -44,7 +44,10 @@ class DiscordCommandHandler(BaseModule):
|
||||
@event("discord_command", "should the bot take care of discord commands", False)
|
||||
def discord_command_handler(self, _, event_data):
|
||||
acc = event_data.account
|
||||
|
||||
ctx: Message = event_data.message
|
||||
if not acc:
|
||||
return
|
||||
message = ctx.clean_content
|
||||
if message.startswith(self.discord.setting_service.get("symbol").get_value()):
|
||||
threading.Thread(target=self.command_service.process_command(
|
||||
@@ -138,6 +141,7 @@ class DiscordCommandHandler(BaseModule):
|
||||
('#(.+?)#', r'\1'),
|
||||
('<', '<'),
|
||||
('>', '>'),
|
||||
(r"<font color=('*?).+?\1>", ''),
|
||||
('</font>', '')]:
|
||||
ctx = re.sub(pattern, sub, ctx)
|
||||
cnt = 1
|
||||
@@ -147,7 +151,7 @@ class DiscordCommandHandler(BaseModule):
|
||||
|
||||
ctx.rstrip()
|
||||
ctx.rstrip(">")
|
||||
return ctx
|
||||
return self.discord.text.strip_html_tags(ctx)
|
||||
|
||||
@command(command="discord", params=[Const("invite")], access_level="member",
|
||||
description="Get a personal Discord invite", sub_command="invite")
|
||||
@@ -389,7 +393,7 @@ class DiscordCommandHandler(BaseModule):
|
||||
|
||||
@timerevent(budatime="5m", description="update activity")
|
||||
def change_count(self, _, _1):
|
||||
if hasattr(self, "loop"):
|
||||
if hasattr(self.discord, "loop"):
|
||||
count = self.db.query_single('SELECT count(*) as count from online '
|
||||
'where char_id NOT IN (select char_id from org_bots) and bot=?',
|
||||
[self.bot.get_char_id()]).count
|
||||
|
||||
@@ -342,9 +342,9 @@ class DiscordController:
|
||||
DictObject(acc), msg.content,
|
||||
prefix + msg.content)
|
||||
else:
|
||||
prefix = f"[-UNK-] {msg.author.username}: " if self.alias_usage().get_value() else f"[DC] {msg.author.username}: "
|
||||
prefix = f"[-UNK-] {msg.author.name}: " if self.alias_usage().get_value() else f"[DC] {msg.author.name}: "
|
||||
self.relay_hub_service.send_message("Discord_(" + channel.name+")",
|
||||
DictObject({'char_id': 0, 'name': msg.author.username, 'discord_handle': f'{msg.author.name}#{msg.author.discriminator}'}), msg.content,
|
||||
DictObject({'char_id': 0, 'name': msg.author.name, 'discord_handle': f'{msg.author.name}#{msg.author.discriminator}'}), msg.content,
|
||||
prefix + msg.content)
|
||||
if str(channel.id) not in self.channel_blacklist().get_value().lstrip("[").rstrip("]").split(','):
|
||||
self.bot.event_service.fire_event("discord_command", DictObject({'account': acc, 'message': msg}))
|
||||
@@ -395,7 +395,7 @@ class DiscordController:
|
||||
return True
|
||||
|
||||
def check(self, msg: Message):
|
||||
if msg.pinned or (len(msg.embeds) > 0 and (msg.created_at.utcnow() < datetime.utcnow()-timedelta(hours=12))):
|
||||
if msg.pinned or (len(msg.embeds) > 0) and (msg.created_at.utcnow() < datetime.utcnow() - timedelta(hours=12)):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
"join": {
|
||||
"en_US": "{char} has joined the private channel. {logon}",
|
||||
"de_DE": "<orange>Online<end>: {char}. {logon}"
|
||||
"de_DE": "<orange>Online</orange>>: {char}. {logon}"
|
||||
},
|
||||
"leave": {
|
||||
"en_US": "<highlight>{char}</highlight> has left the private channel. {logoff}",
|
||||
|
||||
@@ -59,8 +59,8 @@ class TopicController:
|
||||
|
||||
def format_topic_message(self, topic):
|
||||
time_string = self.util.time_to_readable(int(time.time()) - topic["created_at"])
|
||||
return f"Topic: <highlight>{topic['topic_message']}<end> " \
|
||||
f"[set by <highlight>{topic['created_by']['name']}<end>][{time_string} ago]"
|
||||
return f"Topic: <highlight>{topic['topic_message']}</highlight> " \
|
||||
f"[set by <highlight>{topic['created_by']['name']}</highlight>][{time_string} ago]"
|
||||
|
||||
@event(PrivateChannelService.JOINED_PRIVATE_CHANNEL_EVENT, "Show topic to characters joining the private channel")
|
||||
def show_topic(self, _, event_data):
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
# from core.aochat import server_packets, client_packets
|
||||
# from core.conn import Conn
|
||||
# from core.decorators import instance
|
||||
# from core.igncore import IgnCore
|
||||
# from core.logger import Logger
|
||||
# from core.lookup.character_service import CharacterService
|
||||
# from core.setting_service import SettingService
|
||||
# from core.setting_types import TextSettingType, BooleanSettingType, ColorSettingType
|
||||
# from core.text import Text
|
||||
# from modules.onlinebot.online.org_alias_controller import OrgAliasController
|
||||
#
|
||||
#
|
||||
# @instance("AllianceRelayController")
|
||||
# class AllianceRelayController:
|
||||
# relay_channel_id = None
|
||||
# MESSAGE_SOURCE = "alliance"
|
||||
#
|
||||
# def __init__(self):
|
||||
# self.logger = Logger(__name__)
|
||||
#
|
||||
# # noinspection DuplicatedCode
|
||||
# def inject(self, registry):
|
||||
# self.bot: IgnCore = registry.get_instance("bot")
|
||||
# self.setting_service: SettingService = registry.get_instance("setting_service")
|
||||
# self.character_service: CharacterService = registry.get_instance("character_service")
|
||||
# self.message_hub_service = registry.get_instance("message_hub_service")
|
||||
# self.public_channel_service = registry.get_instance("public_channel_service")
|
||||
# self.text: Text = registry.get_instance("text")
|
||||
# self.alias_controller: OrgAliasController = registry.get_instance("org_alias_controller")
|
||||
#
|
||||
# def pre_start(self):
|
||||
# self.message_hub_service.register_message_source(self.MESSAGE_SOURCE)
|
||||
#
|
||||
# def start(self):
|
||||
# self.setting_service.register(self.module_name, "arelaybot", "",
|
||||
# TextSettingType(allow_empty=True), "Bot for alliance relay")
|
||||
#
|
||||
# self.setting_service.register(self.module_name, "arelay_enabled", False,
|
||||
# BooleanSettingType(), "Enable the alliance relay")
|
||||
#
|
||||
# self.setting_service.register(self.module_name, "arelay_color", "#C3C3C3",
|
||||
# ColorSettingType(),
|
||||
# "Color of messages from relay")
|
||||
#
|
||||
# # self.message_hub_service.register_message_destination(self.MESSAGE_SOURCE, self.handle_relay_hub_message, [],
|
||||
# # [self.MESSAGE_SOURCE])
|
||||
#
|
||||
# self.bot.register_packet_handler(server_packets.PrivateChannelInvited.id, self.handle_private_channel_invite,
|
||||
# 100)
|
||||
# self.bot.register_packet_handler(server_packets.PrivateChannelMessage.id, self.handle_private_channel_message)
|
||||
#
|
||||
# # noinspection DuplicatedCode
|
||||
# def handle_private_channel_invite(self, conn: Conn, packet: server_packets.PrivateChannelInvited):
|
||||
# if conn.id != "main":
|
||||
# return
|
||||
#
|
||||
# if not self.setting_service.get("arelay_enabled").get_value():
|
||||
# return
|
||||
#
|
||||
# channel_name = self.character_service.get_char_name(packet.private_channel_id)
|
||||
# if self.setting_service.get_value("arelaybot").lower() == channel_name.lower():
|
||||
# self.bot.send_packet(client_packets.PrivateChannelJoin(packet.private_channel_id))
|
||||
# self.logger.info("Joined private channel {channel}".format(channel=channel_name))
|
||||
# self.relay_channel_id = packet.private_channel_id
|
||||
#
|
||||
# # noinspection DuplicatedCode
|
||||
# def handle_private_channel_message(self, conn: Conn, packet: server_packets.PrivateChannelMessage):
|
||||
# if conn.id != "main":
|
||||
# return
|
||||
#
|
||||
# if not self.setting_service.get("arelay_enabled").get_value():
|
||||
# return
|
||||
#
|
||||
# # ignore packets from the bot's own private channel and from the bot itself
|
||||
# if packet.private_channel_id == self.bot.get_char_id() or packet.char_id == self.bot.get_char_id():
|
||||
# return
|
||||
#
|
||||
# message = packet.message.lstrip()
|
||||
# if message[:6] != "!agcr ":
|
||||
# return
|
||||
#
|
||||
# message = message[6:]
|
||||
# formatted_message = self.setting_service.get("arelay_color").format_text(message)
|
||||
#
|
||||
# sender = None
|
||||
# self.message_hub_service.send_message(self.MESSAGE_SOURCE, sender, message, formatted_message)
|
||||
#
|
||||
# def handle_relay_hub_message(self, ctx):
|
||||
# if not self.setting_service.get("arelay_enabled").get_value():
|
||||
# return
|
||||
#
|
||||
# plain_msg = ctx.message or ctx.formatted_message
|
||||
# invite = self.text.make_chatcmd("click here", "/tell <myname> discord invite",
|
||||
# style="style='text-decoration:none'")
|
||||
# name = f"[{self.alias_controller.get_alias(ctx.sender.org_id)}] {ctx.sender.name}"
|
||||
# blob = self.text.format_page('Info',
|
||||
# f"<header>::: Information :::</header><br><br>"
|
||||
# f"This message has been sent to you by:<br><br>"
|
||||
# f"<header2>Igncom</header2><br>"
|
||||
# f"<notice>{ctx.sender.discord_handle}</notice><br>"
|
||||
# f"<highlight>{name}</highlight> on Alliance Discord.<br><br>"
|
||||
# f"To reply, either respond in the relay or "
|
||||
# f"contact them directly at the provided handles.<br><br>"
|
||||
# f"<header2>Have you joined The Alliance Discord yet? "
|
||||
# f"If not <highlight>{invite}</highlight> to receive an invite.</header2>")
|
||||
# self.send_message_to_alliance(f"{name}: {plain_msg}" + f" <yellow>[{blob}]</yellow>")
|
||||
#
|
||||
# def send_message_to_alliance(self, msg):
|
||||
# if self.relay_channel_id:
|
||||
# packet = client_packets.PrivateChannelMessage(self.relay_channel_id,
|
||||
# "!agcr " + self.text.format_message(msg, False), "\0")
|
||||
# self.bot.conns["main"].send_packet(packet)
|
||||
@@ -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)
|
||||
|
||||
@@ -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>] ",
|
||||
|
||||
@@ -203,7 +203,7 @@ class RaidController:
|
||||
continue
|
||||
if prof != i.profession:
|
||||
info += "\n\n<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>"
|
||||
info += "\n" + f"<img src=rdb://{self.profs.get(i.profession)}><tab><green>{i.profession}<end>\n"
|
||||
info += "\n" + f"<img src=rdb://{self.profs.get(i.profession)}><tab><green>{i.profession}</green>\n"
|
||||
info += "<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>"
|
||||
prof = i.profession
|
||||
|
||||
|
||||
@@ -53,11 +53,11 @@ class NotifyController:
|
||||
logs = self.get_log(alts, limit or 20)
|
||||
blob = ""
|
||||
if len(logs) == 0:
|
||||
return "No data for <highlight>%s<end> recorded." % char.name
|
||||
return f"No data for <highlight>{char.name}</highlight> recorded."
|
||||
for log in logs:
|
||||
blob += f"<grey>[{self.util.format_datetime(log.time)}]</grey> <highlight>{log.name}<end> -> " \
|
||||
blob += f"<grey>[{self.util.format_datetime(log.time)}]</grey> <highlight>{log.name}</highlight> -> " \
|
||||
f"{'<green>logged on</green>' if log.status == 1 else '<red>logged off</red>'}.\n"
|
||||
return f"<highlight>{char.name}<end> was last seen at " \
|
||||
return f"<highlight>{char.name}</highlight> was last seen at " \
|
||||
f"{self.util.format_date(logs[0].time)}. {self.text.format_page('More', blob)}"
|
||||
|
||||
def get_log(self, char_list, length=16):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
# import asyncio
|
||||
# import datetime
|
||||
# import html
|
||||
#
|
||||
# # noinspection PyPackageRequirements
|
||||
# from discord import Embed
|
||||
#
|
||||
# from core.command_service import CommandService
|
||||
# from core.db import DB
|
||||
# from core.decorators import instance
|
||||
# from core.logger import Logger
|
||||
# from core.lookup.character_service import CharacterService
|
||||
# from core.lookup.pork_service import PorkService
|
||||
# from core.message_hub_service import MessageHubService
|
||||
# from core.registry import Registry
|
||||
# from core.setting_service import SettingService
|
||||
# from core.setting_types import NumberSettingType
|
||||
# from core.text import Text
|
||||
# from core.igncore import IgnCore
|
||||
# from modules.core.accounting.services.access_service import AccessService
|
||||
# from modules.core.discord.discord_controller import DiscordController
|
||||
#
|
||||
#
|
||||
# # noinspection DuplicatedCode,PyAttributeOutsideInit
|
||||
# @instance()
|
||||
# class MessageDistributor:
|
||||
# MESSAGE_SOURCE = "discord"
|
||||
#
|
||||
# def __init__(self):
|
||||
# self.logger = Logger(__name__)
|
||||
#
|
||||
# def inject(self, registry):
|
||||
# self.bot: IgnCore = registry.get_instance("bot")
|
||||
# self.db: DB = registry.get_instance("db")
|
||||
# self.character_service: CharacterService = registry.get_instance("character_service")
|
||||
# self.access_service: AccessService = registry.get_instance("access_service")
|
||||
# self.pork: PorkService = registry.get_instance("pork_service")
|
||||
# self.relay_hub_service: MessageHubService = registry.get_instance("message_hub_service")
|
||||
# self.discord: DiscordController = registry.get_instance("discord_controller")
|
||||
# self.cmd_service: CommandService = registry.get_instance("command_service")
|
||||
# self.setting_service: SettingService = registry.get_instance("setting_service")
|
||||
# self.text: Text = registry.get_instance("text")
|
||||
#
|
||||
# def pre_start(self):
|
||||
# self.relay_hub_service.register_message_source("public_relay")
|
||||
# self.relay_hub_service.register_message_source("tell_logger")
|
||||
# self.relay_hub_service.register_message_source("system_logger")
|
||||
# self.relay_hub_service.register_message_source("access_denied_logger")
|
||||
# self.relay_hub_service.register_message_source("member_logger")
|
||||
#
|
||||
# def start(self):
|
||||
# self.relay_hub_service.register_message_destination("tell_log", self.handle_logging_tell, ["tell_logger"],
|
||||
# ["tell_log"])
|
||||
# self.setting_service.register(self.module_name, "dc_tell_log", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the Tell Log")
|
||||
#
|
||||
# self.relay_hub_service.register_message_destination("access_denied_log", self.handle_logging_denied,
|
||||
# ["access_denied_logger"], ["access_denied_log"])
|
||||
# self.setting_service.register(self.module_name, "dc_denied_log", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the Access Denied Log")
|
||||
#
|
||||
# self.relay_hub_service.register_message_destination("relay_log", self.handle_logging_relay,
|
||||
# ["alliance", "public_relay"], ["relay_log"])
|
||||
# self.setting_service.register(self.module_name, "dc_relay_log", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the Relay Log")
|
||||
#
|
||||
# self.relay_hub_service.register_message_destination("public_relay", self.handle_public_relay, ["alliance"],
|
||||
# ["public_relay"])
|
||||
# self.setting_service.register(self.module_name, "dc_relay_public", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the Public Relay Channel")
|
||||
#
|
||||
# self.relay_hub_service.register_message_destination("system", self.handle_logging_system, ["system_logger"],
|
||||
# ["system"])
|
||||
# self.setting_service.register(self.module_name, "dc_system_log", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the System Channel")
|
||||
#
|
||||
# self.relay_hub_service.register_message_destination("dc_member_log", self.handle_logging_members,
|
||||
# ["member_logger"], ["dc_member_log"])
|
||||
# self.setting_service.register(self.module_name, "dc_member_log", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the Member Log")
|
||||
#
|
||||
# if Registry.get_instance("darknet", is_optional=True):
|
||||
# self.relay_hub_service.register_message_destination("dc_darknet_log", self.handle_darknet_log, ["darknet"],
|
||||
# [""])
|
||||
# self.setting_service.register(self.module_name, "dc_darknet_log", 0, NumberSettingType(allow_empty=True),
|
||||
# "ChannelID for the Darknet Log")
|
||||
#
|
||||
# def handle_public_relay(self, ctx):
|
||||
# if self.setting_service.get_value("dc_relay_public") != "0":
|
||||
# message = self.format(ctx.formatted_message)
|
||||
# self.discord.send_message(self.setting_service.get_value("dc_relay_public"), html.unescape(message),
|
||||
# delete=3600) # delete after 1h
|
||||
#
|
||||
# def handle_logging_tell(self, ctx):
|
||||
# if self.setting_service.get_value("dc_tell_log") != "0":
|
||||
# message = self.format(ctx.message)
|
||||
# self.discord.send_message(self.setting_service.get_value("dc_tell_log"),
|
||||
# f"[FROM] {self.character_service.get_char_name(ctx.sender)}: {message}")
|
||||
#
|
||||
# def handle_logging_denied(self, ctx):
|
||||
# if self.setting_service.get_value("dc_denied_log") != "0":
|
||||
# message = self.format(ctx.message)
|
||||
# self.discord.send_message(self.setting_service.get_value("dc_denied_log"), message)
|
||||
#
|
||||
# def handle_darknet_log(self, ctx):
|
||||
# if self.setting_service.get_value("dc_darknet_log") != "0":
|
||||
# message = self.format(ctx.message)
|
||||
# self.discord.send_message(self.setting_service.get_value("dc_darknet_log"), message)
|
||||
#
|
||||
# def handle_logging_relay(self, ctx):
|
||||
# if self.setting_service.get_value("dc_relay_log") != "0":
|
||||
# message = self.format(ctx.formatted_message)
|
||||
# self.discord.send_message(self.setting_service.get_value("dc_relay_log"), f"{html.unescape(message)}")
|
||||
#
|
||||
# def handle_logging_system(self, ctx):
|
||||
# if self.setting_service.get_value("dc_system_log") != "0":
|
||||
# message = self.format(ctx.message)
|
||||
# self.discord.send_message(self.setting_service.get_value("dc_system_log"), f"{html.unescape(message)}")
|
||||
#
|
||||
# def handle_logging_members(self, ctx):
|
||||
# if self.setting_service.get_value("dc_member_log") != "0":
|
||||
# channel = self.discord.client.get_channel(int(self.setting_service.get_value("dc_member_log")))
|
||||
# spam = []
|
||||
# current = 0
|
||||
# for message in ctx.message:
|
||||
# current += 1
|
||||
# spam.append(Embed(title=f"Recent changes - {datetime.date.today()} - ({current}/{len(ctx.message)})",
|
||||
# description=message, color=3066993))
|
||||
# asyncio.run_coroutine_threadsafe(self.send_spam(channel, spam), self.discord.loop)
|
||||
#
|
||||
# async def send_spam(self, channel, message):
|
||||
# if self.discord.client.is_ready():
|
||||
# for i in message:
|
||||
# await channel.send(embed=i)
|
||||
#
|
||||
# def format(self, message):
|
||||
# return self.text.strip_html_tags(message)
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -26,7 +26,7 @@ class ChatController:
|
||||
@command(command="lft", params=[Any("message", is_optional=True)], access_level="member",
|
||||
description="Show a highly visible message")
|
||||
def lft_command(self, _, message):
|
||||
lft = f"<a href='chatcmd:///lft <font color=#FFFF00>» {message or '<myname>'}<end>'>/lft {message or '<myname>'}</a>"
|
||||
lft = f"<a href='chatcmd:///lft <font color=#FFFF00>» {message or '<myname>'}</font>'>/lft {message or '<myname>'}</a>"
|
||||
return self.text.format_page("Use this command for going LFT", "<yellow>────────────────</yellow>\n"
|
||||
f"<highlight>{lft}</highlight>\n"
|
||||
f"<yellow>────────────────</yellow>")
|
||||
|
||||
@@ -44,9 +44,9 @@ class LeaderController:
|
||||
description="Show the current raid leader")
|
||||
def leader_show_command(self, _):
|
||||
if self.leader:
|
||||
return "The current raid leader is <highlight>{leader}<end>.".format(leader=self.leader.name)
|
||||
return "The current raid leader is <highlight>{leader}</highlight>.".format(leader=self.leader.name)
|
||||
else:
|
||||
return "There is no current raid leader. Use <highlight><symbol>leader set<end> to become the raid leader."
|
||||
return "There is no current raid leader. Use <highlight><symbol>leader set</highlight> to become the raid leader."
|
||||
|
||||
@command(command="leader", params=[Const("echo"), Options(["on", "off"])], access_level="leader",
|
||||
description="Echo whatever the current leader types in channel, in a distinctive color", sub_command="mgn")
|
||||
@@ -54,8 +54,8 @@ class LeaderController:
|
||||
if self.leader:
|
||||
if self.can_use_command(request.sender.char_id):
|
||||
self.echo = switch_to == "on"
|
||||
return f"Raidleader echo for <highlight>{self.leader.name}<end> has been turned " \
|
||||
f"<highlight>{switch_to}<end>."
|
||||
return f"Raidleader echo for <highlight>{self.leader.name}</highlight> has been turned " \
|
||||
f"<highlight>{switch_to}</highlight>."
|
||||
else:
|
||||
return "Insufficient access level."
|
||||
elif self.leader is None and switch_to == "on":
|
||||
@@ -66,7 +66,7 @@ class LeaderController:
|
||||
def leader_echo_status_command(self, _1, _2):
|
||||
if self.leader:
|
||||
on_off = "on" if self.echo else "off"
|
||||
return f"<highlight>{self.leader.name}<end> is set as leader, leader echo is <highlight>{on_off}<end>"
|
||||
return f"<highlight>{self.leader.name}</highlight> is set as leader, leader echo is <highlight>{on_off}</highlight>"
|
||||
else:
|
||||
return "No current leader set, echo is off."
|
||||
|
||||
@@ -87,7 +87,7 @@ class LeaderController:
|
||||
description="Set another character as raid leader")
|
||||
def leader_set_other_command(self, request, _, char):
|
||||
if not char.char_id:
|
||||
return "Could not find <highlight>{player}<end>.".format(player=char)
|
||||
return "Could not find <highlight>{player}</highlight>.".format(player=char)
|
||||
|
||||
return self.set_raid_leader(request.sender, char)
|
||||
|
||||
@@ -154,18 +154,18 @@ class LeaderController:
|
||||
self.echo = False
|
||||
self.bot.send_private_message(old_leader.char_id,
|
||||
f"You have been removed as raid leader "
|
||||
f"by <highlight>{sender.name}<end>.")
|
||||
return f"You have removed <highlight>{old_leader.name}<end> as raid leader."
|
||||
f"by <highlight>{sender.name}</highlight>.")
|
||||
return f"You have removed <highlight>{old_leader.name}</highlight> as raid leader."
|
||||
else:
|
||||
return f"You do not have a high enough access level to remove raid leader " \
|
||||
f"from <highlight>{self.leader.name}<end>."
|
||||
f"from <highlight>{self.leader.name}</highlight>."
|
||||
elif sender.char_id == set_to.char_id:
|
||||
if not self.leader:
|
||||
self.leader = sender
|
||||
self.echo = self.setting_service.get("leader_auto_echo").get_value()
|
||||
reply = "You have been set as raid leader."
|
||||
if self.echo:
|
||||
reply += " Leader echo is <green>enabled<end>."
|
||||
reply += " Leader echo is <green>enabled</green>."
|
||||
return reply
|
||||
elif self.leader.char_id == sender.char_id:
|
||||
self.leader = None
|
||||
@@ -175,29 +175,29 @@ class LeaderController:
|
||||
old_leader = self.leader
|
||||
self.leader = sender
|
||||
self.echo = self.setting_service.get("leader_auto_echo").get_value()
|
||||
reply = f"<highlight>{sender.name}<end> has taken raid leader from you."
|
||||
reply = f"<highlight>{sender.name}</highlight> has taken raid leader from you."
|
||||
if self.echo:
|
||||
reply += " Leader echo is <green>enabled<end>."
|
||||
reply += " Leader echo is <green>enabled</green>."
|
||||
self.bot.send_private_message(old_leader.char_id, reply)
|
||||
reply = f"You have taken raid leader from <highlight>{old_leader.name}<end>."
|
||||
reply = f"You have taken raid leader from <highlight>{old_leader.name}</highlight>."
|
||||
if self.echo:
|
||||
reply += " Leader echo is <green>enabled<end>."
|
||||
reply += " Leader echo is <green>enabled</green>."
|
||||
return reply
|
||||
else:
|
||||
return f"You do not have a high enough access level to " \
|
||||
f"take raid leader from <highlight>{self.leader.name}<end>."
|
||||
f"take raid leader from <highlight>{self.leader.name}</green>."
|
||||
else:
|
||||
if self.can_use_command(sender.char_id):
|
||||
self.leader = set_to
|
||||
self.echo = self.setting_service.get("leader_auto_echo").get_value()
|
||||
reply = f"<highlight>{sender.name}<end> has set you as raid leader."
|
||||
reply = f"<highlight>{sender.name}</highlight> has set you as raid leader."
|
||||
if self.echo:
|
||||
reply += " Leader echo is <green>enabled<end>."
|
||||
reply += " Leader echo is <green>enabled</green>."
|
||||
self.bot.send_private_message(set_to.char_id, reply)
|
||||
reply = f"<highlight>{set_to.name}<end> has been set as raid leader by {sender.name}."
|
||||
reply = f"<highlight>{set_to.name}</highlight> has been set as raid leader by {sender.name}."
|
||||
if self.echo:
|
||||
reply += " Leader echo is <green>enabled<end>."
|
||||
reply += " Leader echo is <green>enabled</green>."
|
||||
return reply
|
||||
else:
|
||||
return f"You do not have a high enough access level to " \
|
||||
f"take raid leader from <highlight>{self.leader.name}<end>."
|
||||
f"take raid leader from <highlight>{self.leader.name}</highlight>."
|
||||
|
||||
@@ -93,7 +93,7 @@ class OrgListController:
|
||||
blob += "History: <{side}>{HISTORY}</{side}><br><br>"
|
||||
blob += "[{ADD}] - [{REM}]<br>"
|
||||
if info[0]["GOVERNINGNAME"] == "Department":
|
||||
blob += "<br><notice>Generals<end><br>"
|
||||
blob += "<br><notice>Generals</notice><br>"
|
||||
blob += "<generals>"
|
||||
blob = blob.format(**info[0], side=info[0]["SIDE_NAME"].lower(),
|
||||
ADD=self.text.make_chatcmd("Add to our orgs",
|
||||
@@ -106,20 +106,20 @@ class OrgListController:
|
||||
blob = blob.replace("<president>", member["NAME"])
|
||||
if info[0]["GOVERNINGNAME"] == "Department":
|
||||
if member["RANK"] == 1:
|
||||
generals += "- {NAME} ({LEVELX}/<green>{ALIENLEVEL}<end>) {PROF}<br>".format(**member)
|
||||
generals += "- {NAME} ({LEVELX}/<green>{ALIENLEVEL}</green>) {PROF}<br>".format(**member)
|
||||
blob = blob.replace("<generals>", generals)
|
||||
return ChatBlob(orgs[0].org_name, blob)
|
||||
elif len(orgs) == 0:
|
||||
return f"No org with the name <highlight>{org}<end> was found on PoRK."
|
||||
return f"No org with the name <highlight>{org}</highlight> was found on PoRK."
|
||||
else:
|
||||
blob = "Your search had multiple results; please pick an org:<br>"
|
||||
for org in orgs:
|
||||
if Registry.get_instance('org_alias_controller', is_optional=True):
|
||||
blob += f'[{self.text.make_chatcmd("Add", f"/tell <myname> orgs add {org.org_id}")}]'
|
||||
blob += f'[{self.text.make_chatcmd("More", f"/tell <myname> orgs info {org.org_id}")}]'
|
||||
blob += f' <highlight>{org.org_name}<end> ' \
|
||||
f'(<highlight>{org.org_id}<end>) <{org.faction.lower()}>{org.faction}<end> ' \
|
||||
f'[<highlight>{org.member_count}<end> members]<br><pagebreak>'
|
||||
blob += f' <highlight>{org.org_name}</highlight> ' \
|
||||
f'(<highlight>{org.org_id}</highlight>) <{org.faction.lower()}>{org.faction}</{org.faction.lower()}> ' \
|
||||
f'[<highlight>{org.member_count}</highlight> members]<br><pagebreak>'
|
||||
return ChatBlob("Pick an Org", blob)
|
||||
|
||||
def start_orglist_lookup(self, reply, org_id):
|
||||
|
||||
Reference in New Issue
Block a user