Fixed temporary bans, and added an option to exclude discord from banning.
changed the color of "Time is UP!" in the roll results, as requested.
This commit is contained in:
@@ -67,10 +67,14 @@ class BanService:
|
||||
|
||||
return num_rows
|
||||
|
||||
def remove_ban(self, char_id):
|
||||
def remove_ban(self, char_id, tmp=False):
|
||||
t = int(time.time())
|
||||
num_rows = self.db.exec("UPDATE ban_list SET ended_early = 1 "
|
||||
"WHERE char_id = ? AND (finished_at > ? OR finished_at = -1)", [char_id, t])
|
||||
if not tmp:
|
||||
num_rows = self.db.exec("UPDATE ban_list SET ended_early = 1 "
|
||||
"WHERE char_id = ? and ended_early = 0", [char_id])
|
||||
else:
|
||||
num_rows = self.db.exec("UPDATE ban_list SET ended_early = 2 "
|
||||
"WHERE char_id = ? AND (finished_at < ?)", [char_id, t])
|
||||
if num_rows:
|
||||
self.db.exec("UPDATE account SET disabled = 0 "
|
||||
"WHERE main = (SELECT main from account where char_id=?)", [char_id])
|
||||
@@ -83,19 +87,19 @@ class BanService:
|
||||
"WHERE char_id = (SELECT main from account where char_id=?) and disabled=1",
|
||||
[char_id])
|
||||
|
||||
def get_ban_list(self):
|
||||
def get_ban_list(self, full=True) -> list[DictObject]:
|
||||
t = int(time.time())
|
||||
return self.db.query("SELECT b.*, COALESCE(p1.name, b.char_id) AS name, p2.name AS sender_name FROM ban_list b "
|
||||
"LEFT JOIN player p1 ON b.char_id = p1.char_id "
|
||||
"LEFT JOIN player p2 ON b.sender_char_id = p2.char_id "
|
||||
"WHERE ended_early != 1 AND (finished_at > ? OR finished_at = -1) "
|
||||
"ORDER BY b.created_at DESC", [t])
|
||||
return self.db.query(f"SELECT b.*, COALESCE(p1.name, b.char_id) AS name, p2.name AS sender_name FROM ban_list b "
|
||||
f"LEFT JOIN player p1 ON b.char_id = p1.char_id "
|
||||
f"LEFT JOIN player p2 ON b.sender_char_id = p2.char_id "
|
||||
f"WHERE ended_early < 1 AND (finished_at > ? {'OR finished_at = -1' if full else ''}) "
|
||||
f"ORDER BY b.created_at DESC", [t])
|
||||
|
||||
def check_for_banned(self, context):
|
||||
char_id = context.char_id
|
||||
if self.get_ban(char_id):
|
||||
# do nothing if character is banned
|
||||
self.logger.info("ignoring banned character %d for command '%s'" % (char_id, context.message))
|
||||
self.logger.info(f"ignoring banned character {self.account_service.character_service.resolve_char_to_name(char_id, default=str(char_id))} for command '{context.message}'")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user