Do not load settings which are not active (module not loaded)

Restart the bot, on heavy DB errors, with an 30 seconds delay (like: all connections terminated by DB, table_definition_cache exhausted)
Fix for channel prefixing (org <-> priv)
This commit is contained in:
2021-11-30 16:57:31 +01:00
parent c100b0ea76
commit bf6c1842d2
17 changed files with 57 additions and 29 deletions
@@ -159,7 +159,7 @@ class AccountController:
self.db.exec("DELETE FROM pending_accounts where main=? or alt=?", [account[0].main, account[0].main])
self.db.exec("DELETE FROM mail where recipient=? or sender=?", [account[0].main, account[0].main])
self.account_service.add_log(request.sender.char_id, "system",
f"Disabled Account of <highlight>{user.name}</highlight>.",
f"Purged the account of <highlight>{user.name}</highlight>.",
request.sender.char_id)
return f"Character <highlight>{user.name}'s</highlight> Account has been purged!"
else:
+2 -1
View File
@@ -6,6 +6,7 @@ from core.chat_blob import ChatBlob
from core.command_param_types import Const, Options, Character, Multiple, Any
from core.decorators import instance, command
from core.dict_object import DictObject
from core.sender_obj import SenderObj
from core.setting_service import SettingService
from core.text import Text
from core.translation_service import TranslationService
@@ -135,7 +136,7 @@ class AltsController:
for alt in alts:
char_id = self.character_service.resolve_char_to_id(alt)
if not char_id:
notfound.append(alt)
notfound.append(alt.name if type(alt) == SenderObj else alt)
continue
alt = DictObject({"char_id": char_id, "name": alt})
if main.char_id == alt.char_id:
@@ -78,7 +78,7 @@ class PrivateChannelController:
return hjson.load(f)
def handle_incoming_relay_message(self, ctx):
if not self.display_main().get_value() == "1" and ctx.source == "org_channel" and ctx.sender:
if self.display_main().get_value() and ctx.source == "private_channel" and ctx.sender:
name = f"{OrgChannelController.ORG_CHANNEL_PREFIX} <yellow>{ctx.sender.name}</yellow>"
if account := self.account_service.get_account(ctx.sender.char_id):
if account.main != ctx.sender.char_id:
@@ -92,9 +92,9 @@ class PrivateChannelController:
if not self.bot.is_ready():
if data.packet.char_id not in self.reinvite:
account = data.account
if account.disabled == 1:
if not self.account_service.simple_checks(account):
return
if self.pork.get_character_info(data.packet.char_id).org_id == self.bot.public_channel_service.org_id:
if self.account_service.get_entry(data.packet.char_id).get("member", self.bot.public_channel_service.org_id) == self.bot.public_channel_service.org_id:
return
if account.auto_invite == 1:
self.reinvite.append(data.packet.char_id)
@@ -102,12 +102,12 @@ class PrivateChannelController:
if self.private_channel_service.in_private_channel(data.packet.char_id):
return
account = data.account
if account.disabled == 1:
if not self.account_service.simple_checks(account):
return
if self.db.query_single("SELECT * from org_bots where char_id=?", [data.packet.char_id]):
return
if account.auto_invite == 1:
if self.pork.get_character_info(data.packet.char_id).org_id != self.bot.public_channel_service.org_id:
if self.account_service.get_entry(data.packet.char_id).get("member", self.bot.public_channel_service.org_id) != self.bot.public_channel_service.org_id:
self.private_channel_service.invite(data.packet.char_id)
self.bot.send_mass_message(data.packet.char_id, "You have been "
"<highlight>auto invited</highlight> "