Fixed warnings caused by non-existing messagehub channels.
Changed the setting registration, removed the warnings. Loot roll messages are more obvious now. Superadmins are meant to stay mostily hidden, but are being exposed in !system again.
This commit is contained in:
@@ -14,19 +14,16 @@ class MessageHubController:
|
||||
self.message_hub_service = registry.get_instance("message_hub_service")
|
||||
self.getresp = partial(registry.get_instance("translation_service").get_response, "module/system")
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
|
||||
@command(command="messagehub", params=[], access_level="admin",
|
||||
description="Show the current message hub subscriptions")
|
||||
def messagehub_cmd(self, _):
|
||||
blob = self.getresp("messagehub_info") + "\n"
|
||||
subscriptions = self.message_hub_service.hub
|
||||
for destination, obj in subscriptions.items():
|
||||
edit_subs_link = self.text.make_tellcmd(destination, "messagehub edit %s" % destination)
|
||||
blob += "\n%s\n" % edit_subs_link
|
||||
edit_subs_link = self.text.make_tellcmd(destination, f"messagehub edit {destination}")
|
||||
blob += f"\n{edit_subs_link}\n"
|
||||
for source in obj.sources:
|
||||
blob += " └ %s\n" % source
|
||||
blob += f" └ {source}\n"
|
||||
|
||||
return ChatBlob(self.getresp("messagehub_title", {"count": len(subscriptions)}), blob)
|
||||
|
||||
@@ -43,13 +40,13 @@ class MessageHubController:
|
||||
if source in obj.invalid_sources:
|
||||
continue
|
||||
|
||||
sub_link = self.text.make_tellcmd("Subscribe", "messagehub subscribe %s %s" % (destination, source))
|
||||
unsub_link = self.text.make_tellcmd("Unsubscribe", "messagehub unsubscribe %s %s" % (destination, source))
|
||||
sub_link = self.text.make_tellcmd("Subscribe", f"messagehub subscribe {destination} {source}")
|
||||
unsub_link = self.text.make_tellcmd("Unsubscribe", f"messagehub unsubscribe {destination} {source}")
|
||||
status = ""
|
||||
if source in obj.sources:
|
||||
count += 1
|
||||
status = "<green>%s</green>" % self.getresp("subscribed")
|
||||
blob += "%s [%s] [%s] %s\n\n" % (source, sub_link, unsub_link, status)
|
||||
status = f"<green>{self.getresp('subscribed')}</green>"
|
||||
blob += f"{source} [{sub_link}] [{unsub_link}] {status}\n\n"
|
||||
|
||||
return ChatBlob(
|
||||
self.getresp("messagehub_edit_title", {"destination": destination.capitalize(), "count": count}), blob)
|
||||
|
||||
@@ -34,24 +34,24 @@ class SystemController:
|
||||
def start(self):
|
||||
self.ts.register_translation("module/system", self.load_system_msg)
|
||||
|
||||
self.setting_service.register_new(self.module_name, "expected_shutdown", True, BooleanSettingType(),
|
||||
"Helps bot to determine if last shutdown was expected or due to a problem")
|
||||
self.setting_service.register_new("core.system", "symbol", "!",
|
||||
TextSettingType(["!", "#", "*", "@", "$", "+", "-"]),
|
||||
"Symbol for executing bot commands")
|
||||
self.setting_service.register_new("core.system", "org_channel_max_page_length", 7500,
|
||||
NumberSettingType([4500, 6000, 7500, 9000, 10500, 12000]),
|
||||
"Maximum size of blobs in org channel")
|
||||
self.setting_service.register_new("core.system", "private_message_max_page_length", 7500,
|
||||
NumberSettingType([4500, 6000, 7500, 9000, 10500, 12000]),
|
||||
"Maximum size of blobs in private messages")
|
||||
self.setting_service.register_new("core.system", "private_channel_max_page_length", 7500,
|
||||
NumberSettingType([4500, 6000, 7500, 9000, 10500, 12000]),
|
||||
"Maximum size of blobs in private channel")
|
||||
self.setting_service.register(self.module_name, "expected_shutdown", True, BooleanSettingType(),
|
||||
"Helps bot to determine if last shutdown was expected or due to a problem")
|
||||
self.setting_service.register(self.module_name, "symbol", "!",
|
||||
TextSettingType(["!", "#", "*", "@", "$", "+", "-"]),
|
||||
"Symbol for executing bot commands")
|
||||
self.setting_service.register(self.module_name, "org_channel_max_page_length", 7500,
|
||||
NumberSettingType([4500, 6000, 7500, 9000, 10500, 12000]),
|
||||
"Maximum size of blobs in org channel")
|
||||
self.setting_service.register(self.module_name, "private_message_max_page_length", 7500,
|
||||
NumberSettingType([4500, 6000, 7500, 9000, 10500, 12000]),
|
||||
"Maximum size of blobs in private messages")
|
||||
self.setting_service.register(self.module_name, "private_channel_max_page_length", 7500,
|
||||
NumberSettingType([4500, 6000, 7500, 9000, 10500, 12000]),
|
||||
"Maximum size of blobs in private channel")
|
||||
|
||||
self.setting_service.register_new("core.system", "accept_commands_from_slave_bots", True, BooleanSettingType(),
|
||||
"Accept and respond to commands sent to slave bots (only applies if you have "
|
||||
"added slave bots in the config)")
|
||||
self.setting_service.register(self.module_name, "accept_commands_from_slave_bots", True, BooleanSettingType(),
|
||||
"Accept and respond to commands sent to slave bots (only applies if you have "
|
||||
"added slave bots in the config)")
|
||||
|
||||
def load_system_msg(self):
|
||||
with open("modules/core/system/system.msg", mode="r", encoding="utf-8") as f:
|
||||
|
||||
@@ -9,6 +9,7 @@ import psutil
|
||||
from core.chat_blob import ChatBlob
|
||||
from core.command_param_types import Any, Character
|
||||
from core.decorators import instance, command
|
||||
from core.lookup.character_service import CharacterService
|
||||
from core.util import Util
|
||||
|
||||
|
||||
@@ -23,6 +24,7 @@ class UtilController:
|
||||
self.access_service = registry.get_instance("access_service")
|
||||
self.event_service = registry.get_instance("event_service")
|
||||
self.public_channel_service = registry.get_instance("public_channel_service")
|
||||
self.character_service: CharacterService = registry.get_instance("character_service")
|
||||
self.getresp = registry.get_instance("translation_service").get_response
|
||||
|
||||
@command(command="checkaccess", params=[Character("character")], access_level="moderator",
|
||||
@@ -94,14 +96,13 @@ class UtilController:
|
||||
bots_connected += f"{_id} - {conn.char_name} ({conn.char_id})\n"
|
||||
|
||||
for channel_id, name in self.public_channel_service.get_all_public_channels().items():
|
||||
pub_channels += "%s - <highlight>%d</highlight>\n" % (name, channel_id)
|
||||
pub_channels += f"{name} - <highlight>{channel_id:d}</highlight>\n"
|
||||
|
||||
for event_type in self.event_service.get_event_types():
|
||||
event_types += "%s\n" % event_type
|
||||
event_types += f"{event_type}\n"
|
||||
|
||||
for access_level in self.access_service.get_access_levels():
|
||||
access_levels += "%s (%d)\n" % (access_level["label"], access_level["level"])
|
||||
|
||||
access_levels += f"{access_level['label']} ({access_level['level']:d})\n"
|
||||
blob = self.getresp("module/system", "status_blob", {
|
||||
"bot_ver": f"{self.bot.major_version}.{self.bot.minor_version}",
|
||||
"os_ver": platform.system() + " " + platform.release(),
|
||||
@@ -112,7 +113,7 @@ class UtilController:
|
||||
"db_type": self.db.type if not self.db.MARIADB else f"{self.db.MARIADB} with "
|
||||
f"{self.db.pool_size} active connections",
|
||||
"mem_usage": self.util.format_number(psutil.Process(os.getpid()).memory_info().rss / 1024),
|
||||
"superadmin": "Not Set",
|
||||
"superadmin": ", ".join([self.character_service.get_char_name(x) or str(x) for x in self.bot.superadmin]),
|
||||
"bl_used": self.buddy_service.get_buddy_list_size(),
|
||||
"bl_size": self.buddy_service.buddy_list_size,
|
||||
"uptime": self.util.time_to_readable(int(time.time()) - self.bot.start_time, max_levels=None),
|
||||
|
||||
Reference in New Issue
Block a user