Moved org finder to the core
Allowed viewing the most recent account logs by using !account log recent Allowed removing of chatbots Moved the so far hardcoded org prefixing into the DB, which allows dynamically changing them. Fix for orgrosters; org leaves are being detected now.
This commit is contained in:
@@ -55,7 +55,10 @@ class AccountLogController(BaseModule):
|
||||
sub_command="moderate")
|
||||
def account_add_log(self, request: command_request, _, log_type, user, text):
|
||||
main = self.account_service.get_main(user.char_id).char_id
|
||||
if not main:
|
||||
return f"The main of <highlight>{user}</highlight> could not be found. Are you sure there is an account?"
|
||||
self.account_service.add_log(main, log_type, text, request.sender.char_id)
|
||||
return f"The log entry for <highlight>{self.character_service.resolve_char_to_name(main)}</highlight> has been added successfully."
|
||||
|
||||
# noinspection LongLine
|
||||
@command(command="account", params=[Const("log"), Const("id"), Int("id")], access_level="moderator",
|
||||
@@ -73,7 +76,14 @@ class AccountLogController(BaseModule):
|
||||
f"Message: <grey>{entry.reason}</grey>\n"
|
||||
f"Logging Time: <highlight>{self.util.format_datetime(entry.created_at)}</highlight>")
|
||||
else:
|
||||
return f"No Logentry with ID {id} found."
|
||||
return f"No Logentry with ID {log_id} found."
|
||||
|
||||
@command(command="account", params=[Const("log"), Const("recent")], access_level="moderator",
|
||||
description="View the 20 most recent log entries",
|
||||
sub_command="moderate")
|
||||
def account_view_recent(self, _, _1, _2):
|
||||
entries = self.account_service.get_logs(limit=20)
|
||||
return ChatBlob(f"Most Recent logentries", self.display_logs(entries))
|
||||
|
||||
def display_logs(self, entries) -> str:
|
||||
blob = ""
|
||||
|
||||
@@ -532,14 +532,21 @@ class AccountService:
|
||||
"VALUES (?, ?, ?, ?, ?, ?)",
|
||||
[main, log_type, delta, leader, message, time.time()])
|
||||
|
||||
def get_logs(self, user, log_type=None, limit=25) -> List[DictObject]:
|
||||
if not log_type:
|
||||
return self.db.query("SELECT * FROM account_log "
|
||||
"where char_id=? and type != 'admin' order by log_id desc LIMIT ? ", [user, limit])
|
||||
|
||||
def get_logs(self, user=None, log_type=None, limit=25) -> List[DictObject]:
|
||||
if not user:
|
||||
if not log_type:
|
||||
return self.db.query("SELECT * FROM account_log "
|
||||
"where type != 'admin' order by log_id desc LIMIT ? ", [limit])
|
||||
else:
|
||||
return self.db.query("SELECT * FROM account_log "
|
||||
"where type=? order by log_id desc LIMIT ?", [log_type, limit])
|
||||
else:
|
||||
return self.db.query("SELECT * FROM account_log "
|
||||
"where char_id=? and type=? order by log_id desc LIMIT ?", [user, log_type, limit])
|
||||
if not log_type:
|
||||
return self.db.query("SELECT * FROM account_log "
|
||||
"where char_id=? and type != 'admin' order by log_id desc LIMIT ? ", [user, limit])
|
||||
else:
|
||||
return self.db.query("SELECT * FROM account_log "
|
||||
"where char_id=? and type=? order by log_id desc LIMIT ?", [user, log_type, limit])
|
||||
|
||||
def get_log_by_id(self, log_id) -> DictObject:
|
||||
return self.db.query_single("SELECT * FROM account_log where log_id=? ", [log_id])
|
||||
|
||||
Reference in New Issue
Block a user