Various Fixes.
generified the Worldboss module; removed the spammy-section as of currently, will be readded at a later stage.
This commit is contained in:
@@ -230,7 +230,7 @@ class AccountController:
|
||||
if len(alts) < 1:
|
||||
return "No Account registered for this user."
|
||||
prefs = self.preferences.get_pref_view_small(alts[0])
|
||||
response = f"<header>{alts[0].name}'s Account</header>\n\n" \
|
||||
response = f"" \
|
||||
f" Owner: <notice>{alts[0].name}</notice> ({alts[0].char_id}) " \
|
||||
f"[{self.text.make_tellcmd('W', f'whois {alts[0].name}')}] " \
|
||||
f"[{self.text.make_tellcmd('Alts', f'alts {alts[0].name}')}] " \
|
||||
|
||||
@@ -69,7 +69,7 @@ class DiscordCommandHandler(BaseModule):
|
||||
'discord_handle':
|
||||
f'{ctx.author.name}#{ctx.author.discriminator}'}),
|
||||
reply, reply)
|
||||
if type(reply) == ChatBlob:
|
||||
elif type(reply) == ChatBlob:
|
||||
if reply.embed:
|
||||
embeds = Embed(title=self.parseDiscord(f"{reply.page_prefix} {reply.title} {reply.page_postfix}"),
|
||||
color=0x00FF00,
|
||||
@@ -89,22 +89,36 @@ class DiscordCommandHandler(BaseModule):
|
||||
reply, reply)
|
||||
if embeds:
|
||||
if len(embeds.description) > 4000:
|
||||
body = self.discord.text.split_by_separators(embeds.description, 4000, 10)
|
||||
body = self.discord.text.split_by_separators(embeds.description, 3000, 10)
|
||||
tmp1 = embeds
|
||||
embeds = []
|
||||
for x, e in enumerate(body):
|
||||
tmp = tmp1.copy()
|
||||
tmp.description = e
|
||||
tmp.title += f"*Page ({x}/{len(body)})*"
|
||||
tmp.title += f"*Page ({x+1}/{len(body)})*"
|
||||
embeds.append(tmp)
|
||||
|
||||
else:
|
||||
embeds = [embeds]
|
||||
if len(rsp) > 2000:
|
||||
rsp = self.discord.text.split_by_separators(rsp, 2000)
|
||||
for page in rsp:
|
||||
self.discord.client.loop.create_task(ctx.reply(page))
|
||||
# if len(rsp) > 2000:
|
||||
# rsp = self.discord.text.split_by_separators(rsp, 2000)
|
||||
# for page in rsp:
|
||||
# self.discord.client.loop.create_task(ctx.reply(page))
|
||||
# else:
|
||||
tmp = []
|
||||
_len = 0
|
||||
for x in embeds:
|
||||
_len += len(x.description)
|
||||
if _len < 6000:
|
||||
tmp.append(x)
|
||||
else:
|
||||
self.discord.client.loop.create_task(ctx.reply(rsp, embeds=tmp))
|
||||
tmp = [x]
|
||||
_len = len(x.description)
|
||||
if len(tmp) > 0:
|
||||
self.discord.client.loop.create_task(ctx.reply(rsp, embeds=tmp))
|
||||
else:
|
||||
self.discord.client.loop.create_task(ctx.reply(rsp, embeds=embeds))
|
||||
self.discord.client.loop.create_task(ctx.reply(rsp))
|
||||
|
||||
def parseDiscord(self, ctx: str, blob=False):
|
||||
proficon = {1: "sold", 2: "ma", 3: "eng", 4: "fixer", 5: "agent", 6: "adv", 7: "trad", 8: "crat", 9: "enf",
|
||||
@@ -115,8 +129,9 @@ class DiscordCommandHandler(BaseModule):
|
||||
f"<notice>{self.discord.util.get_profession(proficon.get(int(match)))}</notice>")
|
||||
|
||||
for x in ["`", '*', '_', '|']:
|
||||
ctx = ctx.replace(x, f' \\{x.strip()}')
|
||||
ctx = ctx.replace(x, f'\\{x}')
|
||||
for pattern, sub in [(r"(<br>|\n|</br>)", r"\n"),
|
||||
(r"`", "´"),
|
||||
(r"<highlight>(.*?)</highlight>", r"**\1**"),
|
||||
(r"<title>(.*?)</title>", r"**__\1__**"),
|
||||
(r"<header>(.*?)</header>", r"**__\1__**"),
|
||||
@@ -126,8 +141,9 @@ class DiscordCommandHandler(BaseModule):
|
||||
(r"<myname>", self.bot.get_char_name()),
|
||||
(r"<symbol>", self.discord.setting_service.get_value("symbol")),
|
||||
# (r"<a href=(.*?)itemref://\d+/\d+/\d+\1>(.+?)<\/a>", r"`\2`"),
|
||||
(r"<a href=(.*?)itemref://(\d+)/\d+/(\d+)\1>(.+?)<\/a>", r"[\4](https://aoitems.com/item\/\2\/\3/)" if blob else r"`\4`"),
|
||||
(r"<a href=(.*?)itemid://(\d+)/(\d+)\1>(.+?)<\/a>", r"[\4](https://aoitems.com/item\/\2\/\3/)" if blob else r"`\4`"),
|
||||
(r"<a .+?href=(.*?)chatcmd:///start (.+?)\1>(.+?)</a>", r"[\3](\2)"),
|
||||
(r"<a href=(.*?)itemref://(\d+)/\d+/(\d+)\1>(.+?)<\/a>", r"[\4](https://aoitems.com/item/\2/\3/)" if blob else r"`\4`"),
|
||||
(r"<a href=(.*?)itemid://(\d+)/(\d+)\1>(.+?)<\/a>", r"[\4](https://aoitems.com/item/\2/\3/)" if blob else r"`\4`"),
|
||||
(r"<(.+?)>\s*?<\1>", ''),
|
||||
(r"<pagebreak>", ''),
|
||||
(r"<a.+?href=\'.*?\'>(.*?)</a>", r'`\1`'),
|
||||
@@ -147,9 +163,15 @@ class DiscordCommandHandler(BaseModule):
|
||||
while cnt > 0:
|
||||
ctx, cnt = re.subn(r"<(black|white|yellow|blue|green|red|orange|grey|cyan|violet)>(.*?|\d+?)</\1>", r"\2",
|
||||
ctx)
|
||||
ctx.rstrip().rstrip(">")
|
||||
y = re.split('(`.+?`)', ctx)
|
||||
ctx = ""
|
||||
for x in y:
|
||||
if x.startswith("`"):
|
||||
for var in ['*', '_', '|']:
|
||||
x = x.replace(f"\\{var}", f'{var}')
|
||||
ctx += x
|
||||
|
||||
ctx.rstrip()
|
||||
ctx.rstrip(">")
|
||||
return self.discord.text.strip_html_tags(ctx)
|
||||
|
||||
@command(command="discord", params=[Const("invite")], access_level="member",
|
||||
|
||||
@@ -18,7 +18,7 @@ class DiscordData:
|
||||
return self.db.exec("UPDATE account SET discord_handle = ? WHERE discord_id = ?", [handle, discord_id])
|
||||
|
||||
def get_discord_invite(self, invite):
|
||||
return self.db.query_single("SELECT * FROM account WHERE discord_invite = ? and a.main=a.char_id", [invite])
|
||||
return self.db.query_single("SELECT * FROM account a WHERE discord_invite = ? and a.main=a.char_id", [invite])
|
||||
|
||||
def get_account_discord_id(self, discord_id):
|
||||
return self.db.query_single("SELECT * FROM account a left join player p on a.char_id=p.char_id WHERE a.discord_id = ? and a.main=a.char_id", [discord_id])
|
||||
@@ -66,7 +66,7 @@ class PrivateChannelController:
|
||||
|
||||
@event("connect", "Reinvite previous raiders")
|
||||
def reinvite_all(self, _, _1):
|
||||
for user in self.reinvite:
|
||||
for user in set(self.reinvite):
|
||||
self.bot.send_mass_message(user, "You have been <green>reinvited</green> into my private channel "
|
||||
"after a bot restart or crash; Sorry for the inconvenience.")
|
||||
self.priv.invite(user)
|
||||
|
||||
Reference in New Issue
Block a user