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:
@@ -51,6 +51,7 @@ class OrgController:
|
||||
self.alias_controller: OrgAliasController = registry.get_instance("org_alias_controller")
|
||||
self.account_service: AccountService = registry.get_instance("account_service")
|
||||
self.cache: CacheService = registry.get_instance("cache_service")
|
||||
self.org_alias: OrgAliasController = registry.get_instance("org_alias_controller")
|
||||
|
||||
def start(self):
|
||||
self.db.exec("CREATE TABLE IF NOT EXISTS orgs(org_id int primary key not null)")
|
||||
@@ -65,12 +66,12 @@ class OrgController:
|
||||
self.buddy_service.add_buddy(player.char_id, "member")
|
||||
|
||||
@command(command="orgs", params=[Const("add"), Any("Organisation")], access_level="admin",
|
||||
description="Add an org to the online list")
|
||||
description="Add an org to the online list", sub_command="moderate")
|
||||
def orgs_add_any(self, sender, _, org):
|
||||
return self.orgs_add(org, sender)
|
||||
|
||||
def orgs_add(self, search, sender):
|
||||
orgs = self.find_org(search)
|
||||
orgs = self.org_pork.find_org(search)
|
||||
if len(orgs) == 1:
|
||||
orgs = orgs[0]
|
||||
if self.db.exec("REPLACE INTO orgs(org_id) VALUES(?)",
|
||||
@@ -95,12 +96,12 @@ class OrgController:
|
||||
return ChatBlob("Pick an Org", blob)
|
||||
|
||||
@command(command="orgs", params=[Const("rem"), Any("Organisation")], access_level="admin",
|
||||
description="Remove an org from the online list")
|
||||
description="Remove an org from the online list", sub_command="moderate")
|
||||
def orgs_rem_any(self, _, _1, org):
|
||||
return self.orgs_rem(org)
|
||||
|
||||
def orgs_rem(self, search):
|
||||
orgs = self.find_org(search)
|
||||
orgs = self.org_pork.find_org(search)
|
||||
|
||||
if len(orgs) == 1:
|
||||
orgs = orgs[0]
|
||||
@@ -124,19 +125,21 @@ class OrgController:
|
||||
return ChatBlob("Pick an Org", blob)
|
||||
|
||||
@command(command="orgs", params=[Const("list", is_optional=True)], access_level="member",
|
||||
description="View all orgs on the online list", sub_command="list")
|
||||
description="View all orgs on the online list", sub_command="online_info")
|
||||
def orgs_list(self, sender: CommandRequest, _):
|
||||
head = "<header>Organisations in our Alliance<end>"
|
||||
head = "<header>Organisations registered as Members<end>"
|
||||
blob = ""
|
||||
for org in self.db.query("SELECT * from orgs o "
|
||||
"left join all_orgs a on o.org_id = a.org_id order by a.org_name"):
|
||||
for org in self.db.query("SELECT o.*, a.*, oa.org_alias from orgs o "
|
||||
"left join all_orgs a on o.org_id = a.org_id "
|
||||
"left join org_alias oa on o.org_id = oa.org_id order by a.org_name"):
|
||||
org = DictObject(org)
|
||||
blob += "- %s%s<highlight>%s<end> (%d) with <highlight>%d<end> members\n" % (
|
||||
blob += "- %s%s%s<highlight>%s<end> (%d) with <highlight>%d<end> members\n" % (
|
||||
"[<highlight>" + self.text.make_chatcmd("Info", "/tell <myname> orgs info %d" % org.org_id,
|
||||
style="style='text-decoration:none'") + "</highlight>] ",
|
||||
"[<red>" + self.text.make_chatcmd("Remove", "/tell <myname> orgs rem %d" % org.org_id,
|
||||
style="style='text-decoration:none'") + "</red>] " if
|
||||
sender.sender.access_level["level"] <= 10 else "",
|
||||
f"[<highlight>{self.org_alias.get_alias(org.org_id)}</highlight>] ",
|
||||
org.org_name, org.org_id,
|
||||
self.db.query_single("SELECT member_count from all_orgs where org_id=?", [org.org_id]).member_count)
|
||||
|
||||
@@ -291,12 +294,6 @@ class OrgController:
|
||||
self.threads["roster"] = thread
|
||||
thread.start()
|
||||
|
||||
def find_org(self, search, table="all_orgs"):
|
||||
if search.isdigit():
|
||||
return self.db.query("SELECT * FROM " + table + " where org_id = ?", [search])
|
||||
elif isinstance(search, str):
|
||||
return self.db.query("SELECT * FROM " + table + " where org_name LIKE ?", ["%" + search + "%"])
|
||||
|
||||
def fetch_single(self, org_id, org_name, sender: object):
|
||||
start = time.time()
|
||||
data = []
|
||||
|
||||
Reference in New Issue
Block a user