Reduced & updated dependencies.

By default, messages larger than 2.000 characters (sent via tells) get sent via slaves, if these exist.
Fixes #3
This commit is contained in:
2021-10-18 19:39:14 +02:00
parent dea25b05a5
commit bb445e868d
20 changed files with 124 additions and 152 deletions
@@ -36,8 +36,7 @@ class AccountController:
@command(command="account", params=[], access_level="member",
description="View your account")
def account(self, request: command_request):
out = self.show_account(request.sender.char_id)
self.bot.send_mass_message(request.sender.char_id, out)
return self.show_account(request.sender.char_id)
@command(command="accounts", params=[Const('online', is_optional=True)], access_level="moderator",
description="View all accounts")
@@ -238,6 +237,10 @@ class AccountController:
if not mod:
response += f" Options: {prefs}\n"
response += f" Points: <notice>{alts[0].points}</notice>\n"
last_seen = {}
for x in alts:
if x.last_seen > last_seen.get("last_seen", 0):
last_seen = x
access_levels = {f"Member ({alts[0].member})": self.account_service.check_member(alts[0].char_id),
"Officer": self.account_service.check_officer(alts[0].char_id),
"General": self.account_service.check_general(alts[0].char_id),
@@ -252,12 +255,13 @@ class AccountController:
perms.append(key)
response += f" Status: {'<green>Open</green>' if alts[0].disabled == 0 else '<red>Closed</red>'}\n"
response += f" Created at: <notice>{self.util.format_datetime(alts[0].created)}</notice>\n"
response += f" Last seen on <notice>{last_seen.name}</notice> <highlight>{self.util.time_to_readable(time.time()-last_seen.last_seen)}</highlight> ago\n"
response += f" Permissions: <notice>{', '.join(perms)}</notice>\n"
if alts[0].discord_joined == 1:
joined = '(Joined server)'
joined = ' (Joined server)'
else:
joined = '(Left server)' if alts[0].discord_invite != '' else 'Never joined'
response += f" Discord: <notice>{alts[0].discord_handle}</notice> {joined}\n\n"
joined = ' (Left server)' if alts[0].discord_invite != '' else 'Never joined'
response += f" Discord: <notice>{alts[0].discord_handle}</notice>{joined}\n\n"
log_types = ['Points', 'Loot', 'Raid', 'Public', 'Admin', 'System']
response += " Logs: ["
for i in log_types:
@@ -580,6 +580,8 @@ class DiscordController:
async def on_message(self, msg: Message):
if msg.author.id == self.client.user.id:
return
if not self.setting_service.get_value("dc_relay_public"):
return
channel: TextChannel = msg.channel
if channel.id == int(self.setting_service.get_value("dc_relay_public")):
if self.setting_service.get_value('is_alliance_bot') == "0":
@@ -141,10 +141,7 @@ class PrivateChannelController:
if len(banned) > 0:
out += f'The Character <highlight>{", ".join(banned)}</highlight> is <red>banned</red>, ' \
f'and cannot be invited.'
if request.channel == "priv":
return out.strip("\n")
else:
self.bot.send_mass_message(request.sender.char_id, out.strip("\n"))
return out.strip("\n")
@command(command="kick", params=[Character("character")], access_level="moderator",
description="Kick a character from the private channel")
+3 -2
View File
@@ -1,3 +1,4 @@
import json
import math
from core.buddy_service import BuddyService
@@ -165,7 +166,7 @@ class RIAdminController:
description="take the RI from another bot")
def ritake(self, request, raiders: str):
users = raiders.split(",")
if request.sender.char_id not in eval(self.setting_service.get_value('riadmin_network')):
if request.sender.char_id not in json.loads(self.setting_service.get_value('riadmin_network')):
return
for user in users:
char = self.character_service.resolve_char_to_id(user.strip())
@@ -277,7 +278,7 @@ class RIAdminController:
def riadmin_create(self, _, _2, raid_instance_name, bot):
if not bot.char_id:
return self.getresp("global", "char_not_found", {"char": bot.name})
if bot.char_id not in eval(self.setting_service.get_value('riadmin_network')):
if bot.char_id not in json.loads(self.setting_service.get_value('riadmin_network')):
return "Bot not valid: please ask an Administrator to verify it first."
raid_instance = self.get_raid_instance(raid_instance_name)
if raid_instance:
@@ -32,4 +32,4 @@ class OrgOnlineController(OnlineController):
blob = self.online_display.format_by_channel_prof(query, params)
else:
blob = self.online_display.format_by_org(query, params)
self.bot.send_mass_message(request.sender.char_id, self.online_display.format_blob(blob))
return self.online_display.format_blob(blob)
+1 -1
View File
@@ -30,7 +30,7 @@ class OrgOnlineController(OnlineController):
query = "and channel_id IN (1, 2) "
params = [self.bot.name, self.bot.get_char_id()]
blob = self.online_display.format_by_channel_prof(query, params)
self.bot.send_mass_message(request.sender.char_id, self.online_display.format_blob(blob))
return self.online_display.format_blob(blob)
def pre_start(self):
super().pre_start()
+3 -4
View File
@@ -85,8 +85,7 @@ class AOUController:
obj.aou = self.text.make_chatcmd("AO-Universe.com", "/start https://www.ao-universe.com")
obj.text = self.format_bbcode_code(guide_info.text)
self.bot.send_mass_message(request.sender.char_id,
ChatBlob(guide_info.name, self.getresp("module/aou", "guide", {**obj})))
return ChatBlob(guide_info.name, self.getresp("module/aou", "guide", {**obj}))
@command(command="aou", params=[Const("all", is_optional=True), Any("search")], access_level="member",
description="Search for an AO-Universe guides")
@@ -117,9 +116,9 @@ class AOUController:
if count == 0:
return self.getresp("module/aou", "no_guide_search", {"search": search})
else:
self.bot.send_mass_message(request.sender.char_id, ChatBlob(
return ChatBlob(
self.getresp("module/aou", "search_guide_title" + ("_all" if include_all_matches else ""),
{"search": search, "count": count}), blob))
{"search": search, "count": count}), blob)
def retrieve_guide(self, guide_id):
cache_key = "%d.xml" % guide_id
+8 -10
View File
@@ -74,18 +74,16 @@ class MailController:
@command(command="mail", params=[Const('all', is_optional=True)], description="Show your mails",
access_level="member")
def mail_show(self, sender, const_all):
mails, title = None, "You dont have any unread mails."
if const_all:
mails = self.get_mails(sender.sender.char_id, True)
if mails:
self.bot.send_private_message(sender.sender.char_id, ChatBlob("All your recent Mails", mails))
else:
return "You dont have any mails."
mails, title = self.get_mails(sender.sender.char_id, True), "All your recent Mails"
else:
mails = self.get_mails(sender.sender.char_id)
if mails:
self.bot.send_private_message(sender.sender.char_id, ChatBlob("Your unread mails", mails))
else:
return "You dont have any unread mails."
mails, title = self.get_mails(sender.sender.char_id), "Your unread mails"
if mails:
self.bot.send_private_message(sender.sender.char_id, ChatBlob(title, mails))
else:
return title
@command(command="mail", params=[Options(["read"]), Int("ID")],
description="mark a mail as read", access_level="member")
-35
View File
@@ -85,37 +85,6 @@ hh:mm - DD.MM.YYYY
f" [{self.text.make_chatcmd('orgs', '/tell <myname> orgs')}] " \
f"[{self.text.make_chatcmd('admins', '/tell <myname> admins')}]\n"
@event("connect", "prepare info msg")
def prepare_info(self, _, _1):
self.INFO = ChatBlob("Welcome", f"<font color=CCInfoText>You're getting this message,\n"
f"because you recently joined the clan alliance\n"
f"<highlight>The New Alliance</highlight> or in short "
f"<highlight>TNA</highlight>.\n"
f"I'm <notice><myname></notice>, a bot with the task to "
f"automate a few workflows around here,\n"
f"while making the life of everyone a bit easier.\n"
f"\n"
f"You can see a list of all my orgs by using "
f"{self.text.make_tellcmd('!orgs', 'orgs')}.\n"
f"Whenever you use {self.text.make_tellcmd('!online', 'online')} "
f"I'll show you who's currently around.\n"
f"We've got regular raids, you can view them by using "
f"{self.text.make_tellcmd('!raids', 'raids')}\n"
f"If you'd like to stay out, thats fine. Just turn all settings off here: "
f"{self.text.make_tellcmd('here', 'prefs')}\n"
f"\n"
f"If you encounter any issues, my administrators will help you. just ask them, "
f"you can find them all here: {self.text.make_tellcmd('!admins', 'admins')}\n"
f"\n"
f"<highlight>Thats it already. "
f"Thank you for taking your time to read this note. See you ingame!</highlight>"
f"</font>")
self.INFO = f"\n<yellow>________________\n\n" \
f" No need to <red>PANIC</red>!\n" \
f" [{self.text.paginate_single(self.INFO)}]\n" \
f" to our alliance!\n" \
f"________________</yellow>"
@event(event_type="member_logon", description="Send news to players logging in")
def logon_event(self, _, data):
if not self.bot.is_ready():
@@ -140,10 +109,6 @@ hh:mm - DD.MM.YYYY
discord,
self.preferences.get_pref_view_small(account))
# This one is kinda redudant now that the simple checks get done above, will remove it in the future.
if account.last_seen == 0 and self.setting_service.get_value('is_alliance_bot') == "1":
self.bot.send_mass_message(data.packet.char_id, self.INFO)
@command(command="raids", params=[], description="Show the Raids", access_level="member")
def show_raids(self, _):
with open("data/latest_raids.txt", "r") as f:
+1 -1
View File
@@ -89,7 +89,7 @@ class TimerController:
blob += "\n\n<header>Manual Timers</header>\n"
for timer in data:
repeats = ""
if timer.repeating_every >= 0:
if timer.repeating_every > 0:
repeats = f" (Repeats every {self.util.time_to_readable(timer.repeating_every)})"
blob += f"<pagebreak>Name: <highlight>{timer.name}</highlight>\n"
blob += f"Time left: <highlight>" \
@@ -120,7 +120,7 @@ class CharacterInfoController:
msg = ChatBlob(f"Basic Info for {char.name}", blob)
else:
msg = f"Could not find character <highlight>{char.name}</highlight> on RK{dimension:d}."
if request.channel == "msg":
if request.channel == "msg" and request.conn.id == "main":
self.bot.send_mass_message(request.sender.char_id, msg)
else:
request.reply(msg)