polls get sent to all members on logon

dirty fix for the MA nanolines
There's an error with the urllib, downgrading the dependency.
This commit is contained in:
2021-09-01 14:33:33 +02:00
parent 9f1da9a00d
commit 3c8eb7bb70
4 changed files with 38 additions and 15 deletions
@@ -305,10 +305,23 @@ class AccountService:
return ["success", True]
def get_orgs(self) -> list:
try:
return [x["org_id"] for x in self.db.query("SELECT * from orgs", [])]
except SqlException:
return [self.bot.public_channel_service.org_id]
# With the broader usage of the "simple_checks" (Check for ban, org membership, ....)
# We might need to cache the orgs matching the filters.
# As these dont change as frequently as the account [if at all],
# Saving them for longer should be safe.
if not hasattr(self, "orgs"):
try:
def del_orgs(_):
del self.orgs
self.orgs = [x["org_id"] for x in self.db.query("SELECT * from orgs", [])]
self.bot.job_scheduler.delayed_job(del_orgs, 60)
return self.orgs
# The table "orgs" does not exist, which means the bot is not running the onlinebot modules.
# Cache lifetime is infinity, as the bot usually wont leave its org while its online.
except SqlException:
self.orgs = [self.bot.public_channel_service.org_id]
return self.orgs
return self.orgs
def create_users(self, users, disable=False) -> int:
# Default preferences
@@ -530,6 +543,8 @@ class AccountService:
points = -points
self.db.exec("UPDATE account set points = points-? where char_id=(select main from account where char_id=?)",
[points, char_id])
if account := self.acc_cache.get(char_id, None):
account.points -= points
self.add_log(char_id, 'points', reason, leader, delta=-points)
def add_rank(self, char_id, rank) -> int: